这适用于 ffmpeg 2.5.2 版本:
ffmpeg.exe -i test.mp4 -f mp4 -c copy -ss 00:00:00.000 -to 00:00:00.500 -y test1.mp4
但我无法让它在新版本上运行。
它们不会产生错误,实际上它们都生成输出文件,但只有 2.5.2 的输出可以播放。输出文件的大小略有不同。2.5.2 版本较大。
以下是测试运行的输出:
版本 2.5.2
c:\Work\ff>ffmpeg.exe -i test.mp4 -f mp4 -c copy -ss 00:00:00.000 -to 00:00:00.500 -y test1.mp4
ffmpeg version 2.5.2 Copyright (c) 2000-2014 the FFmpeg developers
built on Dec 30 2014 17:18:09 with gcc 4.9.2 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat 56. 15.102 / 56. 15.102
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2020-04-23 19:38:19
encoder : Lavf58.42.100
Duration: 00:00:30.56, start: 0.046440, bitrate: 890 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 544x408 [SAR 1:1 DAR 4:3], 780 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
creation_time : 2020-04-23 19:38:19
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2020-04-23 19:38:19
handler_name : SoundHandler
Output #0, mp4, to 'test1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.15.102
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 544x408 [SAR 1:1 DAR 4:3], q=2-31, 780 kb/s, 25 fps, 12800 tbn, 12800 tbc (default)
Metadata:
creation_time : 2020-04-23 19:38:19
handler_name : VideoHandler
Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 128 kb/s (default)
Metadata:
creation_time : 2020-04-23 19:38:19
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 13 fps=0.0 q=-1.0 Lsize= 51kB time=00:00:00.51 bitrate= 823.2kbits/s
video:41kB audio:9kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.384930%
版本 4.2.2
c:\Work\ff>ffmpeg.exe -i test.mp4 -f mp4 -c copy -ss 00:00:00.000 -to 00:00:00.500 -y test1.mp4
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122
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. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2020-04-23T19:38:19.000000Z
encoder : Lavf58.42.100
Duration: 00:00:30.56, start: 0.000000, bitrate: 890 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 544x408 [SAR 1:1 DAR 4:3], 780 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
creation_time : 2020-04-23T19:38:19.000000Z
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2020-04-23T19:38:19.000000Z
handler_name : SoundHandler
Output #0, mp4, to 'test1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 544x408 [SAR 1:1 DAR 4:3], q=2-31, 780 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
Metadata:
creation_time : 2020-04-23T19:38:19.000000Z
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2020-04-23T19:38:19.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= 9kB time=00:00:00.48 bitrate= 157.5kbits/s speed=28.7x
video:0kB audio:9kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 10.191668%
我究竟做错了什么?
答案1
可能是存在编辑列表。-ignore_editlist true
为版本 4.2.2 的命令添加输入选项:
ffmpeg -y -ignore_editlist true -i input.mp4 -c copy -ss 00:00:00.000 -to 00:00:00.500 output.mp4