gpt4 book ai didi

c# - 视频文件未在 C# 中使用 FFMpeg 进行修剪和复制

转载 作者:行者123 更新时间:2023-12-04 23:24:03 32 4
gpt4 key购买 nike

我正在尝试在带有 FFMpeg 的 Visual Studios 中使用 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

最佳答案

你可以这样尝试:

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();

关于c# - 视频文件未在 C# 中使用 FFMpeg 进行修剪和复制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56127346/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com