Show HN: Download videos, but only the parts you want
videodownloadtool.io
videodownloadtool.io
The video editing and streaming is CPU and bandwidth intensive. If you want to use this a lot, you're better off using your own server (there are 1-click deploys to both Heroku and Digital Ocean along with a link to the Dockerfile and source), but I've added a link to a demo server if you just want to try it out. Depending on how much use this gets, performance might go down the drain.
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, I found a way to combine ffmpeg and youtube-dl to grab sections of video from a twitch or yt video. The following is an example which replicates the videodownloadtool.io example.
ffmpeg -ss 00:15:34 -to 00:16:09 -i $(youtube-dl -f best -g https://www.youtube.com/watch?v=Qf2tplcb6eE) -vf "crop=(iw*0.75):(ih*0.80):(iw*0.20):(ih*0.08)" ./output.mp4(It depends on youtube-dl -g producing a video URL that ffmpeg understands, which unfortunately is not always the case.)
Related: https://github.com/ytdl-org/youtube-dl/blob/master/README.md...
The caveat is this will only give you up to 720p video, since higher quality have separate audio and video (likely in DASH format), which ffmpeg can understand, but you need to modify the command accordingly. (The default for youtube-dl is `-f bestvideo+bestaudio`; with `-g` it gives you exactly that: two urls for audio and video respectively).
I think you just answered your own question. ;)
If I'm understanding correctly your snippet you're downloading the whole video anyway, no?
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?
Simulate here means it does not download the video. You pass the URL to the ffmpeg which actually downloads the video.
Yes, clearly (after possible initial confusion) -g provides the URL from ffmpeg, which is the actual downloader. The issue then is is moved to the "seek" operation, which is not done by either command (the URL does not contain positioning (for the start of range), and ffmpeg downloads from the beginning of the video - undesirable - up to the specified limit - wanted).
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 x3|(read x;curl -LHUser-Agent: -sv4 "$x"|grep -o "https://r[^\"]*"|sed 's/%26/\&/g;s/%25/%/g;s/%3F/?/g;s/\\u0026/\&/g;s/%3D/=/g;s/%2C/,/g;s/%2F/\//g') >.yt; x3|(read x;curl -LHUser-Agent: -sv4 "$x"|grep -o "https://r[^\"]*"|sed 's/%26/\&/g;s/%25/%/g;s/%3F/?/g;s/\\u0026/\&/g;s/%2C/,/g;s/%2F/\//g') >.yt;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?
Since I'm usually using a web browser, it's more convenient for me to open a new tab and paste in the video URL than open a terminal and remember what the youtube-dl command has to be. Also, smartphones cannot use youtube-dl in convenient ways, at least the last time I tried, so I'd have to open a new SSH session on my phone and painstakingly type everything, and so on.
There used to be a site for exactly this purpose called hierogly.ph but it was shut down, and the author didn't open-source it.
The video I tried is https://www.youtube.com/watch?v=5-X_2VXpEds and I just set a start and stop time.
To crop it and process it at scale you are talking about thousands of dollars of servers to first download the file then process it.
Found a previous post from someone using that lib https://news.ycombinator.com/item?id=26580333
There are a few out there, some have been shutdown for some reason, some seem to be not working and ones which promise think kind of feature are paid. So I needed a 30seconds clip from a 40mins video and not something that I need that frequently that I want pay a monthly subscription for. I ended up using youtube-dl and with a lot of trial and error of various custom commands to finally get what I wanted.
Why didn't you give it a different name than "video download...". It could project vidown or something that's easy to query.