【问题标题】:How to rotate video in 90 degrees using AxWindowsMediaPlayer library如何使用 AxWindowsMediaPlayer 库将视频旋转 90 度
【发布时间】:2019-03-06 05:12:14
【问题描述】:

我需要在 c# 技术的 windows 媒体播放器应用程序中应用视频旋转 (0, 90, -90) 度。我正在使用AxWindowsMediaPlayer库来实现视频播放以及属性PlayPosStopNextVoliume控件等。但我没有任何属性可以将视频旋转 90 度或 -90 度。

如何在 windows 媒体播放器应用程序中实现视频旋转?有什么想法吗?

【问题讨论】:

  • 你能告诉我为什么你把这个问题投反对票吗?我没有找到任何解决方案。所以我发布了这个问题。请让我知道谁对此投了反对票以及反对票的原因。

标签: c# .net winforms windows-media-player


【解决方案1】:

最后我可以使用 FFmpeg 库解决视频旋转(90 度)问题。下载最新版本的 FFmpeg zip for windows,解压缩并保存在驱动器 C 上的 FFmpeg 库文件夹[注意:可以选择任何驱动器或路径]。

定义一个带有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;
}

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

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

transpose = 1 旋转 90 度。

可以使用以下转置参数:

0 = 90CounterCLockwise and Vertical Flip (default)
1 = 90Clockwise
2 = 90CounterClockwise
3 = 90Clockwise and Vertical Flip

Use -vf "transpose=2,transpose=2" for 180 degrees.

【讨论】:

  • 到目前为止,这是一个很好的解决方案,我尝试了整个过程并提供了很好的帮助。比专门用于此目的的软件更好。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-20
  • 1970-01-01
  • 1970-01-01
  • 2017-02-02
  • 2010-11-21
  • 2012-12-23
相关资源
最近更新 更多