Fast interlaced AVCHD (PAL) conversion with Mencoder-SVN

Thanks to a Urkki, I've found out that mencoder-SVN nowadays supports AVCHD transcoding pretty well now. So I'll publish my current (quite easy) script for converting AVCHD into 720p Mpeg4.

First get a current svn version of mplayer and compile and install it:
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd mplayer
CFLAGS= ./configure && make && sudo make install

Then you can use this command:
mencoder 00001.MTS -o 1.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=10000:threads=2:ilme:ildct -lavdopts threads=2 -vf scale=1280:720:1 -fps 50

Notes
- I need fps 50 because mplayer doesn't yet detect the fps automatically in my files.
- I've used two threads to speed things up on multi-core systems: threads= should be the number of cores your cpu has.
- I have interlaced content and preserve the interlacing: scale=...:1, ilme:ildct.

6 comments:

  1. I haven't been able to make this work. I keep getting messages like the following:

    Pos: 6.0s 199f ( 0%) 25.40fps Trem: 72min 1261mb A-V:0.027 [2766:384]
    1 duplicate frame(s)!
    Pos: 6.1s 203f ( 0%) 25.47fps Trem: 68min 1214mb A-V:0.007 [2784:384]
    1 duplicate frame(s)!

    I tried different fps settings, but I don't know the correct setting. Not in the user manual for my camera - Panasonic HDC-SD1PP. I made the recording on HE compression setting. Also, I believe the scale is 1920x1024, so I modified the command to use "scale=1920:1024:1". Same result. Any ideas? Thanks very much.

    ReplyDelete
  2. Hey, I don't see the problem. I also get those messages while transcoding but the result seems to be fine! What svn release are you using?

    Cheers

    ReplyDelete
  3. What frame rates have you tried? It might be that you need 59.94.

    ReplyDelete
  4. And you can try forcing the duplicate frames to be encoded with -vf harddup. (If you want the full resolution just leave away the scale filter!)

    ReplyDelete
  5. Hey, thanks for the responses. I ran this to completion overnight (the source is 2.5GB or so) and it partially worked, but not completely. First, the sound is not synchronized with the video. Second, the video quality looks great for about 1 minute 50 seconds, then it breaks down and just basically displays junk on the screen. Third, the aspect ratio looks wrong -- it looks narrower than it should.

    Also, after some time, the output started including the following errors:

    1 duplicate frame(s)!
    Pos:3871.8s 232195f (100%) 15.07fps Trem: 0min 4795mb A-V:0.016 [10000:384]
    1 duplicate frame(s)!
    Last message repeated 8 timesps Trem: 0min 4795mb A-V:0.016 [10000:384]
    [h264 @ 0x8c672e0]illegal short term buffer state detected

    1 duplicate frame(s)!
    [h264 @ 0x8c672e0]Missing reference picture 0min 4795mb A-V:0.014 [10000:384]
    [h264 @ 0x8c672e0]illegal short term buffer state detected
    [h264 @ 0x8c672e0]Missing reference picture 0min 4795mb A-V:0.014 [10000:384]

    Here's the command I used:

    mencoder 00000.MTS -o 1.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=10000:threads=2:ilme:ildct -lavdopts threads=1 -vf harddup -fps 59.94

    Where in the world did you come up with 59.94 fps?

    This all seems way too hard. I really don't want to become an expert on video formats and conversions. I just want to be able to view my file :-(

    Thank you again for your help. I'll be happy to try more experiments if you wish to offer some more advice.

    ReplyDelete
  6. Try the new better script I've published here: http://linux-tipps.blogspot.com/2010/01/transcoding-50-fps-interlaced-avchd-to.html

    Also try adding -demuxer lavf with a recent mencoder version.

    ReplyDelete

I appreciate comments. Feel free to write anything you wish. Selected comments and questions will be published.