ffmpeg streaming video not in sync

1.3k views Asked by At

I have a problem saving a streaming with ffmpeg. The problem is that video is not in sync with audio.

The video comes 2-3 seconds before the audio.

I try by removing and editing options but nothing change, I make some research too and I try all solution described in this great answer posted here, but it didn't work for me.

I tried to download a chunk from playlist and I've got a .ts file with audio/video in sync.

If I play the streaming with VLC player I can hear the audio without video for some seconds, then the video appear and is in sync with audio.

ffplay play the same streaming correctly too: seems like there is the time information inside audio and video codec and can be played correctly in sync.

How can I ask ffmpeg to take audio and video in sync?

If you need ffmpeg or ffplay outputs I will post them.


Edit: as requested, I report the full ffmpeg output of a simple command to save stream output to file:

$ ffmpeg -i http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/master.m3u8?hdnts=st=1554271074~exp=1554271524~acl=/*~hmac=14df2434241f7fd52f5a6012094367180f8567a1a733f7ef9eeef3dc7b46ebb2 -c copy out.mp4
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-ffplay --enable-libmp3lame --enable-libopus --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --enable-openssl --disable-lzma --enable-nonfree
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/index_2_av-p.m3u8?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/index_2_av-b.m3u8?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/index_1_av-p.m3u8?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/index_1_av-b.m3u8?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/index_2_a-p.m3u8?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/index_2_a-b.m3u8?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427138_2_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427138_2_av-b.ts?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427138_1_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427138_1_av-b.ts?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427138_2_a-p.ts?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427138_2_a-b.ts?sd=10&rebase=on' for reading
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdf0025e00] non-existing PPS 0 referenced
[h264 @ 0x7ffdf0028200] non-existing PPS 0 referenced
[h264 @ 0x7ffdf0028200] decode_slice_header error
[h264 @ 0x7ffdf0028200] no frame!
[NULL @ 0x7ffdf0025e00] non-existing PPS 0 referenced
[h264 @ 0x7ffdf0028200] non-existing PPS 0 referenced
[h264 @ 0x7ffdf0028200] decode_slice_header error
[h264 @ 0x7ffdf0028200] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[NULL @ 0x7ffdf0025e00] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[h264 @ 0x7ffdf0028200] non-existing PPS 0 referenced
[h264 @ 0x7ffdf0028200] decode_slice_header error
[h264 @ 0x7ffdf0028200] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[NULL @ 0x7ffdf0025e00] non-existing PPS 0 referenced
[h264 @ 0x7ffdf0028200] non-existing PPS 0 referenced
[h264 @ 0x7ffdf0028200] decode_slice_header error
[h264 @ 0x7ffdf0028200] no frame!
[NULL @ 0x7ffdf0025e00] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[h264 @ 0x7ffdf0028200] non-existing PPS 0 referenced
[h264 @ 0x7ffdf0028200] decode_slice_header error
[h264 @ 0x7ffdf0028200] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
[NULL @ 0x7ffdef028000] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] non-existing PPS 0 referenced
[h264 @ 0x7ffdef02a400] decode_slice_header error
[h264 @ 0x7ffdef02a400] no frame!
Input #0, hls,applehttp, from 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/master.m3u8?hdnts=st=1554271074~exp=1554271524~acl=/*~hmac=14df2434241f7fd52f5a6012094367180f8567a1a733f7ef9eeef3dc7b46ebb2':
  Duration: N/A, start: 65871.264133, bitrate: N/A
  Program 0 
    Metadata:
      variant_bitrate : 528000
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv), 400x224, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      variant_bitrate : 528000
    Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 528000
    Stream #0:2: Data: timed_id3 (ID3  / 0x20334449)
    Metadata:
      variant_bitrate : 528000
  Program 1 
    Metadata:
      variant_bitrate : 528000
    Stream #0:3: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv), 400x224, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      variant_bitrate : 528000
    Stream #0:4: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 528000
    Stream #0:5: Data: timed_id3 (ID3  / 0x20334449)
    Metadata:
      variant_bitrate : 528000
  Program 2 
    Metadata:
      variant_bitrate : 1328000
    Stream #0:6: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv), 720x404, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      variant_bitrate : 1328000
    Stream #0:7: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 1328000
    Stream #0:8: Data: timed_id3 (ID3  / 0x20334449)
    Metadata:
      variant_bitrate : 1328000
  Program 3 
    Metadata:
      variant_bitrate : 1328000
    Stream #0:9: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv), 720x404, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Metadata:
      variant_bitrate : 1328000
    Stream #0:10: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 1328000
    Stream #0:11: Data: timed_id3 (ID3  / 0x20334449)
    Metadata:
      variant_bitrate : 1328000
  Program 4 
    Metadata:
      variant_bitrate : 128000
    Stream #0:12: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 128000
    Stream #0:13: Data: timed_id3 (ID3  / 0x20334449)
    Metadata:
      variant_bitrate : 128000
  Program 5 
    Metadata:
      variant_bitrate : 128000
    Stream #0:14: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 128000
    Stream #0:15: Data: timed_id3 (ID3  / 0x20334449)
    Metadata:
      variant_bitrate : 128000
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv), 720x404, q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc
    Metadata:
      variant_bitrate : 1328000
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 528000
Stream mapping:
  Stream #0:6 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[hls,applehttp @ 0x7ffdef800000] No longer receiving playlist 1rate=1167.5kbits/s speed=4.93x    
[hls,applehttp @ 0x7ffdef800000] No longer receiving playlist 5
[hls,applehttp @ 0x7ffdef800000] No longer receiving playlist 3
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427139_2_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427139_1_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] No longer receiving playlist 4
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427140_2_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427140_1_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/index_1_av-p.m3u8?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427141_1_av-p.ts?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/index_2_av-p.m3u8?sd=10&rebase=on' for reading
[hls,applehttp @ 0x7ffdef800000] Opening 'http://la7livehls-lh.akamaihd.net/i/livebkup_1@372883/segment155427141_2_av-p.ts?sd=10&rebase=on' for reading
[mp4 @ 0x7ffdf0170600] Non-monotonous DTS in output stream 0:1; previous: 1440768, current: 1439744; changing to 1440769. This may result in incorrect timestamps in the output file.
(...)
0

There are 0 answers