LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-18-2007, 05:13 PM   #1
stringZ
Member
 
Registered: Dec 2006
Posts: 42

Rep: Reputation: 15
mencoder skips frames when dealing with MPEG2 audio streams


Dear forumers!

Nowadays, due to my job I've got to transcode video a lot, mostly from PAL MPEG-2 to XviD. I use mencoder, because this is the fastest and most efficient solution, but there's a little problem which always gives me hard time when transcoding. Basically PAL DVD compliant MPEG-2 streams are encoded with audio codec mp2 (MPEG 1 - Layer 2), this is the standard, but mencoder cannot handle it without glitches, it skips 5-6 frames at the beginning and this causes the whole audio stream of the conversion will have positive or negative latency and this causes a/v desync. It can be fixed guessing the delay caused by the frameskips and using the -audio-delay option, but it takes a lot of time, especially when it comes to transcode a 2-3 hour footage.

Basically I convert interlaced PAL MPEG-2 streams (25fps) into progressive xvid (50fps) avi using the tfields filter.

Like this.

Code:
mencoder -oac mp3lame -lameopts mode=1:cbr:aq=1:br=192 -ovc xvid -xvidencopts \
bitrate=740:par=pal43:qpel -vop scale=480:360,tfields -fps 50 some.mpg -o some.avi
And the console log:

Code:
1 duplicate frame(s)!
Pos:   0.8s     22f ( 0%) 12.92fps Trem:   3min  16mb  A-V:0.042 [0:192]
Skipping frame!
Pos:   1.1s     32f ( 1%) 13.47fps Trem:   3min  15mb  A-V:0.042 [875:191]
Skipping frame!
Pos:   1.5s     43f ( 1%) 13.17fps Trem:   4min  17mb  A-V:0.041 [905:191]
Skipping frame!
Pos:   2.1s     58f ( 1%) 13.16fps Trem:   4min  17mb  A-V:0.041 [837:191]
Skipping frame!
Pos:   3.1s     85f ( 2%) 12.86fps Trem:   5min  18mb  A-V:0.040 [828:191]
Skipping frame!
Pos:   4.2s    112f ( 2%) 12.96fps Trem:   5min  19mb  A-V:0.016 [781:192]
This point it stops skipping frames and continues encoding without any problem, but these skipped frames curse the whole video.

Funny if I do the transcoding with the -nosound option, it won't skip any frames, so the video part is handled correctly.
Moreover, if I encode only the audio stream using the -ovc frameno method it does skip frames, so the problem is with reading the first few audio frames. The skip problem is there even if I simply copy the audio stream (-oac copy)!

I tried not converting to 50fps, only applying a deinterlace filter (pp=lb) and keeping it at 25fps. Then it skips half as much frames (2-3), implicitly. This can't be felt so much in the audio-delay, so I don't really have to waste my time with mencoder -oac copy -ovc copy -audio-delay <something>, but 50fps is very important for some footages of mine.

I tried those alternative audio decoders which mplayer includes and can decode mp2 (-ac ffmp2, -ac mp3), none of them worked correctly.

Under no circumstances want I leave mencoder and use another program to transcode,
and this problem ought to be solved, but I've run out of ideas, this is why I'm asking for your help.

Any ideas?
Thanks a lot, I appreciate it

Last edited by stringZ; 05-18-2007 at 05:16 PM.
 
Old 05-18-2007, 05:52 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

Try the '-noskip' flag.

Dave
 
Old 05-19-2007, 05:49 AM   #3
stringZ
Member
 
Registered: Dec 2006
Posts: 42

Original Poster
Rep: Reputation: 15
Tried both -noskip and -skiplimit 0, none of them worked well. Also tried variating the parameters with different mencoder versions: 1.0rc1 (the latest), 1.0pre8, 1.0pre7, cvs-20050928. The result was always the same. I don't think there's problem with the footages, because other programs (like VirtualDub under Windows) works correctly, but it's slower and can't be automatized as easily as mencoder.
 
Old 05-20-2007, 04:57 AM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
The only other thing I can suggest is to play with the -mc option.

Failing that, you might get more joy on the mplayer mailing lists.

Dave
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get number of frames or time from a vob (dvd-mpeg2 video) schneidz Programming 3 03-23-2007 03:40 AM
encoding picture frames using mencoder ellensn Linux - Software 2 05-31-2006 01:46 PM
mencoder to make mpeg2 files DJOtaku Linux - General 2 09-17-2005 09:01 AM
mencoder/mplayer and splitting both audio and video streams from source... bai_design Linux - Software 0 02-06-2005 04:52 PM
VHS to MPEG2(DVD) with transcode or mencoder? jovir Linux - Software 4 01-12-2005 02:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration