Trying to str replace patches while doing `for` on a specific directory

by Nimer Sulieman   Last Updated September 11, 2019 14:00 PM

I am trying to run the ffmpeg command on a directory containing a lot of MP4 files, this ffmpeg command should generate multi bitrate files on a single file. And it works fine.
I am running a loop using for command, but I don't know how to rename the file ex:
original file: original.mp4 should generate 2 files: original_400.mp4 and original_800.mp4.
I am using this code to do that, but the generated file name is same as the original one:

IFS=$'\n'; set -f
for f in $(find /storage/original/hd -name '*.mp4')
do
echo $f

ffmpeg -y -i $f  -c:a libfdk_aac  -ac 2 -ab 64k -c:v libx264 -preset:v veryfast -threads 0 -r 24 -g 48 -keyint_min 48 -sc_threshold 0 -x264opts no-mbtree:bframes=1 -pass 1 -b:v 286k -s 384x216 $f
ffmpeg -y -i $f  -c:a libfdk_aac  -ac 2 -ab 64k -c:v libx264 -preset:v fast -threads 0 -r 24 -g 48 -keyint_min 48 -sc_threshold 0 -x264opts no-mbtree:bframes=1 -pass 2 -b:v 286k -s 384x216 $f
ffmpeg -y -i $f  -c:a libfdk_aac  -ac 2 -ab 64k -c:v libx264 -preset:v fast -threads 0 -r 24 -g 48 -keyint_min 48 -sc_threshold 0 -x264opts no-mbtree:bframes=1 -pass 2 -b:v 630k -s 640x360 $f
done
unset IFS; set +f

Thanks

Tags : centos bash ffmpeg


Related Questions


dvr rtsp to website (iOS and android)

Updated February 23, 2018 19:00 PM

How can I delete old log files?

Updated August 25, 2015 21:09 PM