AVS Forum banner

1 - 20 of 176 Posts

·
Registered
Joined
·
339 Posts
Discussion Starter #1
Hi,


For those of us using Linux, I put together a readme and some sample scripts on how to convert .m2ts files to a format playable with mplayer.


Here's a link to the package I put together:
http://www.olmosconsulting.com/m2ts.tar.gz


Here is the procedure used:

1. Use xporthdmv to convert the file into .mpv and .mpa files.

2. Use ldecod to convert the .mpv file into a .yuv file.

3. Rename the .mpa file ldecod created to .ac3

4. Convert the .yuv file into a .y4m file using yuv4mpeg.


At this point, you have a .y4m file and .ac3 file which should be

standard.


5. Use ffmpeg to create a .avi file that contains the .y4m

transcoded to something else and the .ac3 file.


Sample commands:

xporthdmv -nh FILE.m2ts 1 1 1

ldecod -i bits0001.mpv -o /tmp/FILE.yuv

mv bits0001.mpa /tmp/FILE.ac3

yuv4mpeg -w 1440 -h 1080 -x 420mpeg2 /tmp/FILE.y4m

ffmpeg -i /tmp/FILE.y4m -i /tmp/FILE.ac3 -acodec copy -vcodec h264 -sameq -s 1440x1080 -aspect 16:9 -b 15000000 FILE.avi


If there is anyone out there who knows what they are doing with ffmpeg and

has suggestions, I'd love to hear them.


Axel
 

·
Registered
Joined
·
5 Posts
It's about a month that I'm looking for a m2ts conversion.

I spent a lot of hour in internet, but this is the first solution I found that use only opensource programs.

I tried and it works fine.

I found only a little problems during the last step:

ffmpeg -i /tmp/FILE.y4m -i /tmp/FILE.ac3 -acodec copy -vcodec h264 -sameq -s 1440x1080 -aspect 16:9 -b 15000000 FILE.avi


The output is:
Input #0, yuv4mpegpipe, from 'bits0001.y4m':

Duration: N/A, bitrate: N/A

Stream #0.0: Video: rawvideo, yuv420p, 1440x1080, 29.97 fps(r)

Input #1, ac3, from 'bits0001.ac3':

Duration: 00:00:21.3, start: 0.000000, bitrate: 448 kb/s

Stream #1.0: Audio: ac3, 48000 Hz, 5 channels, 448 kb/s

Output #0, avi, to 'output.avi':

Stream #0.0: Video: 0x0000, yuv420p, 1440x1080, q=2-31, 2115098 kb/s, 29.97 fps(c)

Stream #0.1: Audio: ac3, 48000 Hz, 5 channels, 448 kb/s

Stream mapping:

Stream #0.0 -> #0.0

Stream #1.0 -> #0.1

Unsupported codec for output stream #0.0


Then i tried with mpegvideo code and it runs well.


I use cinelerra and the 1080i source video has to deinterlace.

Do you think it's better to deinterlace during the conversion m2ts->avi or could be better to deinterlace using cinelerra filter?


Thanks very much
 

·
Registered
Joined
·
130 Posts
For all of you Mac OS X users, this is a viable solution. I will give Axel full details on how I got it to work so that he can include it in his m2ts.tar.gz file. There are still a few bugs to work out (aspect ratio for one), but I was able to get the m2ts file converted, and I can view it in various programs. Stay tuned.
 

·
Registered
Joined
·
6 Posts
How were you able to get the file on to your Linux workstation? Has anyone been successful in mounting the drive over USB? I've been trying this to no avail. What device should I use on the mount command? I'm using RH9, so my kernel may certainly be to old for this cambera. After reading through theBlu-ray Disc/DVD+RW/+R/-R[W] for Linux article it seems an upgrade may be in order.


Any pointers?
 

·
Registered
Joined
·
5 Posts
Hi Mangel,


I use Kubuntu edgy and it autodetect and mount itself pendrive and camera.

I prefer to use windows to save the m2ts file on a fat32 partition and then I return in linux and use a script for convert the m2ts->quicktime mov file with mpeg4+aac codec.

The script is very slow, but the mov file works fine in cinelerra.


When you connect the device to usb port try to use the command

lsusb


You can see the list of the founded devices.


Bye


Giorgio


Quote:
Originally Posted by mangell /forum/post/0


How were you able to get the file on to your Linux workstation? Has anyone been successful in mounting the drive over USB? I've been trying this to no avail. What device should I use on the mount command? I'm using RH9, so my kernel may certainly be to old for this cambera. After reading through theBlu-ray Disc/DVD+RW/+R/-R[W] for Linux article it seems an upgrade may be in order.


Any pointers?
 

·
Registered
Joined
·
130 Posts
As I have discussed with Axel in PMs, the yuv4mpeg step can be skipped using the following command:


% ffmpeg -r 29.97 -s 1440x1080 -i /tmp/samplevideo.yuv -i /tmp/samplevideo.ac3 -vcodec mpeg4 -acodec copy -aspect 16:9 -b 15000k samplevideo.avi


Ffmpeg will take the *.yuv file created by ldecod and convert it to whatever format you like. Note that the order of options is important (which might help Giorgio's problem).

[edited] video and audio now sync properly with the addition of -r 29.97
 

·
Registered
Joined
·
130 Posts
I have posted Mac OS X instructions here for converting AVCHD content to HDV, and hopefully Axel will include them in his package. You should still get Axel's m2ts.tar.gz file (see first post at top of page) since it has a sample video clip and other information.


My instructions illustrate how to convert AVCHD content into HDV content, which is a format supported by iMovieHD and Final Cut. Of course, you can convert your videos into many other formats too, but that is up to you.


A new option is Voltaic . This bundles the whole process together into one program (and does not require QTPro). Of course, the benefit of my instructions are that it is the free way of doing a conversion.
 

·
Registered
Joined
·
5 Posts
Thanks for your suggestion Octane. I will try it.


The procecude is very slow. Remove a step is a good idea.


I also tried -vcodec mpeg4 but I must use -acodec aac.

I don't know why, but I have problem using -acode copy. Cinelerra don't work with this ac3 stream.


I also tried the option -deinterlace. It seems work well.

At the moment I prefer use pal low resolution format and so I use this command:


ffmpeg -i /tmp/samplevideo.y4v -i /tmp/samplevideo.ac3 -acodec aac -ac 5 -ab 448 -r 25 -vcodec mpeg4 -sameq -s 720x576 -aspect 16:9 -deinterlace samplevideo.mov


Bye

Quote:
Originally Posted by 0ctane /forum/post/0


As I have discussed with Axel in PMs, the yuv4mpeg step can be skipped using the following command:


% ffmpeg -r 29.97 -s 1440x1080 -i /tmp/samplevideo.yuv -i /tmp/samplevideo.ac3 -vcodec mpeg4 -acodec copy -aspect 16:9 -b 15000k samplevideo.avi
 

·
Registered
Joined
·
5 Posts
Hi Octane,


I tried to use directly yuv file but my ffmpeg don't recognize yuv codec:

Code:
Code:
FFmpeg version SVN-r7773, Copyright (c) 2000-2006 Fabrice Bellard, et al.
  configuration:  --enable-faac --enable-gpl --enable-pthreads --disable-debug --disable-mmx --enable-a52
  libavutil version: 49.2.0
  libavcodec version: 51.29.0
  libavformat version: 51.8.0
  built on Jan 31 2007 08:18:23, gcc: 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)
picture size invalid (0x0)
[rawvideo @ 0x6d4880]Could not find codec parameters (Video: rawvideo, yuv420p)
/mnt/hda4/temp/file.yuv: could not find codec parameters
Did you compile ffmpeg or did you install it from binary? Can you give me the configuration options. You can find it on the second line when you run ffmpeg.


Thanks


Quote:
Originally Posted by 0ctane /forum/post/0


% ffmpeg -r 29.97 -s 1440x1080 -i /tmp/samplevideo.yuv -i /tmp/samplevideo.ac3 -vcodec mpeg4 -acodec copy -aspect 16:9 -b 15000k samplevideo.avi
 

·
Registered
Joined
·
130 Posts

Quote:
Originally Posted by Giorgio Arlanch /forum/post/0


Hi Octane,

I tried to use directly yuv file but my ffmpeg don't recognize yuv codec:

Code:
Code:
picture size invalid (0x0)
[rawvideo @ 0x6d4880]Could not find codec parameters (Video: rawvideo, yuv420p)
/mnt/hda4/temp/file.yuv: could not find codec parameters

I have to requote myself: "Note that the order of options is important". Maybe I should have written "VERY important". If the -r 29.97 -s 1440x1080 is NOT before your input (-i) you will get the error you experienced (I had to post to the ffmpeg forums in order to learn this lesson). By having the -r -s before the -i you are telling ffmpeg that the input is 29.97fps and at a 1440x1080 size.
 

·
Registered
Joined
·
339 Posts
Discussion Starter #11

Quote:
Originally Posted by 0ctane /forum/post/0


For all of you Mac OS X users, this is a viable solution. I will give Axel full details on how I got it to work so that he can include it in his m2ts.tar.gz file. There are still a few bugs to work out (aspect ratio for one), but I was able to get the m2ts file converted, and I can view it in various programs. Stay tuned.

Thanks so much for this!! I updated the .tar.gz with the improvements.
 

·
Registered
Joined
·
339 Posts
Discussion Starter #12
It looks to me that our videos are NOT 16:9, but are 4:3. Dropping the -aspect 16:9 from the ffmpeg line makes the video smaller, but the aspect looks right. Can anyone verify?
 

·
Registered
Joined
·
5 Posts
Thanks Octane,


using the right order it works well.

And now, the next step, is to remove ldecod!

Quote:
Originally Posted by 0ctane /forum/post/0


... "VERY important". If the -r 29.97 -s 1440x1080 is NOT before your input (-i) ...
 

·
Registered
Joined
·
6 Posts
i tried your instructions at octane(dot)net for getting this to convert with a mac. i'm getting strange results. in iMovieHD, the avi just comes out black. i tried with the sample in axel's post and also with a sample i got from somewhere else (i don't want to commit to buying the camera until i am comfortable that i can edit footage with it), both with the same results. in FCP, it tells me that it is missing a codec.


any ideas?
 

·
Registered
Joined
·
6 Posts
ok, after running all the scrits, i can get it to work in mplayer, but i'm still getting "no codec" in fcp. do i have to get this codec from somewhere?
 

·
Registered
Joined
·
6 Posts
after playing around with the m2tstoavi script a bit, i think i *might* be getting somewhere:


i can load stuff into fcp if i change the vcodec to mpeg2video and change the extension of the file to .mpg. only problem is i don't get sound. i'm thinking that fcp doesn't support ac3? anyway, i tried to set acodec to something other than copy and i get:


[ac3 @ 0x423514]A52 library liba52.so.0 could not be opened!

dlopen(liba52.so.0, 1): image not found


i tried to recompile with --enable-shared but that got a compile error. i am using the ffmpeg revision 7013. the one checked out as a result of the download script doesn't seem to work with the configuration options in the "configure" script. it seems they have changed at some point.


any ideas?
 

·
Registered
Joined
·
6 Posts
i've been playing with some of the settings for ffmpeg. i changed the script around so that i could change the video codec, audio codec, format and the output file extension.


i ended up with:

set codec=mpeg4

set acodec=mp3

set fformat=mov

set fext=mov


and i use the -f option which forces a certain format on ffmpeg.


and that seemed to work ok in fcp if i set the project to:

HDV 1080i60


the only problem is that i have to always render the timeline, which will take a long time. i'm wondering if there is some format i could use ffmpeg to transform to that fcp will handle natively.


the other section of the scrip that i modified is the bottom that calls ffmpeg:


echo ffmpeg -r 29.97 -s 1440x1080 -i $tmpfile".yuv" -i $tmpfile".ac3" -f $fformat -vcodec $codec -sameq -acodec $acodec -aspect 16:9 -b 15000k $outputfile

ffmpeg -r 29.97 -s 1440x1080 -i $tmpfile".yuv" -i $tmpfile".ac3" -f $fformat -vcodec $codec -sameq -acodec $acodec -aspect 16:9 -b 15000k $outputfile && rm -f $tmpfile".ac3" $tmpfile".yuv"


john
 

·
Registered
Joined
·
6 Posts
Ok.. using all the steps above, you can get an mpeg4/mp3 .mov file (i guess you loose the surround sound feature of the camera). from there, you can use Compressor to convert to HDV. once the file is in HDV, you can edit natively in FCP.


I am planning on using the above script and apple's Folder Actions feature to create an apple script that will run when .m2ts files are dropped into my "porjects" folder. with this, i will have pretty much the same workflow as if FCP handled AVCHD natively.


when i get all this done, i will post all the relevant scripts, etc.


john
 

·
Registered
Joined
·
6 Posts
ok... i got an SR1 from fry's electronics (they still have a "no restocking fee" return policy) and tried some video out. i was able to edit, but for every min. of recorded footage, it took about 20-30 mins to convert. this will not work for me since i usually shoot underwater footage on a dive trip. i like to shoot in the morning and edit in the afternoons/evenings. i couldn't wait the 5 hours it would take to convert 10 mins of video.


i think i'll go with the HDR-HC7. looks like it has some better stats anyway, especially for the low light conditions when diving.
 

·
Registered
Joined
·
10 Posts
xport is not compiling for me without warnings. And it doesn't seem to be working. As I understand it, xport should convert the .MTS (m2ts) file into seperate video and audio files in original format- eg: mp4 and ac3. The audio file is playable in VLC, but the video is not.


The warning I get when trying to compile xport on a mac are:

gcc -o xportdmv xport.c ; chmod 755 xportdmv

xport.c:37: warning: integer constant is too large for 'long' type

xport.c: In function 'parse_ac3_audio':

xport.c:383: warning: integer constant is too large for 'long' type

xport.c: In function 'parse_mp2_audio':

xport.c:626: warning: integer constant is too large for 'long' type


This is a PowerMac G5 with OS X 10.4.8


I checked the first line and the value is being put into a long long type, not a long type, and long long seems to be supported on the Mac, so I'm not sure how to get GCC to compile this correctly... it wants to put it in a long (And this probably causes the video problems I was seeing.)


gcc --version

powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5367)

Copyright (C) 2005 Free Software Foundation, Inc.
 
1 - 20 of 176 Posts
Top