FFMPEG-非单调DTS


15

当我使用FFMPEG使用以下命令将视频从MP4转换为M3U8时,

ffmpeg -i op.mp4  -b:v 128k -flags -global_header -map 0:0 -map 0:1 -f segment -segment_time 4 -segment_list_size 0 -segment_list op.m3u8 -segment_format mpegts op%05d.ts

我收到以下警告:

Non-monotonous DTS in output stream 0:1; previous: 347527, current: 346508; changing to 347528. This may result in incorrect timestamps in the output file.

生成了M3U8,但只有音频在QuickTime播放器上播放。

样本MP4和M3U8均可在此处获得

所以,我想知道

  1. 错误背后的原因。它是损坏的mp4还是转换期间的问题。m3u8是可播放的,无法在QuickTime上正确播放。只显示音频,不显示视频。

  2. 我怎么可能解决这个问题

完整的FFMPEG控制台输出:

ffmpeg version git-2013-06-06-c51654f Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun  6 2013 12:54:24 with gcc 4.6.3 (GCC) 20120306 (Red Hat 4.6.3-2)
  configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264
  libavutil      52. 35.100 / 52. 35.100
  libavcodec     55. 15.100 / 55. 15.100
  libavformat    55.  8.102 / 55.  8.102
  libavdevice    55.  2.100 / 55.  2.100
  libavfilter     3. 75.101 /  3. 75.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'op.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.8.102
  Duration: 00:00:06.00, start: 0.010000, bitrate: 679 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 640x364 [SAR 1:1 DAR 160:91], 590 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 130 kb/s
    Metadata:
      handler_name    : SoundHandler
[segment @ 0x32e1d60] Codec for stream 0 does not use global headers but container format requires global headers
[segment @ 0x32e1d60] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, segment, to 'op%05d.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.8.102
    Stream #0:0(eng): Video: mpeg2video, yuv420p, 640x364 [SAR 1:1 DAR 160:91], q=2-31, 128 kb/s, 90k tbn, 25 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: mp2, 44100 Hz, stereo, s16, 128 kb/s
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg2video)
  Stream #0:1 -> #0:1 (aac -> mp2)
Press [q] to stop, [?] for help
[segment @ 0x32e1d60] Non-monotonous DTS in output stream 0:1; previous: 347527, current: 346508; changing to 347528. This may result in incorrect timestamps in the output file.
frame=  109 fps=0.0 q=31.0 size=N/A time=00:00:04.29 bitrate=N/A dup=14 drop=0  frame=  151 fps=0.0 q=24.8 Lsize=N/A time=00:00:06.00 bitrate=N/A dup=14 drop=0    
video:350kB audio:96kB subtitle:0 global headers:0kB muxing overhead -100.004823%

使用vsync和async选项时,出现的错误是“流0的编解码器不使用全局头,但是容器格式需要全局头”。这是控制台输出:

ffmpeg -i op.mp4  -b:v 128k -flags -global_header -map 0:0 -map 0:1 -f segment -segment_time 4 -segment_list_size 0 -segment_list nop.m3u8 -segment_format mpegts nop%05d.ts  
ffmpeg version git-2013-06-06-c51654f Copyright (c) 2000-2013 the FFmpeg developers
  built on Jun  6 2013 12:54:24 with gcc 4.6.3 (GCC) 20120306 (Red Hat 4.6.3-2)
  configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264
  libavutil      52. 35.100 / 52. 35.100
  libavcodec     55. 15.100 / 55. 15.100
  libavformat    55.  8.102 / 55.  8.102
  libavdevice    55.  2.100 / 55.  2.100
  libavfilter     3. 75.101 /  3. 75.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'op.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.8.102
  Duration: 00:00:06.00, start: 0.010000, bitrate: 679 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 640x364 [SAR 1:1 DAR 160:91], 590 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 130 kb/s
    Metadata:
      handler_name    : SoundHandler
[segment @ 0x3bf3d60] Codec for stream 0 does not use global headers but container format requires global headers
[segment @ 0x3bf3d60] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, segment, to 'nop%05d.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.8.102
    Stream #0:0(eng): Video: mpeg2video, yuv420p, 640x364 [SAR 1:1 DAR 160:91], q=2-31, 128 kb/s, 90k tbn, 25 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: mp2, 44100 Hz, stereo, s16, 128 kb/s
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg2video)
  Stream #0:1 -> #0:1 (aac -> mp2)
Press [q] to stop, [?] for help
[segment @ 0x3bf3d60] Non-monotonous DTS in output stream 0:1; previous: 347527, current: 346508; changing to 347528. This may result in incorrect timestamps in the output file.
frame=  119 fps=0.0 q=31.0 size=N/A time=00:00:04.68 bitrate=N/A dup=14 drop=0  frame=  151 fps=0.0 q=24.8 Lsize=N/A time=00:00:06.00 bitrate=N/A dup=14 drop=0    
video:350kB audio:96kB subtitle:0 global headers:0kB muxing overhead -100.004823%

请提供完整的ffmpeg控制台输出。
llogan 2013年

编辑以添加完整的ffmpeg控制台输出
Divya Bhargov

如果添加参数会-vsync 1 -async 1怎样?
harrymc

1
我不明白您要做什么。M3U8是播放列表规范,而不是视频格式。请提供有关所需用例的更多详细信息。
MrDrMcCoy 2014年

2
这个星球上
大概

Answers:


1

您的CSI剪辑也将转换为非单调DTS消息。我可以在VLC中播放MP4剪辑,但是ffplay最终出现了问题。我不知道那是什么意思。

ffmpeg -i op.mp4 -b:v 128k -flags -global_header -map 0:0 -map 0:1 -f segment -segment_time 4 -segment_list_size 0 -segment_list op.m3u8 -segment_format mpegts op%05d.ts

只需获取ffmpeg的较新版本。您的日期是2013年6月。2014年3月的矿山工作得很好。mp4在VLC上对我来说还不错。单个.ts文件对我来说也很好。

C:\temp>dir op*
 Volume in drive C has no label.
 Volume Serial Number is xxx-xxx

 Directory of C:\temp

10/07/2014  08:52 PM               169 op.m3u8
10/07/2014  08:51 PM           509,425 op.mp4
10/07/2014  08:52 PM           404,764 op00000.ts
10/07/2014  08:52 PM           148,520 op00001.ts
               4 File(s)      1,062,878 bytes

op.m3u8以4秒的增量创建了该段,直到文件被完全处理。

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:5
#EXTINF:4.120000,
op00000.ts
#EXTINF:1.960000,
op00001.ts
#EXT-X-ENDLIST

1

mp4只有6秒长,并且音频流的长度与视频长度不同,我可以通过执行以下操作来同步两者并摆脱DTS错误:

ffmpeg -i op.mp4 -ss 00:00:00.11 -t 00:00:06.00 -vn -y op.wav

ffmpeg -i op.mp4 -ss 0.010000 -t 00:00:06 -vcodec rawvideo -an -y op.avi

ffmpeg -i op.avi -i op.wav -b:v 590k -b:a 130k -t 00:00:06 -y op_fixed.mp4

基本上,这会重新创建mp4,并修复了一些较小的损坏问题,同时使两个流的长度相同。

另外,您的命令行不需要两个-map参数,原始mp4的编解码器都不支持全局标头,除此之外,我不认为您仍然需要它们。完成上面列出的步骤后,以下各项应正确完成:

ffmpeg -i op_fixed.mp4 -b:v 128k -f segment -segment_time 4 -segment_list_size 0 -segment_list op.m3u8 -segment_format mpegts op%05d.ts
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.