[MPlayer-users] How to start playing files why they are still being recorded? How to stream?

Christian Jaeger chrjae at gmail.com
Fri Feb 28 21:35:32 CET 2014


Due to not finding a single GUI program that worked with a USB video
grabbing device, and the fact that mencoder worked, I've written a new
GUI program[1] to use mencoder and mplayer (and arecord, aplay, oggenc
and ogg123) to make this usable for a 'normal' user. This worked
pretty perfectly on my Debian stable machine, but failed on that other
person's Ubuntu installation.

[1] https://github.com/pflanze/recordvideo

The approach:
 -  mencoder records from v4l to a file; I give it "-noaudio" since I
couldn't figure out how to make it record video properly while also
recording audio, so I'm recording audio separately using arecord and
oggenc, and then we use OpenShot later on to merge the two streams
 -  3 (or so) seconds later, mplayer plays back from the file, with a
"-wid" option that makes it play into a widget of the Gtk application.
This is the part that fails on Ubuntu.

I've tried the equivalents of the following:

# (A) does work fine on Debian, but on Ubuntu, stops playing back
after 3 seconds,
# since it seems to be snapshotting the length of the file when
starting to play and
# then stop playing even if the file has grown by the time it reaches the end:
mencoder $opts -o file - & sleep 3; mplayer -wid xyz file

# (B) using pipes, does not work (on Debian) unless sleep is very big,
and then also only
# 'works' by first showing tons of blocky garbage until it finally
starts showing real video:
mencoder $opts -o - - | cat > file & sleep 3; tail -f -c 20000000 file
| mplayer -wid xyz -

and variations inbetween.

(1) Is there a way to tell mplayer on Ubuntu to continue playing a
file even if it reaches the time that it read from the file when
(2) Is there a way to record video to a pipe and still have it
playable by mplayer (i.e. as a stream of officially indetermined

I would consider other players instead of mplayer but it is pretty
essential to make the output appear as part of my app's GUI, and
mplayer is the only program that I found that allows me to specify an
X windows id (using -wid).

Perhaps I should just take the source code of the version that works
on Debian and recompile it with different paths on Ubuntu to install
it there in an alternative location; but considering the number of
dependencies involved I fear that this will be rather time consuming,
also, I'm sure it much lowers the worth of my program to other people.

If I can make it work with mencoder and mplayer at all, I'd like to
know if I can make mencoder record the audio at the same time, too
(when I tried that it did make the video go totally out of sync with
the audio, while showing frame loss messages or some such, and choppy
video IIRC.) My current options are:

mencoder -quiet tv:// -tv driver=v4l2:device="$VIDEODEV" -ovc lavc=yes
-lavcopts vcodec=mpeg4 -nosound -o - -

mplayer on our Ubuntu station is: Version: 2.0-554-gf63dbad-1ubuntu1

If I can't make it work reasonably with mencoder and mplayer, I'll
consider using libraries instead (SDL?, ...?); I fear this is going to
take a lot of work to get right, though, suggestions very welcome.


More information about the MPlayer-users mailing list