2

I have a lot of avi files in one folder and trying to convert them in to mp4. I am using this bash script not sure whats wrong. any idea?

#!/bin/bash
for i in *.avi;
  do name=`echo $i | cut -d'.' -f1`;
  echo $name;
  avconv -i -vcodec libx264 -acodec aac -strict experimental  -threads 3 "$i" "$name.mp4";
done

the error I get is :

-vcodec: No such file or directory
2
  • 2
    You need to put the -i flag directly before the input file, "$i" in this case. – Alex R. Aug 1 '14 at 16:15
  • 1
    avconv -i "$i"-vcodec libx264 -acodec aac -strict experimental -threads 3 "$name.mp4" should work, just to clarify @AlexR.'s answer. – roadmr Aug 1 '14 at 16:27
6

You need to specify the input file right after the -i switch, like so:

#!/bin/bash

for i in *.avi;
do
    name=`echo $i | cut -d'.' -f1`;
    avconv -i "$i" -vcodec libx264 -acodec aac -strict experimental  -threads 3 "$name.mp4";
done

Your version was looking for an input file named "-vcodec".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.