[MEncoder-users] Re: forcing encode of lost frames as duplicates

Josh Sutton josh.sutton at cohdawireless.com
Wed Aug 9 02:55:26 CEST 2006

Corey Hickey <bugfood-ml <at> fatooh.org> writes:

> > I'm trying to produce a video from a video server stream running 
> > across a lossy wireless link.  The problem is that time needs to 
> > be preserved even if frames are lost.  ie if I'm receiving nominally 
> > 30 fps and say 20 frames are lost, then the remaining 10 frames should
> >  be duplicated such that they still occupy 1 second. 
> >  
> > The duplicate frames work fine using mplayer and displaying on the screen.
> > If I start mplayer displaying on the screen and disconnect the ethernet to 
> > simulate frame losses, then mplayer holds the last frame.  However when I
> > use mencoder to either copy or reencode the stream to disk, the missing
> > frames are skipped (not inserted), and the playback shows time 
> > discontinuities.
> > 
> > I've also tried using mplayer with the -vo jpeg option.  But skipped frames
> > are not encoded.
> > 
> > the mencoder.exe harddup switch does not work.
> You mean '-vf harddup', right?

Yep.  Reading between the lines, I don't think this is what the harddup is
actually meant for, so it's not totally suprising that it doesn't do what 
I want it to do.

What I'm looking for is a tool that will blindly write new frames to disk even
if they weren't received.  So that frame rate and hence playback time is
preserved.   Perhaps there is a better way to achieve this than using these
tools, but so far I have not found it.

> > I suspect because the frames are
> > missing, not duplicates.
> What exactly is the video data you're feeding mencoder? Is it an MPEG,
> or a series of JPEGs, or what?

The input stream is an mpeg stream from an rtsp session.  The mencoder command
line and output is below.  If frames are not received, then the transmit time
stamp on the encoded video jumps from say 11 seconds to 13 seconds.  What I want
is for the the encoded video to hold the frame received at 11 seconds for a full
2 seconds and then move on to the frames received at 13 seconds.

$ mencoder rtsp:// -o op.avi -vf harddup -ovc
lavc  -noskip -noaspect
MEncoder 1.0pre8-3.4.2 (C) 2000-2006 MPlayer Team
CPU:               Intel(R) Pentium(R) 4 CPU 3.20GHz (Family: 15, Model: 3,
Stepping: 4)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 0
Compiled with runtime CPU detection.
Connecting to server[]: 554...
rtsp_session: Not a Real server. Server type is 'unknown'.
STREAM_LIVE555, URL: rtsp://
success: format: 21  data: 0x0 - 0x0
Stream not seekable!
Initiated "video/MP4V-ES" RTP subsession on port 4154
demux_rtp: Guessed the video frame rate as 30 frames-per-second.
        (If this is wrong, use the "-fps <frame-rate>" option instead.)
VIDEO:  [mp4v]  0x0  0bpp  30.000 fps    0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:21  fourcc:0x7634706D  size:0x0  fps:30.00  ftime:=0.0000
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [harddup]
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
[mpeg4 @ 00997678]header damaged
Error while decoding frame!
VDec: vo config request - 352 x 240 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
videocodec: libavcodec (352x240 fourcc=34504d46 [FMP4])
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp
Pos:  13.7s    412f ( 0%) 32.67fps Trem:   0min   0mb  A-V:0.000 [892:0]]
Flushing video frames
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp

Video stream:  892.628 kbit/s  (111578 B/s)  size: 1528626 bytes  13.700 secs 
412 frames

More information about the MEncoder-users mailing list