我正在尝试在带有FFMpeg的Visual Studio中使用C#剪辑视频。我运行下面的代码,除了不会创建新的视频文件之外,它不会再出现任何错误。
我一直在这里查看以确保我使用的是正确的代码,但是经过多次尝试,它仍然不会被复制。
string videoFile = @"C:\Users\dave\Documents\video 1.mp4";
string outputFile = @"C:\Users\dave\Documents\video 2.mp4";
Process process = new Process();
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.FileName = @"C:\Users\dave\Documents\ffmpeg.exe";
process.StartInfo.Arguments = "ffmpeg -i " + videoFile + " -ss 00:30:00 -t 00:00:10 -c copy " + outputFile;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.Start();
我原本希望从原始视频中截取一段视频,从30秒开始,持续10秒,但是什么也没创建。
我正在使用https://ffmpeg.zeranoe.com/builds/上的最新FFMpeg
更新如果我在命令提示符下运行代码-文件虽然损坏了
ffmpeg -i "C:\\Users\\dave\\Documents\\video 1.mp4" -ss 00:30:00 -t 00:00:10 -c copy "C:\\Users\\dave\\Documents\\video 2.mp4"
ffmpeg version N-93851-gdcc999819d Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.3.1 (GCC) 20190414
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 27.100 / 56. 27.100
libavcodec 58. 52.101 / 58. 52.101
libavformat 58. 27.103 / 58. 27.103
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 51.100 / 7. 51.100
libswscale 5. 4.101 / 5. 4.101
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\\Users\\dave\\Documents\\video 1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
creation_time : 2019-01-15T21:57:04.000000Z
title : My Movie
encoder : Lavf56.15.102
description : This video is about My Movie
Duration: 00:06:48.22, start: 0.000000, bitrate: 1283 kb/s
Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 1202 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 2997 tbc (default)
Metadata:
creation_time : 2019-01-15T21:57:04.000000Z
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 74 kb/s (default)
Metadata:
creation_time : 2019-01-15T21:57:04.000000Z
handler_name : SoundHandler
Output #0, mp4, to 'C:\\Users\\dave\\Documents\\video 2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
description : This video is about My Movie
title : My Movie
encoder : Lavf58.27.103
Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 1202 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 11988 tbc (default)
Metadata:
creation_time : 2019-01-15T21:57:04.000000Z
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 74 kb/s (default)
Metadata:
creation_time : 2019-01-15T21:57:04.000000Z
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=-1.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
答案 0 :(得分:0)
您可以通过以下方式尝试:
string videoFile = @"C:\Users\dave\Documents\video 1.mp4";
string outputFile = @"C:\Users\dave\Documents\video 2.mp4";
string command = @"ffmpeg -i ""{0}"" -ss 00:30:00 -t 00:00:10 ""{1}""";
Process process = new Process();
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.FileName = @"C:\Users\dave\Documents\ffmpeg.exe";
process.StartInfo.Arguments = string.Format(command,videoFile,outputFile);
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.Start();