Categories
Computing HowTo Linux Ubuntu

How to convert .MTS files to .AVI in Ubuntu using ffmpeg

Just a quick post. If you want to bulk convert .MTS files (from JVC or Sony HD camcorders) then you can use the below script:

You’ll need csh and ffmpeg installed:

sudo apt-get install csh ffmpeg

Make a new file called convert (I use joe but you can use nano or whatever you prefer)

joe convert

Copy and paste the below:

#!/bin/csh
# For NTSC change -fps 50 tp -fps 60000/1001 below
foreach f ($*)
ffmpeg -i $f -threads 4 -deinterlace -f avi  -r 25 -vcodec libxvid -vtag XVID  -s 1920×1080  -aspect 16:9 -maxrate 1800k -b 1500k -qmin 3 -qmax 5 -bufsize 4096 -mbd 2 -bf 2 -flags +4mv -trellis -aic -cmp 2 -subcmp 2 -g 300 -acodec libmp3lame -ar 48000 -ab 128k -ac 2 -o ${f:r}.avi
end
Make the file executable:
chmod +x convert
Convert your .MTS files:
./convert *.MTS
Done!

5 replies on “How to convert .MTS files to .AVI in Ubuntu using ffmpeg”

for me wasn’t work until I’ve change -s (size) to one of the following (man ffmpeg)
`sqcif’
128×96
`qcif’
176×144
`cif’
352×288
`4cif’
704×576
`16cif’
1408×1152
`qqvga’
160×120
`qvga’
320×240
`vga’
640×480
`svga’
800×600
`xga’
1024×768
`uxga’
1600×1200
`qxga’
2048×1536
`sxga’
1280×1024
`qsxga’
2560×2048
`hsxga’
5120×4096
`wvga’
852×480
`wxga’
1366×768
`wsxga’
1600×1024
`wuxga’
1920×1200
`woxga’
2560×1600
`wqsxga’
3200×2048
`wquxga’
3840×2400
`whsxga’
6400×4096
`whuxga’
7680×4800
`cga’
320×200
`ega’
640×350
`hd480′
852×480
`hd720′
1280×720
`hd1080′
1920×1080

AND

removing -o from the end. last parametr it’s always the output file

best, sobiech

Hey,

I’m in the US and I see the notation in your code for NTSC vs. PAL… but I can’t figure out what section of the code to change… can you help?

Matt

Leave a Reply

Your email address will not be published. Required fields are marked *

*