Code Monkey home page Code Monkey logo

Comments (3)

schaecsn avatar schaecsn commented on August 31, 2024

I understand the root cause by now. Most videos are a single stream of video and audio but some videos have a separate audio stream. The latter is common when the ARD Mediathek web front-end provides the choice among standard audio and clear speech audio.

In the past, mediathek failed to play such videos. Commit adec25b from a few minutes ago plays now at least video.

Note: The youtube-dl fork https://github.com/yt-dlp/yt-dlp can merge in real-time such separate video and audio into one stream and pipe it to stdio / ffplay. By replacing

-  "best[width<=${MEDIATHEK_QUALITY}]/bestvideo[width<=${MEDIATHEK_QUALITY}]"
+  "best[width<=${MEDIATHEK_QUALITY}]/bestvideo[width<=${MEDIATHEK_QUALITY}]+bestaudio"

and

- youtube-dl
+ yt-dlp

such videos can be played in mediathek as well. At least in theory. Yt-dlp fails to sync audio and video of livestreams (such as the one from the ARD Mediathek) resulting in audio lagging a few seconds behind. For now, above patch is not applied.

from ard-mediathek-cli.

schaecsn avatar schaecsn commented on August 31, 2024

such videos can be played in mediathek as well. At least in theory. Yt-dlp fails to sync audio and video of livestreams (such as the one from the ARD Mediathek) resulting in audio lagging a few seconds behind. For now, above patch is not applied.

I opened a bug against yt-dlp for the sync issue yt-dlp/yt-dlp#4433

from ard-mediathek-cli.

schaecsn avatar schaecsn commented on August 31, 2024

yt-dl is basically invoking

ffmpeg -y  -i https://mcdn.wdr.de/wdr/wdrfs/weltweit/master-540p-1600.m3u8  -i https://mcdn.wdr.de/wdr/wdrfs/weltweit/master-audio2-128.m3u8 -c copy -map 0:0 -map 1:0 -f mpegts - |  ffplay -loglevel 8  -infbuf -

Here is the verbose output with noise filtered out

$ (ffmpeg -y -i https://mcdn.wdr.de/wdr/wdrfs/weltweit/master-540p-1600.m3u8  -i https://mcdn.wdr.de/wdr/wdrfs/weltweit/master-audio2-128.m3u8 -c copy -map 0:0 -map 1:0 -f mpegts - |  ffplay -loglevel 8  -infbuf -) 2>&1 | egrep  -v "Skip|Opening"
ffmpeg version 4.3.4-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-6)
  configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, hls, from 'https://mcdn.wdr.de/wdr/wdrfs/weltweit/master-540p-1600.m3u8':
  Duration: N/A, start: 5490.880267, bitrate: N/A
  Program 0 
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 960x540 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
    Metadata:
      variant_bitrate : 0
Input #1, hls, from 'https://mcdn.wdr.de/wdr/wdrfs/weltweit/master-audio2-128.m3u8':
  Duration: N/A, start: 5502.889600, bitrate: 115 kb/s
  Program 0 
    Metadata:
      variant_bitrate : 0
    Stream #1:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 115 kb/s
    Metadata:
      variant_bitrate : 0
      id3v2_priv.com.elementaltechnologies.timestamp.utc: 2022-08-14T17:44:28Z
      id3v2_priv.com.apple.streaming.transportStreamTimestamp: \x00\x00\x00\x00\x1d\x85\x11\xa0
Output #0, mpegts, to 'pipe:':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 960x540 [SAR 1:1 DAR 16:9], q=2-31, 50 fps, 50 tbr, 90k tbn, 90k tbc
     Metadata:
      variant_bitrate : 0
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 115 kb/s
    Metadata:
      variant_bitrate : 0
      id3v2_priv.com.elementaltechnologies.timestamp.utc: 2022-08-14T17:44:28Z
      id3v2_priv.com.apple.streaming.transportStreamTimestamp: \x00\x00\x00\x00\x1d\x85\x11\xa0
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[hls @ 0x564283356400] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[hls @ 0x56428362fe80] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)

Apparently, the start timestamps differ, here by 12 seconds

Input #0, hls, from 'https://mcdn.wdr.de/wdr/wdrfs/weltweit/master-540p-1600.m3u8':
  Duration: N/A, start: 5490.880267, bitrate: N/A
Input #1, hls, from 'https://mcdn.wdr.de/wdr/wdrfs/weltweit/master-audio2-128.m3u8':
  Duration: N/A, start: 5502.889600, bitrate: 115 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)

ffmpeg blindly merges two streams. I can't find the proper options to sync them. ffmpeg sync_file_id does not do the trick, e.g. replacing -map 0:0 with -map 0:0,1 resulted in a slightly modified stream mapping, but the video was still not in sync.

Stream mapping:
  Stream #0:0 -> #0:0 [sync #1:0] (copy)
  Stream #1:0 -> #0:1 (copy)

Inserting -ss 12 helps, but the timestamp difference is a running target and every invocation of yt-dl / ffmpeg comes with a new value.

from ard-mediathek-cli.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.