代码之家  ›  专栏  ›  技术社区  ›  Ali Azam adi

如何使用AxWindowsMediaPlayer库将视频旋转90度

  •  -1
  • Ali Azam adi  · 技术社区  · 7 年前

    AxWindowsMediaPlayer 库来实现视频播放以及属性 Play Pos , Stop , Next , Voliume

    如何在windows media player应用程序中实现视频轮换?有什么想法吗?

    0 回复  |  直到 7 年前
        1
  •  0
  •   Ali Azam adi    7 年前

    最后,我可以解决视频旋转(在90度)使用 FFmpeg 图书馆。下载最新版本的 FFmpeg 压缩窗口,提取并保留 驱动器C上的库文件夹[NB:可以选择任何驱动器或路径]。

    定义一个函数 string 名为的参数 command

    /// <summary>
    /// Execute the command and output the result
    /// </summary>
    private String Command(string command)
    {
        int time_out = 6;
        System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
    
        psi.FileName = @"C:\ffmpeg\bin\ffmpeg.exe";
    
        psi.RedirectStandardInput = false;
        psi.RedirectStandardOutput = true;
        psi.UseShellExecute = false;
        //Do not display windows
        psi.CreateNoWindow = true;
        //Specify command line
        psi.Arguments = command;
        //Start-up
        Process p = Process.Start(psi);
        //Read output
        string results = p.StandardOutput.ReadToEnd();
        //WaitForExit needs to be after ReadToEnd
        //(To prevent blocking by parent process and child process)
        p.WaitForExit(time_out * 1000);  //Wait maximum specified milliseconds until process terminates
        if (!p.HasExited) p.Close();
        //Display output result
        return results;
    }
    

    然后像这样调用传递cmdarg的函数

    string inputPath = @"C:\SampleVideo.mp4";
    string outputFile = @"C:\SampleVideoOutput.mp4";
    
    string cmdArgs = string.Empty;
    cmdArgs = " -i \"" + inputPath + "\" -vf \"transpose=1\" \"" + outputFile + "\"";
    
    Command(cmdArgs);
    

    下面是简单的命令行命令-

    ffmpeg -i input.mp4 -vf "transpose=1" output.mp4
    

    可使用以下转置参数:

    0 = 90CounterCLockwise and Vertical Flip (default)
    1 = 90Clockwise
    2 = 90CounterClockwise
    3 = 90Clockwise and Vertical Flip
    
    Use -vf "transpose=2,transpose=2" for 180 degrees.
    
    推荐文章