我希望 output.mp4 包含 input.mpg 中从 00:00:39 开始到 00:01:29 结束的视频的无损副本。我尝试过这个(使用 Windows 10):
ffmpeg -ss 00:00:39 -i input.mpg -to 00:01:29 -c:v copy -c:a copy output.mp4
这产生了错误:
track 1: codec frame size is not set
Timestamps are unset in a packet for stream 0
pts has no value
此外,输出不包含 50 秒的摘录(即 0:39 到 1:29)。相反,它持续约 1:29,就好像我用了 -t 而不是 -to。
我发现我可以通过使用以下命令首先将 input.mpg 重新混合为 input.mp4 来减轻错误消息:
ffmpeg -i input.mpg input.mp4
但我不确定这个命令是否产生了无损输出。它相对较慢,生成的文件大小不到原始文件的一半。另一方面,在其许多进度报告的末尾,它确实提到了“复用开销”,这表明它是重新复用而不是重新编码。
经过重新混合的努力后,我重新运行了上面显示的第一个命令,将其修改为引用 input.mp4 而不是 input.mpg。这没有产生任何错误消息,并且摘录确实从正确的位置开始。不幸的是,output.mp4 仍然太长:1:32,而不是 1:29 或 0:50。
我计划在 Adobe Premiere Elements 2020 中编辑 output.mp4 和其他视频剪辑,我发现它在接受内容方面很挑剔,而且不稳定,只要感觉到不完美就会崩溃。
我的问题是:如何修改上面显示的第一个命令以从 input.mpg 中生成所需的无损 50 秒摘录?
以下是第一个命令的完整日志:
D:\>ffmpeg -ss 00:00:39 -i input.mpg -to 00:01:29 -c:v copy -c:a copy output.mp4
ffmpeg version git-2020-06-12-38737b3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200523
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-libsrt --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-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 54.100 / 56. 54.100
libavcodec 58. 92.100 / 58. 92.100
libavformat 58. 46.101 / 58. 46.101
libavdevice 58. 11.100 / 58. 11.100
libavfilter 7. 86.100 / 7. 86.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Input #0, mpeg, from 'input.mpg':
Duration: 00:07:53.38, start: 0.213367, bitrate: 6313 kb/s
Stream #0:0[0x1bf]: Data: dvd_nav_packet
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 720x480 [SAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Side data:
cpb: bitrate max/min/avg: 8000000/0/0 buffer size: 1835008 vbv_delay: N/A
Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
[mp4 @ 0000029a2189fc00] track 1: codec frame size is not set
Output #0, mp4, to 'output.mp4':
Metadata:
encoder : Lavf58.46.101
Stream #0:0: Video: mpeg2video (Main) (mp4v / 0x7634706D), yuv420p(tv, progressive), 720x480 [SAR 8:9 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Side data:
cpb: bitrate max/min/avg: 8000000/0/0 buffer size: 1835008 vbv_delay: N/A
Stream #0:1: Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 192 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:2 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0000029a2189fc00] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mp4 @ 0000029a2189fc00] pts has no value
Last message repeated 371 times
frame= 1397 fps=0.0 q=-1.0 size= 35072kB time=00:00:46.15 bitrate=6225.3kbits/s spe[mp4 @ 0000029a2189fc00] pts has no value
Last message repeated 344 times
frame= 2681 fps=0.0 q=-1.0 Lsize= 67808kB time=00:01:28.99 bitrate=6241.7kbits/s speed=94.2x
video:65658kB audio:2100kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.073772%