Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # README:
- #
- # Run this script as follows:
- #
- # ./video.sh urls.txt videos
- #
- # Where urls.txt is a list of RTSP links
- # and videos is the directory that you would
- # like to save the downloaded videos to. If
- # the designated directory does not exist, it
- # will be created automatically.
- #
- # NOTE: DO NOT APPEND a / after the directory name
- file=$1
- dir=$2
- # Create the directory if it
- # does not exist already.
- create_dir() {
- mkdir -p $dir
- }
- # Pipe each stream into a file
- # in the designated output directory
- download() {
- # echo $1 $2
- ffmpeg -i $1 -acodec copy -vcodec copy $2 < /dev/null
- }
- # Iterate through the input file line by line
- # Download each file by URL
- iterate() {
- pids=""
- while read url; do
- filename=$(echo "$url" | sed 's:.*/::')
- download $url "$dir/$filename" &
- pids="$pids ${!}"
- done < $file
- for pid in $pids; do
- wait $pid || let "RESULT=1"
- done
- if [ "$RESULT" == "1" ]; then
- return 1
- fi
- }
- main() {
- create_dir
- iterate
- }
- main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement