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 19: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:// | + | If you want to try any of this on your own machine you will need to install |
+ | |||
+ | Note that some distros package // | ||
- | Note that some distros package dvb-apps as dvb-utils and that there is another bundle of dvb related utilities named DVBapps. If you have installed or built the correct dvb-apps, in addition to some include files, libraries and frequency listings you should have installed the follwing command line utilities | ||
< | < | ||
rick[~]$ ls saves/ | rick[~]$ ls saves/ | ||
Line 18: | Line 19: | ||
I will only discuss the use of //scan// and //tzap// in this tutorial. | 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 // | + | In order to tune a channel with //tzap// or indeed other applications including //mplayer// and //xine// you will first need a // |
< | < | ||
Line 36: | Line 37: | ||
</ | </ | ||
- | To create my channels.conf I run scan with the path to au-Melbourne and redirect stdout to a file. | + | To create my //channels.conf// I run scan with the path to //au-Melbourne// and redirect stdout to a file. |
< | < | ||
Line 94: | Line 95: | ||
</ | </ | ||
- | Tzap uses // | + | Tzap uses // |
< | < | ||
Line 109: | Line 110: | ||
</ | </ | ||
- | Once tzap has tuned the channel it will remain tuned until the process is terminated. | + | Once tzap has tuned the channel it will remain tuned until the process is terminated. |
< | < | ||
Line 126: | Line 127: | ||
</ | </ | ||
- | 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 | + | 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 |
< | < | ||
Line 132: | Line 133: | ||
</ | </ | ||
- | This will redirect | + | The next command redirects |
< | < | ||
Line 140: | Line 141: | ||
</ | </ | ||
+ | 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 | ||
+ | |||
+ | ---- | ||
+ | |||
+ | //< | ||
+ | |||
+ | //< | ||
+ | |||
+ | //< | ||
tutorials/command_line_dvb.1330762080.txt.gz · Last modified: 2017/10/12 21:58 (external edit)