Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Path to the directory with the input videos
- folder="./to_convert"
- # Quantity of webms to produce for each input video
- quantity=6
- # Length of each webm (in seconds)
- interval=10
- # Whether you want audio or not
- audio=true
- if [[ "$audio" = true ]]; then
- audio_bitrate=96
- audio_settings="-c:a libvorbis -ac 2 -b:a ${audio_bitrate}K"
- else
- audio_bitrate=0
- audio_settings="-an"
- fi
- # Change 4 to whatever file size limit you have (in MB)
- video_bitrate=$(bc <<< 4*1000*8/$interval-$audio_bitrate)
- # Change into the video folder
- cd "$folder" || exit
- # Create sub-directory for all produced webms
- mkdir ../done 2> /dev/null
- for input in *; do (
- # Where to start the first webm (in seconds)
- start=0
- for (( i = 1; i <= quantity; i++ ))
- do
- ffmpeg -y -hide_banner -ss $start -i "$input" -t $interval -c:v libvpx -crf 10 -qmax 50 -b:v ${video_bitrate}K -deadline good -cpu-used 0 $audio_settings "../done/${input%.*}_${i}.webm"
- (( start+=interval ))
- done
- ); done
Add Comment
Please, Sign In to add comment