LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Problems with mencoder (https://www.linuxquestions.org/questions/linux-server-73/problems-with-mencoder-623271/)

brokenpromises 02-23-2008 06:15 AM

Problems with mencoder
 
I'm using a script (hwdVideoShare - an addon for joomla. I've also tried clipshare out, and had the same problem as described below) and .avis etc transcode to flv just fine, but I've found there are certain 'problem formats' (wmvs and mp4s - there might be more but I haven't had time to test). These refuse to transcocde properly. Frames get dropped, resulting in audio/video sync errors etc. Here is the command hwdVideoShare it supposed to run:

Code:

$cmd_mencoder = "$mencoderpath $path_original -o $path_new -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -vf scale=450:400 -srate 22050";
But that errors out like so:

Code:

$ mencoder test.wmv -o test.flv -of lavf -oac mp3lame -lameopts abr:br=56
 vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -vf scale=450:400 -srate 22050
MEncoder 1.0rc2-4.1.2 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 Quad CPU          @ 2.40GHz (Family: 6, Model: 15, Stepping: 7)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2

Option lavfopts: Unknown suboption i_certify_that_my_video_stream_does_not_use_b_frames
Error parsing option on the command line: -lavfopts

Exiting... (error parsing command line)

So to fix, I have to remove

Code:

-lavfopts i_certify_that_my_video_stream_does_not_use_b_frames
from the conversion command. That leaves me with this:

Code:

mencoder test.wmv -o test.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=450:400 -srate 22050
I ran this command in order to convert the test file and to write the output into a file:

Code:

mencoder test.wmv -o test.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=450:400 -srate 22050 > output
Here is what is in 'output' after the conversion is complete:

Code:

MEncoder 1.0rc2-4.1.2 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 Quad CPU          @ 2.40GHz (Family: 6, Model: 15, Stepping: 7)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2

success: format: 0  data: 0x0 - 0xd836e
ASF file format detected.
[asfheader] Audio stream found, -aid 1
[asfheader] Video stream found, -vid 2
VIDEO:  [WMV3]  640x480  24bpp  1000.000 fps  768.0 kbps (93.7 kbyte/s)
[V] filefmt:6  fourcc:0x33564D57  size:640x480  fps:1000.00  ftime:=0.0010
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, s16le, 96.0 kbit/6.81% (ratio: 12005->176400)
Selected audio codec: [ffwmav2] afm: ffmpeg (DivX audio v2 (FFmpeg))
==========================================================================
OK, exit
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [scale w=450 h=400]
==========================================================================
Opening video decoder: [dmo] DMO video codecs
Creating new registry
Failed to open registry file '/var/www/.mplayer/registry' for writing.
DMO dll supports VO Optimizations 0 1
DMO dll might use previous sample when requested
Failed to open registry file '/var/www/.mplayer/registry' for writing.
Failed to open registry file '/var/www/.mplayer/registry' for writing.
Failed to open registry file '/var/www/.mplayer/registry' for writing.
GetOutput r=0x0  size:921600  align:1
StreamCount r=0x0  1  1
Decoder supports the following formats: YV12 YUY2 UYVY YVYU RGB8 RGB555 RGB565 RGB24 RGB32
Decoder is capable of YUV output (flags 0x1b)
VDec: vo config request - 640 x 480 (preferred colorspace: Packed YUY2)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
videocodec: libavcodec (450x400 fourcc=31564c46 [FLV1])
[VE_LAVC] High quality encoding selected (non-realtime)!
Selected video codec: [wmv9dmo] vfm: dmo (Windows Media Video 9 DMO)
==========================================================================
MP3 audio selected.
VIDEO CODEC ID: 22
AUDIO CODEC ID: 15001, TAG: 0
Writing header...

I'm also getting a lot of

Code:

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

65 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

65 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

32 duplicate frame(s)!

32 duplicate frame(s)!

34 duplicate frame(s)!

32 duplicate frame(s)!

32 duplicate frame(s)!

33 duplicate frame(s)!

36 duplicate frame(s)!

31 duplicate frame(s)!

31 duplicate frame(s)!

66 duplicate frame(s)!

34 duplicate frame(s)!

39 duplicate frame(s)!

36 duplicate frame(s)!

35 duplicate frame(s)!

36 duplicate frame(s)!

36 duplicate frame(s)!

35 duplicate frame(s)!

36 duplicate frame(s)!

36 duplicate frame(s)!

35 duplicate frame(s)!

36 duplicate frame(s)!

34 duplicate frame(s)!

35 duplicate frame(s)!

35 duplicate frame(s)!

35 duplicate frame(s)!

skipped frame errors. So many in fact, that i can't even scroll back up far enough.

Note the skipped frames. This causes huge issues with audio/video sync.

HOW TO FIX THESE SKIPPED FRAMES! I suspect getting "i_certify_that_my_video_stream_does_not_use_b_frames" is the key, but so far I've been unsuccessful. I'm pulling my hair out and have been for some time.

ANY help appreciated. I'm desperate.

ComputerGreek 02-23-2008 03:57 PM

Try explicitly stating the out frame rate -ofps and see what happens.

dive 02-23-2008 05:17 PM

Shouldn't it be -lavcopts? May just be a typo.

brokenpromises 02-23-2008 08:48 PM

I have somewhat fixed the problem, after finding out that downgrading to "MPlayer 1.0rc1-4.1.2" is a fix for this, after some EXTENSIVE googling.

I use this command now:

Code:

mencoder test.wmv -o test.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=800:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -vf scale=450:400 -srate 22050
and it produces the following output:

Code:

MEncoder 1.0rc1-4.1.2 (C) 2000-2006 MPlayer Team
CPU: Intel(R) Core(TM)2 Quad CPU          @ 2.40GHz (Family: 6, Model: 15, Stepping: 7)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2

success: format: 0  data: 0x0 - 0xd836e
ASF file format detected.
VIDEO:  [WMV3]  640x480  24bpp  30.000 fps    0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:6  fourcc:0x33564D57  size:640x480  fps:30.00  ftime:=0.0333
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, s16le, 96.0 kbit/6.81% (ratio: 12005->176400)
Selected audio codec: [ffwmav2] afm: ffmpeg (DivX audio v2 (FFmpeg))
==========================================================================
** MUXER_LAVF *****************************************************************
You have certified that your video stream does not contain B frames.
REMEMBER: MEncoder's libavformat muxing is presently broken and will generate
INCORRECT files in the presence of B frames. Moreover, due to bugs MPlayer
will play these INCORRECT files as if nothing were wrong!
*******************************************************************************
OK, exit
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [scale w=450 h=400]
==========================================================================
Opening video decoder: [dmo] DMO video codecs
DMO dll supports VO Optimizations 0 1
DMO dll might use previous sample when requested
GetOutput r=0x0  size:921600  align:1
StreamCount r=0x0  1  1
Decoder supports the following formats: YV12 YUY2 UYVY YVYU RGB8 RGB555 RGB565 RGB24 RGB32
Decoder is capable of YUV output (flags 0x1b)
VDec: vo config request - 640 x 480 (preferred colorspace: Packed YUY2)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
SwScaler: reducing / aligning filtersize 7 -> 8
SwScaler: reducing / aligning filtersize 7 -> 8
SwScaler: reducing / aligning filtersize 6 -> 5
SwScaler: reducing / aligning filtersize 6 -> 5

SwScaler: BICUBIC scaler, from yuv420p to yuv420p using MMX2
SwScaler: using 8-tap MMX scaler for horizontal luminance scaling
SwScaler: using 8-tap MMX scaler for horizontal chrominance scaling
SwScaler: using n-tap MMX scaler for vertical scaling (YV12 like)
SwScaler: 640x480 -> 450x400
videocodec: libavcodec (450x400 fourcc=766c66 [flv])
[VE_LAVC] High quality encoding selected (non-realtime)!
Selected video codec: [wmv9dmo] vfm: dmo (Windows Media Video 9 DMO)
==========================================================================
MP3 audio selected.
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
VIDEO CODEC ID: 0
AUDIO CODEC ID: 15001, TAG: 0
Writing header...
Pos:  0.7s    22f (25%)  0.00fps Trem:  0min  0mb  A-V:0.070 [0:45]
Skipping frame!
Pos:  1.1s    34f (32%) 28.48fps Trem:  0min  0mb  A-V:0.069 [1298:46]
Skipping frame!
Pos:  1.9s    58f (44%) 34.52fps Trem:  0min  0mb  A-V:0.067 [1328:47]
Skipping frame!
Pos:  2.3s    73f (53%) 36.92fps Trem:  0min  0mb  A-V:0.006 [1358:47]]
1 duplicate frame(s)!
Pos:  4.2s    129f (77%) 43.63fps Trem:  0min  0mb  A-V:0.012 [1231:47]]
1 duplicate frame(s)!
Pos:  5.0s    152f (88%) 43.08fps Trem:  0min  0mb  A-V:0.019 [1151:47]
1 duplicate frame(s)!
Pos:  5.6s    169f (97%) 42.13fps Trem:  0min  0mb  A-V:0.023 [1118:47]
1 duplicate frame(s)!
Pos:  6.2s    184f (100%) 41.12fps Trem:  0min  0mb  A-V:-0.024 [1079:47]
1 duplicate frame(s)!
Pos:  6.2s    185f (100%) 40.96fps Trem:  0min  0mb  A-V:-0.026 [1083:47]
Flushing video frames
Writing index...
SEEK 4
SEEK 52
SEEK 174
SEEK 887461

Video stream: 1083.010 kbit/s  (135376 B/s)  size: 843845 bytes  6.233 secs  185 frames

Audio stream:  47.674 kbit/s  (5959 B/s)  size: 36738 bytes  6.165 secs

Still a few 'flushed' frames, there's still some audio/video sync issue, but its nowhere near as bad as it used to be.

I'm guessing there is no 100% fix to this?

Also - If I hard-wire -ofps 24 into the script, what happens when it comes across a video that isn't 24 fps? Which is more than likely seeing users are going to be uploading their own videos.

ComputerGreek 02-23-2008 10:40 PM

Quote:

Originally Posted by brokenpromises (Post 3067762)
Also - If I hard-wire -ofps 24 into the script, what happens when it comes across a video that isn't 24 fps? Which is more than likely seeing users are going to be uploading their own videos.

Your script can grab the framerate from the video header.

Your file looks a bit weird:

MEncoder 1.0rc2-4.1.2 (C) 2000-2007 MPlayer Team
VIDEO: [WMV3] 640x480 24bpp 1000.000 fps 768.0 kbps (93.7 kbyte/s)

MEncoder 1.0rc1-4.1.2 (C) 2000-2006 MPlayer Team
VIDEO: [WMV3] 640x480 24bpp 30.000 fps 0.0 kbps ( 0.0 kbyte/s)

0.0 kbps?

brokenpromises 02-23-2008 11:39 PM

Oh I see, reason it look weird is because I was trying out different builds at the time. Initially I had no success, but "MEncoder 1.0rc1-4.1.2 (C) 2000-2006 MPlayer Team" (an older build) works as it takes the

Code:

-lavfopts i_certify_that_my_video_stream_does_not_use_b_frames
arguments without erroring out.

How can I get the frame rate from the header? I have very little scripting experience :(


All times are GMT -5. The time now is 06:34 AM.