Advertisement
spookybathtub

copra-dragndrop.sh

Feb 28th, 2014
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.02 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #Directories must be defined without trailing slash
  4. output_dir="/Volumes/RAID/temp/TINASHE"
  5.  
  6. echo "This script will encode source files for copra and save to:"
  7. echo "$output_dir."
  8. echo "Source files will not be modified."
  9.  
  10. #Check if any arguments were passed
  11. if [ -z "$1" ]
  12. then
  13.     echo
  14.     echo "Usage:    copra-dragndrop [OPTION]... SRC [SRC]..."
  15.     echo
  16. else
  17.     mkdir -p $output_dir
  18.     echo "Errors:" > /tmp/dailies-encode.log
  19.     echo
  20.     echo "Processing $# files..."
  21.     for f
  22.     do
  23.         filename=$(basename $f)
  24.         # get number of audio channels
  25.         num_channels=`ffprobe -loglevel error -show_streams -select_streams a $f | grep channels | cut -d = -f 2`
  26.         base="${filename%.*}"
  27.  
  28.         # check if output file already exists and log the error
  29.         if [ -f "$output_dir/$base.mp4" ]; then
  30.             echo "$output_dir/$base.mp4 already exists. Skipping."
  31.             echo "$output_dir/$base.mp4 already exists. Skipping." >> /tmp/dailies-encode.log
  32.             continue
  33.         fi
  34.        
  35.         # encode either 0, 1, or 2 audio channels
  36. #           if [ -z "$num_channels" ]; then
  37.                 echo "Encoding" $filename "with zero audio channels"
  38.  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
  39.             elif [ "$num_channels" -le 2 ]; then
  40.                 echo "Encoding" $filename "with $num_channels audio channels"
  41.                 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
  42.             else
  43.                 echo "Encoding" $filename "with first two audio channels only"
  44.                 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
  45.             fi
  46.     done
  47. fi
  48.  
  49. # cat /tmp/dailies-encode.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement