使用ffmpeg将TS-Stream转换为MKV

时间:2017-10-27 07:01:25

标签: ffmpeg mkv transport-stream matroska

我正在使用ffmpeg 3.2.7,我将ts-file无损转换为mkv时出现问题。 源文件是使用dumprtp(来自dvbstream 0.5)记录的转储IPTV流。

ffmpeg -i Test.ts -map 0:0 -map 0:2 -vcodec copy -acodec copy -f matroska Test.mkv

转换成功,但输出文件每隔几秒就会像素化一样。

当我用MKVToolnix转换它时,一切看起来都很好。

有没有人能解决这个问题? 也许有一些选项可以正确同步流?

以下是示例输出:

# ffmpeg -i Test.ts -map 0:0 -map 0:2 -vcodec copy -acodec copy -f matroska Test.mkv
ffmpeg version 3.2.7 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.0 (OpenWrt GCC 6.3.0 r212-46f973b)
  configuration: --enable-cross-compile --cross-prefix=i486-openwrt-linux-gnu- --arch=i386 --target-os=linux --prefix=/opt --pkg-config=pkg-config --enable-shared --enable-static --enable-pthreads --enable-zlib --disable-doc --disable-debug --disable-lzma --disable-vaapi --disable-vdpau --disable-outdevs --enable-avresample --enable-libopus --enable-small --enable-gpl --enable-libmp3lame --enable-libx264
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[NULL @ 0x81f9580] SPS unavailable in decode_picture_timing
[NULL @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mp3 @ 0x81fb860] Header missing
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mp3 @ 0x81fb860] Header missing
    Last message repeated 1 times
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mp3 @ 0x81fb860] Header missing
    Last message repeated 3 times
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mp3 @ 0x81fb860] Header missing
    Last message repeated 1 times
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mp3 @ 0x81fb860] Header missing
    Last message repeated 3 times
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mp3 @ 0x81fb860] Header missing
    Last message repeated 1 times
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mp3 @ 0x81fb860] Header missing
    Last message repeated 1 times
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mp3 @ 0x81fb860] Header missing
    Last message repeated 1 times
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mp3 @ 0x81fb860] Header missing
    Last message repeated 1 times
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mp3 @ 0x81fb860] Header missing
    Last message repeated 1 times
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mp3 @ 0x81fb860] Header missing
    Last message repeated 7 times
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] SPS unavailable in decode_picture_timing
[h264 @ 0x81f9580] non-existing PPS 0 referenced
[h264 @ 0x81f9580] decode_slice_header error
[h264 @ 0x81f9580] no frame!
[mp3 @ 0x81fb860] Header missing
    Last message repeated 1 times
[h264 @ 0x81f9580] reference picture missing during reorder
    Last message repeated 1 times
[h264 @ 0x81f9580] Missing reference picture, default is 2147483647
    Last message repeated 1 times
[h264 @ 0x81f9580] mmco: unref short failure
    Last message repeated 1 times
[h264 @ 0x81f9580] number of reference frames (0+5) exceeds max (4; probably corrupt input), discarding one
[mp3 @ 0x81fb860] Header missing
    Last message repeated 3 times
[h264 @ 0x81f9580] reference picture missing during reorder
    Last message repeated 2 times
[h264 @ 0x81f9580] Missing reference picture, default is 65627
    Last message repeated 2 times
[mp3 @ 0x81fb860] Header missing
    Last message repeated 1 times
[h264 @ 0x81f9580] mmco: unref short failure
    Last message repeated 3 times
[h264 @ 0x81f9580] Increasing reorder buffer to 2
[mp3 @ 0x81fb860] Header missing
    Last message repeated 295 times
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mp3 @ 0x81fb860] Header missing
    Last message repeated 13 times
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mp3 @ 0x81fb860] Header missing
    Last message repeated 2 times
[mpegts @ 0x81f6280] decoding for stream 1 failed
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] PES packet size mismatch
    Last message repeated 1 times
[mpegts @ 0x81f6280] Could not find codec parameters for stream 1 (Audio: mp3, 0 channels, s16p): unspecified frame size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'Test.ts':
  Duration: 00:01:00.54, start: 48882.340000, bitrate: 3181 kb/s
    Stream #0:0[0x100]: Video: h264, yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:11 DAR 20:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x103]: Audio: mp3, 0 channels, s16p
    Stream #0:2[0x102]: Audio: mp2, 48000 Hz, stereo, s16p, 192 kb/s
    Stream #0:3[0x101]: Audio: ac3, 48000 Hz, stereo, fltp, 384 kb/s
Output #0, matroska, to 'Test.mkv':
  Metadata:
    encoder         : Lavf57.56.101
    Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:11 DAR 20:11], q=2-31, 25 fps, 50 tbr, 1k tbn, 90k tbc
    Stream #0:1: Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, 192 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:2 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
.
.
.
[mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] changing packet size to 192
    [mpegts @ 0x81f6280] changing packet size to 188
[mpegts @ 0x81f6280] PES packet size mismatch
frame= 2971 fps=2674 q=-1.0 Lsize=   17441kB time=00:00:59.90 bitrate=2385.2kbits/s speed=53.9x    
video:16037kB audio:1410kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

谢谢

1 个答案:

答案 0 :(得分:0)

我无法使用多个播放器重现您的输入流。 .ts看起来比所有玩家中的mkv更强硬,我想由于.ts中的纠错信息,但最终它不会100%罚款。查看ffplay的输出有很多与mpeg相关的错误,这意味着你只是没有流转储中的所有视频数据来正确解码它。

不幸的是,您没有办法将碎片.ts文件中的直接流复制转换为帧精确容器,而无需解码和重新编码。