Live data from Hacker News

Show HN: Download videos, but only the parts you want

videodownloadtool.io

21–30 of 39 posts

Re: Show HN: Download videos, but only the parts you want

#21

Pretty cool! I'm curious as to why this is offered as a cloud machine and not something that runs locally. Wouldn't the encoding performance on a free or cheap cloud instance be poor? I create a lot of video compilations using twitch and youtube videos as source. My internet is 5Mbps down, 3Mbps up, so it can take hours to download long video streams and extract just the parts I want. Because of my network limitation…

> Because of my network limitation If I'm understanding correctly your snippet you're downloading the whole video anyway, no?

I also see that, that syntax should not just download a slice: -f is for the format and -g should be simulation (-g for --get-url : 'Simulate, quiet but print title'). Probably an "undocumented" behaviour of '-g'?

Re: Show HN: Download videos, but only the parts you want

#23

Pretty cool! I'm curious as to why this is offered as a cloud machine and not something that runs locally. Wouldn't the encoding performance on a free or cheap cloud instance be poor? I create a lot of video compilations using twitch and youtube videos as source. My internet is 5Mbps down, 3Mbps up, so it can take hours to download long video streams and extract just the parts I want. Because of my network limitation…

> Because of my network limitation If I'm understanding correctly your snippet you're downloading the whole video anyway, no?

It looks kinda like that, but no. ‘youtube-dl -f best -g …’ returns a url, and ffmpeg seeks in the video stream and doesn’t download the whole thing.

Re: Show HN: Download videos, but only the parts you want

#24

Pretty cool! I'm curious as to why this is offered as a cloud machine and not something that runs locally. Wouldn't the encoding performance on a free or cheap cloud instance be poor? I create a lot of video compilations using twitch and youtube videos as source. My internet is 5Mbps down, 3Mbps up, so it can take hours to download long video streams and extract just the parts I want. Because of my network limitation…

below is (edited for hn) the script i use instead of youtube-dl. the ffmpeg option is added; need to test it. this script works with all non-commercial videos, like the one in the parent comment. for commercial videos that restrict downloads, a browser with limited DNS and request blocking or youtube-dl or a headless browser will work. if use m.youtube.com with minimum headers then should always get mp4 urls with 1-2 quality options: itag=18 or itag=22. run the script with no arguments to see what quality options are available. then run it again with 1 argument to download or run it with 3 arguments to download an excerpt.

if script is called "yt" usage is

  echo https://www.youtube.com/watch?v=Qf2tplcb6eE |yt

  echo https://www.youtube.com/watch?v=Qf2tplcb6eE |yt 22

  echo https://www.youtube.com/watch?v=Qf2tplcb6eE |yt 22 00:15:34 00:16:09


     x3(){ # youtube url variations, adjust as needed
     sed '
     /youtube.googleapis.com/{s//www.youtube.com/;s>/v/>/watch?v=>;};
     s/youtu\.be./www.youtube.com\/watch?v=/;
     s/embed./watch?v=/;s/&.*//;
     ';};
     case $# in :) 
     ;;0)    
     x3|(read x;curl -LHUser-Agent: -sv4 "$x"|grep -o "https://r[^\"]*"|sed 's/\\u0026/\&/g;s/%3D/=/g;s/%2C/,/g;s/%2F/\//g') >.yt;
     grep -o "itag=[^&%]*" .yt||exec echo video removed;
     exit
     ;;1)
     x1=$(x3|sed 's/.*watch?v=//;s/[&%].*//')
     x2=$(sed -n "/itag=$1/p" .yt)
     esac;
     test "${x1}"||exit;
     case $# in :)
     ;;1) exec curl -LHUser-Agent: -sv4Ro "${x1}".mp4 "${x2}"
     ;;3) exec ffmpeg -ss $2 -to $3 -i "${x2}" -vf "crop=(iw*0.75):(ih*0.80):(iw*0.20):(ih*0.08)" "${x1}".mp4
     esac

Re: Show HN: Download videos, but only the parts you want

#25

Pretty cool! I'm curious as to why this is offered as a cloud machine and not something that runs locally. Wouldn't the encoding performance on a free or cheap cloud instance be poor? I create a lot of video compilations using twitch and youtube videos as source. My internet is 5Mbps down, 3Mbps up, so it can take hours to download long video streams and extract just the parts I want. Because of my network limitation…

Maybe it has something to do with the referral codes in the links?

Re: Show HN: Download videos, but only the parts you want

#27

Earlier quoted context omitted.

> Because of my network limitation If I'm understanding correctly your snippet you're downloading the whole video anyway, no?

It looks kinda like that, but no. ‘youtube-dl -f best -g …’ returns a url, and ffmpeg seeks in the video stream and doesn’t download the whole thing.

Wow nice! Thanks for the explanation, else I would have dismissed this beautiful hack!

Re: Show HN: Download videos, but only the parts you want

#29
post #21

Earlier quoted context omitted.

> Because of my network limitation If I'm understanding correctly your snippet you're downloading the whole video anyway, no?

I also see that, that syntax should not just download a slice: -f is for the format and -g should be simulation (-g for --get-url : 'Simulate, quiet but print title'). Probably an "undocumented" behaviour of '-g'?

My former comment (uneditable) was not really getting the mechanism: -g does get the URL, as the expanded option name says (though the explanation says something different), and `ffmpeg -i URL` accepts as input the googlevideo.com URLs. Ok.

Also, the costruct seems to accept input, at least sometimes, from e.g. '-f 137' (mp4 1080), so "very Hi-Res", and '-f 140' (m4a 128kbit), which can be then recombined. So, downloads higher than "720 rasterbars" are in general possible - and they are probably frequent real cases, when one needs to obtain a few frames of very high quality video.

The thing is, it seems to download the initial part anyway. The command takes a lot of time to download, and using e.g. 'iftop' one can see that the command starts downloading immediately, e.g. maybe ~5MB with a '-ss 00:00:10', and ~10MB with a '-ss 00:00:20': the use of '-tt range_end' or '-t duration' will stop downloading at the correct point, but the construct does not really "seek" to the starting point of the video.

Maybe adding some parameter to the URL?

Re: Show HN: Download videos, but only the parts you want

#30

Pretty cool! I'm curious as to why this is offered as a cloud machine and not something that runs locally. Wouldn't the encoding performance on a free or cheap cloud instance be poor? I create a lot of video compilations using twitch and youtube videos as source. My internet is 5Mbps down, 3Mbps up, so it can take hours to download long video streams and extract just the parts I want. Because of my network limitation…

Thanks! It’s cloud because I assume that a lot of people who want to use it will run into issues installing all the dependencies (yt-dlp and ffmpeg), and there’s also the bonus of being able to use this on any device (phones or work computers).

I made it open source so that anyone who wants to run it locally can do so, but maybe there’s a better way to do an easy to install local version?

Post reply on HN