Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # MOVdir2mov
- # Converts all .MOV files in a dir to .mov and chops "frames to crop" frames from end
- if [[ ${#1} = 0 ]] || [[ ${#2} = 0 ]] ; then
- echo "Usage : MOVdir2mov <path to dir> <frames to crop> "
- exit 1
- fi
- frames_to_crop=$2
- path_to_ffmpeg=/home/$USER/kdenlive/20110124/bin/
- MOV2mov()
- {
- filename=$1
- # Create output path and filename
- outfile=$(echo $filename | cut -d. -f1)".mov"
- # Get clip duration
- duration=$(ffmpeg -i $filename 2>&1| grep Duration |sed 's/: /*/'|cut -d* -f2|cut -d, -f1)
- echo "duration "$duration
- # Convert duration to seconds
- oldifs=$IFS
- IFS=:
- arr=($duration)
- IFS=$oldifs
- dursecs=$(echo ${arr[0]}*3600 + ${arr[1]}*60 + ${arr[2]} | bc)
- # Convert duration to frames
- frames=$(echo "$dursecs * 29.97" | bc)
- # Round up frames to integer
- frames=$(echo "($frames + 0.9999)/1" | bc)
- echo "Frames in clip "$frames
- # Subtract frames from total
- ((oframes="$frames"-"$frames_to_crop"))
- echo "Frames to output "$oframes
- # Render with ffmpeg
- "$path_to_ffmpeg"ffmpeg -vsync 0 -i $filename -vframes $oframes -r 29.97 -vcodec copy -acodec copy $outfile
- #ffmpeg -vsync 0 -i $filename -vframes $oframes -r 29.97 -vcodec copy -acodec copy $outfil
- }
- for i in "$1"/*.MOV ; do
- MOV2mov $i
- done
- # end of file ------------------------
Add Comment
Please, Sign In to add comment