LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   MTS Video Conversion (https://www.linuxquestions.org/questions/linux-software-2/mts-video-conversion-672091/)

kromberg 09-24-2008 12:49 PM

MTS Video Conversion
 
Is there any good software that will convert the MTS or AVCHD format to any other usable formats?

Keith

almatic 09-24-2008 02:54 PM

ffmpeg will do it. I usually convert them into dv/pal since hd format is too big for my monitor and dv will be accepted by all video editors. Use somthing like this :

ffmpeg -i input.mts -f avi -vcodec dvvideo -s pal -aspect 4:3 -qscale 4 -acodec pcm_s16le -ac 2 output.avi

kromberg 09-24-2008 05:32 PM

Hmmm... that seems to cause ffmpeg from freshrpms for FC7_i386 to seg fault. I think I will play around with ffmpeg and some other possible settings.....

Keith

almatic 09-24-2008 05:41 PM

can you play the .mts video with ffplay ?

kromberg 09-25-2008 08:58 AM

Quote:

Originally Posted by almatic (Post 3290785)
can you play the .mts video with ffplay ?

No. It is very grainy and slow.

Keith

almatic 09-25-2008 12:37 PM

and what program do you use to watch these files ? Are you using a 64bit system ? If yes you should first make sure that the codecs work correctly for 64bit (in this case h264 and ac3 probably).

Shadow_7 10-06-2008 05:15 PM

vlc seems to be the best for playing these for me. Although stuck at about 25% speed to see every frame without dropping frames and such. On my 2GHz laptop.

As far as conversion. mencoder seems to start spewing junk video wise after two or three minutes of .mts footage. ffmpeg is the only one I've gotten to transcribe the video completely. And ffmpeg is the only one to extract the audio. mplayer does a coredump when trying to extract the audio. vlc was either doing just audio, or just video depending on the compile options (swscale?) and version(0.8.6 / 0.9.3) for me. mencoder does alright for the first minute plus though. It's just that past a certain point, it starts creating content that more closely resembles a screen saver than the source video. Although it functions right with most formats other than .mts/60i video.

ffmpeg -i 00000.mts -r 60000/1001 -an -f mp4 -vcodec mpeg4 -r 30000/1001 00000.mp4
ffmpeg -i 00000.mts -vn 00000.wav

The only problem I seem to have is when rejoining them, the default 25 fps of ffmpeg is causing sync issues with 30fps content. It's truncating at the end of the audio, which is still a few frames shy of what should have been 60i / 60 fps content converted to 30 fps content. At least several seconds worth on a five minute clip.

The below seems to work on shorter clips. When going from 24Mbps AVCHD / 60i to other formats. But still suffers on longer clips. And the initial couple of frames seem to be plagued with artifacts which aren't in the original.

mencoder -of mpeg -mpegopts muxrate=36000 -mc 0 -oac lavc -fps 60000/1001 -ofps 30000/1001 -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:vmax_b_frames=2:vb_strategy=1:precm p=2:cmp=2:subcmp=2:preme=2:qns=2:vbitrate=36000 -vf scale=1280:720 ./00000.mts -o 00000.mpeg

or

ffmpeg -i 00000.mp4 -i 00000.wav -sameq -s hd720 -r 30000/1001 00000.mpg

to rejoin the previous extractions. Although it doesn't seem to ever complete for me. Using mencoder to rejoin the converted video and separate audio seems to be the only workable fps compensation method. At least on longer clips. So use 00000.mp4 -audiofile 00000.wav -o 00000.mpeg at the end of the mencoder line above to put the parts back together. For some reason -oac copy hangs about the 4th frame, -oac lavc bypasses that.

Still mostly greek to me, I'm an audio guy. But I'm working on getting an HD camcorder, and learned the above while trying to work with some samples I gathered from the target cam at best buy. Needless to say, not quite as painless as I'd hoped. And ffmpeg seems to be the only one interested in keeping the original quality IMO. Not that mencoder isn't capable, it's just that it tends to make most of my attempts to scale my HD content look like YouTube quality.

Shadow_7 10-06-2008 05:21 PM

silly emoticons. replace faces with colon plus lower case p.

Shadow_7 10-07-2008 12:50 AM

If everything worked as it should you could probably use:

ffmpeg -i 00000.mts -sameq -target ntsc-dvd 00000.mpeg

But I seem to have issues with that, so here's my script of sorts.

#!/bin/bash

if [ ! $1 ] || [ ! $2 ] || [ ! $3 ] || [ ! $4 ]; then
echo "USAGE: Input_MTS_File Output_MP4_File Output_WAV_File Output_MPEG_File"
exit 1
fi

INFILE=$1
MP4FILE=$2
WAVFILE=$3
MPEGFILE=$4

echo $INFILE $MP4FILE $WAVFILE $MPEGFILE

file $INFILE >> convert.log
date +%F-%H:%M:%S:%N >> convert.log

# export video ONLY to an MP4 file
ffmpeg -i $INFILE -r 60000/1001 -sameq -f mp4 -vcodec mpeg4 -an -r 30000/1001 $MP4FILE

file $MP4FILE >> convert.log
date +%F-%H:%M:%S:%N >> convert.log

# export audio ONLY to a WAV file
ffmpeg -i $INFILE -vn $WAVFILE

file $WAVFILE >> convert.log
date +%F-%H:%M:%S:%N >> convert.log

# merge the MP4 file and WAV file while converting 60fps to 30fps.
# NOTE: tried to do that in the first step (-r 60000/1001), but it didn't work apparently.
mencoder -of mpeg -mpegopts muxrate=36000 -mc 0 \
-fps 60000/1001 -ofps 30000/1001 -ovc lavc \
-lavcopts vcodec=mpeg4:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:vmax_b_frames=2:vb_strategy=1:precm p=2:cmp=2:subcmp=2:preme=2:qns=2:vbitrate=6000 \
-vf scale=1280:720 -oac lavc \
-audiofile $WAVFILE $MP4FILE -o $MPEGFILE

file $MPEGFILE >> convert.log
date +%F-%H:%M:%S:%N >> convert.log

# END #

The mencoder line could probably be improved. The results are decent, but it's in essence skipping every other frame 60i. Which I attempted to correct in the initial ffmpeg line, but failed. And I'm probably missing some key frames or something as the initial two seconds of footage ends up with artifacts. And if you fast forward, or jump around in the video, it takes a bit to get back to normal. And it's quite wasteful space wise. The interim MP4 file is nearly 4x's the size of the originating MTS file. Not to mention taking forever to run. Roughly 6x's+ what it took to record on the camcorder, to convert and scale it on a 2GHz laptop. But using mencoder on the original MTS file results in artifact overdrive after the first two minutes or so. Using ffmpeg on the original MTS converts 60 fps to 30 fps without dropping any frames. Thus the video becomes twice as long and half as fast as the audio. The funny faces will probably be : plus p on the mencoder stuff. I haven't figured out how, or if emoticons can turned off on this forum.

I needed to get at a minimum the x264 stuff from videolan.org. And recompile ffmpeg / mplayer / and friends to include/support that lib. On debian stable, although debian-multimedia.org probably overcomes that need. Ultimately I want/need to use external audio on my clips. So some steps in the above could probably be combined to lower space / time / cpu usage. Or not. The above script works for me for now. YMMV.

Shadow_7 10-07-2008 08:30 AM

Taking a clue from the linux journals ffmpeg magic article / youtube clip.

ffmpeg -i 00000.mts -sameq -an -f yuv4mpegpipe - | yuvfps -s 60000:1001 -r 60000:1001 | ffmpeg -f yuv4mpegpipe -sameq -i - -sameq -s 1280x720 -f mpeg2video -r 60000/1001 video_only.mpeg

Success for keeping 60fps. Success for keeping quality. Success for taking care of scaling and saving a lot of HDD space in step 1. And surprisingly processing time is greatly reduced, while maintaining quality. Although I'm not quite sure about audio sync yet. And not exactly something that most people can retype from memory. And you still need to extract audio, and remerge it. But that can be done with ffmpeg now since it's not going to assume that your 60i content is 30p (no mater how you try to tell it otherwise). And watching 60fps content at 60fps (assuming CPU power to do so) looks light years better in terms of motion / motion stutter.

DBabo 08-30-2009 12:33 PM

Shadow, any luck to get everything ( video and audio) in one shot ?

oudinmelanie09 03-04-2011 01:40 AM

FFMPEG seems to be quite professional and it is a hard work for newbee like me.

And now I found a software named Aunsoft MTS Converter for Mac which is a nice assisstant for new comers like me. I always use it to convert MTS files from Panasonic TM700 to ProRes for editing in FCP.

http://www.aunsoft.com/mts-converter-mac/

Enjoy your video

Tameka R Henderson 02-27-2014 03:40 AM

m2ts video converter
 
Wow, I was looking for exactly this piece of software to help me figure out my oly form, thanks for sharing.
I would recommend you also try m2ts video converter which is free to download trial software.
http://www.freem2tsconverter.com/


All times are GMT -5. The time now is 12:29 PM.