0

This command works great:

ffmpeg \
-i /mnt/share/Movies2/"nameofmovie.mkv" \
-map 0:0 \
-map 0:1 \
-map 0:2 \
-c:v libx264 \
-preset veryfast \
-tune film \
-crf 18 \
-c:a:0 copy \
-c:a:1 copy \
/mnt/share/Converted/"nameofmovie".mkv

But i want to either be able to read the input file from a text file or to run this command one after another for each file i want to convert. Is there a script i can set up to do this? Not all the files are in the same folder or the same format so something where i could just change the file name and format would be great. I used to have a bash script that could do this for an entire folder but that's not what i am trying to do here. I am using Ubuntu server 18.04 Also i'm pretty new to this i've found this for a whole folder:

for i in *.avi;
do name=`echo $i | cut -d'.' -f1`;
echo $name;
ffmpeg -i "$i" "${name}.mov";
done

But i dont know how to adapt this for individual files

John
  • 1
  • 2
  • Not an answer to your question, but you can certainly [shorten and simplify](https://stackoverflow.com/a/33766147/1109017) your second command. – llogan Mar 11 '19 at 17:48

1 Answers1

0

Create a text file the_list.txt as follows:

File1.mp4:mp4
File2.avi:avi

Here the first field is the filename, the second the source format (can be derived from file extenstion, but keeping it simple).

Create a script do_conv.sh:

cat the_list.txt | while read L
do
   FNAME=$( echo $L | cut -d':' -f1 )
   SRCFMT=$( echo $L | cut -d':' -f2 )
   echo 'Next File: ${FNAME}"
   if [ "${SRCFMT}" = "mp4" ]
   then
      ffmpeg -i ${FNAME} ....
   elif [ "${SRCFMT}" = "mp4" ]
   then
      ffmpeg -i ${FNAME} ....
   else
      ffmpeg -i ${FNAME} ....
   fi
done

Not sure exactly what conversion you want to be but hopefully this template can get you started.

TenG
  • 3,429
  • 2
  • 22
  • 36