Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
is it possible to download only desired time interval? #4821
Comments
|
At the moment, there is no such functionality. This is quite complicated internally, because we need to find a table of which times correspond to which byte intervals, interpret that table, download the partial file (that's actually the easy part), and then reassemble the whole shebang so that the headers are valid. |
|
You could try to let youtube-dl only generate the url and then feed that url to ffmpeg. SET /P url=
FOR /F %%A IN ('youtube-dl.exe -g %url%') DO (
ffmpeg.exe -ss 00:41:55 -i "%%A" -c copy -t 00:03:00 output.mp4
) |
|
Thank You.. !! |
|
+1 Long Twitch videos can sometimes be upwards of 5 GiB or more, and if you just want watch a small part of them, you have to wait a long time to be able to even watch that. |
|
@corone17 This command downloads a full video to /tmp files or somewhere, loads it for cutting OR it naturally retrieves a part of remote file? |
|
@corone17 This didn't work with long video: http://www.youtube.com/watch?v=eyU3bRy2x44 :-( |
|
@alexmatveev I didn't actually test it 3 months ago, so you could try and run the following as a batch-file: @ECHO off
:Input
ECHO.
SET url=
ECHO Enter Youtube-url:
SET /P url=
IF "%url%" EQU "" GOTO End
IF "%url: =%" NEQ "%url%" GOTO Input
ECHO Enter start time (in seconds, or in hh:mm:ss[.xxx] form):
SET /P start=
ECHO Enter duration (in seconds, or in hh:mm:ss[.xxx] form):
SET /P dur=
ECHO.
FOR /F "delims==" %%A IN ('youtube-dl.exe --no-warnings --get-filename "%url%"') DO SET filename=%%A
FOR /F %%B IN ('youtube-dl.exe -g "%url%"') DO (
ffmpeg.exe -hide_banner -ss "%start%" -i "%%B" -c copy -t "%dur%" "%filename%"
)
GOTO Input
:EndIf you make sure youtube-dl.exe and ffmpeg.exe are in the same directory, then this will work fine for your 3hour fireplace video :p. |
|
Closing as a duplicate of #622. |
|
@Reino17 Could you please write a shell script? (for linux users) |
|
I'm sorry, but I'm not a Linux user. I have very little experience with Linux's shell script. |
|
@Reino17 Ok, still thanks |
|
i finally made an account because I'm desperate for a clipconverter dot cc alternative because they've recently made impossible restrictions to what they could download. Really hope you find a way :( |
|
I know this is a somewhat difficult feature, but it is a great one to add. Right now, I want to grab a 2 minute clip from a 3 gig video file! I'd love to be able to give you the -ss and -t flags like ffmpeg. |
|
youtube-dl does have a --postprocessor-args command-line parameter. Example: youtube-dl --postprocessor-args "-ss 00:13:00.00 -t 00:04:00.00" https://youtu.be/... where -ss indicates start position (13 minutes in) and -t indicates new length (4 minutes) of output video. Just tried it with a 47-minute video that had about 4 hours of nothing on the end of it. I used --postprocessor-args "-t 00:47:00.0" and it worked fine. |
|
I know that this question is long but you can do it using this command:
You need to have the |
|
Yes, but that would mean I will have to download what could be a 1 gb file to get a few seconds |
|
I was primarily giving a command-line-friendly solution. If your download speed is too slow, then what alternative would you suggest for downloading a smaller chunk of the original? |
|
teocci's command works perfectly and doesn't download the entire video; I just tried it. Inspired by it and Reino17's script, I hacked together a non-interactive Bash function that downloads a range of any youtube-dl downloadable video, provided you have ffmpeg. You can put it in you download-clip() {
# $1: url or Youtube video id
# $2: starting time, in seconds, or in hh:mm:ss[.xxx] form
# $3: duration, in seconds, or in hh:mm:ss[.xxx] form
# $4: format, as accepted by youtube-dl (default: best)
# other args are passed directly to youtube-dl; eg, -r 40K
local fmt=${4:-best}
local url="$(youtube-dl --get-url "$1" -f $fmt ${@:5})"
local filename="$(youtube-dl --get-filename "$1" ${@:5})"
ffmpeg -loglevel warning -hide_banner \
-ss $2 -i "$url" -c copy -t $3 "$filename"
printf "Saved to: %s\n" "$filename"
# based on Reino17's and teocci's comments in https://github.com/rg3/youtube-dl/issues/4821
}A few catches:
|
|
Very nice. |
|
Thanks, Reino17.
I preferred I also forgot to add the format option to the get-filename command, because it can change the extension. As I can't find a documentation for the urls-options order except what you mentioned, I will change the code to put the urls at the end. Thanks. I also added the For quieter output, you can remove download-clip() {
# $1: url or Youtube video id
# $2: starting time, in seconds, or in hh:mm:ss[.xxx] form
# $3: duration, in seconds, or in hh:mm:ss[.xxx] form
# $4: format, as accepted by youtube-dl (default: best)
# other args are passed directly to youtube-dl; eg, -r 40K
local fmt=${4:-best}
local url="$(youtube-dl -g -f $fmt ${@:5} "$1")"
local filename="$(youtube-dl --get-filename -f $fmt ${@:5} "$1")"
ffmpeg -loglevel warning -hide_banner -stats \
-ss $2 -i "$url" -c copy -t $3 "$filename"
printf "Saved to: %s\n" "$filename"
# based on Reino17's and teocci's comments in https://github.com/rg3/youtube-dl/issues/4821
} |
|
That's a great step. Do you think you could convert it to Python and submit it as a patch? |
|
@noureddin do you know a way of doing same but with support for resuming? |
|
@satnatantas, if ffmpeg can resume a paused transcoding, it can be done. But unfortunately I couldn't find a way to do that reliably; the best way I was able to find is to pause using |
|
any progress ? |
I want to download small part of a video which is 2 hours long and 1080p. How can i do that with youtube-dl?