我使用此命令来转换
ffmpeg -i spider.mkv -acodec libfaac -ar 48000 -ab 128k -ac 2 -vcodec libx264 -vf "scale=480:-1" -r 24 -f mpegts spider.ts
但输出文件 (spider.ts) 中的帧的时间戳与原始文件不同。spider.mkv 中的帧与spider.ts 中的1:00:00
帧不同1:00:00
这是什么原因?我应该用什么方法解决它?
FFmpeg 的输出:
ffmpeg version N-44232-gd93a53a Copyright (c) 2000-2012 the FFmpeg developers
built on Sep 12 2012 13:20:28 with Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
configuration: --enable-nonfree --enable-libfaac --enable-libfreetype --enable-libmp3lame --enable-libx264 --enable-gpl --cc=cc --cxx=c++ --extra-cflags=-I/usr/X11/include/freetype2/freetype --extra-cflags=-I/usr/X11/include/freetype2 --extra-cflags=-I/usr/X11/include --extra-ldflags=-L/usr/X11/lib --extra-ldflags=-lfreetype --extra-ldflags=-lz --extra-ldflags=-lbz2
libavutil 51. 72.100 / 51. 72.100
libavcodec 54. 55.100 / 54. 55.100
libavformat 54. 25.105 / 54. 25.105
libavdevice 54. 2.100 / 54. 2.100
libavfilter 3. 16.100 / 3. 16.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, matroska,webm, from 'spider.mkv':
Metadata:
creation_time : 2012-10-28 04:27:50
Duration: 02:16:17.16, start: 0.000000, bitrate: 1629 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p, 1280x544 [SAR 1:1 DAR 40:17], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), s16, 768 kb/s (default)
[mpegts @ 0x7fc151035e00] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'spideddr.ts':
Metadata:
encoder : Lavf54.25.105
Stream #0:0(eng): Video: h264, yuv420p, 480x204 [SAR 1:1 DAR 40:17], q=-1--1, 90k tbn, 24 tbc (default)
Stream #0:1(eng): Audio: aac, 48000 Hz, stereo, s16, 128 kb/s (default)
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (dca -> libfaac)
Press [q] to stop, [?] for help
number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding onedrop=0
[h264 @ 0x7fc152380600] number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding one
number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding onedrop=0
number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding one drop=0
number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding one drop=0
number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding one drop=0
number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding one drop=0
number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding one drop=0
number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding one drop=0
[h264 @ 0x7fc152381e00] mmco: unref short failure
[h264 @ 0x7fc152381e00] number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding one
[h264 @ 0x7fc15237ee00] reference picture missing during reorder
[h264 @ 0x7fc15237ee00] Missing reference picture
[h264 @ 0x7fc15237ee00] reference picture missing during reorder
[h264 @ 0x7fc15237ee00] Missing reference picture
[h264 @ 0x7fc15237ee00] reference picture missing during reorder
[h264 @ 0x7fc15237ee00] Missing reference picture
[h264 @ 0x7fc152380000] mmco: unref short failure
[h264 @ 0x7fc152380000] number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding one
[h264 @ 0x7fc15237ee00] reference picture missing during reorder
[h264 @ 0x7fc15237ee00] Missing reference picture
[h264 @ 0x7fc152381800] mmco: unref short failure
number of reference frames (0+6) exceeds max (5; probably corrupt input), discarding one drop=0
Read error20 fps=172 q=25.0 size= 226486kB time=01:18:37.84 bitrate= 393.3kbits/s dup=113 drop=0
frame=113267 fps=172 q=-1.0 Lsize= 226680kB time=01:18:39.46 bitrate= 393.5kbits/s dup=113 drop=0
video:120521kB audio:73724kB subtitle:0 global headers:0kB muxing overhead 16.698057%
答案1
您正在强制 FFmpeg 使用不同的帧速率:
输入 #0, matroska,webm, 来自‘spider.mkv’: …23.98 帧/秒 输出 #0,mpegts,到‘spideddr.ts’: …24 待定
尝试完全省略该-r
选项,看看是否能解决问题,或者明确将帧速率设置为 23.98。
如果这不起作用,我怀疑是因为原始输入视频流已损坏。x264 会非常急切地告诉您它在编码过程中丢弃了一些参考帧并复制了其他参考帧。实际上没有办法避免这种情况,因为这是源流的问题——无论它来自哪里。
另外,有什么理由使用 MPEG-TS 容器吗?MP4 在这里同样适用,而且可能得到各种播放设备的更好支持。