[chbot] V4L2 tutorial

Mark Atherton markaren1 at xtra.co.nz
Thu Oct 27 17:08:47 BST 2011


Hi Col,

Be careful with your show of enthusiasm, you are circling the 
DigiLite-ZL Digital Video [black-hole] project, and may get pulled in :)

<http://www.idesignz.org/DigiLiteZL_FPGA/DigiLiteZL-FPGA.htm>http://www.idesignz.org/DigiLiteZL_FPGA/DigiLiteZL-FPGA.htm 
-- Ben now has the FPGA code working [smart cookie huh], and I have 
created an animated test card, 
<http://www.idesignz.org/DATV_test_card/FTP.zip>http://www.idesignz.org/DATV_test_card/FTP.zip 
so the next step is to add real time video encoding using Linux.

Anyway, progress so far:

v4l2-ctl -i 2                           // select composite input 
[your starting point]
v4l2-ctl -c stream_type=1               // Transport Stream (this errors)
v4l2-ctl -c video_bitrate=2920000       // bit rate
v4l2-ctl -c video_bitrate_mode=0        // fixed bit-rate

Took me a while to configure the MPEG-2 encoder, and to find that:

v4l2-ctl --set-ctrl=stream_type=1
         is the same as
V4l2-ctl -c stream_type=1

As a side issue I need a Transport Stream (TS) at 3.683 Mbps for the 
modulator. The modulator then adds 204/188 Reed Solomon ECC bringing 
the rate up to 4.0 Mbps. 1/2 Viterbi then further increases the rate 
to 4 M sym/sec (IQ pairs) which is 8 Mbps. The 3.686 Mbps rate is 
derived from a basic MPEG video rate of 2.920 Mbps + Audio + System 
Information (SI) + 5% null packet stuffing.

Setting stream_type does more than just affect the output multiplex 
type. Published information on the Conexant CX23415 MPEG-2 encoder 
(as used on the PVR-150 PCI card) claims that it is capable of 
creating TS directly, but errors indicate differently. It appears to 
only be capable of being configured in various Program Stream formats.

One solution is to write a filter to demux Program Stream to video 
and audio elementary streams, add SI tables, then remux to TS.

Let me know [off list] if any of this this interests you.

Useful links:

http://ivtvdriver.org/index.php/V4l2-ctl -- summary of V4l2-ctl, 
although is should really be called v4l2-ctl

<http://v4l2spec.bytesex.org/spec-single/v4l2.html>http://v4l2spec.bytesex.org/spec-single/v4l2.html 
-- another summary, with some example at the bottom

<http://linuxtv.org/downloads/v4l-dvb-apis/>http://linuxtv.org/downloads/v4l-dvb-apis 
-- Linux Media Infrastructure API

<http://linuxtv.org/wiki/index.php/Hauppauge_WinTV-HVR-1900>http://linuxtv.org/wiki/index.php/Hauppauge_WinTV-HVR-1900 
-- just bought one of these, and will have a go at configuring it 
when I have the PVR-150 under control

I am in the process of de-mystifying some of the Digital Broadcast 
magic and will continue to publish work, and credit contributors in 
the process.

Thanks again for you initial push, half of the struggle (for me at 
any rate) is to find the correct initial search key-word, which in 
this case was "v4l2-ctl"

Regards,

Mark

>Please post some sample commands, so I can add them to my notes. ( I 
>may have to dig the card out of a box of old bits. ) - Col.





More information about the Chchrobotics mailing list