Skip to content

Instantly share code, notes, and snippets.

@heri16
Last active March 23, 2022 04:02
Show Gist options
  • Save heri16/e9ee594928c826195916a73fd6ce1e3c to your computer and use it in GitHub Desktop.
Save heri16/e9ee594928c826195916a73fd6ce1e3c to your computer and use it in GitHub Desktop.
Download / Record Youtube Live stream

Install streamlink utility (https://streamlink.github.io/install.html)

choco install streamlink

Notes:

Record stream

Option 1: Save youtube stream then convert to mp4 format (Faststart)

streamlink --hls-live-restart https://youtu.be/gIB2egm7tL8 1080p,best -o rec1.ts
ffmpeg -i .\rec1.ts -c copy -bsf:a aac_adtstoasc -f mp4 -movflags faststart+separate_moof .\rec1.mp4

Option 2: Save youtube stream directly to mp4 format (ISMV "smooth streaming")

streamlink --hls-live-restart https://youtu.be/gIB2egm7tL8 1080p,best --stdout | ffmpeg -i pipe:0 -c copy -bsf:a aac_adtstoasc -f mp4 -movflags empty_moov+separate_moof+frag_keyframe .\rec2.mp4

Option 3: Pass youtube stream in media player (e.g. VLC) over mp4 format

streamlink --hls-live-restart https://youtu.be/gIB2egm7tL8 1080p,best --stdout | ffmpeg -i pipe:0 -c copy -bsf:a aac_adtstoasc -f mp4 -movflags empty_moov+separate_moof+frag_keyframe pipe:1 | player

References:

@stiv-yakovenko
Copy link

streamlink often disconnects, this makes it unusual for my purposes of youtube recording :(

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