1

I would like to do what the title says

This is a ffmpeg command to download from a specific time in a video, offline or online.

ffmpeg -ss (stop time) -i (direct video link) -t (start time) -c:v copy -c:a copy (title.mp4)

I am going to be downloading this on OSX. I dont care what the title is.

I think* there is a bash command that allows me to change the timings in this command up by a specific amount (+300 seconds per, the counter for start and stop time is in raw seconds)

So, bash script that runs that command but increases the start and stop times incrementally by 300 (the stop timing being 60+ seconds ahead), downloads, then repeats.

Noble
  • 51
  • 10

1 Answers1

3

here it is:

contents of youtube-dl:

#!/usr/bin/env bash

# set start to 0, 300, 600... up to 72000 (20 hours)
for start in `seq 0 300 72000`; do

  # set the outfile name
  file="$2.$start.60.mp4"

  ffmpeg -ss $start -i "$1" -t 60 -c:v copy -c:a copy "$file"

  # get the duration of the last outfile
  last_duration=`ffprobe -i "$file" -show_entries format=duration -v quiet -of csv="p=0"`
  # if last outfile's duration isn't greater than a second, delete it and stop
  [[ ! "$last_duration" -gt 1 ]] && rm -f $file && exit

done

then do:

chmod +x youtube-dl

usage:

./youtube-dl "http://your/movie.flv" title

ps: i discovered that your ffmpeg command was a little broken: it's -t (duration), not -t (start time).

refs:

ffmpeg usage (slhck, 2012)

ffprobe usage (ivan-neeson, 2014)

Community
  • 1
  • 1
webb
  • 4,180
  • 1
  • 17
  • 26
  • 1
    Thanks! :) I am going to test this out right now. If you have any spare time, I wonder how hard it would be to make a script that allows me to input a link, the specific times i wanted from that link/video, and download it... Anyways, you have been a great help! :D – Noble May 18 '16 at 05:30
  • you're welcome! it's definitely possible to make a script based on this that would allow you to provide specific clipping times. it would be simpler than this script, as it would only need the `ffmpeg` line, plus one new line to compute duration based on stop time - start time e.g. using `expr` http://stackoverflow.com/questions/8385627/subtract-2-variables-in-bash. notice also how `$1` and `$2` automatically get set to the first and second parameters you put in the command line, e.g., `"http://your/movie.flv"` and `title`. Same goes for `$3`, etc... – webb May 18 '16 at 23:02
  • 1
    Okay perfect! I will put this on my list of things to do :) – Noble May 19 '16 at 01:59