Use v4l2loopback with mplayer.
- Download it,
- compile it (
make
and su -c 'make install'
),
- load the module with
su -c 'modprobe v4l2loopback'
,
then change one line in the file examples/yuv4mpeg_to_v4l2.c
of the v4l2loopback source folder from
v.fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420;
to
v.fmt.pix.pixelformat = V4L2_PIX_FMT_YVU420;
and do make
in this folder.
Then run it from the examples
directory like this:
mkfifo /tmp/pipe # only needed once, as long as you do not delete the file /tmp/pipe
./yuv4mpeg_to_v4l2 < /tmp/pipe &
mplayer movie.mp4 -vf scale=480:360 -vo yuv4mpeg:file=/tmp/pipe
where you replace movie.mp4
with the name of your video file. And replace /dev/video0
with your loopback device.
MPlayer is able to play any webstreams, all kind of video files, even from stdin! I just tested it with a file from http://www.tagesschau.de which is a german news site.
TS=$(wget "http://www.tagesschau.de/multimedia/video/" -q -O - | grep --regexp='http.*\.webm"' | sed -e 's%.*href="%%' -e 's%\.webm".*%\.webm%')
./yuv4mpeg_to_v4l2 < /tmp/pipe &
mplayer $TS -vf scale=480:360 -vo yuv4mpeg:file=/tmp/pipe
Instead of the $TS you could put a -
(which stands for stdin). And in front of mplayer your ffmpeg command redirecting its output to stdout. So something like:
./yuv4mpeg_to_v4l2 < /tmp/pipe &
fmpeg -someOptions ... -o - | mplayer - -vf scale=480:360 -vo yuv4mpeg:file=/tmp/pipe
Did not test the last one, because you did not tell how your ffmpeg command look like.
It was all hunky-dory right up until you said "fake webcam-style device usable by flash". – Ignacio Vazquez-Abrams – 2012-04-13T03:05:06.803
I'm not sure what you mean? By "webcam-style" device I meant something like a fake /dev/videoN device file, or something similar. I assume this is how the captured video would be usable by flash. – bkconrad – 2012-04-13T03:07:05.430
Exactly. That's hard. – Ignacio Vazquez-Abrams – 2012-04-13T03:08:08.347