mplayer can't read udp video stream

lagarkane picture lagarkane · Apr 16, 2014 · Viewed 9.7k times · Source

Im trying to compare latency between different video codecs using ffmpeg and mplayer's benchmark.

I am using this command line to generate and send the stream:

ffmpeg -s 1280x720 -r 100 -f x11grab -i :0.0 -vcodec mpeg2video -b:v 8000 -f mpegts udp://localhost:4242

And I'm successfully using ffplay to receive and read it in real time:

ffplay -an -sn -i -fflags nobuffer udp://localhost:4242?listen

Now instead of playing the stream with ffplay, i'd like to use the mplayer benchmark to get some information on the latency:

mplayer -msglevel all=6 -benchmark udp://localhost:4242

But I get this output instead:

Playing udp://localhost:4242.
get_path('sub/') -> '/home/XXXXX/.mplayer/sub/'
STREAM_UDP, URL: udp://localhost:4242
Filename for url is now udp://localhost:4242
Listening for traffic on localhost:4242 ...
Timeout! No data from host localhost
udp_streaming_start failed
No stream found to handle url udp://localhost:4242

I tried with rtp protocol instead, didn't work either...

Does anyone have an idea what i'm doing wrong?

Answer

lagarkane picture lagarkane · Apr 23, 2014

Thanks for the answers,

I actually tried a lot of different codecs, especially vp9, h264 and mpeg2, but the best low latency i got were with mpeg2video. Here are 3 of the command lines I used. I read the ffmpeg streaming guide and the different codec's encoding guides to try to get the best parameters for each of them, but the difference is noticeable:

ffmpeg -an -sn -s 1280x720 -r 30 -f x11grab -i :0.0 -vcodec libx264 -crf 18 -tune zerolatency -preset ultrafast -pix_fmt yuv420p -profile:v baseline -b:v 8000 -f mpegts threads 4 udp://127.0.0.1:4242

ffmpeg -s 1280x720 -r 30 -f x11grab -i :0.0 -vcodec mpeg2video -b:v 800k -f mpegts -threads 8 udp://127.0.0.1:4242

ffmpeg -t 5 -s 1280x720 -r 30 -f x11grab -i :0.0 -vcodec libvpx-vp9 -an -crf 18 -b:v 1M -f webm -threads 8 udp://127.0.0.1:4242

On localhost, I'm close to no latency at all with mpeg2video, when I have almost 1sec latency with h264. I heard vp9 could have very low latency too, but I apparently don't know how to use the options in ffmpeg, cuz I get really bad latency values...

Anyway, to get back to the topic, 127.0.0.1 instead of localhost doesn't help, and with ffmpeg://udp://ip:port it doesn't work either... :/ I think I may have wrong configurations on mplayer. maybe I should try to compile it myself. But actually, I don't even know if mplayer would give me the informations I want (the average number of ms for a codec to encode/decode a frame, so that I can compare my different codecs precisely).

EDIT: Sorry for that... ffmpeg://udp://ip_addr works =) I made a typing mistake... n_n Thanks a lot. Though, the quality of the video is really aweful compared to ffplay when I use mplayer...