Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Script:-
- #!/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"
- echo "Output file = "$outfile
- # 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 -i $filename -vframes $oframes -vcodec copy -acodec copy $outfile
- }
- for i in "$1"/*.MOV ; do
- MOV2mov $i
- done
- # end of file ------------------------
- Output:-
- [baz@jackodesktop ~]$ MOVdir2mov /store/Video/croptest/test 4
- Output file = /store/Video/croptest/test/100_0008.mov
- duration 00:00:07.67
- Frames in clip 230
- Frames to output 226
- FFmpeg version git-5f3b831, Copyright (c) 2000-2011 the FFmpeg developers
- built on Jan 24 2011 14:59:48 with gcc 4.4.3
- configuration: --prefix=/home/baz/kdenlive/20110124 --disable-doc --disable-network --disable-ffserver --enable-gpl --enable-version3 --enable-shared --enable-debug --enable-pthreads --enable-libmp3lame --enable-libx264 --enable-libvpx
- libavutil 50. 36. 0 / 50. 36. 0
- libavcore 0. 16. 1 / 0. 16. 1
- libavcodec 52.108. 0 / 52.108. 0
- libavformat 52. 94. 0 / 52. 94. 0
- libavdevice 52. 2. 3 / 52. 2. 3
- libavfilter 1. 74. 0 / 1. 74. 0
- libswscale 0. 12. 0 / 0. 12. 0
- Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/store/Video/croptest/test/100_0008.MOV':
- Metadata:
- major_brand : qt
- minor_version : 0
- compatible_brands: qt
- creation_time : 2010-12-08 09:30:50
- comment : KODAK PlaySport Video Camera, Zx3
- comment-eng : KODAK PlaySport Video Camera, Zx3
- Duration: 00:00:07.67, start: 0.000000, bitrate: 8611 kb/s
- Stream #0.0(eng): Video: h264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 8524 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
- Metadata:
- creation_time : 2010-12-08 09:30:50
- Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 128 kb/s
- Metadata:
- creation_time : 2010-12-08 09:30:50
- Output #0, mov, to '/store/Video/croptest/test/100_0008.mov':
- Metadata:
- major_brand : qt
- minor_version : 0
- compatible_brands: qt
- creation_time : 2010-12-08 09:30:50
- comment : KODAK PlaySport Video Camera, Zx3
- comment-eng : KODAK PlaySport Video Camera, Zx3
- encoder : Lavf52.94.0
- Stream #0.0(eng): Video: libx264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=2-31, 8524 kb/s, 30k tbn, 29.97 tbc
- Metadata:
- creation_time : 2010-12-08 09:30:50
- Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, 128 kb/s
- Metadata:
- creation_time : 2010-12-08 09:30:50
- Stream mapping:
- Stream #0.0 -> #0.0
- Stream #0.1 -> #0.1
- Press [q] to stop encoding
- frame= 226 fps= 0 q=-1.0 Lsize= 7890kB time=7.51 bitrate=8609.6kbits/s
- video:7766kB audio:117kB global headers:0kB muxing overhead 0.089689%
- [baz@jackodesktop ~]$
Add Comment
Please, Sign In to add comment