Convert MTS/M2TS(AVCHD) to AVI
Update: Please follow my updated ffmpeg tutorial: convert your AVCHD movies with ffmpeg. It is quicker to install, and does the trick.
In this tutorial I will describe how to configure and install m2tstoavi from command line, on Ubuntu 9.04 (Jaunty Jackalope)
The m2tstoavi script was written by Axel Olmos, and is the easiest way to convert mts/m2ts video files into an avi. Here is the work flow I followed to get m2tstoavi installed.
By default Ubuntu 7.10 does not have either universe or multiverse enabled. You can skip this step if you already have universe and multiverse enabled.
1. Enable universe and multiverse repositories.
From command line, open /etc/apt/sources.list
sudo gedit /etc/apt/sources.listUncomment these lines, and substitute jaunty to match your Ubuntu version (i.e feisty,gutsy):
deb http://us.archive.ubuntu.com/ubuntu jaunty universe
deb http://us.archive.ubuntu.com/ubuntu jaunty multiverseFinally update your packages list.
sudo apt-get update2. Install the packages required by the m2tstoavi script.
Grab all the dependent packages, with this command:
sudo apt-get install mplayer ffmpeg a52dec mencoder x264 faad faac libfaad2-0 libfaad2-dev subversion csh build-essential3. Download
Obtain the m2tstoavi script from here. Or use wget to download it from command-line.
wget http://www.olmosconsulting.com/m2ts.tar.gzUntar the file, and cd into the directory
tar zxvf m2ts.tar.gz
cd m2ts4. Configure
The download script needs to be configured with the current version of H.264/AVC reference software.
sudo gedit downloadModify the following line, to current version of #H.264/AVC
set version=16.05. Install
Now start the installation script
sudo ./install6. Using the m2tstoavi script.
Here is how to use the default conversion method. This method has a large hard drive overhead and requires approximately 4 GB / min.
m2tstoavi sample.mts7. Recommended Method
I recommend using the alternative script, m2tstoavi.fifo. This script uses named pipes, and that reduces the amount of free space required.
First change the file’s permissions to make it executable.
sudo chmod 744 m2tstoavi.fifoIf you don’t want to type “./” before the command, move the script into your path
sudo cp m2tstoavi.fifo /usr/local/bin
Comments
Hi I'm having a few problems. I need videos to convert from mts to avi so that I can open them in a software package called Anvil. However, after I run m2tstoavi.fifo, the resulting avi file does not use the correct codecs. Anvil is kinda picky so I'm trying to use cinepak (ffcvid) for the video and pcm (uncompressed) for the audio. I was hoping you could tell me how to switch the codecs.
Also the audio is out of sync when I play the video on mplayer. I think I fixed that issue with the -nobps option but it still does this thing where the audio restarts its playback when I try to jump to another portion of the video (weird). I can only guess the audio is completely detached from the video.
$ m2tstoavi.fifo 00007.MTSusing:
/usr/local/bin/xporthdmv
ldecod: Command not found.
m2tstoavi.nofifo filename.m2ts
using:
/usr/local/bin/xporthdmv
/usr/local/bin/ldecod
/usr/bin/ffmpeg
/usr/local/bin/m2tstoavi.nofifo Starting.
xporthdmv -hn filename.m2ts 1 1 1
Unsupported Option: n
Cannot open bitstream file
ldecod -i bits0001.mpv -o /tmp/filename.yuv
----------------------------- JM 12.2 (FRExt) -----------------------------
Decoder config file : (null)
--------------------------------------------------------------------------
Input H.264 bitstream : bits0001.mpv
Output decoded YUV : /tmp/Inglorious_Bastards.yuv
Output status file : log.dec
Input reference file : test_rec.yuv does not exist
SNR values are not available
--------------------------------------------------------------------------
POC must = frame# or field# for SNRs to be correct
--------------------------------------------------------------------------
Frame POC Pic# QP SnrY SnrU SnrV Y:U:V Time(ms)
--------------------------------------------------------------------------
Cannot open Annex B ByteStream file 'bits0001.mpv'
ffmpeg -r 29.97 -s 1440x1080 -vcodec mpeg4 -sameq -i /tmp/Inglorious_Bastards.yuv -acodec copy -i /tmp/Inglorious_Bastards.ac3 -b 15000k Inglorious_Bastards.avi
FFmpeg version 0.5-30.fc11, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/share/man --enable-shared --enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-avfilter-lavf --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --disable-libamr-nb --disable-libamr-wb --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i586 -mtune=generic -fasynchronous-unwind-tables --disable-stripping --extra-cflags=-I/usr/include/nvidia-graphics --extra-ldflags=-L/usr/lib/nvidia-graphics
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Jun 8 2009 18:07:32, gcc: 4.4.0 20090506 (Red Hat 4.4.0-4)
Input #0, rawvideo, from '/tmp/filename.yuv':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: rawvideo, yuv420p, 1440x1080, 29.97 tbr, 29.97 tbn, 29.97 tbc
/tmp/filename.ac3: no such file or directory
I am assuming this is due to the issue with the command:
xporthdmv -hn filename.m2ts 1 1 1
Which gives me:
Cannot open bitstream file
Is this a bad m2ts file?
I will mention I am using Fedora 11 at the moment and the install went fine, the little congratulations video played...
any filename i supply to the command line it says "File *******.m2ts not found"
Does it need to be in a certain folder/path?
The path should not matter.
You can try m2tstoavi ./input.m2ts
Hi,
When I want to install this with the command 'sudo ./install', I get the message:
sudo: unable to execute ./install: Permission denied
What am I doing wrong? It should work with 'sudo' in the command, shouldn't it?
Thanks.
It might be the path you are trying to run the command from. Try moving the directory to your home folder and try again.
This reaaaaaly needs to be updated for Ubuntu 9.04..
Hi
Did any one try this o9.04 Ubuntu 9.04 !
With a hope that the latest version of Ubuntu will have all the drivers I've installed Ubuntu 9.04.
If this doesn't work on Ubuntu 9.04 then I will have to revert back to which is a painful work.
thanks & regards,
For all People that get this Error Message:
ldecod: command not found
Download manualy an older JM-Version from this site
http://iphome.hhi.de/suehring/tml/download/old_jm/
unzip the file and make following steps
cd JM
chmod a+x unixprep.sh
./unixprep.sh
cd ldecod
make
than you have a new file in the /JM/bin/ directory: ldecode.exe
now you made an link in /usr/bin/ like
ln -s /opt/JM/bin/ldecode.exe /usr/bin/ldecod
without .exe at the end of the Line and the /opt/ you must change to the path where do you unzip the older Version.
I take the Version 12.2 and I don't habe Problems anymore.
Greetings
Björn
thank you very much for the walkthrough however when i get to step 5. and run either of:
i get the error
sudo apt-get install mplayer ffmpeg a52dec mencoder x264 faad faac libfaad2-0 libfaad2-dev subversion csh build-essential</li></ul>luke@mackerel:~/Videos/m2ts$ sudo install
install: missing file operand
Try `install --help' for more information.
should be:
sudo ./install
You guys may be interested in the open-source ffmpeg-based solution I made to bypass all the pain of compilation, etc. See http://www.crypticide.com/dropsafe/article/2657
If you get this output:
-------
Run the configure script to configure the downloaded software
The ./download script has ended.
Starting ./configure script.
/bin/sed
Removing DOS LF chars...
Done.
x264
No suitable assembler found. Install 'yasm' to get MMX/SSE optimized code.
If you really want to compile without asm, configure with --disable-asm.
x264 done
---------
You need to install nasm for anything else to work
I get no video, but sound is working.
00053( b ) 106 38 16 4:2:0 37600057( P ) 114 38 14 4:2:0 291
00055( B ) 110 39 18 4:2:0 245
read_new_slice: Found NALU_TYPE_FILL, len 1
Skipping these filling bits, proceeding w/ next NALU
[mpeg4 @ 0x717380]header damaged
Error while decoding stream #0.0
[mpeg4 @ 0x717380]header damaged
Error while decoding stream #0.0
[mpeg4 @ 0x717380]header damaged
Error while decoding stream #0.0
[mpeg4 @ 0x717380]header damaged
Error while decoding stream #0.0
00056( b ) 112 40 16 4:2:0 358
-------------------- Average SNR all frames ------------------------------
SNR Y(dB) : 0.00
SNR U(dB) : 0.00
SNR V(dB) : 0.00
Total decoding time : 17.677 sec (3.394 fps)
--------------------------------------------------------------------------
Exit JM 15 (FRExt) decoder, ver 15.0
[mpeg4 @ 0x717380]header damaged
Error while decoding stream #0.0
[mpeg4 @ 0x717380]header damaged
Error while decoding stream #0.0
frame= 0 fps= 0 q=0.0 Lsize= 125kB time=2.43 bitrate= 422.6kbits/s
video:0kB audio:114kB global headers:0kB muxing overhead 10.046601%
/usr/local/bin/m2tstoavi.fifo complete.
Whats wrong?
Almost there...
Audio works, but I get no video.
[code]
[mpeg4 @ 0xacd380]header damaged
Error while decoding stream #0.0
[mpeg4 @ 0xacd380]header damaged
Error while decoding stream #0.0
[mpeg4 @ 0xacd380]header damaged
Error while decoding stream #0.0
[mpeg4 @ 0xacd380]header damaged
Error while decoding stream #0.0
01133( b ) 2266 246 20 4:2:0 401
01137( P ) 2274 246 19 4:2:0 227
01135( B ) 2270 247 21 4:2:0 276
read_new_slice: Found NALU_TYPE_FILL, len 1
Skipping these filling bits, proceeding w/ next NALU
[mpeg4 @ 0xacd380]header damaged
Error while decoding stream #0.0
[mpeg4 @ 0xacd380]header damaged
Error while decoding stream #0.0
[mpeg4 @ 0xacd380]header damaged
Error while decoding stream #0.0
[mpeg4 @ 0xacd380]header damaged
Error while decoding stream #0.0
01136( b ) 2272 248 21 4:2:0 378
-------------------- Average SNR all frames ------------------------------
SNR Y(dB) : 0.00
SNR U(dB) : 0.00
SNR V(dB) : 0.00
Total decoding time : 395.985 sec (2.879 fps)
--------------------------------------------------------------------------
Exit JM 15 (FRExt) decoder, ver 15.0
[mpeg4 @ 0xacd380]header damaged
Error while decoding stream #0.0
[mpeg4 @ 0xacd380]header damaged
Error while decoding stream #0.0
frame= 0 fps= 0 q=0.0 Lsize= 2182kB time=45.63 bitrate= 391.7kbits/s
video:0kB audio:2139kB global headers:0kB muxing overhead 2.014668%
[1] + Done ldecod -i bits0001.mpv -o /tmp/00001.yuv
/usr/local/bin/m2tstoavi.fifo complete.
[/code]
What could wrong?
i have also tried to install this on hardy and have the same problem as anonymous. can anybody shed some light on this?
For people having problems with ldecod not be being found. sudo apt-get install ctags
PS I used
sudo apt-get install libfaad-dev
as I couldn't get libfaad2 and it worked fine (except for sound sync)
Hey Wes,
got it working, thanks. (Errors with 'command not found' were solved: it was because I didn't type in proper version from link and just typed in 14.0). Using Panasonic HDC-SD9.
However, same problem as person up above, i.e. sound is out of sinc. In fact, I don't think its out of sinc, I think the video is FAST because with longer videos the sound increases its lag behind the video (and if sound was too slow, it would sound different). Any ideas for solutions?
Thanks.
But it is not easy.
here is another tutorial:
how to Convert MTS/M2TS(AVCHD) to AVI on mac.
For MTS's from Sony, just renaming the file from .mts to .mpg -- both mplayer and ffplay will then play it. Dunno if sound works, but hey, it'll save you a few hours!
This not works with hardy for me.
a52dec and libfaad2-dev are not in the repository (universe and multiverse is enabled). Instead a52dec I installed liba52-0.7.4-dev (libfaad2-dev I skipped).
After running the install script I get the following message running "./m2tstoavi samplevideo.m2ts":
using:
./xporthdmv
ldecod: Command not found.
Anyone installed this in hardy and has an idea what I did wrong?
Hello. I have the following message:
using:/usr/local/bin/xporthdmv
ldecod: Command not found.
What is wrong?
I noticed that encoding a mts file to avi with fifo method takes forever.
What is the average time for conversion of a say 100 MB mts file?
- currently encoding 424mb mts file, its going and going.....
shoot me email back! jbspillman@gmail.com
I have the following error message:
using:/usr/local/bin/xporthdmv
ldecod: Command not found.
What is ldecod and how can I get it? Thank you for answer.
I have the following error message:
using:/usr/local/bin/xporthdmv
ldecod: Command not found.
What is ldecod and how can I get it? Thank you for answer.
thank you for the work, but it still seems to have some problem with the "m2ts" file largger than 2GB.
On my Ubuntu 7.10 , the csh and xporthdmv are both unable to support that.
In csh, the condition testing statement " -f my.m2ts" returns false,
and the xporthdmv returns "Cannot open bitstream file "
Im having trouble with the ./install script.
It doesn't appear to compile ldecod correctly.
Run the compile script to compile the software.The ./configure script has ended.
Starting ./compile script.
checking dependencies
compiling object file "obj/annexb.o" ...
compiling object file "obj/biaridecod.o" ...
compiling object file "obj/block.o" ...
compiling object file "obj/cabac.o" ...
compiling object file "obj/context_ini.o" ...
compiling object file "obj/erc_api.o" ...
compiling object file "obj/erc_do_i.o" ...
compiling object file "obj/erc_do_p.o" ...
compiling object file "obj/errorconcealment.o" ...
compiling object file "obj/filehandle.o" ...
compiling object file "obj/fmo.o" ...
compiling object file "obj/header.o" ...
compiling object file "obj/image.o" ...
compiling object file "obj/ldecod.o" ...
compiling object file "obj/leaky_bucket.o" ...
compiling object file "obj/loopFilter.o" ...
compiling object file "obj/macroblock.o" ...
compiling object file "obj/mb_access.o" ...
compiling object file "obj/mbuffer.o" ...
compiling object file "obj/mc_prediction.o" ...
compiling object file "obj/memalloc.o" ...
compiling object file "obj/nal.o" ...
compiling object file "obj/nal_part.o" ...
compiling object file "obj/nalu.o" ...
compiling object file "obj/nalucommon.o" ...
compiling object file "obj/output.o" ...
compiling object file "obj/parset.o" ...
compiling object file "obj/parsetcommon.o" ...
compiling object file "obj/rtp.o" ...
compiling object file "obj/sei.o" ...
compiling object file "obj/transform8x8.o" ...
compiling object file "obj/vlc.o" ...
creating binary "../bin/ldecod.exe"
... done
update tag table
/bin/sh: ctags: command not found
make: *** [tags] Error 127
cp: cannot stat `bin/ldecod.exe': No such file or directory
chmod: cannot access `../xporthdmv': No such file or directory
chmod: cannot access `../ldecod': No such file or directory
The source of this problem lies with nasm
If you see this early in the output
-----
Run the configure script to configure the downloaded software
The ./download script has ended.
Starting ./configure script.
/bin/sed
Removing DOS LF chars...
Done.
x264
No suitable assembler found. Install 'yasm' to get MMX/SSE optimized code.
If you really want to compile without asm, configure with --disable-asm.
x264 done
----
Then you need to install nasm using synaptic package manager
Thanks for the very helpful tutorial. I got this to work (to the point of the sample video at least) in Kubuntu 8.04.
Just in case anyone else has this - I tripped over a small problem getting it working. The x264 section of the configure script complained that I didn't have a suitable assembler, and suggested yasm. I tried installing yasm, but the script then complained that the version wasn't recent enough. It suggested nasm, which I put in - the error went away.
I also discovered that it was necessary to delete everything and start again from the extraction from the archive after messing up step 5 by failing to sudo - i.e. simply repeating the step but using sudo didn't cure the problem.
Also, do you maybe mean 755 instead of 744 in step 7?
Anyway, thanks again for the help.
wesley, I can't get the install script to work. The output I get is below :-
checking dependencies
compiling object file "obj/annexb.o" ...
compiling object file "obj/biaridecod.o" ...
compiling object file "obj/block.o" ...
compiling object file "obj/cabac.o" ...
compiling object file "obj/context_ini.o" ...
compiling object file "obj/erc_api.o" ...
compiling object file "obj/erc_do_i.o" ...
compiling object file "obj/erc_do_p.o" ...
compiling object file "obj/errorconcealment.o" ...
compiling object file "obj/filehandle.o" ...
compiling object file "obj/fmo.o" ...
compiling object file "obj/header.o" ...
compiling object file "obj/image.o" ...
compiling object file "obj/ldecod.o" ...
compiling object file "obj/leaky_bucket.o" ...
compiling object file "obj/loopFilter.o" ...
compiling object file "obj/macroblock.o" ...
compiling object file "obj/mb_access.o" ...
compiling object file "obj/mbuffer.o" ...
compiling object file "obj/mc_prediction.o" ...
compiling object file "obj/memalloc.o" ...
compiling object file "obj/nal.o" ...
compiling object file "obj/nal_part.o" ...
compiling object file "obj/nalu.o" ...
compiling object file "obj/nalucommon.o" ...
compiling object file "obj/output.o" ...
compiling object file "obj/parset.o" ...
compiling object file "obj/parsetcommon.o" ...
compiling object file "obj/quant.o" ...
In file included from src/quant.c:24:
inc/quant.h:32: error: conflicting types for ‘qmatrix’
inc/global.h:76: error: previous declaration of ‘qmatrix’ was here
src/quant.c:226: error: conflicting types for ‘qmatrix’
inc/global.h:76: error: previous declaration of ‘qmatrix’ was here
src/quant.c: In function ‘init_qp_process’:
src/quant.c:242: warning: implicit declaration of function ‘malloc’
src/quant.c:242: warning: incompatible implicit declaration of built-in function ‘malloc’
src/quant.c:245: warning: incompatible implicit declaration of built-in function ‘malloc’
make: *** [obj/quant.o] Error 1
cp: cannot stat `bin/ldecod.exe': No such file or directory
chmod: cannot access `../xporthdmv': No such file or directory
chmod: cannot access `../ldecod': No such file or directory
Run the configure2 script to configure ffmpeg and mplayer
The ./compile script has ended.
Installing xporthdmv into /usr/local
Installing hdrsr1 into /usr/local
Installing m2tstoavi into /usr/local
Doing make install for x264-snapshot-20080629-2245
Makefile:3: config.mak: No such file or directory
./configure
No suitable assembler found. Install 'yasm' to get MMX/SSE optimized code.
If you really want to compile without asm, configure with --disable-asm.
make: *** [config.mak] Error 1
Doing make install for a52dec-0.7.4
Making install in autotools
make[1]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/autotools'
make[2]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/autotools'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/autotools'
make[1]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/autotools'
Making install in include
make[1]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/include'
make[2]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/include'
make[2]: Nothing to be done for `install-exec-am'.
/bin/bash ../autotools/mkinstalldirs /usr/local/include/a52dec
/usr/bin/install -c -m 644 a52.h /usr/local/include/a52dec/a52.h
/usr/bin/install -c -m 644 attributes.h /usr/local/include/a52dec/attributes.h
/usr/bin/install -c -m 644 audio_out.h /usr/local/include/a52dec/audio_out.h
/usr/bin/install -c -m 644 mm_accel.h /usr/local/include/a52dec/mm_accel.h
make[2]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/include'
make[1]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/include'
Making install in doc
make[1]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/doc'
make[2]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/doc'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/doc'
make[1]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/doc'
Making install in liba52
make[1]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/liba52'
make[2]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/liba52'
/bin/bash ../autotools/mkinstalldirs /usr/local/lib
/bin/bash ../libtool --mode=install /usr/bin/install -c liba52.la /usr/local/lib/liba52.la
/usr/bin/install -c .libs/liba52.lai /usr/local/lib/liba52.la
/usr/bin/install -c .libs/liba52.a /usr/local/lib/liba52.a
ranlib /usr/local/lib/liba52.a
chmod 644 /usr/local/lib/liba52.a
PATH="$PATH:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/liba52'
make[1]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/liba52'
Making install in libao
make[1]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/libao'
make[2]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/libao'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/libao'
make[1]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/libao'
Making install in src
make[1]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/src'
make[2]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/src'
/bin/bash ../autotools/mkinstalldirs /usr/local/bin
/bin/bash ../libtool --mode=install /usr/bin/install -c a52dec /usr/local/bin/a52dec
/usr/bin/install -c a52dec /usr/local/bin/a52dec
/bin/bash ../libtool --mode=install /usr/bin/install -c extract_a52 /usr/local/bin/extract_a52
/usr/bin/install -c extract_a52 /usr/local/bin/extract_a52
make install-man1
make[3]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/src'
/bin/bash ../autotools/mkinstalldirs /usr/local/man/man1
/usr/bin/install -c -m 644 ./a52dec.1 /usr/local/man/man1/a52dec.1
/usr/bin/install -c -m 644 ./extract_a52.1 /usr/local/man/man1/extract_a52.1
make[3]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/src'
make[2]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/src'
make[1]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/src'
Making install in vc++
make[1]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/vc++'
make[2]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/vc++'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/vc++'
make[1]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/vc++'
Making install in test
make[1]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/test'
make[2]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4/test'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/test'
make[1]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4/test'
make[1]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4'
make[2]: Entering directory `/home/oliver/avchd/src/a52dec-0.7.4'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4'
make[1]: Leaving directory `/home/oliver/avchd/src/a52dec-0.7.4'
Starting ./configure2 script.
Run the compile2 script to compile ffmpeg and mplayer.
The ./configure2 script has ended.
Starting ./compile2 script.
Run the installasroot script as root to install the software in /usr/local/bin
The ./compile2 script has ended.
using:
./xporthdmv
ldecod: Command not found.
MPlayer 1.0rc2-4.2.3 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Pentium(R) 4 CPU 2.66GHz (Family: 15, Model: 2, Stepping: 7)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Apologies for the long post, but I really don't know which bit is relevant
Oliver
Good morning and thank you for your help converting .m2ts to.avi. It helped me.:-)
I would like to ask you a question:
Why do you use "Sudo" to untar?
With this command: sudo tar zxvf m2ts.tar.gz, is it possible to make it without using sudo. Because with sudo, a locked file is got. What I think strange.
Thank you for your answer.
Hi Patrice
Thank you for your feedback.
This tutorial documents the method I use to install m2tstoavi. When I
install m2tstoavi, I usually download it into /usr/local/bin. Which as
you know, is only writable by root.
So that is the reason, why I use "sudo" to untar, it needs root
permissions to untar in that folder.
However you raise a good point, if users download m2tstoavi to their
own personal directory. Then the sudo would not be necessary.
I will update my tutorial.
Bingo ! That is it Wesley. I compiled ffmpeg with the instructions of your article and converted a samplevideo correctly. Thanks a lot for the support !
I suspect the problem is that you are using the repository verision of ffmpeg "FFmpeg version SVN-rUNKNOWN". You might need the latest svn version of svn ffmpeg.
I wrote this article, that shows you how to compile ffmpeg
same result Unknown codec 'libmp3lame'
Try substituting libfaac with libmp3lame
Does not work for me;
:~/compilations/m2ts$ ffmpeg -i samplevideo.m2ts -acodec libfaac -ab 256k -ac 2 -vcodec mpeg4 -sameq -aspect 16:9 -b 15000k -copyts output_filename.mov
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --enable-libvorbis --enable-libtheora --enable-libogg --enable-libgsm --enable-dc1394 --disable-debug --enable-libmp3lame --enable-libfaadbin --enable-libfaad --enable-libfaac --enable-xvid --enable-x264 --enable-liba52 --enable-amr_nb --enable-amr_wb --enable-shared --prefix=/usr
libavutil version: 1d.49.3.0
libavcodec version: 1d.51.38.0
libavformat version: 1d.51.10.0
built on Apr 3 2008 18:39:35, gcc: 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
[h264 @ 0x7fa34c89f8d0]PAFF interlacing is not implemented
[h264 @ 0x7fa34c89f8d0]concealing 3060 DC, 3060 AC, 3060 MV errors
Input #0, mpegts, from 'samplevideo.m2ts':
Duration: 00:00:02.4, start: 1.100100, bitrate: 16367 kb/s
Stream #0.0[0x1011]: Video: h264, yuv420p, 1440x1080, 29.97 fps(r)
Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, 5:1, 448 kb/s
Unknown codec 'libfaac'
I have libfaac0 installed. When I replace libfaac with libfaac0 I get the same output.
Thanks for the fine set of sommand scripts; At first glance, everything seems to work. Unfortunately, I encounter 2 problems:
* Playing the *avi in mplayer works fine, howeveer, in VLC I have no sound!
* When importing the *avi into cinelerra, ist pretends to be audio only, no video!
I tried several container formats and/or seperate files juggling with ffmpeg, but I can't find any container format holding both video and audio!!!
Any hints or suggestions are highly welcome!
Saw this and couldn't resist....why not play the video twice, once in cinelerra (minimised, audio only) and again in vlc....simultaneously. 'Course, lipsynching might be a slight problem, bet...
You are correct, the default ffmpeg parameters used by m2tstoavi don't create files that can be imported into cinelerra.
These parameters have been reported to create files that can be imported into Cinelerra.
ffmpeg -i filename.mts -acodec libfaac -ab 256k -ac 2 -vcodec mpeg4 -sameq -aspect 16:9 -b 15000k -copyts output_filename.movaudio codec = libfaac
video codec = mpeg4
container = mov
Please let me know if that helps.
one of your first responses in this thread reads "I’m not sure if the quality is affected by the conversion process. I will look into this for you"
i should have put quotes around my 'lossyness'. converting file formats is often lossy i.e. some detail/quality is lost. i was just wondering how lossy this is. did you ever find anything out?
kbps figures dont mean much to me i'm afraid. can you *see* any difference?
I can tell you that the audio quality is unaffected(no loss). The video looks perfectly fine on my lcd monitor or standard television.
However I do believe the video quality would be noticeable on a HD televison. I will try to confirm this in the new future.
I apologize for the delay .
Small correction - Step 4 should be:
sudo gedit download
Thank you for helping improve this article.
Why is it that I can never get the ./install command to work? Here is the output:
root@ryan-laptop:/home/ryan/m2ts# ./install
bash: ./install: /bin/csh: bad interpreter: No such file or directory
Can anyone help?
The problem is the csh shell is not installed on your system.
Install csh with this command:
sudo apt-get install cshHi.
It would be usefull if you changed the command
sudo ./install
to
sudo csh ./install
On some systems csh isn't default shell and frankly, as a newbie I didn't know that there is such a thing like different shells.
Invoking it explicitly in csh or tcsh could save some time.
Great work by the way, thanks a lot!
@paul
I'm sorry, I haven't heard the term "lossyness" before. I'm not sure if your referring to loss in sound or video quality.
Here is an example of the video/audio bitrates of a HD MTS video, and after the transcoded bitrates.
Original MTS File
Video bitrate: 9573 kb/sAudio:48000 Hz, 5:1, 448 kb/s
Transcoded to AVI
Video bitrate: 461 kb/sAudio 48000 Hz, 5:1, 448 kb/s
As you can see, there is quite a loss in the video bitrate. The audio is not affected. Hope this helps
hey wes. great work :)
did you find out anything about the lossyness of this procedure.
I had trouble with the frame resolution that this script assumes. It’s assuming 1440×1080, and my camera can shoot @1920×1080. If you try to process a 1920 file with this script, you’ll get “flipping” (not sure if that’s the right term) where it looks as if you had turned the old-school “vert” knob on your TV too far one way or the other.
The fix is to edit the m2tstoavi(.fifo) script. Replace 1440 with 1920, and the video will turn out fine.
Of course, the files will only have sound in mplayer, the sound, when you do have it, is out of sync by a few seconds, and the output file won’t import into Cinelerra. Time to do some more googling…
From Convert MTS/M2TS(AVCHD) to AVI
I had to make the same change to my script. I recorded video on a Panasonic SD9 and after making the change from "1440" to "1920", the picture showed up like it was suppose to. It does look good.
I had trouble with the frame resolution that this script assumes. It’s assuming 1440×1080, and my camera can shoot @1920×1080. If you try to process a 1920 file with this script, you’ll get “flipping” (not sure if that’s the right term) where it looks as if you had turned the old-school “vert” knob on your TV too far one way or the other.The fix is to edit the m2tstoavi(.fifo) script. Replace 1440 with 1920, and the video will turn out fine.
Of course, the files will only have sound in mplayer, the sound, when you do have it, is out of sync by a few seconds, and the output file won’t import into Cinelerra. Time to do some more googling…
From Convert MTS/M2TS(AVCHD) to AVI
Hi Wes,
thanks for your tutorial. Unfortunately I’m not able to install it.
Already step 2 fails on my machine (UbuntuStudio 8.04).
> ’sudo apt-get install mplayer ffmpeg a52dec mencoder x264 faad faac libfaad2-0 libfaad2-dev subversion csh’
leads to the first error:
Paket a52dec ist ein virtuelles Paket, das bereitgestellt wird von:liba52-0.7.4-dev 0.7.4-11ubuntu1
Sie sollten eines explizit zum Installieren auswählen.
E: Paket a52dec hat keinen Installationskandidaten
Description is unfortunately in german. It says said a52dec does not posses a installation candidate !?
If I replaced ‘a52dec’ by ‘liba52-0.7.4-dev’ it leads to the next error:
‘Die folgenden Pakete haben nichterfüllte Abhängigkeiten:libfaad2-dev: Hängt ab: libfaad2-0 (= 2.0.0+cvs20040908+mp4v2+bmp-0ubuntu5) aber 2.6.1-2 soll installiert werden
E: Kaputte Pakete’
It says that ‘libfaad2-dev: depends libfaad2-0 (= 2.0.0+cvs20040908+mp4v2+bmp-0ubuntu5)’,
but 2.6.1-2 is atempted to be installed –> Error: corrupted packes!?
Any ideas or suggestions?
Thanks in advance for your efforts.
Bye
Hergerger
@Fraize
It seems that your Ubuntu does not have the ability to compile programs. In order to compile anything in Ubuntu, you need a package called build-essential.
sudo apt-get install build-essentialWes,
I, too, get the “xporthdmv: Command not found.” error when I try to invoke m2tstoavi script. I’m running Hardy with the latest patches.
I did notice that the compiler script threw the following errors when I ran it. I executed it as su:
Run the compile script to compile the software.
The ./configure script has ended.
Starting ./compile script.xport.c:5:19: error: stdio.h: No such file or directory
xport.c:6:20: error: stdlib.h: No such file or directory
xport.c:7:20: error: string.h: No such file or directory
xport.c:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
xport.c: In function 'main':
...
cp: cannot stat `bin/ldecod.exe’: No such file or directory
chmod: cannot access `../xporthdmv’: No such file or directory
chmod: cannot access `../ldecod’: No such file or directory
Thanks!
Fraize
Wes,
Appreciate it. All good to go. Had a dual install with OS X so I had to disable Journaling which in turn allowed me more than read permission on the disk. I’m currently chewing through the conversions. Now I just have to pick which editing software I’m going to use. What’s your recommendation?
Thanks!
Petah
I am glad to here that you were able to free yourself from the monolithic beast of vista.
Let me know if you need a hand getting your second drive mounted with read/write.
Wes,
Disregard my problem running it in the media location folder. Looks like my second disk is a read only environment. Time for some google work.
Thanks again!
Wes,
Thank you very much! I got it to run.
I reinstalled and followed the tutorial exactly and as long as I execute the m2tstoavi.fifo from the m2ts folder that I unzipped it works great. If I change into the folder the files are in I still get the above error, which is still a huge help. Now I just have to figure out how to change the output folder since the videos are on a separate hard drive, and the drive with the m2ts folder (aka the location that runs the file properly is on aa smaller drive. I guess I can whole swap the folder to my larger drive.
Thanks again for the help. You’ve let me move to my new build computer free from the monolithic beast of vista!
@Petah
Thanks for posting all the required details.
Try running Step 5 as root, that should fix the problem
Hello. I’m having a tough time getting this to work properly. I’m using Ubuntu 64 bit with the following error:
petah@desky:/media/SataTwo/Camcorder/BDMV/STREAM$ m2tstoavi.fifo *
using:
/usr/local/bin/xporthdmv
/usr/local/bin/ldecod
/usr/bin/ffmpeg
/usr/local/bin/m2tstoavi.fifo Starting.
xporthdmv -hn 00000.MTS 1 1 1
Unsupported Option: n
Cannot open video output file
mkfifo: cannot create fifo `/tmp/00000.yuv’: File exists
ldecod -i bits0001.mpv -o /tmp/00000.yuv
[1] 7107
ffmpeg -r 29.97 -s 1440×1080 -vcodec mpeg4 -sameq -i /tmp/00000.yuv -acodec copy -i /tmp/00000.ac3 -b 15000k 00000.avi
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: –enable-gpl –enable-pp –enable-swscaler –enable-pthreads –enable-libvorbis –enable-libtheora –enable-libogg –enable-libgsm –enable-dc1394 –disable-debug –enable-shared –prefix=/usr
libavutil version: 1d.49.3.0
libavcodec version: 1d.51.38.0
libavformat version: 1d.51.10.0
built on Mar 12 2008 15:36:03, gcc: 4.2.3 (Ubuntu 4.2.3-2ubuntu4)
—————————– JM 14.0 (FRExt) —————————–
Decoder config file : (null)
————————————————————————–
Input H.264 bitstream : bits0001.mpv
Output decoded YUV : /tmp/00000.yuv
Output status file : log.dec
Input reference file : test_rec.yuv does not exist
SNR values are not available
————————————————————————–
POC must = frame# or field# for SNRs to be correct
————————————————————————–
Frame POC Pic# QP SnrY SnrU SnrV Y:U:V Time(ms)
————————————————————————–
Cannot open Annex B ByteStream file ‘bits0001.mpv’
If anyone has any suggestions I’d be extremely grateful
@Lauri
I suspect that you are missing xporthdmv.
To verify if xportdmv is installed, run this from command line
which xporthdmvIf xporthdmv is installed it will output something like this:
/usr/local/bin/xporthdmvgreat nothing shows and after some searching i can not find how to rectify the situation
Hi, when I try to run “m2tstoavi.fifo 00000.mts” in my video folder it says: “using: xporthdmv: Command not found.”
Both m2toavi and -fifo do the same. I’m using ubuntu 8.04 and commands should be installed properly. Am I missing this “xporthdmv” -part? Thx a lot!
@retlaw
I think I found the problem, please confirm. The problem was step 5 needs to be ran as root, with sudo.
Ok, finally got the script to run again by deleting the first line of script and retyping it but now I get the following problem:
Cannot open Annex B ByteStream file ‘bits0001.mpv’
Any suggestions?
Thanks!
Greetings. Thanks for putting this together. I ran through the instructions and got the sample video converted at the end of the install but am having problems running the script using my files. When I try to execute the script I get:
/usr/local/bin/m2tstoavi.fifo: line 1: #!/bin/csh: No such file or directory
/usr/local/bin/m2tstoavi.fifo: line 11: syntax error near unexpected token `(’
/usr/local/bin/m2tstoavi.fifo: line 11: ` set files=($*)’
here’s the file itself:
#!/bin/csh
#The scripts and instructions in this package are free to use and
#redistribute AT YOUR OWN RISK!! Standard disclaimers apply.
#NO WARRANTY!
if ( $#argv == “0″ ) then
echo usage: $0 filename.m2ts …
exit
else
set files=($*)
endif
I do have a csh file in the bin folder (a link to executable actually), but I can’t create a folder due to that link being there.
If anyone has any suggestions I’d be much obliged.
Thanks!
@Chris
My suggestion would be to try and view through VLC. By default the video is converted into mpeg4, and the audio is AC3, inside an AVI container.
Please let me know if this helps.
My setup is a headless linux box running Ubuntu 7.10 server. I have to pull the samplevideo off to view. I’ve been able to get the video to convert, but there is no audio when I copy the resulting AVI to a Windows XP box. Thanks for your help.
Chris, after you used the install script, did the samplevideo automatically play on your screen?
What program did you use to view the video?
After installing I view the samplevideo.avi file and it is 2 seconds of black. Are there some codec’s I am missing?
Thank you Peter for your insight into the “command not found” problem”. I have added the steps you have mentioned to the how to.
To all with the “command not found” problem: Just copy the m2tstoavi.fifo script into your /usr/local/bin folder, just like the other scripts:
sudo chmod 744 m2tstoavi.fifo
sudo cp m2tstoavi.fifo /usr/local/bin
The script is then in your path and you can omit the ./ before the command.
In response to Roberto’s comment regarding the “command not found” message with the m2tstoavi.fifo command… I had the same problem. I seem to have fixed it my changing the permission on it to 744, and opening it with “./m2tstoavi.fifo ________.mts”. In other words, for me it seems that the command required a “./” prior to the text whereas the normal command did not. Hope this helps…
New problem!
Sound is working now (after installing some codecs)
But resulting avi is strange and can be played only by mplayer :(
when I try to play it by Kaffeine or other movie-player, time-slider starts jumping back and forward
and sound starts to work asynchronously with picture :( (speed of picture is not constant)
Hi! This script works fine :)
Thank you
The only problem is sound :(
I have no sound after converting
My camera is SR5E
If it is a permissions problem then change the permissions of the folder with:
% sudo chmod 777 m2ts
Be careful with 777 because it gives everyone on that machine access to the folder.
For more information on changing file permissions check this site. Linux Permissions
Then
% sudo ./m2ts/install
Hi. Sorry, but i’m a linux newbie, I’m stuck at the part where you have to ./path/install but it says that i don’t have the permission to do so. Can anyone help me?
% ./m2ts/install./m2ts/install: Permission denied.
If it says “command not found”, I suspect the m2tstoavi.fifo is not in your path. If you goto the directory where m2tstoavi is installed, you should be able to type ./m2tstoavi.fifo and it should work.
For your second question. Do you have a NTSC or PAL video camera(HDR-SR7 or HDR SR7E). You can locate the model on the bottom of the camera.
Another problem: I’ve just finished converting a MTS file into avi but all images are distorted and colors are changed. If I watch directly from the camera, instead, the video is perfect. Should I use a program or a particular configuration?
thanks again
I followed all the steps you described, but when I try to use the m2tstoavi.fifo command it gives me “command not found”. What could be the problem? The installation was completed successfully I think, or at least it didn’t give me any error messages.
thanks
Cool, I just needed to modify the ffmpeg command to add -deinterlace and -aspect 16:9
This works great for me. You don’t happen to know how I could easily de-interlace the video from my Canon HG10 do you? Thanks!
I’m not sure if the quality is affected by the conversion process. I will look into this for you.
With my HDR-SR7, I have to press the “computer” option on the [USB SELECT] screen. Then Ubuntu mounts it automatically, and puts an icon on the desktop.
Wesley thanks for the great post and helping us get through this on Ubuntu! I have a question though if you have a second? My question is what does all this converting do to the quality of the video? And does Ubuntu just recognize and mount the camera that is hooked up via usb like an hdrux1! Any help would be much appreciated thanks.
Post new comment