Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Directories must be defined without trailing slash
- output_dir="/Volumes/RAID/temp/TINASHE"
- echo "This script will encode source files for copra and save to:"
- echo "$output_dir."
- echo "Source files will not be modified."
- #Check if any arguments were passed
- if [ -z "$1" ]
- then
- echo
- echo "Usage: copra-dragndrop [OPTION]... SRC [SRC]..."
- echo
- else
- mkdir -p $output_dir
- echo "Errors:" > /tmp/dailies-encode.log
- echo
- echo "Processing $# files..."
- for f
- do
- filename=$(basename $f)
- # get number of audio channels
- num_channels=`ffprobe -loglevel error -show_streams -select_streams a $f | grep channels | cut -d = -f 2`
- base="${filename%.*}"
- # check if output file already exists and log the error
- if [ -f "$output_dir/$base.mp4" ]; then
- echo "$output_dir/$base.mp4 already exists. Skipping."
- echo "$output_dir/$base.mp4 already exists. Skipping." >> /tmp/dailies-encode.log
- continue
- fi
- # encode either 0, 1, or 2 audio channels
- # if [ -z "$num_channels" ]; then
- echo "Encoding" $filename "with zero audio channels"
- normal ffmpeg -loglevel warning -stats -i $f -pix_fmt yuv420p -vf scale=hd720 -an -vcodec libx264 -preset veryfast -tune film -crf 20 -level 31 -profile:v high -g 8 -maxrate 4M -bufsize 10M $output_dir/$base.mp4
- elif [ "$num_channels" -le 2 ]; then
- echo "Encoding" $filename "with $num_channels audio channels"
- ffmpeg -loglevel warning -stats -i $f -pix_fmt yuv420p -vf scale=hd720 -acodec libfdk_aac -b:a 128k -vcodec libx264 -preset veryfast -tune film -crf 20 -level 31 -profile:v high -g 8 -maxrate 4M -bufsize 10M $output_dir/$base.mp4
- else
- echo "Encoding" $filename "with first two audio channels only"
- ffmpeg -loglevel warning -stats -i $f -pix_fmt yuv420p -vf scale=hd720 -acodec libfdk_aac -b:a 128k -map_channel 0.1.0 -map_channel 0.1.1 -vcodec libx264 -preset veryfast -tune film -crf 20 -level 31 -profile:v high -g 8 -maxrate 4M -bufsize 10M $output_dir/$base.mp4
- fi
- done
- fi
- # cat /tmp/dailies-encode.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement