video - Pipe VLC output to ffplay?
2013-08
I have a (broken) PC, where VLC plays videos on only the left half the screen, which seems related to OpenGL/drivers (see here). On the other hand, ffplay
doesn't have the half-window problem, but can open only some videos I want to play.
So, similar to How can I pipe output of ffmpeg to ffplay?, I thought of piping VLC to ffplay
; and I got this far (I'm using this video):
$ cvlc Rent_an_Ambassador.ogv --sout '#transcode{vcodec=IYUV}:std{access=file,mux=raw,dst=-}' | ffplay -f rawvideo -s 398x224 pipe:-
...
Warning: call to srand(1369860697)
Warning: call to rand()
Blocked: call to unsetenv("DBUS_ACTIVATION_ADDRESS")
Blocked: call to unsetenv("DBUS_ACTIVATION_BUS_TYPE")
[0x98f4b64] dummy interface: using the dummy interface module...
[0x9903254] mux_dummy mux: Open
[rawvideo @ 0x98bf890]Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'pipe:-':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0.0: Video: rawvideo, yuv420p, 398x224, 25 tbr, 25 tbn, 25 tbc
So, basically ffplay
it picks up that VLC's IYUV
should be yuv420p
, as I read in Libav user questions and discussions - Re: Scale image from 4:2:2 to 4:2:0
Note that YUV420P is a.k.a. I420 and IYUV.
... unfortunately, the video output is all wrong:
Note that if I don't specify the size for ffplay
, it fails with:
picture size invalid (0x0)
Last message repeated 1 times
[rawvideo @ 0x9c6f890]Could not find codec parameters (Video: rawvideo, yuv420p)
[rawvideo @ 0x9c6f890]Estimating duration from bitrate, this may be inaccurate
pipe:-: could not find codec parameters
So, my question is:
- Would anyone know of a proper command line for piping from
vlc
toffplay
- using raw video? - Is there a way to make
vlc
play audio as usual, and pipe its video output as raw video toffplay
(so as to avoid the overhead of muxing video and audio into a new format, which ffplay would have to additionally demux?)
EDIT: Here's one command line that does provide proper video with test file as above (via The VideoLAN Forums • Sending YUV data to a pipe under windows):
cvlc Rent_an_Ambassador.ogv --vout=yuv --yuv-yuv4mpeg2 --yuv-file=/dev/stdout | ffplay pipe:-
However:
ffplay
segfaults when I try to unpack some other videos withvlc
- For yet a third category of videos,
vlc
will not export FPS setting - soffplay
will start, show a frame, and then freeze display (and you'd have to continually scroll the mouse button, so the video window refreshes). Note here that you cannot force ffplay frame rate for timeless containers - and when doing--yuv-file
(instead of--sout
) the--sout-transcode-fps
will not apply (from thevlc
side of things)
Have you tried disabling hardware video acceleration in VLC? This might fix the half-screen problem.
Yes I realize this isn't the question asked, but it seems to be an XY Problem.
How can I pipe the output of ffmpeg to ffplay?
At the moment I use a workaround in bash :
mkfifo spam
(ffplay spam 2> /dev/null &) ; capture /dev/stdout | ffmpeg -i - spam
I do not know if it is ffmpeg
that cannot output its data to stdout, or ffplay
that cannot take its input from stdin.
If it is ffmpeg
that cannot output its data to stdout:
capture /dev/stdout | ffmpeg -i - >(ffplay 2> /dev/null)
(You migth need to add a -
argument to ffplay
so it takes its input from stdin.)
If it is ffplay
that cannot take its input from stdin:
ffplay <(capture /dev/stdout | ffmpeg -i -) 2> /dev/null
For more informations about the <(command)
and >(command)
construct, see the Process Substitution section of the bash manual.
looks like normal pipes work (at least in windows):
ffmpeg -i sintel.mpg -pix_fmt yuv420p -f rawvideo - | ffplay -f rawvideo -pix_fmt yuv420p -s 720x480 -
haven't tried it with more complicated input/output though...
ffmpeg -f dshow -i video=screen-capture-recorder -pix_fmt yuv420p -f mpegts - | ffplay -analyzeduration 10 -f mpegts -
is slightly faster startup
ffmpeg supports piping operations. See that section of the documentation here.
I don't know how ffplay works, but to pipe the output of ffmpeg to standard output, you can add the pipe command to the end of the ffmpeg command. Example:
ffmpeg -i input.flv pipe:1 | ffplay -i -
ffmpeg -i input.avi <options> -f matroska - | ffplay -
will work; you need to set a container format for the output. This is normally set with ffmpeg looking at the extension you give the output, but here you have to set it manually with -f
. I recommend matroska (MKV) because it can contain almost any video, so whatever you're transcoding it to should work perfectly well.
Note that if you are using Ubuntu 12.04, ffmpeg has been replaced by the libav fork, and you should use avconv
and avplay
instead; the syntax is otherwise identical. There is a sort-of ffmpeg there, but it's crippled by design.