1
I'm trying to write a script to convert all the files in a directory to m4v, whilst trying to keep similar (if not the same) quality and compress the file to reduce the overall size.
I've pieced together a small batch script but it won't run. Can anyone lend a hand/suggest how best to compress and retain quality?
#!/bin/bash
#Convert files using ffmpeg
DIR="/Volumes/Misc/To Convert 2"
for i in $DIR; do ffmpeg -i "$i" -c:v libx264 -crf 19 -preset slow -c:a aac -strict experimental -b:a 192k -ac 2 "/Volumes/Misc/Converted/${i%.*}.m4v"
done
EDIT: OUTPUT This is the output that I get when I try to run the shell script
ffmpeg version 2.6.1-tessus Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
configuration: --cc=/usr/bin/clang --prefix=/Users/tessus/data/ext/ffmpeg/sw --as=yasm --extra-version=tessus --disable-shared --enable-static --disable-ffplay --enable-gpl --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libspeex --enable-bzlib --enable-zlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libxavs --enable-libsoxr --enable-libwavpack --enable-version3 --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvpx --enable-libgsm --enable-libopus --enable-libmodplug --enable-fontconfig --enable-libfreetype --enable-libass --enable-libbluray --enable-filters --disable-indev=qtkit --disable-indev=x11grab_xcb --enable-runtime-cpudetect
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
/Volumes/Misc/ToConvert: Operation not permitted
Thank you for this it worked perfectly (Had to remove the
.
in front of the path though. Is it used for anything? – Tom – 2015-04-29T08:18:28.523You're welcome. The
.
? ...Nope. just a typo (I try it on a local subdirectory so./what/ever/else
) – Hastur – 2015-04-29T08:43:10.450You may also want to link to http://mywiki.wooledge.org/ParsingLs (it's less verbose than the Unix.SE question)
– slhck – 2015-04-29T08:43:16.543@slhck Thanks added references. I agree it's quicker and less scaring. – Hastur – 2015-04-29T08:49:07.773