How to produce a raw video feed

About encoding, codec settings, muxers and filter usage
phreed
New Cone
New Cone
Posts: 7
Joined: 13 Jan 2009 19:39

How to produce a raw video feed

Postby phreed » 13 Jan 2009 19:58

I am adding a rawvid (rgb24) feed from my program (delta3d) and want to use vlc to transcode it and serve it up.
Specifically I want to do this...

Code: Select all

vlc --demux rawvid --rawvid_chroma RV24 --rawvid-width 800 --rawvid-height 600 "http://localhost:13002/"
Starting

Code: Select all

socat stdio tcp-listen:13002
and running vlc in this way shows me that my program should be a tcp server that responds to...

Code: Select all

GET / HTTP/1.1 Host: localhost:13002 User-Agent: VLC media player - version 1.0.0-git Goldeneye - (c) 1996-2008 the VideoLAN team Range: bytes=0- Icy-MetaData: 1
...with a raw video feed.
Do you know where I might find the precise protocol for rawvid (rgb24)?
When testing the rawvid demuxer what do you use to create the rawvideo feed?
Am I posting this in the appropriate forum?
Last edited by phreed on 22 Jan 2009 18:50, edited 1 time in total.

phreed
New Cone
New Cone
Posts: 7
Joined: 13 Jan 2009 19:39

Re: How to produce a raw video feed

Postby phreed » 16 Jan 2009 16:30

The problem was finding a definitive declaration of what constitutes a the rawvid rgb24 stream.
It is simply a stream of pixel values encoded in three bytes (R8+G8+B8 = 24bits) each with neither headers nor frame delimiters.
The frame info is supplied separately to the stream reader (i.e. frame height, width, and rate).

The following mechanisms work for producing a rawvid RGB24 video stream!

The first technique uses BMP files and the ImageMagick 'stream' program to produce a single frame.
The single frame is then duplicated to produce as many frames as desired.

Code: Select all

stream -map rgb -storage-type char test24.bmp ./pixels.rv24 cat ./pixels.rv24 ./pixels.rv24 ./pixels.rv24 ...<repeat>... ./pixels.rv24 > ./sample.rv24 cvlc --demux rawvid --rawvid-fps 30 --rawvid-chroma RV24 --rawvid-width 127 --rawvid-height 64 --no-drop-late-frames ./sample.rv24
The second technique uses ffmpeg to convert a video from a known format to rawvideo.

Code: Select all

ffmpeg -i ./sample.mp4 -f rawvideo -vcodec rawvideo -pix_fmt rgb24 -s 400x300 ./sample.rv24 cvlc --demux rawvid --rawvid-fps 30 --rawvid-chroma RV24 --rawvid-width 400 --rawvid-height 300 --no-drop-late-frames ./sample.rv24
Serving the sample using a webserver (e.g. apache, nginx) plays correctly.

Code: Select all

cvlc --demux rawvid --rawvid-fps 30 --rawvid-chroma RV24 --rawvid-width 400 --rawvid-height 300 --no-drop-late-frames http://localhost/rawvideo/sample.rv24
---
Some handy sample images.
http://wvnvaxa.wvnet.edu/vmswww/bmp.html

phreed
New Cone
New Cone
Posts: 7
Joined: 13 Jan 2009 19:39

Re: How to produce a raw video feed

Postby phreed » 21 Jan 2009 21:23

My remaining vlc specific question is just how minimal can the http server be?
I have been playing around with socat but haven't quite gotten it working yet.

Code: Select all

socat tcp-l:13000 system:'while read line; do case ${line} in \r\n) echo "stream it";; *) echo ${line};; esac; done',pipes
However, my application now can stream video to vlc.
Following the connection I check for the end of the http request, a blank new line (\r\n).
Then before sending rgb24 frames I send a packet containing the following header.

Code: Select all

HTTP/1.1 206 Partial Content\r\n Content-type: application/octet-stream\r\n Connection: keep-alive\r\n \r\n
It may even be possible to send less than this but it works for me.

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: How to produce a raw video feed

Postby Rémi Denis-Courmont » 21 Jan 2009 21:27

Don't use HTTP/TCP/IP. Create a FIFO with mkfifo, or if you start VLC from the feeding program, create a pipe. Let VLC read from it as a normal file.

On Linux, you can even use vmsplice() from the feeder to the FIFO kill one memory copy.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

phreed
New Cone
New Cone
Posts: 7
Joined: 13 Jan 2009 19:39

Re: How to produce a raw video feed

Postby phreed » 22 Jan 2009 18:02

Don't use HTTP/TCP/IP. Create a FIFO with mkfifo, or if you start VLC from the feeding program, create a pipe. Let VLC read from it as a normal file.

On Linux, you can even use vmsplice() from the feeder to the FIFO kill one memory copy.
I'd thought about using a pipe but can it be made to work on windowsXP as well?
(http://www.boost.org/doc/libs/1_37_0/do ... andle.html ?)

Also, I am looking for soft real time where the frame will only be sent to ready listeners.
That is the new frame won't be written to the socket until the last write is complete.

As far as vmsplice goes I am not familiar with it.
Where might I look for some good documentation.

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: How to produce a raw video feed

Postby Rémi Denis-Courmont » 22 Jan 2009 20:17

No, VLC cannot read pipes on Windows since they're not files. It remains that streaming raw video over TCP is a bad idea.

vmsplice() is documented in the Linux development manpages of your distro.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: Bing [Bot] and 8 guests