Answer the question
In order to leave comments, you need to log in
Help debug video autoconverter on bash pliz
Gentlemen, I'm trying to write a script that would check for the presence of an already converted file in a given folder and, if not, encode it. It will probably be easier to understand what I mean by the code.
pastebin.com/C7aG2LEQ
The problem is in line 12, for some reason the check of an existing file skips, as a result it tries to encode it again, which in general I don’t need to do at all, because there are a lot of files there. Plz tell me what is wrong
Answer the question
In order to leave comments, you need to log in
M, how do you have some other commands between the if and then lines?
if
then
echo "$i.mp4 not exist"
echo "Converting "$i"."
/usr/local/bin/ffmpeg -i ${video_folder}$i.mkv -acodec aac -strict experimental -ab 128k -ac 2 -vcodec libx264 -b 1200k -s 1280x720 -r 30 -threads 0 ${films_folder}$i.mp4 ; echo "Convert "$i" to mp4 is done!"
fi
for i in `ls -a $video_folder/*$file_mask*.mkv`
for i in $video_folder/*$file_mask*.mkv
i=$(echo $i | sed 's/.mkv//' | sed 's%^.*/%%')
echo ${i/.mkv}
A Bash script in 99% of cases should start with set -e. It is strange that no one notices such egregious errors.
If you have the message "${films_folder}$i.mp4 not exist" displays the correct file name, then try to move lines 13 and 14 under "then":
if
then
echo "${films_folder}$i.mp4 not exist"
echo "Converting "$i"."
/usr/local/bin/ffmpeg -i ${video_folder}$i.mkv -acodec aac -strict experimental -ab 128k -ac 2 -vcodec libx264 -b 1200k -s 1280x720 -r 30 -threads 0 ${films_folder}$i.mp4
echo "Convert "$i" to mp4 is done!"
else
shift
fi
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question