OtherCrashOverride / c2play

Command line video player for Odroid C2
GNU General Public License v2.0
42 stars 72 forks source link

Support playback from an audio stream passed as a command line argument #12

Open mad-ady opened 7 years ago

mad-ady commented 7 years ago

Here's the problem. If you want to play youtube content higher than 720p you will have a video-only stream and an audio-only stream returned by youtube-dl:

adrianp@frost:~$ youtube-dl --list-formats https://www.youtube.com/watch?v=2b9txcAt4e0 [youtube] 2b9txcAt4e0: Downloading webpage [youtube] 2b9txcAt4e0: Downloading video info webpage [youtube] 2b9txcAt4e0: Extracting video information [youtube] 2b9txcAt4e0: Downloading MPD manifest [info] Available formats for 2b9txcAt4e0: format code extension resolution note 249 webm audio only DASH audio 58k , opus @ 50k (48000Hz), 4.68MiB 250 webm audio only DASH audio 87k , opus @ 70k (48000Hz), 6.67MiB 140 m4a audio only DASH audio 128k , m4a_dash container, mp4a.40.2@128k (44100Hz), 10.96MiB 171 webm audio only DASH audio 132k , vorbis@128k (44100Hz), 10.52MiB 251 webm audio only DASH audio 168k , opus @160k (48000Hz), 13.04MiB 160 mp4 256x144 DASH video 115k , avc1.4d400c, 30fps, video only, 9.50MiB 278 webm 256x144 DASH video 126k , webm container, vp9, 30fps, video only, 7.88MiB 133 mp4 426x240 DASH video 261k , avc1.4d4015, 30fps, video only, 21.16MiB 242 webm 426x240 DASH video 288k , vp9, 30fps, video only, 18.02MiB 243 webm 640x360 DASH video 572k , vp9, 30fps, video only, 35.15MiB 134 mp4 640x360 DASH video 646k , avc1.4d401e, 30fps, video only, 44.23MiB 244 webm 854x480 DASH video 1068k , vp9, 30fps, video only, 66.07MiB 135 mp4 854x480 DASH video 1226k , avc1.4d401f, 30fps, video only, 90.55MiB 247 webm 1280x720 DASH video 2008k , vp9, 30fps, video only, 130.70MiB 136 mp4 1280x720 DASH video 2469k , avc1.4d401f, 30fps, video only, 185.87MiB 248 webm 1920x1080 DASH video 4160k , vp9, 30fps, video only, 238.54MiB 137 mp4 1920x1080 DASH video 4833k , avc1.640028, 30fps, video only, 353.80MiB 264 mp4 2560x1440 DASH video 11109k , avc1.640032, 30fps, video only, 858.77MiB 271 webm 2560x1440 DASH video 22840k , vp9, 30fps, video only, 839.74MiB 266 mp4 3840x2160 DASH video 23781k , avc1.640033, 30fps, video only, 1.79GiB 313 webm 3840x2160 DASH video 41369k , vp9, 30fps, video only, 1.61GiB 36 3gp 320x? small , mp4v.20.3, mp4a.40.2 17 3gp 176x144 small , mp4v.20.3, mp4a.40.2@ 24k 43 webm 640x360 medium , vp8.0, vorbis@128k 18 mp4 640x360 medium , avc1.42001E, mp4a.40.2@ 96k 22 mp4 1280x720 hd720 , avc1.64001F, mp4a.40.2@192k (best)

It would be nice if a client could feed a video URL (such as the one returned by format 264) followed by an audio URL (such as 140) and the player could play them together. (For me playing the DASH video with your player crashes X11 and also MALI, so it may not be an option - https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP)

I realize that it will be problematic to play from two network streams (you'll have to use threads and synchronization). If you feel there's a better approach (e.g. use ffmpeg to mux them and playing from STDIN), let me know.

OtherCrashOverride commented 7 years ago

This is a feature I already wanted to support. I just have not figured out the best way to do it. There really is no need to mux the streams together. It may actually be simple to do with the beta1 architecture by having two independent source elements and graphs with only the clock line connecting them for synchronization.

OtherCrashOverride commented 7 years ago

I have started experimental support for this in the "dualstream" branch: https://github.com/OtherCrashOverride/c2play/tree/dualstream

./c2play-x11 http://video_stream --dual https://audio_stream

[edit] Note that for urls, it may be necessary to enclose them in quotation marks if they contain characters like "&" since they have special meaning to the shell.

./c2play-x11 "http://video_stream" --dual "https://audio_stream"

mad-ady commented 7 years ago

I've tried it and... it seems to work. I was unable to test sound and audio synchronization because I don't have a sound card, but playback has a bit of "lost packets" that could be seen in the logs:

Oct 12 12:40:31 uy-scuti odroid.c2.video.helper[21084]: AmlVideoSink: Adjust PTS - pts=134.311922 vpts=134.200733 drift=-0.111189 (-3.332334 frames)
Oct 12 12:40:31 uy-scuti odroid.c2.video.helper[21084]: AmlVideoSink: Adjust PTS - pts=134.409856 vpts=134.300833 drift=-0.109022 (-3.267399 frames)
Oct 12 12:40:31 uy-scuti odroid.c2.video.helper[21084]: AmlVideoSink: Adjust PTS - pts=134.410467 vpts=134.300833 drift=-0.109633 (-3.285714 frames)
Oct 12 12:40:31 uy-scuti odroid.c2.video.helper[21084]: AmlVideoSink: Adjust PTS - pts=134.411056 vpts=134.300833 drift=-0.110222 (-3.303363 frames)
Oct 12 12:40:31 uy-scuti odroid.c2.video.helper[21084]: AmlVideoSink: Adjust PTS - pts=134.411400 vpts=134.300833 drift=-0.110567 (-3.313686 frames)

I'm guessing you're on the right track. I will update my packages and request for testers.

OtherCrashOverride commented 7 years ago

I will likely need to add some kind of stream pre-buffering so that playback does not start until a certain amount of both video and audio have arrived.