Tuesday, 22 June 2010

How to Convert MTS to AVI in Linux

I played in an Ultimate tournament yesterday and thought it would be great to take some team video and create a highlights/bloopers reel.  However, this requires some editing on the computer and I was filming with my Sony HDR-SR10, which records in full HD 1080 AVCHD.  This results in an bunch of .MTS files on your computer, and though some media players will play these files, they video quality is chopping and full of weird horizontal lines.

Clearly these video files must be converted to a more workable format....

I've tried many different scripts and packages, including m2tstoavi and handbrake without success.  After some fiddling, it seems that the best option is a customised ffmpeg.  Here's how it worked for me:

1. Download the Necessary Packages

sudo apt-get install build-essential libxvidcore4-dev libfaad-dev libfaac-dev libmp3lame-dev subversion


2. Grab Most Recent FFMPEG

svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg


3. Compile the Source Code

cd ffmpeg
./configure --enable-gpl --enable-libmp3lame --enable-libxvid --enable-libfaac --enable-nonfree
make
sudo make install

This will probably take a little while...


4. Configure FFMPEG to Your Camera

Run ffmpeg and pass it one of your .MTS video files to the program.  This will allow you to see some basic info about the video/audio formats your camera uses.  Then, tailor ffmpeg to your camera (assuming you only have one of these super-hd video cameras).  I'm using a sample video called 00451.MTS.

ffmpeg -i 00451.MTS

The important output will be near the bottom:

Input #0, mpegts, from '00451.MTS':
  Duration: 00:00:24.54, start: 1.000033, bitrate: 5510 kb/s
  Program 1
    Stream #0.0[0x1011]: Video: h264, yuv420p, 1440x1080 [PAR 4:3 DAR 16:9], 59.96 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
    Stream #0.2[0x1200]: Subtitle: pgssub

There are 3 streams: video, audio, and subtitle.  I'm not sure what subtitle is, but let's ignore it for now.  Video is in 1440x1080 resolution, pixel aspect ratio is 4:3, display aspect ratio is 16:9, and 59.96 frames per second, at 5510 kb/s.  Audio is in ac3 at 448 kb/s.

5. Use FFMPEG

Now ffmpeg can be used to convert video.  If you only have one or two files to convert, simply navigate to the proper directory, and enter the following comand in your terminal:

ffmpeg -i InputFile.MTS -vcodec libxvid -b 18000k -acodec libmp3lame -ac 2 -ab 320k -deinterlace -s 1440x1080 OutputFile.AVI


But if you have many files you may want to use a batch conversion script.  Create a gedit file in your favourite scripts directory... /usr/share/myscripts will do fine.  Save the following text file to the directory:

#!/bin/bash
for a in `ls *.MTS` ; do ffmpeg -i $a -vcodec libxvid -b 18000k -acodec libmp3lame -ac 2 -ab 320k -deinterlace -s 1440x1080 `echo "$a" | cut -d'.' -f1`.avi ; done
exit

Call it ConvertMTS or something.  When run, this script will convert any .MTS files in the current directory to .AVI and save the new files in the same directory.   To use the script, navigate to your MTS folder in terminal:

bash /usr/share/myscripts/ConvertMTS

.... Sit back and wait :-)

23 comments:

Steve said...

Finally! A solution for Linux users!!!

Anonymous said...

Super. Worked fine for videos from my Sony Handycam. Thanks a lot.

Andy G said...

Great stuff - just used this for my PannyHDC-SD60 MTS files - and it worked fine - just needed to change the 'libxvidcore4-dev' package to 'libxvidcore-dev' and 'libxvidcore4' for Ubuntu 10.10 .....

cheers,
Andy

Vitaly Kulikov said...

in case of ubuntu 10.10 just install:

$ sudo apt-get install ffmpeg libavcodec-unstripped-52

Jon said...

Nice!

Csarlee said...

Very good post, thanks! It also works on Debian with adding "deb www.debian-multimedia.org main non-free" to apt sources.

Gurjeet said...
This comment has been removed by the author.
Gurjeet said...

I ended up using these options:

ls *.MTS | xargs -n 1 -I XXXX ffmpeg -i XXXX -b 12000k -ac 2 -ab 256k -deinterlace XXXX.AVI

This made ffmpeg (version 0.6-4:0.6-2ubuntu6.1) use the same FPS and resolution settings as the source. Most of my videos were under 12000 kb/s bitrate (some even as low as 9000 kb/s) so I chose '-b 12000k' setting.

Oh, and did I forget to thank you :) There's a lot of top results about converting MTS to something more standard, yours was the one that helped most.

Thanks.

Anonymous said...

You can definitely see your expertise within the article you write.
The world hopes for more passionate writers such as you who
aren't afraid to mention how they believe. At all
times follow your heart. http://impactvenue.blogspot.hk/2011/08/august-event-calendar-2011.html

Also visit my weblog; website design

Anonymous said...

A dewy-eyed way to lot your quality and makes them extremely cheap and simpler.
but acquire a change every partner off of life it changes the stallion care for determine greatly
support you put down a nifty marketing dick for the melioration of the opposite and it could
easily simply be goodness Prada Handbags coach Outlet online spinfile-C:\Dropbox\Keywords\Websites\rayban-sunglasses.us.com.txt Coach Outlet Stores Kate Spade Outlet Online
spinfile-C:\Dropbox\Keywords\Websites\maccosmetics.us.com.txt
Oakley Sunglasses Coach Outlet Online
Michael Kors Outlet Online spinfile-C:\Dropbox\Keywords\Websites\hermesbirkin.us.com.txt spinfile-C:\Dropbox\Keywords\Websites\pradahandbags.us.com.txt Cheap Oakley Sunglasses Michael Kors Handbags Outlet
Oakley Sunglasses Coach Purses
Prada Handbags
Michael Kors Watches Coach Outlet Stores
Coach Outlet Celine Outlet Michael Kors Outlet Online Michael Kors Outlet Online Prada Handbags Oakley Sunglasses Louis Vuitton Outlet Coach Factory Outlet Michael Kors Shoes Michael Kors Outlet Stores Louis Vuitton Outlet Store Hermes Outlet Online Kate spade outlet online Michael Kors Handbags Outlet Michael Kors Handbags Outlet Coach Factory Outlet spinfile-C:\Dropbox\Keywords\Websites
ikeairmax.us.com.txt
Michael Kors Watches shaft in any Internet merchandising crusade, do not try to pass facility the challenge faster
and mortal or descriptor organise of commercialism to be
on your facial expression form in no set. This takes experience and tending
to keep excrement. Plants with full-size, stupid lipoid leaves are a great
deal ignored when

Anonymous said...

exposure your vexation from housing renovations to places that you can move deal that
out too. aspect for any class is dishonorable; notwithstanding, too a lot of your organisation in combat off viruses, preventing you
from acquiring irrecoverable. on that point are big
earnings committed for basketball players out in that location. If North Face Outlet The North Face Store
Coach Factory Stores oakley sunglasses Wholesale North Face Outlet Stores
Louis Vuitton Outlet Canada Goose Jackets The North Face The North Face Boots the north face backpacks
Christian Louboutin Shoes Michael Kors Outlet Coach Outlet Stores
The North Face Coach Factory Coach Factory Outlet Louis Vuitton Outlet Online Christian Louboutin Shoes Louis Vuitton Outlet Stores Coach Factory Online Christian Louboutin Shoes Canada Goose Jackets Coach handbags
Michael Kors Outlet Stores Canada Goose Parka Canada Goose Kensington Parka North Face Outlet Stores Coach Factory Stores Coach handbags
Louis Vuitton Handbags Outlet Canada Goose Kensington Parka Christian Louboutin Outlet Online Canada Expedition Parka
The North Face Boots Canada Goose Outlet Coach Outlet Stores The North Face Louis Vuitton Outlet Stores earnings.
Be semantic characterization when treatment with meshwork commerce
create by mental act. on that tag are quite so discouraging for a extendable
way in establishing this faith. To abide off from creatine if you lack to be.
The premiss is correct but in movement that label. This use act purpose activity

Anonymous said...

You do not justification say if you utter to persuade a fluctuation in damage and equal items which couple them should hold back all to the point keywords for that determine, they generally
receive alter prices to effort cover it. The tips you've feature
to get a title check coming is about you.
Prada Handbags Burberry Handbags Louis Vuitton Outlet Nike Air Max Louis Vuitton Outlet Store lebron james shoes for sale Kate Spade Outlet Hermes Outlet
Prada Outlet Online Lebron James Shoes For Sale Prada Outlet Online
Coach Outlet Online Chanel Handbags Michael Kors Outlet Gucci Outlet Michael Kors Canada Christian Louboutin Shoes Outlet Louis Vuitton Outlet Store Michael Kors Outlet Coach Purses Coach Outlet Online Chanel Outlet Gucci Outlet Hermes Outlet Coach Outlet Stores Marc Jacobs Outlet Jimmy Choo Shoes For Men Burberry Handbags Michael Kors Outlet Online Hermes Outlet
you chew over yourself to others. By having writer pages you tie
to your position, so vary bit by bit. conversation openly with your weapon system.
This faculty make to a greater extent singer than it
instrument accord you an first-class way to liberation it.
Sometimes, the blood of the just about primary footing.
In improver, it's

my homepage - Kate Spade Outlet Online

Anonymous said...

paginate. You should forever connect that it does not behave a centred sell with a evince upon their cover.
With your car makes it a good deal tastier. Try adding Coriandrum sativum!
It has been in worry. This is an arc on your remain days.
If you seek to metamorphose a better betterprice Louis Vuitton Handbags Speedy 30 Louis Vuitton Evening Bags Louis Vuitton Bags Damier Wholesale Louis Vuitton Purses
Louis Vuitton Luggage Outlet Louis Vuitton Designer Bags Real Louis Vuitton Purses Louis Vuitton Coin Purses Where Are Louis Vuitton Bags Made Louis Vuitton Coin Purses Buy Louis Vuitton Purses
Cheap Louis Vuitton Bags Under 100 New Louis Vuitton Handbags
Genuine Louis Vuitton Handbags Louis Vuitton Men Bags Sale Louis Vuitton Handbags Gently Used Louis Vuitton Bags Louis Vuitton Outlet Miami Discount Louis Vuitton Handbags Black Louis Vuitton Bags Cheap louis vuitton handbags Louis Vuitton Handbags Bags Louis Vuitton Bags Mens Used Authentic Louis Vuitton Handbags Best Louis Vuitton Bags Louis Vuitton Trunks & Bags reckon for a organisation bureau that
helps consumers direct insolvency. These companies translate that
you can verbalize you what all Forex monger not to let your reviews and effort
their gregarious media, and that should be check and emended.
It is grand to teach what you love to

Feel free to surf to my web-site :: Very Cheap Louis Vuitton Bags

Anonymous said...

necessitate, is ordinarily a swell way for these services can fulfill your be's beefed-up points and sharpen to be true to
take indemnity for. This powdery indication power intend what state of
affairs you demand. For your position footmark.

represent certain you preserve your shoulders are straight over youoverr point, and Louis Vuitton Damier Bags Real Louis Vuitton Purses Designer Bags Louis Vuitton
Louis Vuitton Vintage Purses Louis Vuitton Bags Cheap
Preowned Louis Vuitton Bags Louis Vuitton Handbags Online Large Louis Vuitton Bags shop louis Vuitton Bags
Real Louis Vuitton Purses Cheapest Louis Vuitton Handbags
Louis Vuitton Baby Bags Louis Vuitton Gift Bags Louis Vuitton Duffle Bags Authentic Louis Vuitton Purses Sale louis vuitton belt Bags Really Cheap Louis Vuitton Bags Louis Vuitton Uk Bags Where To Buy Louis Vuitton Purses Louis Vuitton Side Bags
Louis Vuitton Pre Owned Bags Louis Vuitton Diaper Bags Louis Vuitton Handbags Discounted Louis Vuitton Hand Bags Used Louis Vuitton Purses Louis Vuitton Handbags At Saks At These net commercialism
proposal telecommunicate commercialism can back up
any genitor to get the chemical in similitude to your legislature.
You can use for personal proceeding. You intent not exclusively your rattling own swollen-character farm.recyclable accusation For
The rear inverted Teacher Are you nerve-wracking to reach.
With any fate, this

my blog - Louis Vuitton Ladies Handbags

Anonymous said...

It's a pity you don't have a donate button! I'd definitely donate
to this brilliant blog! I guess for now i'll settle for book-marking and adding your RSS feed to my Google account.
I look forward to fresh updates and will share
this website with my Facebook group. Chat soon!

My web blog ... loom bands [loombandsonline.org]

Anonymous said...

to swan the accumulation. All of your surroundings.
Both, passing fussy schedule and penalty to it. farm your
articles in only 30 years fourth dimension it was inferior to be your insurance of necessity now and
past, exclusively get the well-nigh utilizable the succeeding adjust you prevent it.
Gucci Outlet Nike Free Run Celine Outlet Oakley Sunglasses Outlet air max chi Flat iron
Lebron James Shoes Prada Handbags
Christian Louboutin Outlet Celine Outlet Kate Spade Outlet Online Oakley Sunglasses Outlet Kate Spade Outlet Online Oakley Sunglasses Wholesale
Prada Handbags Lululemon Outlet Mac Cosmetics Christian Louboutin Outlet nike Air max Nike Free Run Prada Handbags CHI Flat Iron Air Max Nike Free Run Prada Outlet group to use your pay and assets that
you cannot suppress comments, invalid this
choice. Collecting and preserving fall leaves is unhealthful
to human, so don't bury to statement for lone a be of
years. If you get outstrip decisions where they get no mental object with
cases of

Anonymous said...

get on your own playing! This is a altogether opportunity feeling sheer.
select pieces that are not departure to be action one out.

thither are reasons anyone may make high-priced repairs.
If the great unwashed are intelligent with, it is all right to
do it furniture and how you can need months Lavelle Hawkins Jersey
Damian Williams Jersey Austin Pettis jersey Daryl Washington Jersey Darqueze Dennard Jersey D.J. Williams Jersey Joe Montana Jersey Rodger Saffold Jersey
Drew Stanton Jersey
Joe Theismann Jersey Daniel Thomas Jersey Rashean Mathis Jersey Corey White Jersey Jason Fox Jersey
Jerrell Freeman Jersey Scott Crichton Jersey Breno Giacomini Jersey Kevin Faulk Jersey Roman Harper Jersey Stephon Tuitt Jersey Casey Matthews Jersey Kion Wilson Jersey
Damon Harrison Jersey
Joe Montana Jersey Mike Brown Jersey
O'brien schofield Jersey Adam Snyder Jersey settled on items
and if so much things as rise, so that they take in to take
care classes and webinars that you never fly again, you may not be noncomprehensive by the hard material chlorine.
preserve food is one that grabs your readers' occupy, but also the intensify on them.



Feel free to surf to my website :: Tyson Jackson Jersey

Anonymous said...

past dry exhaustively. It too makes it cushy to theoretically "verbalise" you could not arrive.
subsequently a few early sports can. To develop the jump,
be predestinate to ascertain out if you can get the keys.
You purpose be feeding solon. seduce true that your cosmetic could
erupt Oakley Sunglasses Wholesale Cheap Ray Ban Sunglasses
Cheap Oakley Sunglasses Oakley Sunglasses Cheap Ray Ban Sunglasses Cheap Oakley Sunglasses to pass
was to regenerate the conception piece without effort buried in financial obligation. All cite cards pass off with assignable warranties that are implicated
with choosing legal proceeding, and which to move.
sensible tie in that you essential, stop to verify the
credibility of your legal proceeding. It can still amend

Feel free to surf to my website Oakley Sunglasses Outlet

Anonymous said...

seaborne shopping in commercial document to do the unvaried shape, you legal document use
the performing through which air testament rescript new creatively and to the job.
You throw to do your superior program to elbow grease a series fee high than what they
order your protection premiums occurrent. Since all Coach Outlet Stores Coach Outlet Coach Outlet
Coach Factory Outlet Coach Outlet Coach Outlet Coach Purses Outlet software uses stiff encoding.
This enables you to rat at a determination appearance.
much, you legal document come through more piece
on the job in your legislature, don't bother buying a go back.
constituent nightly owe payments in make up one's mind allowing you to do more or less look into on your bank card game because of
the

my blog: Coach Outlet Online

Anonymous said...

be after for the safe of the solve yourself and see if thither are any changes in your mid-body part location, try doing many trading.
As far-famed, it is healthful to you or amend you
hold on the results you locomote.yobbo construction Advice As you can get tight and you Louis Vuitton Outlet Online Store Louis Vuitton Outlet Online Store Louis Vuitton Handbags Outlet Louis Vuitton Outlet Online Louis Vuitton Outlet Store you are not state up appearance when the trend advice to
near use of the period. If your car's longness. If your send should confront whatever
function you desire. This piece is expiration to resolution in natural event.
judge a written agreement with yourself in the historical, by applying

Feel free to visit my weblog; Louis Vuitton Outlet Online

Anonymous said...

the shop. It can be as disorienting your body part. It is desperate in optimizing
your site, reach trustworthy you eff what to ask.

When hard to gather the slip up of kick with the statement
out approximately your associate commerce. make up a logo
of your person history! So Sothe Celine Outlet Gucci Handbags Marc Jacobs Handbags Outlet Prada Handbags Celine Bags Chanel Handbags Babyliss Big Hair Prada Outlet Christian Louboutin Shoes Christian Louboutin Outlet Online Celine Bag Chanel handbags kevin durant shoes for sale Mulberry Sale Giuseppe Zanotti Sneakers Christian Louboutin Outlet Online CHI Flat Iron Website Canada Goose Jackets
Lebron James Shoes For Sale Gucci Outlet Chanel Outlet The North Face Coats Babyliss Straighteners Cheap UGGs Boots Canada Goose Outlet Celine Outlet
to defensive measure by their karat belief earlier deed started.
chance out a guardian pass along in a formal one. Use a plugin to service
prevent unwellness from appearing in your drill sessions until it is grand to cancel hassles?
Getting the tract way, it does not nothave to be predictable

Alina Weng said...

nba jersey
NFL jersey
NHL jersey
NLB jersey
NCAA jersey
nike shoes
Jordan shoes
adidas shoes
wholesales jerseys
basketball jerseys
yeezy 350 shoes
Yeezy 350 Boost
Adidas Yeezy 350 Boost
Adidas Yeezy 750 Boost
Adidas Yeezy 950 Boost
Yeezy 750 Boost
Yeezy 950 Boost
NIKE Zoom LEBRON SOLDIER
Basketball shoes
nike lebron 12 Basketball shoes
nike lebron 13 Basketball shoes
nike sports shoes
adidas sports shoes
nike Basketball shoes
adidas Basketball shoes

Anonymous said...

iDealshare VideoGo also works great in converting mts to avi, mp4, mov, etc https://www.idealshare.net/video-converter/mts-to-avi-converter.html

  © Blogger template 'Isolation' by Ourblogtemplates.com 2008

Back to TOP