tutorials:command_line_dvb
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:command_line_dvb [2012/03/03 18:08] – rmiles | tutorials:command_line_dvb [2017/10/12 21:58] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | **Command line dvb-t** | + | **Command line dvb-t by example** |
- | I have two budget dvb-t pci cards in a linux box that I use for saving dvb TV programs and, since I am a minimalist, sometimes viewing in real time using xine. In this brief tutorial I will explain how to access DVB broadcasts on the command line and introduce a bare bones example script that will tune a channel, encode a broadcast on the fly and save it to disk. | + | I have two budget dvb-t pci cards in a linux box that I use for saving dvb TV programs< |
- | You might wonder | + | You might ask why in the age of Myth TV would I bother |
- | If you want to try any of this on your own machine you will need to install dvb-apps. If a package is not available for your distro or if you want the latest version go to [[http:// | + | ---- |
- | Note that some distros package | + | If you want to try any of this on your own machine you will need to install /dvb-apps/. If a package is not available for your distro |
+ | Note that some distros package // | ||
+ | |||
+ | < | ||
rick[~]$ ls saves/ | rick[~]$ ls saves/ | ||
atsc_epg | atsc_epg | ||
av7110_loadkeys | av7110_loadkeys | ||
+ | </ | ||
+ | |||
+ | I will only discuss the use of //scan// and //tzap// in this tutorial. | ||
+ | |||
+ | In order to tune a channel with //tzap// or indeed other applications including //mplayer// and //xine// you will first need a // | ||
+ | |||
+ | < | ||
+ | rick[~]$ cat / | ||
+ | # Australia / Melbourne (Mt Dandenong transmitters) | ||
+ | # T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy | ||
+ | # ABC | ||
+ | T 226500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE | ||
+ | # Seven | ||
+ | T 177500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE | ||
+ | # Nine | ||
+ | T 191625000 7MHz 3/4 NONE QAM64 8k 1/16 NONE | ||
+ | # Ten | ||
+ | T 219500000 7MHz 3/4 NONE QAM64 8k 1/16 NONE | ||
+ | # SBS | ||
+ | T 536625000 7MHz 2/3 NONE QAM64 8k 1/8 NONE | ||
+ | </ | ||
+ | |||
+ | To create my // | ||
+ | |||
+ | < | ||
+ | rick[~]$ scan / | ||
+ | </ | ||
+ | |||
+ | The complete // | ||
+ | |||
+ | < | ||
+ | ABC News 24: | ||
+ | ABC1: | ||
+ | ABC2 / ABC4: | ||
+ | ABC1: | ||
+ | ABC3: | ||
+ | ABC Dig Music: | ||
+ | ABC Jazz: | ||
+ | 7 Digital: | ||
+ | 7 Digital 1: | ||
+ | 7TWO: | ||
+ | 7mate: | ||
+ | 7 Digital: | ||
+ | TV4ME: | ||
+ | Nine Digital: | ||
+ | GEM: | ||
+ | GO!: | ||
+ | ONE: | ||
+ | TEN Digital: | ||
+ | ONE: | ||
+ | ELEVEN: | ||
+ | SBS ONE: | ||
+ | SBS TWO: | ||
+ | SBS 3: | ||
+ | SBS 4: | ||
+ | SBS HD: | ||
+ | SBS Radio 1: | ||
+ | SBS Radio 2: | ||
+ | </ | ||
+ | |||
+ | Once the // | ||
+ | |||
+ | Note that I have also successfully used this // | ||
+ | |||
+ | I can now use //tzap// to tune any channel listed in my channels.conf. | ||
+ | |||
+ | //Tzap// needs to know what dvb card (adapter) to use. I have two cards installed. | ||
+ | |||
+ | < | ||
+ | rick[~]$ ls /dev/dvb | ||
+ | adapter0 | ||
+ | </ | ||
+ | |||
+ | //Tzap// also needs to know which // | ||
+ | |||
+ | < | ||
+ | rick[~]$ ls / | ||
+ | demux0 | ||
+ | </ | ||
+ | |||
+ | Tzap uses // | ||
+ | |||
+ | < | ||
+ | rick[~]$ tzap -a 0 -c / | ||
+ | using '/ | ||
+ | reading channels from file '/ | ||
+ | tuning to 226500000 Hz | ||
+ | video pid 0x0200, audio pid 0x028a | ||
+ | status 01 | signal 2a2a | snr 8000 | ber 00003fff | unc 00000000 | | ||
+ | status 1f | signal 2b2b | snr ffff | ber 00000000 | unc 00000000 | FE_HAS_LOCK | ||
+ | status 1f | signal 2b2b | snr ffff | ber 00000000 | unc 00000000 | FE_HAS_LOCK | ||
+ | status 1f | signal 2b2b | snr ffff | ber 00000000 | unc 00000000 | FE_HAS_LOCK | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | Once tzap has tuned the channel it will remain tuned until the process is terminated. Whatever is being broadcast on the tuned channel is available via dvr0 as stdout. | ||
+ | |||
+ | < | ||
+ | rick[~]$ cat / | ||
+ | ���, | ||
+ | ���V12��W1���J��& | ||
+ | V+nx�: | ||
+ | | ||
+ | V&0¶s | ||
+ | | ||
+ | )�@? | ||
+ | | ||
+ | ٤��)▒ O�" | ||
+ | �ˌ# | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | Using cat to stdout is pretty useless but dvr0 can be redirected and saved as a transport stream (.ts) on disk or accessed by an application and viewed in real time by opening up another terminal and running the second command. The following will redirect stdout from dvr0 to a file that can be either viewed as is or encoded to some other format. | ||
+ | |||
+ | < | ||
+ | rick[~]$ cat / | ||
+ | </ | ||
+ | |||
+ | The next command redirects stdout from dvr0 to stdin xine which will then open up in a window. | ||
+ | |||
+ | < | ||
+ | rick[~]$ xine stdin:// | ||
+ | This is xine (X11 gui) - a free video player v0.99.5. | ||
+ | (c) 2000-2007 The xine Team. | ||
+ | </ | ||
+ | |||
+ | The command to access dvr0 with mplayer is even simpler. | ||
+ | |||
+ | < | ||
+ | rick[~]$ mplayer / | ||
+ | MPlayer 20101218-4.5.1 (C) 2000-2010 MPlayer Team | ||
+ | |||
+ | Playing / | ||
+ | TS file format detected. | ||
+ | |||
+ | VIDEO MPEG2(pid=2307) AUDIO MPA(pid=2308) NO SUBS (yet)! | ||
+ | VIDEO: | ||
+ | ========================================================================== | ||
+ | Opening video decoder: [ffmpeg] FFmpeg' | ||
+ | Selected video codec: [ffmpeg2] vfm: ffmpeg (FFmpeg MPEG-2) | ||
+ | ========================================================================== | ||
+ | ========================================================================== | ||
+ | Opening audio decoder: [mp3lib] MPEG layer-2, layer-3 | ||
+ | AUDIO: 48000 Hz, 2 ch, s16le, 256.0 kbit/16.67% (ratio: 32000-> | ||
+ | Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3) | ||
+ | ========================================================================== | ||
+ | AO: [oss] 48000Hz 2ch s16le (2 bytes per sample) | ||
+ | Starting playback... | ||
+ | Movie-Aspect is 1.78:1 - prescaling to correct movie aspect. | ||
+ | VO: [xv] 720x576 => 1024x576 Planar YV12 | ||
+ | A:39429.8 V:39429.8 A-V: -0.000 ct: -0.345 298/ | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | As I mentioned above, I sometimes watch dvb in real time with xine but using tzap in one terminal and then running xine from a second terminal is overkill. However, I do use mplayer' | ||
+ | |||
+ | Except for the inclusion of encoding instructions and a path/name for the out file, the mencoder command is the same as for mplayer, mencoder [/ | ||
+ | |||
+ | < | ||
+ | rick[~]$ mencoder -oac copy -ovc copy -of mpeg -mpegopts format=dvd / | ||
+ | MEncoder 20101218-4.5.1 (C) 2000-2010 MPlayer Team | ||
+ | success: format: 0 data: 0x0 - 0x0 | ||
+ | TS file format detected. | ||
+ | VIDEO MPEG2(pid=2307) AUDIO MPA(pid=2308) NO SUBS (yet)! | ||
+ | VIDEO: | ||
+ | [V] filefmt: | ||
+ | ========================================================================== | ||
+ | Opening audio decoder: [mp3lib] MPEG layer-2, layer-3 | ||
+ | AUDIO: 48000 Hz, 2 ch, s16le, 256.0 kbit/16.67% (ratio: 32000-> | ||
+ | Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3) | ||
+ | ========================================================================== | ||
+ | PACKET SIZE: 2048 bytes, deltascr: 43885 | ||
+ | videocodec: framecopy (720x576 24bpp fourcc=10000002) | ||
+ | audiocodec: framecopy (format=50 chans=2 rate=48000 bits=16 B/s=32000 sample-1) | ||
+ | Limiting audio preload to 0.4s. | ||
+ | Increasing audio density to 4. | ||
+ | Writing header... | ||
+ | INITV: 0.200, 0.160, fps: 25.000 | ||
+ | Pos: | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | I could just save every thing I want to watch as a transport stream but the overhead running mencoder is very minimal. Additionally i prefer to save shows as mpeg-ps videos and I can edit out commercials from using a very fast no frills gui application , gopdit, that was developed specically for editing program streams< | ||
+ | |||
+ | Using two terminals and remembering commands, options and syntax gets to be a bit too much so I'll close this tutorial with an example script that illustrates how the commands tzap and mencoder can be used in a script to record a dvb broadcast. To use this script you would have to edit the variable declarations to suit and run it when the show is about to begin. I have written an interactive script that parses channels.conf, | ||
+ | |||
+ | I'll present that script later on in my series of bash tutorials. | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | # zap-men | ||
+ | # Edit variables to suit. | ||
+ | dvb_card=1 | ||
+ | video_dir=/ | ||
+ | chnl_cnf=/ | ||
+ | channel=ABC1 | ||
+ | duration=3600 | ||
+ | name=luther-abc-friday.mpg | ||
+ | |||
+ | # Tune in and lock channel | ||
+ | tzap -a $dvb_card -c $chnl_cnf -r " | ||
+ | tzap_pid=$! | ||
+ | |||
+ | # Give tzap time to tune in and lock channel | ||
+ | sleep 2 | ||
+ | |||
+ | # Encode on the fly | ||
+ | mencoder -oac copy -ovc copy -of mpeg -mpegopts format=dvd / | ||
+ | mencoder_pid=$! | ||
+ | |||
+ | sleep $duration | ||
+ | |||
+ | kill $tzap_pid | ||
+ | kill $mencoder_pid | ||
+ | |||
+ | # end of script | ||
+ | ################################################## | ||
+ | # Note: | ||
+ | # The ampersand "&" | ||
+ | # the script will never proceed to the mencoder command. Likewiseand the | ||
+ | # mencoder command is follwed by an ampersand else the script will never | ||
+ | # proceed past that command to run the duration of recording and the shut | ||
+ | # down. | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | Rick Miles | ||
+ | |||
+ | 03 March 2012 | ||
+ | |||
+ | ---- | ||
+ | |||
+ | //< | ||
+ | |||
+ | //< | ||
- | I will only discuss the use of scan and tzap in this tutorial. Scan is required to create | + | //< |
- | In order to tune a channel with tzap or indeed other applications including mplayer and xine you will first need a channels.conf file. This is created using the dvb-apps utility, scan, and a file containing initial tuning data for at least one transponder/ |
tutorials/command_line_dvb.1330758519.txt.gz · Last modified: 2017/10/12 21:58 (external edit)