简体   繁体   English

FFmpeg C#视频转换

[英]FFmpeg C# Video Conversion

On the click of a button I am trying to trim down an MP4 videos between two certain times with the use of FFmpeg C# Wrapper. 单击一个按钮,我试图使用FFmpeg C#包装器在两个特定的时间之间修剪MP4视频。 My code is as follows: 我的代码如下:

private void button1_Click(object sender, EventArgs e)
    {
        CAVConverter converter = new CAVConverter();
        converter.LogPath = @"C:\Users\Rachel\Desktop\Log.txt";           
        converter.InputOptions.TimeStart = 5000000; //Start time to trim, unit is um(micro second)
        converter.OutputOptions.TimeLength = 3000000; //Time length to trim, unit is um(micro second)
        converter.AddTask(@"C:\\Users\\Rachel\\Desktop\\Tennis\\Serve.mp4",
                                      @"C:\\Users\\Rachel\\Desktop\\Tennis\\ServeCut.mp4");            
        converter.StartAndWait();            
    }

The code compiles and runs however the Log.txt file returns the following: 该代码编译并运行,但是Log.txt文件返回以下内容:

Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 90000.00 (180000/2) Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\\\\Users\\\\Rachel\\\\Desktop\\\\Tennis\\\\Serve.mp4': Metadata: major_brand : isom minor_version : 0 compatible_brands: isom3gp4 Duration: 00:00:38.76, start: 0.000000, bitrate: 10193 kb/s Stream #0.0(eng): Video: h264, yuv420p, 1280x720, 9982 kb/s, PAR 65536:65536 DAR 16:9, 30 fps, 90k tbr, 90k tbn, 180k tbc Stream #0.1(eng): Audio: libfaad, 48000 Hz, 2 channels, s16, 128 kb/s [mpeg4 @ 09762200]removing common factors from framerate [mpeg4 @ 09762200]timebase not supported by mpeg 4 standard Output #0, mp4, to 'C:\\\\Users\\\\Rachel\\\\Desktop\\\\Tennis\\\\ServeCut.mp4': Stream #0.0(eng): Video: mpeg4, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 90k tbc Stream #0.1(eng): Audio: libfaac, 48000 Hz, 2 channels, s16, 64 kb/s Stream mapping: Stream #0.0 -> #0.0 (Video) Stream #0.1 -> #0.1 (Audio) Error while opening encoder for output stream #0.0 (Video) - maybe incorrect parameters such as bit_rate, rate, width or height Error while opening encoder for output stream #0.0 (Video) - maybe incorrect parameters such as bit_rate, rate, width or height

I don't know much about FFmpeg or videos, so can anybody help me? 我对FFmpeg或视频了解不多,有人可以帮助我吗? Many thanks 非常感谢

You can use commands like this 您可以使用这样的命令

System.Diagnostics.Process.Start(string fileName, string arguments);

or you can use the exe from the official site from ffmpeg and pass the argumentsto them. 或者,您也可以使用ffmpeg官方网站上的exe并将参数传递给他们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM