|
|
![]() |
|
|
|
|
|
#1 | Link |
|
|
Senior Member
|
AVCHD .m2ts conversion for Linux
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.yuv > /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 Last edited by Axel Olmos; 01-17-07 at 11:26 PM.. Reason: typo, said covert instead of convert |
|
|
|
|
|
|
#2 | Link |
|
New Member
|
Congratulation and thanks a lot
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 ![]() |
|
|
|
|
|
#3 | Link |
|
Member
|
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.
|
|
|
|
|
|
#4 | Link |
|
New Member
|
Mount?
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? |
|
|
|
|
|
#5 | Link | |
|
New Member
|
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:
Last edited by Giorgio Arlanch; 02-07-07 at 06:38 AM.. |
|
|
|
|
|
|
#6 | Link |
|
Member
|
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 Last edited by 0ctane; 02-07-07 at 04:38 PM.. Reason: fixing command |
|
|
|
|
|
#7 | Link |
|
Member
|
AVCHD .mts conversion for OS X
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. Last edited by 0ctane; 08-25-08 at 08:47 AM.. Reason: info update |
|
|
|
|
|
#8 | Link | |
|
New Member
|
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:
Last edited by Giorgio Arlanch; 02-08-07 at 01:08 PM.. |
|
|
|
|
|
|
#9 | Link | |
|
New Member
|
Hi Octane,
I tried to use directly yuv file but my ffmpeg don't recognize yuv codec: 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 Thanks Quote:
|
|
|
|
|
|
|
#10 | Link | |
|
Member
|
Quote:
|
|
|
|
|
|
|
#11 | Link | |
|
Senior Member
|
Quote:
|
|
|
|
|
|
|
#14 | Link |
|
New Member
|
no codec for FCP?
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? |
|
|
|
|
|
#16 | Link |
|
New Member
|
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? |
|
|
|
|
|
#17 | Link |
|
New Member
|
i think i got something
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 |
|
|
|
|
|
#18 | Link |
|
New Member
|
Final Cut Pro and ACVHD
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 |
|
|
|
|
|
#19 | Link |
|
New Member
|
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. |
|
|
|
|
|
#20 | Link |
|
New Member
|
Mac Compiltion Warning...
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. |
|
|
|
|
|
#21 | Link | ||
|
Member
|
read all the directions?
Quote:
Quote:
|
||
|
|
|
|
|
#22 | Link | |
|
Senior Member
|
xporthdmv latest version not working yet.
Quote:
|
|
|
|
|
|
|
#23 | Link | |
|
Senior Member
|
Quote:
diff xport.c xport.c.orig 383,384c383,384 < if (pts_aligned != 0 ) { < if (current_pts >= 0 ) { --- > if (pts_aligned != 0xffffffffffffffff) { > if (current_pts >= pts_aligned) { Change lines 383,384 as indicated above. That change makes it work on my machine. (It probably has unintended consequences for other cases I don't understand.) |
|
|
|
|
|
|
#24 | Link |
|
New Member
|
pipe from ldecod to ffmpeg??
Axel - Thanks for your post; works great on the small samples I've played with. Problem is the size of the raw files generated by ldecod - around 4GB / min of video for my samples. Seems like there should be a way to avoid creating the entire raw file, like piping the output of ldecod directly to ffmpeg. I tried this, but it looks like one or the other (or both) doesn't support pipes. Am I wrong? Any ideas?
p28driver |
|
|
|
|
|
#26 | Link |
|
New Member
|
ffmpeg does allow pipes
I dug into this a bit more by looking at the source code for ffmpeg, and it certainly does allow for pipes. Looks like you still have to specify an input filename with the -i option, but for a pipe you specify either "-" or "/dev/stdin" as the input filename.
The remaining question is whether or not the ldecod output can be piped to another program, which looks doubtful. I'm looking into the source code of ldecod to see if it's possible, with or without modifiation... p28driver |
|
|
|
|
|
#27 | Link | |
|
Member
|
Quote:
Chris |
|
|
|
|
|
|
#28 | Link |
|
New Member
|
Perfect!
Thanks, Chris! Named pipes do the trick nicely!
Here's what I tried: % xport -h sample.m2ts 1 1 1 % mv bits0001.mpa sample.ac3 % mkfifo pipe.yuv % ldecod -i bits0001.mpv -o pipe.yuv & % ffmpeg -r 29.97 -s 1440x1080 -i pipe.yuv -i /tmp/sample.ac3 -acodec copy \ -vcodec mpeg4 -aspect 16:9 -b 15000k sample.avi % rm pipe.yuv No gigantic intermediate files, no filling up my hard drive with 15 minutes of raw video I'm just going to delete anyway! This is starting to look like a practical technique. Does anybody have links to other sample videos from any of the Sony AVCHD cameras? Dallas |
|
|
|
|
|
#29 | Link | |
|
Member
|
mp3, Error while opening codec for output stream #0.1
Quote:
Interesting work-around with the pipes guys. I had never used (or even heard of) mkfifo before. I tested it out on one of my videos and it worked just fine. Great job! For Macintosh iMovie users, the ac3 format and -acodec copy does not seem to be a viable option. Apple does not really support ac3, and Quicktime does not seem to be able to convert to a different audio format internally. I slightly modified my command-line options to allow output as mp3. Code:
% ffmpeg -r 29.97 -s 1440x1080 -i avchd.yuv -i avchd.ac3 -vcodec mpeg4 -ac 2 -acodec mp3 -aspect 16:9 -b 15000k sample.avi Thanks to everyone who is contributing, debugging, and optimizing. ![]() |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|