Пример #1
0
    private void RunFFmpegExe(object obj)
    {
        /*
         * 视频命令
         * MP4 ffmpeg.exe -f image2 -i c:\temp\d.jpg -vcodec libx264 -r 10 -b 200k  test.mp4
         * webm ffmpeg.exe - i png / B_ % 5d.png - auto - alt -ref 0 - c:v libvpx export.webm
         */
        DatasStruct data = obj as DatasStruct;
        Process     p    = new Process();

        //p.StartInfo.FileName = ffmpegPath + "/ffmpeg.exe";
        p.StartInfo.FileName = GameManager.FFMpegPath;
        Debug.Log(Path.GetExtension(saveVideoName));

        string arguments = Path.GetExtension(saveVideoName) == ".mp4" ? $"-f image2 -i {seletePicPath}/{picStyteType} -vf  \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" -vf \"split[a], pad = iw * 2:ih[b], [a] alphaextract, [b] overlay=w\"  -b {codeRate}k {saveVideoName}" :
                           $"-i {seletePicPath}/{picStyteType} -r {frameRate} -b {codeRate}k -auto-alt-ref 0  -vcodec libvpx  {saveVideoName}";

        p.StartInfo.Arguments = arguments;
        Debug.Log("ffmeeg 信息:  " + p.StartInfo.Arguments);
        p.StartInfo.CreateNoWindow         = false;
        p.StartInfo.UseShellExecute        = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.Start();
        Debug.Log("ffmeeg 信息: start");
        p.WaitForExit();
        Debug.Log("ffmeeg 信息: Exit");
        p.Close();
        Loom.QueueOnMainThread(() => ShowDiglog());
        data.thread.Abort();
    }
Пример #2
0
    /// <summary>
    /// 转换
    /// </summary>
    /// <param name="exName">目标文件</param>
    public void Convert(string exName)
    {
        if (GetPathIsNull())
        {
            return;
        }
        for (int i = 0; i < movFileList.Count; i++)
        {
            DatasStruct datas  = new DatasStruct();
            Thread      thread = new Thread(RunFFmpegExe);

            datas.thread           = thread;
            datas.inputMovFileName = movFileList[i];
            datas.outVideoFileName = $"{saveMovPath}/{ Path.GetFileNameWithoutExtension(movFileList[i])}{exName}";
            datas.addChunk4        = addchunk4;

            //是否显示dialog 多个mov只展示最后一个dialog  应该根据时间 需要修改
            if (i == movFileList.Count - 1)
            {
                datas.showEndDialog = true;
            }

            thread.Start(datas);
        }
    }
Пример #3
0
    private void RunFFmpegExe(object obj)
    {
        DatasStruct data = obj as DatasStruct;
        Process     p    = new Process();

        p.StartInfo.FileName = GameManager.FFMpegPath;
        Debug.Log(data.outVideoFileName);
        string exName = Path.GetExtension(data.outVideoFileName);

        switch (exName)
        {
        case ".mp4":
            p.StartInfo.Arguments = $"-i {data.inputMovFileName} -vf  \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" -vf \"split[a], pad = iw * 2:ih[b], [a] alphaextract, [b] overlay=w\" -b {codeRate}k -r {frameRate} -y {data.outVideoFileName}";
            break;

        case ".webm":
            //-i text.mov -auto-alt-ref 0 -c:v libvpx -b 1000k  export.webm  //-y是覆盖原来的视频
            p.StartInfo.Arguments = $"-i {data.inputMovFileName} -auto-alt-ref 0 -c:v libvpx  -r {frameRate} -b {codeRate}k -y {data.outVideoFileName}";
            break;

        case ".mov":
            //ffmpeg -i input.mov -vcodec hap -format hap_alpha output-hap.mov
            if (!data.addChunk4)
            {
                p.StartInfo.Arguments = $"-i {data.inputMovFileName} -vcodec hap -format hap_alpha -r {frameRate} -y {data.outVideoFileName}";
            }
            else
            {
                p.StartInfo.Arguments = $"-i {data.inputMovFileName} -vcodec hap -format hap_alpha -chunks 4 -r {frameRate} -y {data.outVideoFileName}";
            }
            break;
        }

        //scale=trunc(iw/2)*2:trunc(ih/2)*2 否则可能遇到“width not divisible by 2”

        Debug.Log("ffmeeg 信息:  " + p.StartInfo.Arguments);
        p.StartInfo.CreateNoWindow         = false;
        p.StartInfo.UseShellExecute        = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.Start();
        Debug.Log("ffmeeg 信息: 开始转换");
        p.WaitForExit();
        Debug.Log("ffmeeg 信息: 转换结束");
        p.Close();
        if (data.showEndDialog)
        {
            Loom.QueueOnMainThread(() => ShowDiglog());
        }
        data.thread.Abort();
    }
Пример #4
0
    public void Convert()
    {
        if (GetPathIsNull())
        {
            return;
        }
        DatasStruct datas  = new DatasStruct();
        Thread      thread = new Thread(RunFFmpegExe);

        datas.thread        = thread;
        datas.picFolderName = seletePicPath;
        datas.outFileName   = saveVideoName;
        thread.Start(datas);
    }