Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminate download after command-line supplied duration #7000

Open
Anonymouslemming opened this issue Sep 27, 2015 · 3 comments
Open

Terminate download after command-line supplied duration #7000

Anonymouslemming opened this issue Sep 27, 2015 · 3 comments
Labels

Comments

@Anonymouslemming
Copy link

@Anonymouslemming Anonymouslemming commented Sep 27, 2015

Looking through the documentation, I can't see a way to download a stream for a specific number of seconds.
This would be useful when downloading from audio services like tunein where the stream does not end at the end of the programme.
At the moment, I'm working around this by calling youtube-dl from a script and killing the background PID after a certain amount of time:

(/usr/local/bin/youtube-dl -q --no-part -o "${OUTFILE}" ${URL}) & DLPID=$!
sleep $DURATION
kill ${DLPID}

Having a --duration flag and terminating after this time would be quite useful for cases like this.

@jaimeMF jaimeMF added the request label Sep 27, 2015
@nagisa
Copy link

@nagisa nagisa commented Sep 29, 2015

There’s a timeout command from coreutils (= available on most unixes), which you can use like this:

timeout {timeout args} {timeout duration} youtube-dl {youtube-dl args}
@repomaa
Copy link

@repomaa repomaa commented Feb 23, 2016

another thing worth mentioning is that this needs the --no-part option to work.

@arendtio
Copy link

@arendtio arendtio commented Jul 9, 2018

Today, I tried both solutions with version 2018.06.14. @Anonymouslemming your solution doesn't seem to kill the ffmpeg background process which keeps recording even after the script exited (hidden by the -q flag). I don't know why it happens but I had a similar solution myself and that problem brought me here ;-)

@nagisa the timeout solution works great and also cleans up the ffmpeg process 👍 The only downside seems to be, that timeout exists with a non-zero status in case of an timeout (relevant when you use it within a script with set -e).

--no-part worked as I expected it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.