[MPlayer-users] How do you play raw h.264 files in mplayer?

David wizzardx at gmail.com
Fri Aug 12 13:32:10 CEST 2011


I've been working with this a bit more, and I have a follow-up question/problem:

Why does mplayer take so long to start playing a h.264 stream that's
passed to it on stdin or over a named pipe?

Here's my scenario:

I have a script, "test.py", which prints out raw h.264 data (from a
DVR) to stdout.

If I pipe that into mplayer like this:

 ./test.py | mplayer - -fps 25

Then it spends about 10 seconds doing this:

-----------
Playing -.
Reading from stdin...
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
-----------

Before finally printing this:

--------
H264-ES file format detected.
Load subtitles in ./
open: No such file or directory
[MGA] Couldn't open: /dev/mga_vid
open: No such file or directory
[MGA] Couldn't open: /dev/mga_vid
[VO_TDFXFB] Can't open /dev/fb0: No such file or directory.
s3fb: can't open /dev/fb0: No such file or directory
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
Audio: no sound
FPS forced to be 25.000  (ftime: 0.040).
Starting playback...
------

At which point the video playback finally starts up.

And a lot of the time, the video playback doesn't start at all, and I
just get a bunch of those "cannot seek" and "seek failure" messages
endlessly.

However, if I pipe that input into a file in one terminal, and then
play that file in another terminal, then the mplayer playback starts
immediately, without that long pause.

So it looks like mplayer may have some bugs with playing raw h.264
from stdin. Or are there some options I can use to help?

I'd prefer to use stdin, so that I can play endlessly without needing
to have a constantly-growing file on the harddrive.

And I have another small issue: When I write to a file, and play it
from mplayer, then if mplayer's fps is too high, then it reaches the
end of the file and stops playing. But if the fps is too low, then
mplayer starts lagging behind (the displayed security footage is no
longer current, and instead reflects a few minutes ago, and so on).

I'm going to try to get the exact FPS of the output video on the DVR
device, so that I can sync mplayer's fps with that, and hopefully not
have either problem.

Is there some way to make mplayer pause and wait for more data when it
reaches the end of a file? Or perhaps some way that I can make
mplayer's fps go slightly higher than the video, and then have
mplayer's fps slow down slightly (to avoid jerky stops and starts - I
see that with stdin/pipes when I set the fps to high), when it nears
the end of the file?

Thanks again,

David.


More information about the MPlayer-users mailing list