Log in

View Full Version : DVR-MS -> MPEG4 with mencoder


brumster
25th January 2008, 15:56
First, a bit of background.

I used to be a myth user but the ongoing maintenance of myth got too much, so I moved (reluctantly, at the time) to an MCE frontend. However my main server remains linux (FC6) and holds all the MP3/video collections, and other files, on a large RAID5 array.

Every now and then I archive DVR-MS files off the frontend and onto the server, where they sit in a batch processing folder awaiting an automated (cron) job that churns through and transcodes the MPEG2 (DVB-T) programmes down into something that'll take up a little less space. This clears up recording space on the front end.

My problem is I'm consistently getting audio/video sync issues, which is not uncommon with DVB broadcast with dropped frames I believe. I have tried all the usual parameters into mencoder and ffmpeg, but to no avail, and I never had issues with them in the past. I have favoured mencoder because of it's performance, but for the record here are some example of what I've tried.

For mencoder :-

mencoder input.dvr-ms -mc 0 -noskip -oac mp3lame -ovc lavc -ofps 25 -vf harddup -lavcopts vcodec=mpeg4:turbo:trell:keyint=100:mbd=2:vpass=1:autoaspect:vbitrate=2000 -ffourcc XVID -o /dev/null
mencoder input.dvr-ms -mc 0 -noskip -oac mp3lame -ovc lavc -ofps 25 -vf harddup -lavcopts vcodec=mpeg4:trell:keyint=100:mbd=2:vpass=2:autoaspect:vbitrate=2000 -ffourcc XVID -o output.avi


The forced 25fps option has been necessary on some of the input files which have detected a frame rate of 1000fps (what gives with that?), and hence hit a problem with insufficient bitrate.

For ffmpeg :-

ffmpeg -i input.dvr-ms -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -b 2000000 -g 300 -vcodec xvid -acodec mp3 -ab 96 output.avi

The ffmpeg is only single pass because it's soooo much slower than mencoder.

Both of these hit the old A/V synch issues on various recordings. Can anyone shed any light on what I'm missing? I'm looking for a linux-based solution here so any options based around processing on the windoze box aren't ideal. Any advice much appreciated ;)

nm
26th January 2008, 10:57
So, have you tried allowing MEncoder to skip frames (remove -noskip, try -mc 1 and -mc 10). Also specify -fps 25 along with your -ofps 25 to properly work around cases where MEncoder doesn't recognize the correct average framerate.

I don't really know DVR-MS container, but the 1000 fps issue implies a variable framerate and that could be one of the reasons for sync problems.

brumster
28th January 2008, 10:18
I'll give it a go - kicked off a run now, so bear with me ;)

EDIT: 1st run, removing the -noskip but keeping -mc 0 and adding the -fps 25, still didn't quite fix it but it seemed better - ie. not out of sync by so much. I'm running again now with the -mc 1 parameter instead of 0.

brumster
28th January 2008, 17:01
Bingo - that did it - removed the -noskip, added the -fps 25 and added -mc 1. Many thanks, nm. So to summarise :-

mencoder Misery_Five_06_08_2007_23_00_02.dvr-ms -mc 1 -oac mp3lame -ovc lavc -ofps 25 -fps 25 -vf harddup -lavcopts vcodec=mpeg4:turbo:trell:keyint=100:mbd=2:vpass=1:autoaspect:vbitrate=2000 -ffourcc XVID -o /dev/null
mencoder Misery_Five_06_08_2007_23_00_02.dvr-ms -mc 1 -oac mp3lame -ovc lavc -ofps 25 -fps 25 -vf harddup -lavcopts vcodec=mpeg4:trell:keyint=100:mbd=2:vpass=2:autoaspect:vbitrate=2000 -ffourcc XVID -o Misery.avi

So what exactly does -mc 0 versus -mc 1 mean (I like to understand why it's fixed it!) ?

EDIT : Scratch that, found it in the man pages but it was hiding up in the mplayer section. So I've basically allowed it to do a maximum of 1 seconds worth of A/V synch correction per video frame, whereas before I wasn't allowing it to do any (-mc 0). I understand now.