Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have several videos on my PC that I would like to shorten. For instance I have a 30 sec video where I want to have the section from sec 15 to 20 (a 5sec video). To cut this, I use avconv.

avconv -i input.mp4 -ss 15 -acodec copy -vcodec copy -t 5 output.mp4

This command works pretty well. I have many videos I want to cut the same way. This is why I created a textfile containing the information: input-name, start of cut, length of cut, output-name. Those are written into in.txt that looks like this:

input.mp4 15 5 output.mp4
input1.mp4 32 10 output1.mp4
input2.mp4 10 7 output2.mp4
...

My question is: How do I have to modify the avconv-command to cut my videos automatically? What I tried was this, but it didn't work at all:

avconv -i $1 -ss $2 -acodec copy -vcodec copy -t $3 $4 < in.txt

Any idea?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

In bash, I would suggest something like

while read -r infile ss t outfile; do 
  avconv -i "$infile" -ss "$ss" -acodec copy -vcodec copy -t "$t" "$outfile"
done < in.txt
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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