Kethsar / ytarchive

Garbage Youtube livestream downloader
MIT License
1.04k stars 86 forks source link

Merge on the go #112

Open t184256 opened 1 year ago

t184256 commented 1 year ago

Just an idea. I think you can pipe the downloaded data directly into ffmpeg (or gstreamer), not consume temporary disk space or RAM and skip the post-download merging.

Proof of concept in bash:

ffmpeg -hide_banner -nostdin -stats -loglevel fatal \
  -i <(cd "$CACHEDIR/audio"; yt-dlp --live-from-start "$URL" -f 140 -o-) \
  -i <(cd "$CACHEDIR/video"; yt-dlp --live-from-start "$URL" -f 133 -o-) \
  -vcodec copy -acodec copy \
  -map 0 -map 1 -movflags +faststart outfile.ts

produces a file that is immediately playable and seekable with VLC.

So, maybe ytarchive could use in_fdN, out_fdN = os.pipe(), -i pipe:{out_fd1} -i pipe:{out_fd2} and write to those fds directly.