我一直在尝试使用 ffmpeg 将一些视频从 QuickTime 重新封装为 MP4,但结果有些混乱。编解码器都兼容 MP4,因此一切正常。问题是生成的 MP4 文件都存在大量视频卡顿。例如,它会播放,然后跳回半秒,然后回到它应该在的位置,然后再跳回一次等等。
我尝试了以下标志的各种组合:-c copy -vcodec copy -acodec copy -copyts
,但没有找到任何有效的方法。那么我需要做什么才能避免重新封装时出现卡顿?
我在这里尝试-c copy -copyts
:
$ ffmpeg -i in.mov -c copy -copyts out2.mp4
ffmpeg version 1.2.2 Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 13 2013 00:49:34 with Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-gnutls --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-nonfree --enable-libfaac
libavutil 52. 18.100 / 52. 18.100
libavcodec 54. 92.100 / 54. 92.100
libavformat 54. 63.104 / 54. 63.104
libavdevice 54. 3.103 / 54. 3.103
libavfilter 3. 42.103 / 3. 42.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2013-02-13 06:40:06
Duration: 00:45:10.08, start: 0.040000, bitrate: 503 kb/s
Stream #0:0(eng): Video: h264 (High) (H264 / 0x34363248), yuv420p, 644x364 [SAR 1:1 DAR 23:13], 402 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
Metadata:
creation_time : 2013-02-13 06:40:06
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s
Metadata:
creation_time : 2013-02-13 06:40:06
handler_name : Apple Alias Data Handler
Output #0, mp4, to 'out2.mp4':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
encoder : Lavf54.63.104
Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 644x364 [SAR 1:1 DAR 23:13], q=2-31, 402 kb/s, 25 fps, 16k tbn, 1k tbc
Metadata:
creation_time : 2013-02-13 06:40:06
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 95 kb/s
Metadata:
creation_time : 2013-02-13 06:40:06
handler_name : Apple Alias Data Handler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=67751 fps=15817 q=-1.0 Lsize= 166739kB time=00:45:10.04 bitrate= 504.0kbits/s
video:133281kB audio:31756kB subtitle:0 global headers:0kB muxing overhead 1.031415%
这里我尝试设置要复制的音频和视频编解码器:
$ ffmpeg -i in.mov -vcodec copy -acodec copy out4.mp4
ffmpeg version 1.2.2 Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 13 2013 00:49:34 with Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-gnutls --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-nonfree --enable-libfaac
libavutil 52. 18.100 / 52. 18.100
libavcodec 54. 92.100 / 54. 92.100
libavformat 54. 63.104 / 54. 63.104
libavdevice 54. 3.103 / 54. 3.103
libavfilter 3. 42.103 / 3. 42.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2013-02-13 06:40:06
Duration: 00:45:10.08, start: 0.040000, bitrate: 503 kb/s
Stream #0:0(eng): Video: h264 (High) (H264 / 0x34363248), yuv420p, 644x364 [SAR 1:1 DAR 23:13], 402 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
Metadata:
creation_time : 2013-02-13 06:40:06
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s
Metadata:
creation_time : 2013-02-13 06:40:06
handler_name : Apple Alias Data Handler
Output #0, mp4, to 'out4.mp4':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
encoder : Lavf54.63.104
Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 644x364 [SAR 1:1 DAR 23:13], q=2-31, 402 kb/s, 25 fps, 16k tbn, 1k tbc
Metadata:
creation_time : 2013-02-13 06:40:06
handler_name : Apple Alias Data Handler
Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 95 kb/s
Metadata:
creation_time : 2013-02-13 06:40:06
handler_name : Apple Alias Data Handler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=67751 fps=15495 q=-1.0 Lsize= 166739kB time=00:45:10.00 bitrate= 504.0kbits/s
video:133281kB audio:31756kB subtitle:0 global headers:0kB muxing overhead 1.031400%
答案1
我认为源文件不知何故损坏了。如果你只重新编码音频流,输出文件的行为是否相同?如果是,那么你还必须重新编码视频流。你可以使用我的应用程序进行快速测试,媒体转换器这是一个 ffmpeg GUI。