Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZDF: audio is 1.8 sec ahead of video #3534

Closed
2 tasks done
litist opened this issue Feb 3, 2021 · 9 comments
Closed
2 tasks done

ZDF: audio is 1.8 sec ahead of video #3534

litist opened this issue Feb 3, 2021 · 9 comments

Comments

@litist
Copy link

litist commented Feb 3, 2021

Plugin Issue

  • This is a plugin issue and I have read the contribution guidelines.
  • I am using the latest development version from the master branch.

Description

When i save a ZDF stream to a file, it happens, that the audio is roughly 1.8sec ahead of the video. I would estimate that this happens in half of the cases, in the others audio is sync.
This also happens when i am using other stream quality options.

Reproduction steps / Explicit stream URLs to test

  1. streamlink https://www.zdf.de/live-tv "720,best" -o zdf_day1_210202_1.mp4 -f --hls-duration 20 --loglevel debug

Log output

root@e55ff1a203c8:/streamlink# /root/.local/bin/streamlink https://www.zdf.de/live-tv "720,best" -o zdf_day1_210202_1.mp4 -f  --hls-duration 20 --loglevel debug
[cli][info] streamlink is running as root! Be careful!
[cli][debug] OS:         Linux-4.15.0-99-lowlatency-x86_64-with-glibc2.29
[cli][debug] Python:     3.8.5
[cli][debug] Streamlink: 2.0.0+34.g64365fa
[cli][debug] Requests(2.25.1), Socks(1.7.1), Websocket(0.57.0)
[cli][info] Found matching plugin zdf_mediathek for URL https://www.zdf.de/live-tv
[utils.l10n][debug] Language code: en_US
[stream.hls][debug] Using external audio tracks for stream 270p (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 270p_alt (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 360p (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 360p_alt (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 540p (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 540p_alt (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 720p (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 720p_alt (language=deu, name=TV Ton)
[utils.l10n][debug] Language code: en_US
[stream.hls][debug] Using external audio tracks for stream 720p (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 720p_alt (language=deu, name=TV Ton)
[utils.l10n][debug] Language code: en_US
[stream.hls][debug] Using external audio tracks for stream 270p (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 270p_alt (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 360p (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 360p_alt (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 540p (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 540p_alt (language=deu, name=TV Ton)
[utils.l10n][debug] Language code: en_US
[stream.hls][debug] Using external audio tracks for stream 270p (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 270p_alt (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 360p (language=deu, name=TV Ton)
[stream.hls][debug] Using external audio tracks for stream 360p_alt (language=deu, name=TV Ton)
[cli][info] Available streams: 270p_alt (worst), 270p, 360p_alt, 360p, 540p_alt, 540p, 720p_alt, 720p (best)
[cli][info] Opening stream: 720p (hls-multi)
[stream.ffmpegmux][debug] Opening hls substream
[stream.hls][debug] Reloading playlist
[stream.hls][debug] First Sequence: 2086956; Last Sequence: 2087840
[stream.hls][debug] Start offset: 0; Duration: 20; Start Sequence: 2087838; End Sequence: None
[stream.hls][debug] Adding segment 2087838 to queue
[stream.ffmpegmux][debug] Opening hls substream
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Adding segment 2087839 to queue
[stream.hls][debug] Adding segment 2087840 to queue
[stream.hls][debug] First Sequence: 2086957; Last Sequence: 2087841
[stream.hls][debug] Start offset: 0; Duration: 20; Start Sequence: 2087839; End Sequence: None
[stream.hls][debug] Adding segment 2087839 to queue
[stream.hls][debug] Adding segment 2087840 to queue
[stream.hls][debug] Adding segment 2087841 to queue
[stream.ffmpegmux][debug] ffmpeg command: ffmpeg -nostats -y -i /tmp/ffmpeg-5819-744 -i /tmp/ffmpeg-5819-93 -c:v copy -c:a copy -map 0:v? -map 0:a? -map 1:a -f mpegts pipe:1
[stream.ffmpegmux][debug] Starting copy to pipe: /tmp/ffmpeg-5819-744
[stream.ffmpegmux][debug] Starting copy to pipe: /tmp/ffmpeg-5819-93
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] Download of segment 2087839 complete
[stream.hls][debug] Download of segment 2087840 complete
[stream.hls][debug] Download of segment 2087841 complete
[stream.hls][debug] Download of segment 2087838 complete
[stream.hls][debug] Download of segment 2087839 complete
[stream.hls][debug] Download of segment 2087840 complete
[cli][debug] Checking file output
[cli][debug] Writing stream to output
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Adding segment 2087841 to queue
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Adding segment 2087842 to queue
[stream.hls][debug] Download of segment 2087841 complete
[download][zdf_day1_210202_1.mp4] Written 2.0 MB (1s @ 1.0 MB/s)                                                                                                                                                                                                                e
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Adding segment 2087842 to queue
[stream.hls][debug] Adding segment 2087843 to queue
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Adding segment 2087843 to queue
[stream.hls][debug] Download of segment 2087842 complete
[stream.hls][debug] Download of segment 2087843 complete
[download][zdf_day1_210202_1.mp4] Written 2.6 MB (4s @ 657.1 KB/s)                                                                                                                                                                                                              e
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Adding segment 2087844 to queue
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Adding segment 2087844 to queue
[stream.hls][debug] Download of segment 2087844 complete
[stream.hls][debug] Download of segment 2087844 complete
[download][zdf_day1_210202_1.mp4] Written 3.6 MB (6s @ 598.8 KB/s)                                                                                                                                                                                                              t
[stream.hls][debug] Adding segment 2087845 to queue
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Adding segment 2087845 to queue
[stream.hls][debug] Download of segment 2087845 complete
[stream.hls][debug] Download of segment 2087845 complete
[download][zdf_day1_210202_1.mp4] Written 4.7 MB (8s @ 578.5 KB/s)                                                                                                                                                                                                              t
[stream.hls][debug] Adding segment 2087846 to queue
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Adding segment 2087846 to queue
[stream.hls][debug] Download of segment 2087846 complete
[stream.hls][debug] Download of segment 2087846 complete
[download][zdf_day1_210202_1.mp4] Written 5.7 MB (10s @ 567.4 KB/s)                                           
[stream.hls][debug] Adding segment 2087847 to queue
[stream.hls][info] Stopping stream early after 20
[stream.segmented][debug] Closing worker thread
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Download of segment 2087847 complete
[stream.segmented][debug] Closing writer thread
[stream.hls][debug] Adding segment 2087847 to queue
[stream.hls][debug] Download of segment 2087847 complete
[download][zdf_day1_210202_1.mp4] Written 6.8 MB (12s @ 469.2 KB/s)                                                                                                                                                                                                             t
[stream.hls][debug] Adding segment 2087848 to queue
[stream.hls][info] Stopping stream early after 20
[stream.segmented][debug] Closing worker thread
[stream.hls][debug] Download of segment 2087848 complete
[stream.segmented][debug] Closing writer thread
[stream.ffmpegmux][debug] Pipe copy complete: /tmp/ffmpeg-5819-93
[download][zdf_day1_210202_1.mp4] Written 7.6 MB (14s @ 493.3 KB/s)                                                                                                                                                                                                             4

[stream.ffmpegmux][debug] Closing ffmpeg thread
[stream.ffmpegmux][debug] Closed all the substreams
[cli][info] Stream ended
[cli][info] Closing currently open stream...

Additional comments, etc.

Love Streamlink? Please consider supporting our collective. Thanks!

@beardypig
Copy link
Member

Does it happen if you watch the stream live?

@back-to
Copy link
Collaborator

back-to commented Feb 3, 2021

@beardypig

[stream.hls][debug] Start offset: 0; Duration: 20; Start Sequence: 2087838; End Sequence: None
...
[stream.hls][debug] Start offset: 0; Duration: 20; Start Sequence: 2087839; End Sequence: None

is is an Streamlink issue with all hls-multi streams, when a Stream start with one segment behind.

Ref #3438 (comment)

--ffmpeg-copyts doesn't work here though

@litist
Copy link
Author

litist commented Feb 3, 2021

Does it happen if you watch the stream live?

Yes, this also happens if i run this:
streamlink https://www.zdf.de/live-tv "720p,best" --player-external-http --player-external-http-port 7001 -l debug

@beardypig
Copy link
Member

@back-to is right, I noticed the same thing - but then I got distracted with something else :) They need to be synchronised some how.

@Billy2011
Copy link
Contributor

They need to be synchronised some how.

With the ffmpeg option -itsoffset (set the input time offset) it would theoretically be possible to synchronize the streams.

@beardypig
Copy link
Member

Need to check the spec to see if the segment number always coincide or if there is some other mechanism that should be used.

@Billy2011
Copy link
Contributor

The #EXT-X-PROGRAM-DATE-TIME tag might be useful.

@beardypig
Copy link
Member

The timestamp must be encoded in the aac file, it is required.

Each Packed Audio Segment MUST signal the timestamp of its first
sample with an ID3 Private frame (PRIV) tag [ID3] at the beginning of
the segment. The ID3 PRIV owner identifier MUST be
"com.apple.streaming.transportStreamTimestamp". The ID3 payload MUST
be a 33-bit MPEG-2 Program Elementary Stream timestamp expressed as a
big-endian eight-octet number, with the upper 31 bits set to zero.
Clients SHOULD NOT play Packed Audio Segments without this ID3 tag.

The question is how to get ffmpeg to use it :)

@bastimeyer
Copy link
Member

Closing in favor of #4721

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants