Linux: Raw Video -> ffmpeg into some compressed format -> TCP/UDP port - Page 1
Forum section: electronics / general

author: Delta
author_rank: Super Contributor
timestamp: January 16, 2016, 12:45:32 pm
content: Happy weekend everyone!Sorry if this is the wrong section, or even the wrong forum...Can anyone please give me the command line options for ffmpeg to get it to read a raw video stream from stdin (or a named pipe/FIFO if necessary), encode it into a compressed format that can be decoded on the fly by Mplayer, and output it to stdout (or a FIFO) for NetCatting out via TCP or UDP.I am capturing a PAL camera using an EasyCap type USB device connected to an old laptop running Ubuntu Server. The EasyCap is of a type (SoMagic DC60++ clone) that is not compatible with V4L, and although I've tried following the guides to patch and recompile the Kernel, but that was way above and I got nowhere...I have installed the "somagic" command, and the following captures and streams raw video on the serverCode:somagic-capture | nc -l 29002and then on a clientCode:nc 192.168.0.27 29002 | mplayer -nocache -vf yadif -demuxer rawvideo -rawvideo "pal:format=uyvy:fps=25" -aspect 4:3 -framedrop -successfully(ish) receives the stream with the following outputCode:MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Teammplayer: could not connect to socketmplayer: No such file or directoryFailed to open LIRC support. You will not be able to use your remote control.Playing -.Reading from stdin...rawvideo file format detected.open: No such file or directory Couldn't open: /dev/mga_vidopen: No such file or directory Couldn't open: /dev/mga_vid This driver only supports the 3Dfx Banshee, Voodoo3 and Voodoo 5. Unable to open /dev/3dfx.Opening video filter: ==========================================================================Opening video decoder:  RAW Uncompressed VideoVDec: vo config request - 720 x 576 (preferred colorspace: Packed UYVY)Could not find matching colorspace - retrying with -vf scale...Opening video filter: VDec: using Packed UYVY as output csp (no 0)Movie-Aspect is 1.33:1 - prescaling to correct movie aspect.SwScaler: reducing / aligning filtersize 1 -> 4Last message repeated 1 timesSwScaler: reducing / aligning filtersize 1 -> 1SwScaler: reducing / aligning filtersize 9 -> 8[swscaler @ 0x8796cb0]BICUBIC scaler, from uyvy422 to yuv420p using MMX2[swscaler @ 0x8796cb0]using 4-tap MMX scaler for horizontal luminance scaling[swscaler @ 0x8796cb0]using 4-tap MMX scaler for horizontal chrominance scaling[swscaler @ 0x8796cb0]using 1-tap MMX "scaler" for vertical scaling (YV12 like)[swscaler @ 0x8796cb0]720x576 -> 720x576VO:  720x576 => 768x576 Planar YV12Selected video codec:  vfm: raw (RAW UYVY)==========================================================================Audio: no soundStarting playback...^\ 0.8 21/ 21 0% 65% 0.0% 0 0What I'd like to do is use ffmpeg to encode the stream to reduce bandwidth, and maybe also reduce the framerate.I've tried reading and re-reading the ffmpeg man pages, and using various examples I've found online, but I'm justCan anyone get me going please?Cheers!

author: BradC
author_rank: Super Contributor
timestamp: January 16, 2016, 02:35:54 pm
content: A bit left-field, but if you already have it playing in mplayer is there any reason you can't just use mencoder to compress it?

author: Delta
author_rank: Super Contributor
timestamp: January 16, 2016, 05:08:56 pm
content: Quote from: BradC on January 16, 2016, 02:35:54 pmThe reason is because I'd never heard of it!Googling now, hopefully it uses the same input command line options as Mplayer....Thanks Brad!

author: Delta
author_rank: Super Contributor
timestamp: January 16, 2016, 07:39:51 pm
content: Well I'm kind of getting there...If I runCode:somagic-capture | mencoder /dev/stdin -vf yadif -demuxer rawvideo -rawvideo "pal:format=uyvy:fps=25" -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=2000 -nosound -of avi -o - | nc -u 192.168.0.6 29002on the sending end, then on the receiving end I getCode:nc -u -l 29002 | mplayer - -cache 1024MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Teammplayer: could not connect to socketmplayer: No such file or directoryFailed to open LIRC support. You will not be able to use your remote control.Playing -.Reading from stdin...Cache fill: 19.53% (204800 bytes)libavformat file format detected.and it just sits there.If I end it with a CTRL^|, I getCode:^\MPlayer interrupted by signal 3 in module: enable_cacheMPlayer interrupted by signal 3 in module: demux_open[mp3 @ 0xa42d8b0]Could not find codec parameters (Audio: mp2, 0 channels, s16)LAVF_header: av_find_stream_info() failedExiting... (End of file)not sure if that's relevant though...So what is going on? Can Mplayer not detect the format of the stream?

author: BradC
author_rank: Super Contributor
timestamp: January 17, 2016, 01:04:46 am
content: Sorry, I meant to ask if you actually had it playing an image or if it just said it was having a crack at it?

author: Delta
author_rank: Super Contributor
timestamp: January 18, 2016, 12:07:38 am
content: At that time it just sat there, it didn't even open the player window.I kept messing around with different CoDecs, and I got some kind of picture, but had serious V-sync issues.I think that the encoder maybe can't read the raw video data fast enough.I've kind of given up on this stupid project, I've managed to cobble something together that grabs a frame every few seconds, but I still get a nice big VBI bar across the jpeg every now and again... And the quality is shit, I think maybe I need to find away to deinterlace, so it uses two fields to produce the jpeg..It's only to look at my hens anyway!