Youtube separate audio and video streams.
by teckk from LinuxQuestions.org on (#6PSB2)
I thought that this might be useful for some of you.
Youtube continues to change every few days so that only separate audio and video streams are available. yt-dlp is keeping up with it. I've had to update yt-dlp 4 times in the last 30 days to keep up. And, it may take a couple of days for them to update. I suspect that youtube is going to continue to do that. And for those of you that can't update yt-dlp every week, that might be hacking you off.
In the mean time, waiting for yt-dlp to update, or if you can't, you can use the version of yt-dlp that you have and something like ffmpeg to play those videos. Just get an audio and a video stream, play them both at once.
For example:
https://m.youtube.com/watch?v=M-k_BW8iLkk
Code:yt-dlp -F https://m.youtube.com/watch?v=M-k_BW8iLkk
sb3 mhtml 48x27 0 mhtml images storyboard
sb2 mhtml 80x45 0 mhtml images storyboard
sb1 mhtml 160x90 0 mhtml images storyboard
sb0 mhtml 320x180 0 mhtml images storyboard
233 mp4 audio only m3u8 audio only unknown Default
234 mp4 audio only m3u8 audio only unknown Default
139-drc m4a audio only 2 2.13MiB 49k https audio only mp4a.40.5 49k 22k low, DRC, m4a_dash
139 m4a audio only 2 2.13MiB 49k https audio only mp4a.40.5 49k 22k low, m4a_dash
140-drc m4a audio only 2 5.66MiB 129k https audio only mp4a.40.2 129k 44k medium, DRC, m4a_dash
140 m4a audio only 2 5.66MiB 129k https audio only mp4a.40.2 129k 44k medium, m4a_dash
602 mp4 256x144 15 ~ 3.74MiB 85k m3u8 vp09.00.10.08 85k video only
394 mp4 256x144 30 3.07MiB 70k https av01.0.00M.08 70k video only 144p, mp4_dash
269 mp4 256x144 30 ~ 7.16MiB 164k m3u8 avc1.4D400C 164k video only
160 mp4 256x144 30 2.30MiB 53k https avc1.4D400C 53k video only 144p, mp4_dash
603 mp4 256x144 30 ~ 7.10MiB 162k m3u8 vp09.00.11.08 162k video only
278 webm 256x144 30 4.09MiB 94k https vp09.00.11.08 94k video only 144p, webm_dash
395 mp4 426x240 30 4.62MiB 106k https av01.0.00M.08 106k video only 240p, mp4_dash
229 mp4 426x240 30 ~13.63MiB 311k m3u8 avc1.4D4015 311k video only
133 mp4 426x240 30 5.32MiB 122k https avc1.4D4015 122k video only 240p, mp4_dash
604 mp4 426x240 30 ~12.59MiB 288k m3u8 vp09.00.20.08 288k video only
242 webm 426x240 30 5.40MiB 124k https vp09.00.20.08 124k video only 240p, webm_dash
396 mp4 640x360 30 8.04MiB 184k https av01.0.01M.08 184k video only 360p, mp4_dash
230 mp4 640x360 30 ~27.09MiB 619k m3u8 avc1.4D401E 619k video only
134 mp4 640x360 30 9.59MiB 220k https avc1.4D401E 220k video only 360p, mp4_dash
605 mp4 640x360 30 ~24.74MiB 565k m3u8 vp09.00.21.08 565k video only
243 webm 640x360 30 9.78MiB 224k https vp09.00.21.08 224k video only 360p, webm_dash
397 mp4 854x480 30 12.12MiB 277k https av01.0.04M.08 277k video only 480p, mp4_dash
231 mp4 854x480 30 ~36.57MiB 836k m3u8 avc1.4D401F 836k video only
135 mp4 854x480 30 14.09MiB 323k https avc1.4D401F 323k video only 480p, mp4_dash
606 mp4 854x480 30 ~31.81MiB 727k m3u8 vp09.00.30.08 727k video only
244 webm 854x480 30 13.04MiB 299k https vp09.00.30.08 299k video only 480p, webm_dash
398 mp4 1280x720 30 17.58MiB 402k https av01.0.05M.08 402k video only 720p, mp4_dash
232 mp4 1280x720 30 ~46.94MiB 1073k m3u8 avc1.4D401F 1073k video only
136 mp4 1280x720 30 19.14MiB 438k https avc1.4D401F 438k video only 720p, mp4_dash
609 mp4 1280x720 30 ~48.37MiB 1106k m3u8 vp09.00.31.08 1106k video only
247 webm 1280x720 30 21.10MiB 483k https vp09.00.31.08 483k video only 720p, webm_dashYou see that there are sep video and sep audio streams only. They have removed 18 and 22.
Not a problem.
This example will play format 134 and 140 together.
Code:agent="Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/119.0.6045.109 Mobile/15E148 Safari/604.1"
prev="https://m.youtube.com/watch?v=M-k_BW8iLkk"
a=$(yt-dlp --user-agent "$agent" -q -g -f 134 "$prev")
b=$(yt-dlp --user-agent "$agent" -q -g -f 140 "$prev")
ffplay pipe &
pid1=$!
ffmpeg -i "$a" -i "$b" -c:a copy -c:v copy -f nut pipe:1 > pipe
while :; do
read -t 1 -s -n 1 key
if [[ "$key" = [Qq] ]]; then
kill "$pid1"
fi
exit
doneAnd I would of course script that, with the bandwidth that you want, with a menu to choose from.
Youtube continues to change every few days so that only separate audio and video streams are available. yt-dlp is keeping up with it. I've had to update yt-dlp 4 times in the last 30 days to keep up. And, it may take a couple of days for them to update. I suspect that youtube is going to continue to do that. And for those of you that can't update yt-dlp every week, that might be hacking you off.
In the mean time, waiting for yt-dlp to update, or if you can't, you can use the version of yt-dlp that you have and something like ffmpeg to play those videos. Just get an audio and a video stream, play them both at once.
For example:
https://m.youtube.com/watch?v=M-k_BW8iLkk
Code:yt-dlp -F https://m.youtube.com/watch?v=M-k_BW8iLkk
sb3 mhtml 48x27 0 mhtml images storyboard
sb2 mhtml 80x45 0 mhtml images storyboard
sb1 mhtml 160x90 0 mhtml images storyboard
sb0 mhtml 320x180 0 mhtml images storyboard
233 mp4 audio only m3u8 audio only unknown Default
234 mp4 audio only m3u8 audio only unknown Default
139-drc m4a audio only 2 2.13MiB 49k https audio only mp4a.40.5 49k 22k low, DRC, m4a_dash
139 m4a audio only 2 2.13MiB 49k https audio only mp4a.40.5 49k 22k low, m4a_dash
140-drc m4a audio only 2 5.66MiB 129k https audio only mp4a.40.2 129k 44k medium, DRC, m4a_dash
140 m4a audio only 2 5.66MiB 129k https audio only mp4a.40.2 129k 44k medium, m4a_dash
602 mp4 256x144 15 ~ 3.74MiB 85k m3u8 vp09.00.10.08 85k video only
394 mp4 256x144 30 3.07MiB 70k https av01.0.00M.08 70k video only 144p, mp4_dash
269 mp4 256x144 30 ~ 7.16MiB 164k m3u8 avc1.4D400C 164k video only
160 mp4 256x144 30 2.30MiB 53k https avc1.4D400C 53k video only 144p, mp4_dash
603 mp4 256x144 30 ~ 7.10MiB 162k m3u8 vp09.00.11.08 162k video only
278 webm 256x144 30 4.09MiB 94k https vp09.00.11.08 94k video only 144p, webm_dash
395 mp4 426x240 30 4.62MiB 106k https av01.0.00M.08 106k video only 240p, mp4_dash
229 mp4 426x240 30 ~13.63MiB 311k m3u8 avc1.4D4015 311k video only
133 mp4 426x240 30 5.32MiB 122k https avc1.4D4015 122k video only 240p, mp4_dash
604 mp4 426x240 30 ~12.59MiB 288k m3u8 vp09.00.20.08 288k video only
242 webm 426x240 30 5.40MiB 124k https vp09.00.20.08 124k video only 240p, webm_dash
396 mp4 640x360 30 8.04MiB 184k https av01.0.01M.08 184k video only 360p, mp4_dash
230 mp4 640x360 30 ~27.09MiB 619k m3u8 avc1.4D401E 619k video only
134 mp4 640x360 30 9.59MiB 220k https avc1.4D401E 220k video only 360p, mp4_dash
605 mp4 640x360 30 ~24.74MiB 565k m3u8 vp09.00.21.08 565k video only
243 webm 640x360 30 9.78MiB 224k https vp09.00.21.08 224k video only 360p, webm_dash
397 mp4 854x480 30 12.12MiB 277k https av01.0.04M.08 277k video only 480p, mp4_dash
231 mp4 854x480 30 ~36.57MiB 836k m3u8 avc1.4D401F 836k video only
135 mp4 854x480 30 14.09MiB 323k https avc1.4D401F 323k video only 480p, mp4_dash
606 mp4 854x480 30 ~31.81MiB 727k m3u8 vp09.00.30.08 727k video only
244 webm 854x480 30 13.04MiB 299k https vp09.00.30.08 299k video only 480p, webm_dash
398 mp4 1280x720 30 17.58MiB 402k https av01.0.05M.08 402k video only 720p, mp4_dash
232 mp4 1280x720 30 ~46.94MiB 1073k m3u8 avc1.4D401F 1073k video only
136 mp4 1280x720 30 19.14MiB 438k https avc1.4D401F 438k video only 720p, mp4_dash
609 mp4 1280x720 30 ~48.37MiB 1106k m3u8 vp09.00.31.08 1106k video only
247 webm 1280x720 30 21.10MiB 483k https vp09.00.31.08 483k video only 720p, webm_dashYou see that there are sep video and sep audio streams only. They have removed 18 and 22.
Not a problem.
This example will play format 134 and 140 together.
Code:agent="Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/119.0.6045.109 Mobile/15E148 Safari/604.1"
prev="https://m.youtube.com/watch?v=M-k_BW8iLkk"
a=$(yt-dlp --user-agent "$agent" -q -g -f 134 "$prev")
b=$(yt-dlp --user-agent "$agent" -q -g -f 140 "$prev")
ffplay pipe &
pid1=$!
ffmpeg -i "$a" -i "$b" -c:a copy -c:v copy -f nut pipe:1 > pipe
while :; do
read -t 1 -s -n 1 key
if [[ "$key" = [Qq] ]]; then
kill "$pid1"
fi
exit
doneAnd I would of course script that, with the bandwidth that you want, with a menu to choose from.