View Full Version : AVCHD .m2ts conversion for Linux
Axel Olmos
01-17-07, 11:13 PM
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
Giorgio Arlanch
01-27-07, 08:23 AM
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
:) :) :)
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.
mangell
02-06-07, 10:47 PM
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?
Giorgio Arlanch
02-07-07, 06:31 AM
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
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?
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
I have posted Mac OS X instructions here (http://www.0ctane.net/files/readme_osx.txt) 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 (http://www.mac1080hd.com). 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.
Giorgio Arlanch
02-08-07, 09:32 AM
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
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
Giorgio Arlanch
02-08-07, 01:58 PM
Hi Octane,
I tried to use directly yuv file but my ffmpeg don't recognize yuv codec:
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
% 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
Hi Octane,
I tried to use directly yuv file but my ffmpeg don't recognize yuv codec:
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.
Axel Olmos
02-08-07, 04:18 PM
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.
Axel Olmos
02-08-07, 05:37 PM
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?
Giorgio Arlanch
02-08-07, 07:40 PM
Thanks Octane,
using the right order it works well.
And now, the next step, is to remove ldecod!
... "VERY important". If the -r 29.97 -s 1440x1080 is NOT before your input (-i) ...
johnellisdm
02-17-07, 02:28 PM
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?
johnellisdm
02-17-07, 03:11 PM
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?
johnellisdm
02-17-07, 07:35 PM
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?
johnellisdm
02-18-07, 02:01 AM
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
johnellisdm
02-19-07, 12:16 PM
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
johnellisdm
02-21-07, 06:09 PM
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.
Lysander
03-14-07, 12:47 PM
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.
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. Yes, xport separates tracks. The video cannot be played in VLC since VLC does not (yet?) recognize AVCHD.
The warning I get when trying to compile xport on a mac are:
... it wants to put it in a long (And this probably causes the video problems I was seeing.)Are you saying that it did compile, but just gave error/warning messages? Did you go through the rest of the procedure to convert to *.yuv and then to a playable mpeg/mp4 format?
Axel Olmos
03-16-07, 09:12 PM
xport is not compiling for me without warnings. And it doesn't seem to be working...
Hi, it turns out the latest version of xporthdmv exports 0 byte audio files. I am in contact with the author who will try and fix it. In the meantime, unless you are lucky enough to find a download of an older version of xport, you are stuck without audio.
Axel Olmos
03-23-07, 07:48 PM
Hi, it turns out the latest version of xporthdmv exports 0 byte audio files. I am in contact with the author who will try and fix it. In the meantime, unless you are lucky enough to find a download of an older version of xport, you are stuck without audio.
For those of you having trouble with xport creating 0 byte audio files:
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.)
p28driver
04-03-07, 01:34 AM
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
Yeah, the hard drive overhead is quite big. I am not aware of being able to pipe into ffmpeg. You could always get onto the ffmpeg development forum and post an inquiry there.
p28driver
04-03-07, 01:02 PM
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
latedate
04-03-07, 02:22 PM
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
If ldecod doesn't accept pipes (stdin) explicitly, can't you work around the problem using named pipes (FIFOs)?
Chris
p28driver
04-03-07, 08:47 PM
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
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?Yes, the camera captures video at 4:3. That is why we need to explicitly state the resolution (1440x1080) and aspect ratio (16:9).
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. % 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
I was previously having "Error while opening codec for output stream #0.1" problems because ac3 is 5 (.1) channel while mp3 is 2 channel. Duh. However, exporting the video to HDV 1440x1080 in Quicktime Pro still causes the audio to drop/fail. More digging...
Thanks to everyone who is contributing, debugging, and optimizing. :D
dwrowley
04-19-07, 08:38 AM
Does anyone have any pre-compiled intel binaries for xport, ldecod, etc.?
Thanks,
David
Does anyone have any pre-compiled intel binaries for xport, ldecod, etc.?
Thanks,
DavidDavid,
Well, yes. Anyone who has followed the instructions has intel binaries for the programs. The big problem is that most of these programs by default use dynamic library linking, and if your libraries are in slightly different places, then you will not be able to use someone else's binaries. Eventually I may build and distribute binaries (if the various packages' licenses allow it). That also requires time that I do not have right now. I did provide my ffmpeg binary to someone to test, but they never told me if it worked or not. Very frustrating.
If you put in a little effort, you can compile the binaries yourself. Alex and I already put in the toughest work in figuring out how to get the ball rolling. And, by building the software yourself, you will better understand how to build other free software too. :cool:
dwrowley
04-24-07, 02:02 AM
An update on my AVCHD to MacOS / Quicktime conversion goal.
Well I was able to get xport compiled and running, and then ldecod (I originally tried JM 12.2 - March 13, 2007 - but got bus errors, so I backed out to 12.1 - worked fine). (Axel's and Jeffrey's documentation was great)
For ffmpeg, when compiling the x264 library, the configure script was a bit screwed up for macs - looking for yasm instead of nasm - but I just grabbed/compiled/installed yasm and all was well.
Everything else (lame, etc.) was straightforward.
I got the mkfifo version of the script running easily (I had to apply the same '-ac 2' fix to map 5.1 to stereo) - and am now happily (though SLOWLY!) transcoding AVCHD .MTS files to 20mbps mpeg4 quicktime files which import nicely into iMovieHD. This makes my new Panasonic HDC-SD3 camcorder FAR more useful to me (and the quality of the video is excellent - full 1920x1080i - and it records to 4gb+ SD cards (SDHC actually)) I now have a complete MacOS only workflow - no more having to run Nero under Windows/Parallels!
It's amazing how many people's efforts went in to this incredible open source environment - all very much appreciated.
Now if we can only improve ldecod performance :-)
Thanks again,
Cheers,
David
It's amazing how many people's efforts went in to this incredible open source environment - all very much appreciated.
I am glad things are working for you. Yes, while Axel was the instigator of this madness, and while I continued the fun, the community has helped a lot with debugging and useful advice.
dwrowley
04-24-07, 05:58 PM
That's excellent news, 0ctane!
Do you know if anyone is working on a higher-performance ldecod?
It would also be great to have AVCHD/.m2ts support in some kind of player (mplayer, vlc, etc.) - right now the best alternative I've found on the mac is to run Elecard's player under Parallels...
Looks like things are starting to come together for the AVCHD format! (I noticed Pinnacle sent out an announce for Studio 11 that supports AVCHD -- and while I don't use Pinnacle, it's good to see further support announced).
David
I don't have to pretend to be a dumb beginning user...I AM ONE. I thought I was purchasing something more than a PAPER WEIGHT to use with my MAC...so far it is the most expensive paper weight ever!
I have the HDC-SD1PP...I have a MacBook Pro fully loaded and up to date running VMware Fusion (so I can move files - images and avchd to the MAC).
I have read everything in this thread...makes me hopeful, but still lost.
Is there something I can do once I have the AVCHD files on the MAC to convert them there or do I have to try and figure out how to make what you all mention above work under Fusion?
Finally...when Premier Pro for MAC comes out and they support AVCHD...how will that work...how will I get files from the camera to the computer?
Final "finally"...I spoke with Panasonic...they said there was NO WAY to use the camera as a webcam. Any of you know otherwise?
At this point I feel like I made a real mistake buying this...but the video looks so nice in bright and dark settings :-)!
Thanks, ---bill
Do you know if anyone is working on a higher-performance ldecod?I am just a hobbiest that has a little programming experience. As far as I know, the JM group are the only ones with ldecod (of course, someone might be calling it something else). Their website has information on the AVCHD specifications, and I know they are continuing to work on improving the code.
It would also be great to have AVCHD/.m2ts support in some kind of player (mplayer, vlc, etc.) - right now the best alternative I've found on the mac is to run Elecard's player under Parallels...Not much of an alternative, especially if you have 1GB RAM or less. Yes, it would be nice to have AVCHD playback support in a Mac program. Go ahead and write it. :eek: I am looking into adding AVCHD support to ffmpeg which would save a step (but in reality it would just be bundling ldecod into ffmpeg). As I have little-to-no AV experience, this may be a delusion, and it might take a few years. Anyone feel like helping my R&D expenses?
I have the HDC-SD1PP...I have a MacBook Pro fully loaded and up to date running VMware Fusion (so I can move files - images and avchd to the MAC).Well, you do not need VMware to access the files. Just plug the USB cable to you Mac. I forget which directory the files live in (DCIM maybe?), but you can just copy them over as if the camera was an external hard drive.
Is there something I can do once I have the AVCHD files on the MAC to convert them there or do I have to try and figure out how to make what you all mention above work under Fusion?
Again, the "solution" we have devised does not require VMware or Windows. You will need to figure out how to use the "command line" on your Mac. Yes, the process is a little laborious. Eventually I hope to make a friendlier interface, so you may want to keep your paperweight a little longer.
Finally...when Premier Pro for MAC comes out and they support AVCHD...how will that work...how will I get files from the camera to the computer? Well, like I wrote above, you will probably just need to drag the files onto your computer and then edit them there. For a better answer, talk to the Premier Pro folks.
Final "finally"...I spoke with Panasonic...they said there was NO WAY to use the camera as a webcam. Any of you know otherwise? Not me.
After playing with setting for a while, I think I have come up with a better encoding scheme for OS X users. This is borrrowing on the pipe information presented earlier, and it includes an optimization for iMovieHD users.% xporthdmv -nh samplevideo.m2ts 1 1 1
% mv bits0001.mpa /tmp/samplevideo.ac3
% mkfifo pipe.yuv
% ldecod -i bits0001.mpv -o pipe.yuv &
% ffmpeg -r 29.97 -s 1440x1080 -i pipe.yuv -i /tmp/samplevideo.ac3 -acodec pcm_s16le -ac 2 -vcodec mpeg4 -aspect 16:9 -b 15000k samplevideo.avi
% rm pipe.yuv /tmp/samplevideo.ac3
We are mapping the AC3 audio into 2 channel PCM which Quicktime is happy about. Yes, the aspect ratio looks funny. You still need to "Export..." from Quicktime Pro in the Apple Intermediate Codec as HDV1080i, and you need to choose Linear PCM Stereo for the audio. The resulting film should appear just fine (16:9) when you import it into iMovieHD. It worked for me, YMMV. :)
Axel Olmos
05-01-07, 08:32 PM
For those of you having trouble with xport creating 0 byte audio files:
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.)
I updated the .tar.gz file to include this change as well as 0ctane's new readme.
dwrowley
05-09-07, 07:06 PM
My pipeline is working well with the JM 12.1 ldecod I compiled, but the performance is SLOW! Apparently 12.2 (release March 13, 2007) has some good performance improvements, but it hangs when I run it on my test files...
Anyone have any luck with using JM 12.2 (on MacOS)?
Thanks,
David
Yes, I am using JM 12.2 right now on OS X.
dwrowley
05-10-07, 04:33 PM
And no problems? Did you make any mods in the src, set special compiler options, or anything else?
Could you perhaps PM me the file? (ldecod is relatively standalone, right?)
Thanks,
David
general question...
Can I do any significant damage is I say mis-type some of the script items in the command line?
outside of the obvious dl *.*
thanks...almost ready to try the wizardry you all have created.
--bill
Raymundo
06-25-07, 08:44 AM
Hi,
I am about to buy a camcorder, and like the Panasonic SD1, howeverneed to know can i down load AVCHD onto my Mac and then edit it from there. I am not very technically savy and i have tried to follow the thread, but it looks like i am going to have trouble doing that. Please advise.
Also, for all SD1 owners, what is the quality of the video like. I read that there is still a "trailing" issue with all AVCHD type recording vs. traditional tape. Is there any thing to be said for that.
Thanks for you comments.
If you follow the instructions in Axel's download (or from my site) you can edit AVCHD content on your Mac (free version). Or, you can wait 1 week. For those of you who are not programming savvy, I will be releasing prebuilt & bundled software to do the conversion to HDV1080i (which can be edited in iMovieHD and FC, but you will have to pay a few bucks). Stay tuned.
If you follow the instructions in Axel's download (or from my site) you can edit AVCHD content on your Mac (free version). Or, you can wait 1 week. For those of you who are not programming savvy, I will be releasing prebuilt & bundled software to do the conversion to HDV1080i (which can be edited in iMovieHD and FC, but you will have to pay a few bucks). Stay tuned.
I hope it isn't out of the range of us working POOR, but either way...thanks to all here that have strived to allow the rest of us to use our cameras with a MAC! Hip, Hip Horray!
--bill
p.s. OCTANE, if you have a mailing list of those interested in your programming magic please ADD me.
graphite99
06-29-07, 04:29 AM
thanks octane for your help. yes a pre-bundled version would be GREAT to have. let us know when your package is avaliable & reliable.
ta!!!
Does anyone have any pre-compiled intel binaries for xport, ldecod, etc.?
Since this seems to be a common question (especially in e-mails), there is a new option. Voltaic (http://www.mac1080hd.com) brings the whole process together in one package. The output format is HDV1080i with the Apple Intermediate Codec. Therefore, the resulting movies are in the native format for iMovieHD and Final Cut. QuicktimePro is not necessary. Visit http://www.mac1080hd.com.
[edit]I don't have a e-mail list yet. I have a personal website (http://0ctane.net) . I am thinking of creating a developer blog, probably with a RSS feed. Unfortunately, I am not great with blogging software.
Thanks Octane and others...the software from Voltaic is WORTH it!
==bill
snostorm
07-19-07, 10:28 PM
I recently bought a Sony HD camcorder the HDR5 HDD 40Gig one. I downloaded the scripts and all dependencies and am having a audio sync issue. I am using JM12.3 ldecod Not sure if that is the problem or not I guess I could try to find 12.2 but the installer did not retrieve it. any help would be greatly appreciated I can try about any thing can program a little and know my way around linux enough to be dangerous
snostorm,
Your problem is probably a regional one. NTSC vs PAL. Set your FPS to 25 if you are in a PAL region or 29.97 if in a NTSC region.
snostorm
07-21-07, 10:01 PM
Here is my ffmpeg command I have also tried moving the -r option around but always get the same results I have also set it to 25 to match what it seems to think the video is but I bought he camcorder in the US so it should be NTSC, not sure why ffmpeg thinks the video is in PAL 25 fps
ffmpeg -r 29.97 -s 1440x1080 -i test_dec.yuv -i test.ac3 -vcodec mpeg4 -acodec copy -aspect 16:9 -b 15000k samplevideo.avi
FFmpeg version SVN-r8743, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/share/man --enable-shared --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --enable-x11grab --enable-dc1394 --enable-liba52bin --enable-libdts --enable-libfaac --enable-libfaadbin --enable-libmp3lame --enable-libogg --enable-libtheora --enable-libvorbis --enable-xvid --extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables --disable-strip
libavutil version: 49.4.0
libavcodec version: 51.40.3
libavformat version: 51.12.1
built on Apr 23 2007 23:45:21, gcc: 4.1.1 20070105 (Red Hat 4.1.1-51)
Input #0, rawvideo, from 'test_dec.yuv':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: rawvideo, yuv420p, 1440x1080, 25.00 fps(r)
Input #1, ac3, from 'test.ac3':
Duration: 00:00:44.5, start: 0.000000, bitrate: 448 kb/s
Stream #1.0: Audio: 0x0000, 48000 Hz, 5:1, 448 kb/s
Output #0, avi, to 'samplevideo.avi':
Stream #0.0: Video: mpeg4, yuv420p, 1440x1080, q=2-31, 15000 kb/s, 29.97 fps(c)
Stream #0.1: Audio: ac3, 48000 Hz, 5:1, 448 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #1.0 -> #0.1
Press [q] to stop encoding
frame= 386 fps= 14 q=4.5 Lsize= 24559kB time=12.9 bitrate=15639.7kbits/s
video:20774kB audio:704kB global headers:0kB muxing overhead 14.346512%
Received signal 2: terminating.
ethos101
07-31-07, 12:57 PM
I am somewhat of a linux noob. I've learned a lot though. Anyways, I try not to compile from source if I don't have to. In fact I think I only ever successfully did it once. I wish there was another way but anyways, here's what I'm getting when I run ./install or ./installasroot or even with ./configure.
/bin/csh: bad interpreter: Permission denied
Surely I am doing something wrong? Can someone shed some light on this for me?
I have Sony HDR-SR1 with .mts files I need to convert then edit.
Thanks in advance.
Here is my ffmpeg command I have also tried moving the -r option around but always get the same results I have also set it to 25 to match what it seems to think the video is but I bought he camcorder in the US so it should be NTSC, not sure why ffmpeg thinks the video is in PAL 25 fps
ffmpeg -r 29.97 -s 1440x1080 -i test_dec.yuv -i test.ac3 -vcodec mpeg4 -acodec copy -aspect 16:9 -b 15000k samplevideo.avi
...
Input #0, rawvideo, from 'test_dec.yuv':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: rawvideo, yuv420p, 1440x1080, 25.00 fps(r)
Input #1, ac3, from 'test.ac3':
Duration: 00:00:44.5, start: 0.000000, bitrate: 448 kb/s
Stream #1.0: Audio: 0x0000, 48000 Hz, 5:1, 448 kb/s
Output #0, avi, to 'samplevideo.avi':
Stream #0.0: Video: mpeg4, yuv420p, 1440x1080, q=2-31, 15000 kb/s, 29.97 fps(c)
The -r command stays at the front as you have posted. Did you get your camera off e-bay or something? It is possible that you did get a PAL camera, as it clearly seems to be the case. I thought I remembered reading something about a cinema mode that would do 24 or 25fps on an otherwise NTSC camera, but I could be mistaken. Offhand, I do not recall any camera options for setting the regional info, but you could check through the menus and manual.
rob_avs
09-16-07, 11:52 PM
snostorm & others:
I am having the EXACT same audio syncing issues. Using all the scripts as is I cannot get the audio to sync to the video... the longer the clip, the more out of sync it gets. I began to suspect the frame rate, and pulled out plenty of hair. I went ahead and forced the ffmpeg step to 25 fps... and the audio sync'd up!
I bought this camera for my wife 12/20/06 from a Best Buy in Kansas City. All the packaging and manuals say NTSC. What am I doing wrong here?
I do not think you are necessarily doing anything wrong. Apparently PAL encoding cameras are finding there was to NTSC regions. I would be very interested to know if there is a way to switch.
rob_avs
09-17-07, 09:55 AM
There is no doubt in my mind that I have a PAL camera. The following scripts produce clips with perfectly sync'd audio (note the 25 fps on the ffmpeg and mencoder steps):
$ cat /usr/local/bin/m2tstoavi
#!/bin/tcsh
#The scripts and instructions in this package are free to use and
#redistribute AT YOUR OWN RISK!! Standard disclaimers apply.
#NO WARRANTY!
echo using:
which xporthdmv || exit
which ldecod || exit
which ffmpeg || exit
if ( $#argv == "0" ) then
echo usage: $0 filename.m2ts ...
exit
else
set files=($*)
endif
set path = ( . $path )
echo $0 Starting.
echo " "
foreach file ($files)
if ( ! -f $file ) then
echo file $file not found
exit
endif
set outputfile=`basename $file | sed s/\.m2ts// | sed s/\.MTS//`
set tmpfile=`echo $outputfile`
set outputfile=$outputfile".avi"
echo Converting $file of $files...
if ( ! -f $tmpfile".ac3" ) then
echo xporthdmv -nh $file 1 1 1
xporthdmv -nh $file 1 1 1 && mv bits0001.mpa $tmpfile".ac3"
else
echo $tmpfile".ac3" already exists, not creating it.
endif
if ( ! -f $outputfile ) then
mkfifo pipe.yuv
echo ldecod -i bits0001.mpv -o pipe.yuv
echo ffmpeg -r 25 -s 1440x1080 -i pipe.yuv -i $tmpfile".ac3" -vcodec mpeg4 -sameq -acodec copy -aspect 16:9 -b 15000k $outputfile
ldecod -i bits0001.mpv -o pipe.yuv &
ffmpeg -r 25 -s 1440x1080 -i pipe.yuv -i $tmpfile".ac3" -vcodec mpeg4 -sameq -acodec copy -aspect 16:9 -b 15000k $outputfile && rm -f $tmpfile".ac3" $tmpfile".yuv"
rm -f bits0001.mpv
rm -f pipe.yuv
else
echo $outputfile exists, not creating it.
endif
end
rm -f ./dataDec.txt ./log.dec
echo $0 complete.
$ cat /usr/local/bin/mencoder_two_pass
#!/bin/tcsh
#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.avi ...
exit
else
set files=($*)
endif
set path = ( . $path )
echo using:
which mencoder || exit
echo $0 Starting.
echo " "
foreach file ($files)
if ( ! -f $file ) then
echo file $file not found
exit
endif
set outputfile=`basename $file | sed s/\.avi// | sed s/\.AVI//`
set outputfile=$outputfile".m2p.avi"
echo MENCODER two-pass encoder converting $file of $files -- pass 1...
mencoder $file -o $outputfile \
-fps 25 \
-vf scale=720:405 \
-oac copy \
-ovc lavc \
-lavcopts \
vcodec=mpeg4:trell:qpel:vbitrate=4000:mbd=1:vqmax=10:lmax=10 :keyint=130:vpass=1:turbo
echo MENCODER two-pass encoder converting $file of $files -- pass 2...
mencoder $file -o $outputfile \
-fps 25 \
-vf scale=720:405 \
-oac copy \
-ovc lavc \
-lavcopts \
vcodec=mpeg4:trell:qpel:vbitrate=4000:mbd=1:vqmax=10:lmax=10 :keyint=130:vpass=2
end
echo $0 complete.
rm divx2pass.log
If the scripts are adjusted to use 29.97 fps the audio in the resulting clip falls more and more out of sync as the length of the clip increases. Judging from this thread and others I have found on the web I know I am not the only one with this issue. Can it be an accident that PAL cameras are in the US in NTSC boxes? Or did Sony realize they were falling short of quantities of NTSC HDR-SR1 leading up to xmas '06? Did they make up the shortfall by boxing PAL cameras in NTSC boxes? I am more than a little disappointed.
I have a fix for the H.264 reference decoder with files from the Panasonic HDC-SD5 AVCHD camcorder. The HDC-SD5 H.264 bitstream does not contain recovery_point SEI messages, and this makes the reference decoder essentially ignore the stream.
I've added an option (-f) to ldecod to force the recovery point.
ldecod -f -i bits0001.mpv
Here's the patched source files (for JM 13.0) along with the Windows binary.
http://www.w6rz.net/ldecod_patch.zip
BTW, has anyone tried to compile xport lately? I've been trying to make it as OS independent as possible. Version 1.00 is here:
http://www.w6z.net/xport.zip
Ron
Mark Fontana
11-29-07, 03:59 AM
Thanks Ron. I haven't had any problem using the existing version of ldecod with H.264 streams from my Panasonic HDC-SD3 (which resembles the HDC-SD1 more than the SD5). I guess that means the recovery_point SEI messages were present in the streams from these earlier models...
Thanks Ron. I will take a look at these new files. As I communicated with you previously, there are a few SD5 cameras out there that have problems, but not all. Hopefully this will solve the problems.
Hi, Ron,
any plans to include this change in the official sources?
Thanks, Gordan
Hi, Ron,
any plans to include this change in the official sources?
Thanks, Gordan
I think Ron has already modified his xport. ldecod is maintained by a different individual.
The current top-of-trunk version of mencoder from SVN at mplayerhq.hu can decode raw .mts files.
That means that if you checkout and build this version of mplayer/mencoder, you can use a single commandline like the one below to do the entire decode/encode in one step. I've done several tests, and seen no A/V sync issues. Here's the command:
# mencoder $file -o ./$file.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=5000 -fps 60 -vf scale=1280:720
Yes, I'm scaling it down, and thats just for playback on my PC. I assume you could stick with 1440:1080 and still get reasonable playback speed as long as you encode as mpeg4. I haven't tried using the x264 encoder yet, but that should work as well.
Looks like it is at least getting close. I grabbed dev-SVN-r25991-4.0.1, but it is having trouble with the video stream. The resulting audio track is of the correct size, but the video track is too long. I also get "X dulicate frame(s)!" messages during the conversion.
Did you pass any additional configure options? Also, your fps should probably be 59.94 (double the NTSC 29.97).
catpunt
02-26-08, 02:21 PM
Try forcing the output FPS like so:
mencoder $file -o ./$file.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=5000 -fps 59.94 -ofps 29.97 -vf scale=1280:720
I think the "X duplicate frames" warning is because mencoder simply discards every other frame for interlaced AVCHD source files.
Has anyone gotten this to work using just ffmpeg without any other programs? I think it's just a matter of making ffmpeg (or libx264) discard every other field to achieve rudimentary "support" for this conversion.
I still get framerate issues with your modifications. Like you say, support is rudimentary. Many people have posted to the ffmpeg mailing list regarding proper handling of interlacing with AVCHD content. We just need someone to, I hate to say it, "get'er done". But, that is a discussion for the ffmpeg mailing list....
catpunt
02-26-08, 02:46 PM
Agreed.
This is the command line I used to get the conversion I wanted:
~/src/mplayer-checkout-2008-02-14/mencoder 00042.MTS -o test.mp4 -oac lavc -ovc lavc -lavcopts acodec=libfaac:vcodec=libx264:vbitrate=800 -of lavf -lavfopts format=mp4 -fps 59.94 -ofps 29.97 -vf scale=1280:720
The frame rate and audio sync of the output file seemed correct.
Louis-Marie
02-27-08, 08:00 AM
I use :
# mencoder /$video.mts -o /$video.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=5000 -fps 50 -vf scale=1280:720
It gives me a perfect audio/video sync, I just loose some frames somtimes.
(ps : sry for my bad english)
What about the date and time of creation information that is tored in MTS file. Is there a way to retrieve this info and then use ffmpeg to store it in resulting file?
What about the date and time of creation information that is tored in MTS file. Is there a way to retrieve this info and then use ffmpeg to store it in resulting file?That information is not stored in the AVCHD file.
kensystem
02-29-08, 02:15 PM
Not sure this is true - the first AVCHD camcorder (hdr-sr1) records shutter speed, gain, f-stop equiv, and AWB in the transport stream metadata. I'm not sure about datetime (if it is only implied fom the file-name) but dont see why it shouldnt be supported in the TS.
Okay, this is getting a bit off topic, but I would like to see your source that says those values are stored in the AVC stream. Framerate and aspect ratio are stored, of course. Have you spent any time looking at the transport stream? Can you find a date and time? Can you find any of those other values?
kensystem
02-29-08, 02:39 PM
The simplest way to demonstrate this is to put old m2ts files back onto the camera (using the vendor software) and turn on the camera's metadata display. As far as transport stream analyzers and what standard the vendor uses to encode this data, that depends. I havent had a licensed transport stream analyzer in my pocession for a while now, and dont know of any free ones.
kensystem
02-29-08, 03:06 PM
I found a free analyzer, and it appears there is not a separate PID for metadata, only a video and audio PID. Perhaps the data is embedded into the video, I do not know. But it is available. Googling for "data code" and mpeg transport stream variants turns up few results, interestingly.
jryoung
04-07-08, 12:21 PM
Hi there, for the first time I have a few large recordings (one maxed out at 4GB - on my 8GB SDHC card on my Panny SD1, and the other is about 3.7GB). The files are playable on the camcorder, but the xporthdmv command seems to fail to read the file. I wondered if the "fopen" c command can handle such a large file. My other files are under 2GB, and they seem fine. Is this a recognised problem? Is there a solution?
Thanks for the great work on Linux and mts!!
Jonathan
Axel Olmos
04-09-08, 03:15 PM
Are you using a 32 bit version of Linux or a 64 bit version?
Hi there, for the first time I have a few large recordings (one maxed out at 4GB - on my 8GB SDHC card on my Panny SD1, and the other is about 3.7GB). The files are playable on the camcorder, but the xporthdmv command seems to fail to read the file. I wondered if the "fopen" c command can handle such a large file. My other files are under 2GB, and they seem fine. Is this a recognized problem? Is there a solution?
Thanks for the great work on Linux and mts!!
Jonathan
I believe fopen64 is supported in Linux. Replace the four fopen function calls in xport to fopen64 and see if it compiles and links.
Ron
If anyone still cares, another way to fix the 2GB limit is to compile with the _FILE_OFFSET_BITS option. Like so:
gcc -O3 -D_FILE_OFFSET_BITS=64 xport.c -o xport
Tested on Solaris only.
Ron
Hi there.
This is a version of m2tstoavi.mencoder which supports pipelining.
$ cat m2tstoavi.mencoder.fifo
#!/bin/csh
set resolution=640x360
set resx=640
#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
set path = ( . $path )
echo using:
which xporthdmv || exit
which ldecod || exit
which ffmpeg || exit
echo $0 Starting.
echo " "
foreach file ($files)
if ( ! -f $file ) then
echo file $file not found
exit
endif
set filebase=`basename $file | sed s/\.m2ts// | sed s/\.MTS//`
#set audiofile=/tmp/$filebase".ac3"
#set videofifo=/tmp/$filebase".yuv"
set audiofile=$filebase".ac3"
set videofifo=$filebase".yuv"
set outputfile=`stat -c %y $file | cut -d \. -f 1`" @"$resolution" ("`basename $file`").avi"
if ( ! -f $audiofile ) then
echo xporthdmv -hn $file 1 1 1
xporthdmv -hn $file 1 1 1 && mv bits0001.mpa $audiofile
else
echo $audiofile already exists, not creating it.
endif
mkfifo $videofifo
echo ldecod -i bits0001.mpv -o $videofifo
ldecod -i bits0001.mpv -o $videofifo > /dev/null &
if ( ! -f "$outputfile" ) then
echo mencoder $videofifo -demuxer rawvideo -rawvideo w=1440:h=1080 -aspect 16:9 \
-vf scale -zoom -xy $resx \
-cache 8192 \
-audiofile $audiofile \
-oac copy -ovc x264 -x264encopts bitrate=5000 \
-o "$outputfile"
mencoder $videofifo -demuxer rawvideo -rawvideo w=1440:h=1080 -aspect 16:9 \
-vf scale -zoom -xy $resx \
-cache 8192 \
-audiofile $audiofile \
-oac copy -ovc x264 -x264encopts bitrate=5000 \
-o "$outputfile"
else
echo $outputfile exists, not creating it.
endif
#echo To remove temporary files: rm -f *.ac3 *.yuv
rm -f ./dataDec.txt ./log.dec bits0001.mpv $videofifo $audiofile
end
echo $0 complete.
Warning.
The script is used for PAL (Sony HDR-UX1E) camera with 25 fps (to convert-and-scale at once). :)
I have no idea is it really necessary to specify fps for NTSC... Perhaps no.
Hi. I'm having a bit of a problem using this script. It's the only method i'w tried so far that gives me a croped output.
For starters, i'm new to the whole avchd world. Actualy i'm new to everything that has anything to do with video editing, but i understand the consepts.
I bought my sony hdr-sr10e a couple of days ago and i am trying to convert the output files to something useable (since i don't have any blueray equipment.).
The problem is: when i try to run the script i get a perfect picture (and no sound in VLC) but the playback never stops. It seems like there is no end of file or something. When i try to play my avi-files in any other player on my windows computer i get no picture, the time runs wild (from 0:00 mins to 2:42 and so on). The strange thing here is that i get audio in those players. (t.d. windows media player, but i think this is because wmp is using the ffdshow ac3 codec).
I was hoping that someone have encountered this cind of problem, and that there is some cind of fix to it.
btw: The output from my camcorder is: 1920x1080, 16Mbits/s and PAL. (norway).
--
Halvard
Hi there.
This is a version of m2tstoavi.mencoder which supports pipelining.
Hi. I'm having a bit of a problem...
and i solved it. It was a codec-problem on my vista machine. the ffdshow was messing about with the ac3-audio-tracks.. no big problem. (and vlc witch is not using any 3d party codecs did not support the audio-tracks from my camcorder. )
mplayer played it without problems btw.
--
HL
Hi folks,
First thanks to everyone who has contributed to this thread, it's been of great help, however I'm now a little stuck. I don't own a HD camera but I'm thinking of getting one, I've been trying out these scripts on random .mts files that people have been uploading to the net and they've all worked great! However I've found some MTS files from the camera that I want to buy in another thread on this forum and I can't get them to work with these scripts. I know the output is in 1920 x 1080 but changing that in the script hasn't helped I still get corrupted audio or .avi files that are 0mb in size, if anyone has any suggestions I'd be really grateful. Heres a link to the files I've been trying to convert
eirikso2.com/Panasonic_HDC-SD5/Original-MTS-Streams-From-Camera/
Following Axels notes/utilities I am able to convert from my Panasonic generated AVCHD .mts file to .mpg or .avi or what ever. However the audio is out of sync. The longer the file plays the further out of sync it becomes. I assume this is directly related to the vbr video encoding. In any case how does one synchronize the audio to the video when transcoding in this fashion?
What I am actually doing is (for example):
xporthdmv -hn 1 1 1 1
ldecod -i bits0001.mpv
ffmpeg -s 1440x1080 -y -i $videofile -i $audiofile -target ntsc-vcd -r 29 -acodec mp3 -vcodec mpeg2video $outputfilempg
Is this still the best way to accomplish this? Thx.
Following Axels notes/utilities I am able to convert from my Panasonic generated AVCHD .mts file to .mpg or .avi or what ever. However the audio is out of sync. The longer the file plays the further out of sync it becomes. I assume this is directly related to the vbr video encoding. In any case how does one synchronize the audio to the video when transcoding in this fashion?
What I am actually doing is (for example):
xporthdmv -hn 1 1 1 1
ldecod -i bits0001.mpv
ffmpeg -s 1440x1080 -y -i $videofile -i $audiofile -target ntsc-vcd -r 29 -acodec mp3 -vcodec mpeg2video $outputfilempg
Is this still the best way to accomplish this? Thx.
First, put the rate in front of the size. Next, use an appropriate rate. This has been discussed previously, but to give you a hint, ntsc is not 29.000fps.
spoleweski
06-19-08, 08:19 PM
Since this seems to be a common question (especially in e-mails), there is a new option. Voltaic (http://www.mac1080hd.com) brings the whole process together in one package. The output format is HDV1080i with the Apple Intermediate Codec. Therefore, the resulting movies are in the native format for iMovieHD and Final Cut. QuicktimePro is not necessary. Visit http://www.mac1080hd.com.
[edit]I don't have a e-mail list yet. I have a personal website (http://0ctane.net) . I am thinking of creating a developer blog, probably with a RSS feed. Unfortunately, I am not great with blogging software.
This program is sweet, but $30usd? thats a bit rich, all it does is convert the files. Why such a heavy price tag??
This program is sweet, but $30usd? thats a bit rich, all it does is convert the files. Why such a heavy price tag??
I don't know. Ask them. You already paid how much for your camera?
spoleweski
06-20-08, 10:58 PM
I don't know. Ask them. You already paid how much for your camera?
1600 AUD
Exactly! And yet there are free conversion programs for pc users like Oxygen Lite 1.2. I've ended up installing bootcamp on my mac and using oxygen to convert the files instead.
debfreak
06-27-08, 12:51 AM
Hi there,
I'm a Debian/Ubuntu user and I recently purchased a Sony HDR-SR12 which records to AVCHD .mts files. I have the files on my machine's hard drive, but I am hesitant to jump into transcoding the video right away. I certainly want them out of the .mts format (because I can't play/edit them right now!) but I would like to preserve video quality by not transcoding.
Now as I understand it, AVCHD uses the H.264/MPEG-4 AVC format for video, which is my target format anyway (at least until Theora/Dirac get better), so as I see it, why should I have to transcode the video? I would like the audio in Vorbis format with the container as Matroska, so I certainly want to make steps to do that, but why do I have to transcode the video at all if My target format is MPEG-4 AVC video, Vorbis audio, and Matroska container?
Is it possible to simply demux the H.264 video and AC-3 audio from each other to get rid of .mts, then simply transcode the AC-3 to Vorbis and remux the pristine H.264 video stream with the newly encoded Vorbis stream into a Matroska container file? This is my ideal situation, and I obviously am not as wise or knowledgeable as some here are, so please tell me why this is or is not possible, and how to do it if it is.
Again, my goal is to not have to transcode the H.264 video the camera records. Once a Free/Open video format of sufficient quality emerges down the line, I plan on transcoding this camera's H.264 recordings into that (probably Dirac?), and one transcoding is enough in my opinion, so I definitely don't want to have to do it twice to reach Dirac in a few years (H.264 --> H.264 --> Dirac is worse than H.264 --> Dirac).
Hope I've been clear enough to elicite an intelligent and clear response,
thank you
Hi there,HelloNow as I understand it, AVCHD uses the H.264/MPEG-4 AVC format for video, which is my target format anyway (at least until Theora/Dirac get better), so as I see it, why should I have to transcode the video? I would like the audio in Vorbis format with the container as Matroska, so I certainly want to make steps to do that, but why do I have to transcode the video at all if My target format is MPEG-4 AVC video, Vorbis audio, and Matroska container?
Is it possible to simply demux the H.264 video and AC-3 audio from each other to get rid of .mts, this is what the xport step doesthen simply transcode the AC-3 to Vorbis and remux the pristine H.264 video stream with the newly encoded Vorbis stream into a Matroska container file? This is my ideal situationIn an ideal world, this would be fine. However, AVCHD's h264 stream is not a garden variety mpeg-4/h264. AVCHD is a bastard child created by Sony and Panasonic. Until a straight decoder is made which will play the AVCHD h264 stream, we have to transcode to a standard h264 (or other format).
Your best option is to transcode stuff now, but keep a hard copy of all the MTS/m2ts files (DVD or Hard drive backup). That is my advice.
jryoung
07-01-08, 12:37 PM
Thanks - sorry for the late reply, but that did the trick.
canonhf100
07-25-08, 02:45 AM
I've been trying to get this script to work,but so far have been unable to get ldecod. The output from the script is :-
Starting ./install script.
Starting ./download script.
Archive: xport.zip
xport.zip unzipped
Archive: jm14.1.zip
jm14.1.zip unzipped
ffmpeg
/usr/bin/ffmpeg
ffmpeg done
mplayer
/usr/bin/mplayer
mplayer done
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
a52dec-0.7.4
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... yes
checking for working aclocal... missing
checking for working autoconf... missing
checking for working automake... missing
checking for working autoheader... missing
checking for working makeinfo... missing
checking whether to enable maintainer-specific portions of Makefiles... no
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking how to run the C preprocessor... gcc -E
checking whether gcc needs -traditional... no
checking if gcc supports -g -O3 flags... yes
checking if gcc supports -g -O3 -fomit-frame-pointer flags... yes
checking if gcc supports -g -O3 -fomit-frame-pointer -mcpu=pentiumpro flags... yes
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognise dependant libraries... pass_all
checking command to parse /usr/bin/nm -B output... ok
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for ranlib... ranlib
checking for strip... strip
checking for objdir... .libs
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... no
checking if we can lock with hard links... yes
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking whether the linker (/usr/bin/ld) supports shared libraries... yes
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
creating libtool
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/timeb.h usability... yes
checking sys/timeb.h presence... yes
checking for sys/timeb.h... yes
checking io.h usability... no
checking io.h presence... no
checking for io.h... no
checking for inttypes.h... (cached) yes
checking for gcc option to accept ANSI C... none needed
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for always_inline... yes
checking for restrict... __restrict__
checking for size_t... yes
checking whether byte ordering is bigendian... no
checking for memalign... yes
checking for gettimeofday... yes
checking for ftime... yes
checking return type of signal handlers... void
checking for _oss_ioctl in -lossaudio... no
checking __attribute__ ((aligned ())) support... 64
configure: creating ./config.status
config.status: creating Makefile
config.status: creating autotools/Makefile
config.status: creating include/Makefile
config.status: creating test/Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating liba52/Makefile
config.status: creating libao/Makefile
config.status: creating vc++/Makefile
config.status: creating include/config.h
config.status: include/config.h is unchanged
config.status: executing default-1 commands
a52dec-0.7.4 done
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/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.
Playing samplevideo.avi.
File not found: 'samplevideo.avi'
Failed to open samplevideo.avi.
I thought the lack of yasm might be the problem, and tried to install it, so far without success.
macgreg
07-28-08, 04:32 PM
Hi,
I just got my sony hdr-sr12, hot off the assembly line.
I took a quick video (48 mb) just to play with for conversion.
When I run it through the m2tstoavi, I end up with a multi-pane fluctuating green video.
I have attached a screen shot.
I get this same output with either the mencoder method or ffmpeg method, so I'm suspect of either the demuxer or ldecoder.
Here are some of the details:
everything installed from the script.
$ xport
xport Transport Stream Demuxer 1.00
$ ldecod
----------------------------- JM 14.1 (FRExt) -----------------------------
Decoder config file : (null)
--------------------------------------------------------------------------
Input H.264 bitstream : test.264
Output decoded YUV : test_dec.yuv
Output status file : log.dec
Input reference file : test_rec.yuv does not exist
SNR values are not available
grammaton76
07-29-08, 01:05 AM
Macgreg, I have an SR-10 and had exactly the same problem you had. The information below is a good starting point, but it is not a conclusive fix. I've noticed that although now I don't get the green screen, I do get major macroblock issues shortly into the video and the audio and video don't seem to sync up.
Edit: I've figured out why the blocks show up. Turns out that the m2tstoavi script isn't setting a bitrate explicitly, and mencoder, by default, uses a bitrate which is ok for DVD-resolution things, but it's horrible for HD-resolution video. So, if you don't want to learn mencoder-fu, then simply add "-lavcopts vcodec=mpeg4:vbitrate=12000" into the mencoder line as mentioned below for the resolution fix. You can tack it onto the end if you want. If you intend to edit the video, then you probably should research mencoder options and translate it to a lossless format instead.
The deal is that the resolution is being assumed by m2tstoavi to be 1440x1080, and I had exactly the same screen you had.
My SR-10's files are apparently 1920x1080, because as soon as I editted the /usr/local/bin/m2tstoavi script and changed everywhere I saw:
"mencoder $videofifo -demuxer rawvideo -rawvideo w=1440:h=1080 -aspect 16:9 -ofps 29.97"
to:
"mencoder $videofifo -demuxer rawvideo -rawvideo w=1920:h=1080 -aspect 16:9 -ofps 29.97"
Suddenly my video output changed from that nasty green screen-spasm into exactly what I'd filmed.
I suspect there's a flag somewhere in the video that could be read/parsed in order to allow m2tstoavi to tell what the original resolution was, but it may not be worth the developer's time to change things.
So, all that folks like us with 1920x1080 cameras must do, is edit one line.
Given that the product literature says that the SR-10 has 2.3 effective megapixels, while the SR-11 and SR-12 have 5.6, it's possible that you may still need to adjust your resolution settings. If that's the case, I recommend going to sonystyle.com and looking at the product spec charts. Whatever item is listed as 1920x1080 (probably "effective resolution" or something) on the SR-10, would probably have a higher-res counterpart on the SR-11 or SR-12.
erlander
07-29-08, 08:24 AM
Hi,
I'm new here and joined because of this thread. I have just purchased a Sony HDR-SR11E and until I sort out AVCHD its in SD mode.
I'm also very new to ffmpeg and encoding.
I have run the script and get the following code in Ubuntu 8.04:
rob@robs:~/m2ts$ m2tstoavi sample.mts
using:
./xporthdmv
ldecod: Command not found.
What do I need to do to get ldecod?
TIA
Rob
grammaton76
07-29-08, 04:14 PM
Hi,
I'm new here and joined because of this thread. I have just purchased a Sony HDR-SR11E and until I sort out AVCHD its in SD mode.
I'm also very new to ffmpeg and encoding.
I have run the script and get the following code in Ubuntu 8.04:
rob@robs:~/m2ts$ m2tstoavi sample.mts
using:
./xporthdmv
ldecod: Command not found.
What do I need to do to get ldecod?
I was just thrashing that out last night myself... here are my notes; not really formatted since they were just for my reference, but obtaining ldecod is covered.
Grr... don't have 3 posts so I can't post URLs. Ok, so just copy the line below into your address bar to see my notes on it.
notes.cheapspeech.com/bin/view/Notes/RefHdCamcorderOnLinux
Now, if someone wants to be real nice to me, maybe they can post an example mencoder command line that'll result in a file which Cinelerra will enjoy trying to import? Right now I'm thrashing around trying to figure out lqt_transcode due to some reading at cinelerra.org/docs/wiki/doku.php?id=supported_file_formats which seems to indicate that most AVI container files (which mencoder seems to work easiest with) aren't going to smell right to cinelerra.
macgreg
07-29-08, 04:16 PM
That was the ticket.
I changed my ffmpeg line from 1440 to 1920 and it worked like a charm.
As a side note, I have been kicking myself all day about not noticing that.
What is 1440 anyway? PAL?
Macgreg, I have an SR-10 and had exactly the same problem you had. The information below is a good starting point, but it is not a conclusive fix. I've noticed that although now I don't get the green screen, I do get major macroblock issues shortly into the video and the audio and video don't seem to sync up.
Edit: I've figured out why the blocks show up. Turns out that the m2tstoavi script isn't setting a bitrate explicitly, and mencoder, by default, uses a bitrate which is ok for DVD-resolution things, but it's horrible for HD-resolution video. So, if you don't want to learn mencoder-fu, then simply add "-lavcopts vcodec=mpeg4:vbitrate=12000" into the mencoder line as mentioned below for the resolution fix. You can tack it onto the end if you want. If you intend to edit the video, then you probably should research mencoder options and translate it to a lossless format instead.
The deal is that the resolution is being assumed by m2tstoavi to be 1440x1080, and I had exactly the same screen you had.
My SR-10's files are apparently 1920x1080, because as soon as I editted the /usr/local/bin/m2tstoavi script and changed everywhere I saw:
"mencoder $videofifo -demuxer rawvideo -rawvideo w=1440:h=1080 -aspect 16:9 -ofps 29.97"
to:
"mencoder $videofifo -demuxer rawvideo -rawvideo w=1920:h=1080 -aspect 16:9 -ofps 29.97"
Suddenly my video output changed from that nasty green screen-spasm into exactly what I'd filmed.
I suspect there's a flag somewhere in the video that could be read/parsed in order to allow m2tstoavi to tell what the original resolution was, but it may not be worth the developer's time to change things.
So, all that folks like us with 1920x1080 cameras must do, is edit one line.
Given that the product literature says that the SR-10 has 2.3 effective megapixels, while the SR-11 and SR-12 have 5.6, it's possible that you may still need to adjust your resolution settings. If that's the case, I recommend going to sonystyle.com and looking at the product spec charts. Whatever item is listed as 1920x1080 (probably "effective resolution" or something) on the SR-10, would probably have a higher-res counterpart on the SR-11 or SR-12.
macgreg
07-29-08, 04:31 PM
modify the download script change:
# Download jm12.2
#
# Versions change often, so if it fails, just
# change the 12.2 below to whatever is listed at
# iphome.hhi.de/suehring/tml/download
#
set version=12.2
to:
set version=14.1
I ran the install script included in the tarball and it downloaded:
jm14.1.zip
unpacked and compiled it no errors.
Hi,
I'm new here and joined because of this thread. I have just purchased a Sony HDR-SR11E and until I sort out AVCHD its in SD mode.
I'm also very new to ffmpeg and encoding.
I have run the script and get the following code in Ubuntu 8.04:
rob@robs:~/m2ts$ m2tstoavi sample.mts
using:
./xporthdmv
ldecod: Command not found.
What do I need to do to get ldecod?
TIA
Rob
grammaton76
07-30-08, 12:37 AM
That was the ticket.
I changed my ffmpeg line from 1440 to 1920 and it worked like a charm.
As a side note, I have been kicking myself all day about not noticing that.
What is 1440 anyway? PAL?
Some cameras are just 1440 instead of 1920, or when they use 1920 it's variable bitrate instead of CBR. Two examples that came up real quick:
www.videodirect.com/Merchant2/merchant.mvc?Screen=PROD&Product_Code=XHA1
www.maximumpc.com/article/jvc_g7hd7_everio_hard_drive_camcorder
erlander
07-30-08, 06:06 AM
I'm still not having any luck. I notice problems with dependencies at step 2 of Wes Bailey's HowTo. ie "sudo apt-get install mplayer ffmpeg a52dec mencoder x264 faad faac libfaad2-0 libfaad2-dev subversion csh build-essential"
I have resolved most of them but have had to un-install programs like Cinerella and Kino.
My current plan is to do a clean install of Ubuntu and then see how I go.
I will have to do some backups of data first for safety's sake so will take a day or 2.
Rob
grammaton76
07-30-08, 07:18 AM
For what it's worth, I found that the Livna repository presents horrible conflicts under Fedora, but going with freshrpms.net versions of mplayer, etc seems to resolve the conflicts. Of course, in Ubuntu I really can't help you there.
I'm not far off from finishing my sr10tomov script (a mutilated version of m2tstoavi). At present, it's geared towards getting files into cinerella. Useful tip: mplayer can't do anything with the video from a mts file, but it can identify and play OR DUMP the audio just fine. I'm using mplayer in the modified script to copy out the audio to avoid the stereo downmixing.
At present, I've moved from mencoder to transcode (better Quicktime support), but I can't get transcode to stop mutilating my audio. I just want it to pass the 5.1 sound through, but I can't find a single way for it to agree to STOP downmixing it to 2-channel stereo. I should amend that; there's ways to get it to stop trying that, but then it insists that the import and/or export methods don't support it.
However, Cinelerra doesn't seem to mind having a separate 6-channel ac3 file and 1920x1080 Quicktime file.
Other than the annoyance of loading two files instead of one, the only major hitch left is that transcode seems to only want to get the full frame count if I tell it that the video's 120FPS. Of course, Cinelerra reads this and says, "Ok, I'm going to make your 1.7s sample video only .5s long". But if I drop the frame rate to a reasonable number, Transcode decides it's done after 13 or so frames and I'm still stuck with only .5s or so of video. So, I can have either all the frames in .5s or around a quarter of my frames in .5s, but for some reason it seems really hung up on only letting me have .5s or so of video once it reaches Cinelerra.
grammaton76
07-30-08, 10:41 AM
Attached, is the sr10tomov script. This modified version of Axel's m2tstoavi is geared towards SR-10 camcorder owners who wish to import their video files into Cinelerra for editing. Edit: I have deleted this older version of the script due to bugs - check farther down in the page for the current version of sr10tomov.
In order to use this script, you should first have Axel's package installed and working, then ensure you've also got ffmpeg installed. There could be other dependencies too, dunno.
Switching to ffmpeg addressed the weird time issue I mentioned one post ago, and also allowed me enough freedom that I was able to get the audio file into the Quicktime container. The resultant file can be loaded into Cinelerra and edited, at least under 2.1-0.14.20080214.fc9 running on Fedora Core 9 on i386.
According to http://cinelerra.org/docs/wiki/doku.php?id=supported_file_formats , the videos this script puts out should be a fairly reasonable format to edit. ffmpeg's output says:
Output #0, mov, to '00040.mts.mov':
Stream #0.0: Video: mpeg4, yuv420p, 1920x1080, q=2-31, 25000 kb/s, 25.00 tb(c)
Stream #0.1: Audio: libfaac, 48000 Hz, 5:1, 448 kb/s
According to the compatibility chart, mpeg4 audio and video in Quicktime files sync well, and are stable. Hopefully that is the case. I will say it syncs fine with my 1.7s sample video, and at present I'm busy rendering a few larger videos (a few minutes each) to see how they do.
By no means do I consider this script to be final or even 'good' yet. It's just there so other SR-10 owners can have a starting point that should at least get the data into Cinelerra in one piece.
BTW, don't run more than one copy of this script in any one directory at a time. The design of ldecod (hardcoded filenames) creates some race conditions that'd mess up batch processing. As long as the scripts are in different working directories, you should be fine.
grammaton76
07-30-08, 04:19 PM
Now that I've seen longer samples... frame rate is definitely off, audio is way off sync.
The separate AC3 file is retaining 5.1 surround sound, but the in-mov track isn't - this can probably be fixed fairly easily.
Interestingly enough, all the spec sheets I've read say that the Sony SR-10 is recording in 25FPS. However, based upon the frame-count benchmarks and run-time benchmarks (comparing audio track runtime vs video runtime), it seems that things should match evenly after tweaking ffmpeg to consider the YUV source to be in 29.97fps.
grammaton76
07-31-08, 04:01 PM
Next generation of sr10tomov attached. It seems to completely fix audio sync, however it's only including a downsampled AC3 track. It does, however, leave the original AC3 track in the directory, so you can still load it separetely into Cinelerra.
I've tested this with some short (30s) videos taken at a shooting range, and it looks like the gunshots are lining up well with what's supposed to be happening. I'm presently rendering some much longer videos, in order to see if there's a gradual loss of sync later on.
Next project is to get inlined 5.1ch audio, and after that I believe I'm done. Let the torch pass on to the next guy who discovers that Sony has made slight improvements to his camera, vs the previous model. :)
Now that I've seen longer samples... frame rate is definitely off, audio is way off sync.
The separate AC3 file is retaining 5.1 surround sound, but the in-mov track isn't - this can probably be fixed fairly easily.
Interestingly enough, all the spec sheets I've read say that the Sony SR-10 is recording in 25FPS. However, based upon the frame-count benchmarks and run-time benchmarks (comparing audio track runtime vs video runtime), it seems that things should match evenly after tweaking ffmpeg to consider the YUV source to be in 29.97fps.
We have seen this behavior before, and I think someone in this thread might have mentioned it. It seems as though (on occasion) PAL cameras are winding up in NTSC locations and vice versa. If you can upload a sample (to a personal site or sharing site), I can take a look at it if you want.
Has anybody tried this on a PS3 running linux?
grammaton76
08-20-08, 09:31 PM
We have seen this behavior before, and I think someone in this thread might have mentioned it. It seems as though (on occasion) PAL cameras are winding up in NTSC locations and vice versa. If you can upload a sample (to a personal site or sharing site), I can take a look at it if you want.
Interesting. I kind of doubt it was a wrong-territory camera, given that it was purchased at an official Sony store. But, I'll attempt to get a sample uploaded somewhere for your inspection.
grammaton76
08-20-08, 09:33 PM
Has anybody tried this on a PS3 running linux?
I'm sure it would work, assuming that ffmpeg and such are available for it. However, I don't think the codecs are particularly optimized for multi threaded operation, which is probably why using a PS3 would be so desirable.
Inquisitive Alex
09-10-08, 02:46 PM
Hello. I tried to run m2tstoavi and had the following error:
using:
/usr/local/bin/xporthdmv
ldecod: Command not found.
Where can I get ldecod?
Hi there Alex,
ldecod is part of the jm package. The newest version seems to be 14.2. If you use the original m2ts package you need to change the version in 'download' file ('set version=14.2').
I hope this helps.
sharan4o
09-20-08, 04:59 AM
hi,
i'm using m2tstoavi with ubuntu 8.04. Compiling went well and the testfile was converted successfully.
Then I tried to convert a 14GB file and the result was:
./m2tstoavi /media/sdc2/Tierra.La.Pelicula.de.Nuestro.Planeta.Blu-ray.1080p.VC-1.DD5.1-GrupoHDS/BDMV/STREAM/00004.m2ts
using:
./xporthdmv
./ldecod
/usr/bin/ffmpeg
./m2tstoavi Starting.
file /media/sdc2/Tierra.La.Pelicula.de.Nuestro.Planeta.Blu-ray.1080p.VC-1.DD5.1-GrupoHDS/BDMV/STREAM/00004.m2ts not found
any ideas?
I wrote a testscript and the result was true. Something wrong with csh?
#!/bin/bash
if [ -f $1 ]
then
echo true
else
echo false
fi
hi,
i'm using m2tstoavi with ubuntu 8.04. Compiling went well and the testfile was converted successfully.
Then I tried to convert a 14GB file and the result was:
any ideas?
I wrote a testscript and the result was true. Something wrong with csh?
Not sure, but it may be because you are trying to convert copyrighted material.
Try running each individual step to see where things are failing.
Galaxydriver
10-11-08, 07:00 AM
Hello,
I'm new here.
I've installed the files and everything works fine.
Due to a better qualitiy of my videos I want to covert my the mts-files with m2tstoavi.fifo.
The quality is much better, but the converted video is very very slow. Well it's hardly to belive it's a video-file. If I don't know it - I'd thougt it's a picture-slide-show..
Maybe I have to change the bitrate, but I don't know where I have to change it..?
Audio is ok.
BTW: I've chaged in m2tstoavi.fifo the line:
ffmpeg -r 29.97 -s 1440x1080 -vcodec mpeg4 -sameq -i $videofifo \
into:
ffmpeg -r 29.97 -s 1920x1080 -vcodec mpeg4 -sameq -i $videofifo \
Does anyone have any solution for this problem?
cu
Chris
cautionyou
10-16-08, 02:36 AM
With the superfast and high-quality m2ts converter (http://www.m2tsconverter.net) can convert M2TS files to so many other formats. What' more, this M2TS Converter has powerful editing function, you can crop, trim the video and customize video effect and merge the video into a file.
http://www.m2tsconverter.net/images/m2tsconverter.gif
grammaton76
10-22-08, 07:17 PM
With the superfast and high-quality m2ts converter (http://www.m2tsconverter.net) can convert M2TS files to so many other formats. What' more, this M2TS Converter has powerful editing function, you can crop, trim the video and customize video effect and merge the video into a file.
Unless there's a Linux version of this application which is not being advertised on the page I loaded (which was ONLY a Windows app as far as I can tell), the quoted post is irrelevant spam to this thread.
krudl3r
11-14-08, 07:55 PM
Not to encourage spamming of this thread, but if it worked under Wine I'd be willing to pay for a windows app that did the job well, as I am having problems with the script...
Hello,
...
BTW: I've chaged in m2tstoavi.fifo the line:
ffmpeg -r 29.97 -s 1440x1080 -vcodec mpeg4 -sameq -i $videofifo \
into:
ffmpeg -r 29.97 -s 1920x1080 -vcodec mpeg4 -sameq -i $videofifo \
Does anyone have any solution for this problem?
The resolution entirely depends on how you originally captured the video. The first generation cameras that Axel and I have were only able to capture at 1440x1080. Current generation cameras cam capture at both 1920 and 1440, so you need to adjust the "-s" flag accordingly.
With the superfast and high-quality m2ts converter (http://www.m2tsconverter.net) can convert M2TS files to so many other formats. What' more, this M2TS Converter has powerful editing function, you can crop, trim the video and customize video effect and merge the video into a file.
I agree with grammaton76. This looks a little suspect.
BruceeL
11-17-08, 08:12 AM
good, I got this
massi888
11-19-08, 04:54 PM
Hello. I tried to run m2tstoavi and had the following error:
using:
/usr/local/bin/xporthdmv
ldecod: Command not found.
Where can I get ldecod?
Hi there Alex,
ldecod is part of the jm package. The newest version seems to be 14.2. If you use the original m2ts package you need to change the version in 'download' file ('set version=14.2').
I hope this helps.
this help very well! Now m2toavi is working on my hardy ubuntu linux system!
Thanks a lot!
vBulletin® v3.7.4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.