User Tools

Site Tools


tutorials:command_line_dvb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:command_line_dvb [2012/03/03 19:55] rmilestutorials:command_line_dvb [2017/10/12 21:58] (current) – external edit 127.0.0.1
Line 1: Line 1:
 **Command line dvb-t by example** **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<sup>//1//</sup> 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.
  
-You might wonder why in the age of Myth TV would I bother to which I would answer that I'm happy enough to be able to open up a terminal (locally or remotely),  type in a command, respond to a couple prompts, and schedule a show to be saved for later viewing. I don't need much more than that.+You might ask why in the age of Myth TV would I bother with DVB on the command line to which I would answer that I'm happy enough to be able to open up a terminal (locally or remotely), type in a command, respond to a couple prompts, and schedule a show to be saved for later viewing. I don't need much more than that.
  
 ---- ----
  
-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://linuxtv.org/wiki/index.php/LinuxTV_dvb-apps]] to get the latest tarball and roll your own. It is a trivial compile with no dependencies or config file to. Just run //make// then //make install// for instant gratification or build your own package. If you prefer, you can just run the executables strait from the build directory.+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://linuxtv.org/wiki/index.php/LinuxTV_dvb-apps]] to get themost recent tarball and roll your own. It is a trivial compile with no dependencies or config file. Just run //make// then //make install// for instant gratification or build your own package. If you prefer, you can run most of the utilities straight from the build directory. 
 + 
 +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 following command line utilities
  
-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 
 <code> <code>
 rick[~]$ ls saves/build/usr/local/bin/ rick[~]$ ls saves/build/usr/local/bin/
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 //channels.conf// file. This is created using the //scan//and a file containing initial tuning data for at least one transponder/channel for your area. Dvb-apps provides this data for the TV transponders in my area (on Mt. Dandenong) in the file ///usr/local/share/dvb/dvb-t/au-Melbourne//.+In order to tune a channel with //tzap// or indeed other applications including //mplayer// and //xine// you will first need a //channels.conf// file which is created using //scan// and a file containing initial tuning data for at least one transponder/channel for your area. //Dvb-apps// provides this data for the TV transponders in my area (on Mt. Dandenong) in the file ///usr/local/share/dvb/dvb-t/au-Melbourne//.
  
 <code> <code>
Line 36: Line 37:
 </code> </code>
  
-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.
  
 <code> <code>
Line 94: Line 95:
 </code> </code>
  
-Tzap uses //adapter0//, //demux0// and //frontend0// by default, so I will only have to specify which adapter to use when tuning a channel. I will also need to also tell //tzap// where the //channel.conf// is and what channel to tune. If I want to set upthe device //dvr0// for recording an mpeg-ts (transport stream) I should also use the flag //-r//. The device //net0// is used when feeding packets into the network protocol stack, i.e. //streaming// a program.+Tzap uses //adapter0//, //demux0// and //frontend0// by default, so I will only have to specify which adapter to use when tuning a channel. I will also need to tell //tzap// where the //channel.conf// is and what channel to tune. If I want to set up the device //dvr0// for recording an mpeg-ts (transport stream) I should also use the flag //-r//. The device //net0// is used when feeding packets into the network protocol stack, i.e. //streaming// a program.
  
 <code> <code>
Line 109: Line 110:
 </code> </code>
  
-Once tzap has tuned the channel it will remain tuned until the process is terminated. The whatever is being broadcast on that tuned channel is available via dvr0 although you need to do something with it+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.
  
 <code> <code>
Line 126: Line 127:
 </code> </code>
  
-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 or encoded to some other format.+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.
  
 <code> <code>
Line 132: Line 133:
 </code> </code>
  
-As can be seen, the above command redirects stdout from dvr0 to stdin xine.+The next command redirects stdout from dvr0 to stdin xine which will then open up in a window.
  
 <code> <code>
Line 169: Line 170:
 </code> </code>
  
-As I mentioned above, I sometimes watch dvb in real time with xine but using tzap in one terminal and then running xine in a second is overkill. However, I do use mplayer's encoding/decoding tool, mencoder, to access dvr0 and encode the transport stream to an mpeg-ps (program stream) on the fly before it is saved to disk.+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's encoding/decoding tool, mencoder, to access dvr0 and encode the transport stream to an mpeg-ps<sup>2</sup> (program stream) on the fly before it is saved to disk.
  
-Except for the inclusion of encoding instructions and a path/name for the out file, the command is the same as for 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 [/path/dvrX].
  
 <code> <code>
Line 197: Line 198:
 </code> </code>
  
-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 commercials from using a very fast minimalist gui application , gopdit, that was developed specically for editing program streams. If I save an hour long show as an mpeg-ts I would later have to spend as much as another hour encoding to mpeg-ps. Better just to encode o the fly.+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<sup>3</sup>. If I record an hour long show as an mpeg-ts I would later have to spend as much as another hour encoding it to mpeg-ps before I can edit it. Better just to encode o the fly.
  
-Using two terminals and remembering commands 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, presents a list of channels for selection and  then prompts for how long to save, where to save, etc. +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, presents a list of channels for selection and then prompts for how long to save, where to save, etc. 
  
 I'll present that script later on in my series of bash tutorials. I'll present that script later on in my series of bash tutorials.
Line 222: Line 223:
  
 # Encode on the fly # Encode on the fly
-mencoder -oac copy -ovc copy -of mpeg -mpegopts format=dvd /dev/dvb/adapter$dvb_card/dvr0 -o /multimedia/$name &+mencoder -oac copy -ovc copy -of mpeg -mpegopts format=dvd /dev/dvb/adapter$dvb_card/dvr0 -o /$video_dir/$name &
 mencoder_pid=$! mencoder_pid=$!
  
Line 240: Line 241:
 </code>  </code> 
  
 +----
 +Rick Miles
 +
 +03 March 2012
 +
 +----
 +
 +//<sup>1</sup> I am using a Dvico Fusion HDTV DVB-T Lite pci card and a WinFast DTV1000 T pci card. The Dvico was certainly not budget priced when I purchased it 7 or 8 years ago but feature wise today it would be considered a budget card. The Winfast was purchased 5 or 6 years ago for $35.00. The only difference was that the Dvico came with windows software and a remote that I never used.//
 +
 +//<sup>2</sup> The mencoder options in this command will encode to a very basic mpeg-ps DVD standard. They would not be suitable for a .VOB quality mpeg.ps. I use a different set of options in a script that will also shrink the video to less than 4.2GB if required. See [[http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-vcd-dvd.html]] for more information on using mencoder to encode DVB quality videos.//
  
 +//<sup>3</sup>3 I have been using gopdit (GOP accurate eDITor) just about as long as I have been recording DVB TV. Gopdit is a is a fast and simple program that lets you cut and merge mpeg-ps files at GOP (group of pictures) boundaries without reencoding. It supports no other file types or operations. The fact is that it is simple and only does one video editing task is on one file type is probably why it is relatively unknown. You can find gopdit at [[http://gopdit.ath.cx/]]//
  
tutorials/command_line_dvb.1330764958.txt.gz · Last modified: 2017/10/12 21:58 (external edit)