<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>my tech blog &#187; DVB</title>
	<atom:link href="http://billauer.se/blog/category/dvb/feed/" rel="self" type="application/rss+xml" />
	<link>https://billauer.se/blog</link>
	<description>Anything I found worthy to write down.</description>
	<lastBuildDate>Thu, 12 Mar 2026 11:36:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Live TV / DVB on Linux demystified</title>
		<link>https://billauer.se/blog/2017/03/dvb-linux-primer-tutorial/</link>
		<comments>https://billauer.se/blog/2017/03/dvb-linux-primer-tutorial/#comments</comments>
		<pubDate>Mon, 13 Mar 2017 20:40:12 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[DVB]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=5159</guid>
		<description><![CDATA[Introduction This is a not-so-short tutorial which is intended to make the setup of a Live TV media center on Linux a bit easier, walking through the processing chain from the digital transmission signal to the picture on the screen. Quite naturally, things go from &#8220;general knowledge&#8221; to a bit more hands-on. The approach here [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>This is a not-so-short tutorial which is intended to make the setup of a Live TV media center on Linux a bit easier, walking through the processing chain from the digital transmission signal to the picture on the screen. Quite naturally, things go from &#8220;general knowledge&#8221; to a bit more hands-on. The approach here is to understand what you&#8217;re doing, something one can avoid when things just work by themselves. If you&#8217;re reading this, odds are they didn&#8217;t.</p>
<p>I suggest starting with the command line tools, as they give a lot of low-level information as they run. Once a TV channel can be viewed with these, I further suggest using Tvheadend as the backend, as it&#8217;s reasonably complicated to work with, and leaves a lot of control to the frontend software.</p>
<p>I also suggest a frontend (Kodi) for everyday TV viewing, and a way to configure it.</p>
<p>All in all, getting this to work is often a rather tedious process. This isn&#8217;t all that bad if one learns a few things on the way.</p>
<h3>The DVB frontend (&#8220;adapter&#8221;)</h3>
<p>Often with a USB interface, the DVB frontend receives the digital signal and turns it into a stream of bytes. Inside, it typically consist of a tuner, a demodulator and a USB interface chip. Often there&#8217;s a demux as well, which is discussed further on.</p>
<ul>
<li><strong>The tuner </strong>(the analog part) nails down a piece of the frequency spectrum with the digital signal in it, and makes it accessible to the demodulator. The signal may arrive from a simple UHF antenna, a satellite dish or from a cable network. In principle, there is no difference: It&#8217;s an analog signal that carries a bitstream of several Mb/s, and the tuner&#8217;s job is to bring the signal down to a known lower frequency, where the demodulator expects it to be. The tuner cares only about the signal&#8217;s center frequency, and possibly its bandwidth.</li>
<li><strong>The demodulator</strong> (the digital communication part) turns the analog signal from the tuner into a stream of digital bits. This is the most sophisticated part, which includes a significant portion of signal processing and also decoding of error-correcting codes (and, of course, correcting bit errors if such are found and are correctable). All this is hidden from the end user, so all the demodulator tells us is typically if it&#8217;s locked on the signal or not. There are quite a few things that need to get synchronized properly, but all we get is something like &#8220;works&#8221; or &#8220;doesn&#8217;t work&#8221;. The demodulator may also supply information about the signal strength, the S/N ratio and the PostBER, which is an estimation of the bit error rate obtained <strong>after</strong> fixing bit errors by virtue of the error correction code. This estimation is possible because all but a fraction of the bits are recovered correctly, so the demodulator knows what its input signal would look like without noise and distortions, and so it can also tell how much noise comes in. And the S/N ratio is calculated accordingly.</li>
<li><strong>The USB interface</strong> chip (the computer hardware part)  is the less interesting part, but it&#8217;s what the computer sees. The driver is often named after it, even though its the other devices that are important. Its main functionalities are: Relaying the output of the demodulator to the computer via a bulk USB endpoint, and supplying means to control and read status from the demodulator and tuner, which is almost always done with an I2C/SMBus over USB kind of bridge. The I2C bus interface may also be used to download firmware to these two devices.</li>
</ul>
<p>In a Linux system, the DVB adapter is represented with device files in /dev/dvb/adapter0/ (the index goes up if there are several of them). The notable file is /dev/dvb/adapter0/dvr0, from which the data stream is read, possibly with plain file I/O. In other words, when the adapter is set up, it&#8217;s possible to record a proper video clip with just &#8220;cat&#8221;, as shown in <a href="https://billauer.se/blog/2017/03/linux-dvb-israel-digital-tv-2/" target="_blank">this post</a>. /dev/dvb/adapter?/{frontend?,mux?} are used to control the device.</p>
<p>There may be other device files as well, such as net0 (for controlling network packet functionality) or ca0 for Conditional Access.</p>
<p>For more insight,  <a href="http://events.linuxfoundation.org/sites/events/files/slides/dtv_pipelines_via_mc_v4.pdf" target="_blank">this set of slides</a> may come handy.</p>
<h3>What&#8217;s in the trunk?</h3>
<p>Assuming that the DVB frontend is tuned and locked on a digital signal, there will be data in <a href="https://en.wikipedia.org/wiki/MPEG_transport_stream" target="_blank">MPEG-TS format</a> flowing out from /dev/dvb/adapter0/dvr0. Almost always, there are several TV/radio channels on a single digital transmission signal: The data stream is used to pass several types of packets, which may contain MPEG video or audio data, or other related data.</p>
<p>The packets that contain MPEG video or audio data are marked with an identifier, PID. In fact, watching a TV program consists of</p>
<ul>
<li>Tuning the DVB adapter to a certain reception frequency, and lock its demodulator on the digital signal</li>
<li>Filter out all packets belonging to a certain PID, and pass them on to an MPEG video decoder</li>
<li>Same for another PID, and pass them on to an MPEG audio decoder</li>
<li>If there are subtitles, there&#8217;s another PID to filter out, and pass on to a subtitle rendering mechanism</li>
</ul>
<p>So all in all, it&#8217;s a lot of packets <em>multiplexed</em> into a single stream of data, and it&#8217;s the receiver&#8217;s job to fish out those of interest. In order to make it easier, packets containing information that organizes the PIDs into <em>services</em>, i.e. TV and radio channels, are also transmitted on the same stream (in dedicated packets).</p>
<p>The end of <a href="https://billauer.se/blog/2017/02/linux-dvb-israel-digital-tv/" target="_blank">this post</a> shows the output of a scan with the dvbv5-scan command-line utility. It lists the information obtained in a specific digital stream in an organized manner. One thing that may be surprising about this list, is that a single service (i.e. TV channel) may contain more than a single audio PID. Which isn&#8217;t all that odd, as some TV channels may have alternative sound tracks, e.g. in different languages.</p>
<p>There&#8217;s also the <a href="http://dvbsnoop.sourceforge.net/" target="_blank">dvbsnoop</a> utility, which shows and dissects the packets of an MPEG-TS stream. Only for those interested in the really gory details.</p>
<p>By the way, in Tvheadend&#8217;s terminology, the raw stream of data that arrives from the demodulator is called <em>a mux</em>. This is a highly confusing misnomer, which probably came from idea that the packets in the stream are <em>multiplexed</em>. To the reset of the world, a &#8220;mux&#8221; is the machine that takes data from several sources and turns them into a stream. Which brings us to:</p>
<h3>Demultiplexing</h3>
<p>Assuming that the PIDs of the video and audio streams of the desired TV channel are known, there are two possibilities to filter them out:</p>
<ul>
<li>Software demuxing: Tell the DVB adapter to send everything to the dvr0 device file, and fish out the matching packets with the media player (or some intermediate software). Actually, it simply means that the media player ignores all packets that don&#8217;t have the requested PIDs.</li>
<li>Hardware demuxing: Using the e.g. /dev/dvb/adapter0/demux0 device file to command the adapter to pass through only packets with certain PIDs to the /dev/dvb/adapter0/dvr0 output.</li>
</ul>
<p>Software demuxing is the preferred choice for the typical domestic use, as it allows viewing more than one TV program at a time (assuming that both programs are on the same digital stream). Hardware demuxing is useful for viewing (or recording) TV with command-line utilities (see these <a href="https://billauer.se/blog/2017/03/linux-dvb-israel-digital-tv-2/" target="_blank">two</a> <a href="https://billauer.se/blog/2017/03/ffplay-demux-dvb/" target="_blank">posts</a> for examples of command line sessions).</p>
<h3>Watching TV for real</h3>
<p>Command-line utilities (see <a href="https://billauer.se/blog/2017/02/linux-dvb-israel-digital-tv/" target="_blank">this</a>, <a href="https://billauer.se/blog/2017/03/linux-dvb-israel-digital-tv-2/">this</a>, and <a href="https://billauer.se/blog/2017/03/ffplay-demux-dvb/" target="_blank">this</a>) can indeed be used to hack together some very basic kit for watching TV, and they are priceless for understanding why things went wrong with the fancier tools (hint: Somehow things always get wrong when video is involved).</p>
<p>But for everyday use, it&#8217;s best to let a TV streaming backend talk with the hardware. It allows fancy media center software as well as command line utilities to easily access TV channels. As of March 2017, I found Tvheadend + Kodi to be the best combination. In Kodi, I went for PVR IPTV Simple Client rather than Tvheadend&#8217;s own front end, as I&#8217;ll explain below.</p>
<p>So let&#8217;s first understand this backend / frontend business, and I&#8217;ll take Tvheadend as an example.</p>
<p>Tvheadend (formerly HTS TVheadend) is a TCP/IP server, which takes control of the DVB adapter(s). And it listens to two TCP/IP ports:</p>
<ul>
<li>HTTP Port 9981: Plain browsers can connect to http://localhost:9981/ for administration and configuration + machine readable playlists and Electronic Program Guide on certain URLs (see below). But most important: Availability of all TV channels as MPEG-TS streams, in a protocol easily accessible by a lot of software, with a plain HTTP connection.</li>
<li>HTSP Port 9982: Home Tv Streaming Protocol (invented for Tvheadend?), seems to be used only be a handful of Linux clients. It&#8217;s a one-stop shop for all TV related information, but my own experience was a bit lame. So I&#8217;ll leave this aside for now.</li>
</ul>
<p>The installation of Tvheadend hence involves making it work with the DVB adapter (which is usually simple if everything works smoothly with the command line utilities) as well as setting up the server. It&#8217;s may not be all that easy (there are worse), but it&#8217;s worth the effort (maybe <a href="https://billauer.se/blog/2017/03/tvheadend-linux/" target="_blank">my own messy jots</a> will help), because:</p>
<ul>
<li>It allows simultaneous view of several TV channels, if they&#8217;re on the same digital stream (i.e. muxed on the same frequency channel). Watch one channel waiting for the commercials to end on another&#8230;</li>
<li>View TV from any computer on the (wireless?) LAN.</li>
<li>Virtually any media playing software supports its output format, MPEG-TS. Including stuff running on Windows.</li>
<li>There are a lot of other features (Electronic Program Guide via the web interface with a browser, recording), but I&#8217;m not sure if these belong to the backend. But they may be useful to some.</li>
</ul>
<p>So let&#8217;s take a look on how the Tvheadend conveys the TV channels to its clients. For this, I&#8217;ll assume that Tvheadend is properly installed, has been set up (through the web interface) to tune on some TV channels, and that it allows access without user/password from localhost (it&#8217;s a convenient setting, and it&#8217;s safe at least for 127.0.0.1/32). And that all access is done from the localhost (even though it can be any computer with HTTP access and due permissions. If so, replace &#8220;localhost&#8221; in the examples below with the IP or domain name of the server).</p>
<p>But first&#8230;</p>
<h3>A word on IPTV / HLS (not really important for DVB, actually)</h3>
<p>We&#8217;ll make a small detour to IPTV or HLS (HTTP Live Streaming), because Tvheadend does something similar. IPTV is the commonly used name for TV channels broadcast over the internet, whether it&#8217;s live or video-on-demand like kind of broadcasts.</p>
<p>An IPTV/HLS stream is  essentially an MPEG-TS stream, similar to the DVB stream on air or cable. In order to  make its broadcast over the web easier, it&#8217;s cut into chunks, each a few  seconds long. The cuts are made on packet boundaries, so each chunk is a  legal MPEG-TS segment by itself. A plain concatenation of several subsequent chunks (with e.g. &#8220;cat&#8221;) makes a perfectly playable MPEG-TS clip. Or stream.</p>
<p>Now to the IPTV client: To start off, the IPTV client is  given an initial playlist (as a file or a URL to download this  playlist from). That playlist is an M3U file, with one or several URLs, usually a TV channel for each. When the client accesses one of these URLs to start showing a channel, it often receives another playlist, which redirects it to other URLs, which in turn might redirect it further, and so on. These playlists are often set up to allow the client to choose different paths, depending on desired bit rate, display resolution, encoding format etc.</p>
<p>Eventually, possibly after a few redirection hops, the client ends with receiving a playlist containing a list of chunks, so it has the information on where to fetch  chunks of MPEG-TS segments from. It starts fetching these chunks, concatenates then, and plays the video stream.</p>
<p>The complicated part of the HLS protocol is the traveling around playlists until the list of chunks is found. Once there, it&#8217;s just a matter of downloading those chunks, concatenating, and treating them as a DVB stream.</p>
<h3>Tvheadend&#8217;s IPTV-like interface</h3>
<p>So M3U playlists is the name of the game. Tvheadend offers the TV and radio channels it exposes as an M3U playlist, available at http://localhost:9981/playlist . In my case, it starts like this:</p>
<pre>#EXTM3U
#EXTINF:-1 tvg-id="38e914f04571f2a3f5c915872ba6e794",88FM

http://localhost:9981/stream/channelid/1880418616?ticket=B0E6E9AB06F41C13C0AEC87B7A88966BCBCCE8F4&#038;profile=pass

#EXTINF:-1 tvg-id="219e62923848dac382ed7fcd35c4ed9e",Aleph

http://localhost:9981/stream/channelid/308452897?ticket=88F2FD731008F28454AB8FF7F75BF896FA1F9C7F&#038;profile=pass

#EXTINF:-1 tvg-id="fd874e5286a13d161eb1fa011fb42731",Bet

http://localhost:9981/stream/channelid/1380878333?ticket=3BF6D86889B5DB3DFCAF2EF25D07894B653C3700&#038;profile=pass

#EXTINF:-1 tvg-id="aae608ee725cad880781301f68592dbc",Ch 1

http://localhost:9981/stream/channelid/1846077098?ticket=116EEC70D4201D82BF2A0F1E9AB7387EC9E12D30&#038;profile=pass

#EXTINF:-1 tvg-id="41d97066c9c97e348f83269a6b18e8e6",Ch 10

http://localhost:9981/stream/channelid/1718671681?ticket=757FAE1BA26561DAEDB659E707627366A5071B17&#038;profile=pass

#EXTINF:-1 tvg-id="fc2a79daaca0afd9a39123d4d0305a1f",Ch 2

http://localhost:9981/stream/channelid/1517890300?ticket=BE2E496685F892A1036B3C982888D0778784BDB4&#038;profile=pass

<span style="color: #888888;">[ ... etc ... ]</span></pre>
<p>After the #EXTM3U header, there are pair of lines for each channel: The first line contains information about the channel (in particular the display name) and the second is the URL for accessing the channel. Unlike HTS/IPTV, this isn&#8217;t a go-find-another-playlist, but it directs immediately to where the video stream can be obtained.</p>
<p>The &#8220;tvg-id&#8221; tag is not common in playlist files in general, and it  pairs the channel with its appearance in the EPG (more about that  later). If you don&#8217;t have it, you probably have an old version of  Tvheadend, which doesn&#8217;t support the EPG trickery I&#8217;m going to show  below.</p>
<p>As the URLs in the playlist are &#8220;for real&#8221;, a plain wget command can be used to record any of these channels. For example, recording from Channel 10:</p>
<pre>$ wget -O mytvshow.ts 'http://localhost:9981/stream/channelid/1718671681?ticket=757FAE1BA26561DAEDB659E707627366A5071B17&amp;profile=pass'
--2017-03-13 11:25:59--  http://localhost:9981/stream/channelid/1718671681?ticket=757FAE1BA26561DAEDB659E707627366A5071B17&amp;profile=pass
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:9981... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [video/mp2t]
Saving to: ‘mytvshow.ts’

mytvshow.ts           [           &lt;=&gt;      ]   3.10M   334KB/s</pre>
<p>This will run in principle forever until stopped with CTRL-C. The mytvshow.ts file can be played with VLC, mplayer, ffplay or any other reasonable media player.</p>
<p>These URLs to the channels don&#8217;t change once Tvheadend has been set up. It&#8217;s therefore possible to download the playlist once, edit away unwanted channels, reorder the list (noted the radio channels at the beginning of the playlist above?), possibly combine with &#8220;real&#8221; IPTV channels, and feed a media center player with the edited playlist file.</p>
<p>It&#8217;s also possible to give these URLs directly to VLC and other media players. Viewing multiple channels at once is as simple as opening several instances of VLC.</p>
<p>One word about what Tvheadend does behind the scenes. In response to the wget command above, the following went to /var/log/syslog:</p>
<pre>Mar 13 11:25:59 tv tvheadend[6410]: mpegts: 538MHz in Idan Plus T - tuning on Realtek RTL2832 (DVB-T) : DVB-T #0
Mar 13 11:25:59 tv tvheadend[6410]: subscription: 0018: "HTTP" subscribing on channel "Ch 10", weight: 100, adapter: "Realtek RTL2832 (DVB-T) : DVB-T #0", network: "Idan Plus T", mux: "538MHz", provider: "Idan +", service: "Ch 10", profile="pass", hostname="127.0.0.1", client="Wget/1.17.1 (linux-gnu)"</pre>
<p>Note that the HTTP connection resulted in a &#8220;subscription&#8221; to a certain channel within Tvheadend. This reflects the way Tvheadend mediates its resources,  a single DVB adapter in this case, to fulfill requirements of subscribers requesting services.</p>
<p>Consequently, stopping the &#8220;recording&#8221; (pressing CTRL-C) resulted in</p>
<pre>Mar 13 11:26:11 tv tvheadend[6410]: subscription: 0018: "HTTP" unsubscribing from "Ch 10", hostname="127.0.0.1", client="Wget/1.17.1 (linux-gnu)"</pre>
<p>Needless to say, something similar happens when a media player opens a connection for streaming live TV.</p>
<h3>EPG</h3>
<p>A neat feature of DVB is that data for an <a href="https://en.wikipedia.org/wiki/Electronic_program_guide" target="_blank">Electronic Program Guide</a> (EPG) is often embedded in the digital stream, so the name of the current program, along with a short description, is available when zapping to a new TV channel. As well as a TV guide to past and future programs, directly on the TV, shown neatly by the media center software.</p>
<p>There is probably <strong>no need to configure anything in Tvheadend </strong>to make this work. All those EPG grabbers available are tools for transferring information <strong>into Tvheadend</strong>, in its absence from the digital stream itself. In particular, if there&#8217;s satisfactory information in the &#8220;Electronic Program Guide&#8221; tab in Tvheadend&#8217;s web interface (http://localhost:9981/ with a browser), nothing needs to be fixed.</p>
<p>The common format for exchanging EPG information in Linux is XMLTV, which as its name implies, is in XML format. Tvheadend exports it at http://localhost:9981/xmltv or http://localhost:9981/xmltv/channels (accessing the former will cause an HTTP 302 redirection to the latter).</p>
<p>As of March 2017, this doesn&#8217;t work on Tvheadend versions available on the &#8220;stable&#8221; apt repositories. If attempting to access the URL for XMLTV from a browser results in &#8220;1 Unknown Code&#8221; appearing, an upgrade is required. Or no EPG will be available with the setup I suggest below.</p>
<p>An XMLTV file typically looks something like this:</p>
<pre>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;!DOCTYPE tv SYSTEM "xmltv.dtd"&gt;
&lt;tv generator-info-name="TVHeadend-4.1-2405~geb495a0~xenial" source-info-name="tvh-Tvheadend"&gt;
&lt;channel id="67a72084ee9a5ddb2fcd89129887bf78"&gt;
&lt;display-name&gt;Ch 99&lt;/display-name&gt;
&lt;/channel&gt;
&lt;channel id="fa723385817605edc2b138d96c259b67"&gt;
&lt;display-name&gt;Ch 33&lt;/display-name&gt;
&lt;/channel&gt;
[ ... ]
&lt;programme start="20170313113000 +0200" stop="20170313123000 +0200" channel="67a72084ee9a5ddb2fcd89129887bf78"&gt;
  &lt;title lang="heb"&gt;ועדה ש.ח כת&amp;apos; עב&amp;apos; כת&amp;apos; ער&amp;apos;&lt;/title&gt;
  &lt;desc lang="heb"&gt;ועדה ש.ח כת&amp;apos; עב&amp;apos; כת&amp;apos; ער&amp;apos;
ועדה מיוחדת לפניות הציבור:
פניות ציבור בנושא התנהלות חברת החשמל בגביית תשלומים ומדיניות ניתוקי חשמל לצרכנים
&lt;/desc&gt;
&lt;/programme&gt;
&lt;programme start="20170313121000 +0200" stop="20170313124500 +0200" channel="<span style="color: #ff0000;"><strong>41d97066c9c97e348f83269a6b18e8e6</strong></span>"&gt;
  &lt;title lang="heb"&gt;ראש בראש כת&amp;apos; עב&amp;apos; &lt;/title&gt;
  &lt;sub-title lang="heb"&gt;פרק 345&lt;/sub-title&gt;
  &lt;desc lang="heb"&gt;פרק 345
העיתונאי חגי סגל מארח ומתווכח. כת&amp;apos; עב&amp;apos;
&lt;/desc&gt;
&lt;/programme&gt;
&lt;programme start="20170313124500 +0200" stop="20170313132000 +0200" channel="41d97066c9c97e348f83269a6b18e8e6"&gt;
  &lt;title lang="heb"&gt;מעונן חלקית כת&amp;apos; עב&amp;apos; &lt;/title&gt;
  &lt;sub-title lang="heb"&gt;פרק 286&lt;/sub-title&gt;
  &lt;desc lang="heb"&gt;פרק 286
תחזית פוליטית: מבט אל השבוע הפוליטי והפרלמנטרי. מגישה: הדס לוי סצמסקי כת&amp;apos; עב&amp;apos;
&lt;/desc&gt;
[ ... ]
&lt;/tv&gt;</pre>
<p>Note that the long hex blob marked red above matches the tvg-id entry of Channel 10 in the playlist given above. This allows pairing between an MPEG-TS stream and its info in the XMLTV file, and hence displaying the current TV program info for its respective channel.</p>
<h3>Using Kodi as the front end</h3>
<p>Kodi is a convenient front end for viewing TV on a media center computer, living room style. I suggest using the PVR IPTV Simple Client with a local file playlist, in particular because of the simplicity of this solution. And that it works so well.</p>
<p>The setup is fairly straightforward. First, install the plugin:</p>
<pre>$ sudo apt-get install kodi-pvr-iptvsimple</pre>
<p>and then, after having Kodi up and running, enable and set up the IPTV Simple Client as follows:</p>
<ul>
<li>Change setting level to Advanced</li>
<li>System &gt; Settings &gt; Enable TV</li>
<li>Enable and Configure PVR IPTV Simple Client  (System &gt; Settings &gt; Add-ons &gt; My add-ons &gt; PVR  Clients &gt; PVR IPTV Simple Client).  Set the playlist to local file, and pick one edited (as suggested above).</li>
<li>Moving on to the   EPG Settings tab, set Location to Remote Path, and XMLTV URL to   http://localhost:9981/xmltv. As mentioned above, this requires a version   of Tvheadend that supports XMLTV export. Check it manually with a browser.</li>
</ul>
<p>The EPG interface isn&#8217;t necessary to watch TV properly, but makes Kodi display what&#8217;s on each channel in a neat way. As far as I know, the only alternative way to have  EPG working with Kodi and Tvheadend is the Tvheadend Kodi plugin, which gave me errors all the time with the 4.09 version of Tvheadend.</p>
<p>Kodi has a screensaver enabled by default, which causes the screen to appear darker after a few minutes. It&#8217;s possible to turn it off under System &gt; Settings &gt; Appearance &gt; Screensaver.</p>
<h3>Summary</h3>
<p>Use Kodi if you want it to look like a set-top-box, or vlc, ffplay or mplayer for a more computerish experience. Tvheadend gives a simple and robust interface to all of these, leaving the gory details to be forgotten. Once you&#8217;ve been through the setup, of course.</p>
<p>If Tvheadend doesn&#8217;t play ball, go for the command-line utilities.</p>
<p>And if all of this takes forever to complete, remember: TV is a waste of time either way.</p>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2017/03/dvb-linux-primer-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brix media center Linux installation notes</title>
		<link>https://billauer.se/blog/2017/03/brix-linux-media-center-notes/</link>
		<comments>https://billauer.se/blog/2017/03/brix-linux-media-center-notes/#comments</comments>
		<pubDate>Sun, 12 Mar 2017 15:09:45 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[DVB]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=5153</guid>
		<description><![CDATA[Intro These are my jots as I installed Linux Mint 18.1 on a Gigabyte GB-BACE-3160 Compact PC with a 240 GB SSD hard disk and 8 GB RAM, for the purpose of driving my TV in the living room. Not all issues are solved yet. General notes Use ssh -X. It allows X-windows to open [...]]]></description>
			<content:encoded><![CDATA[<h3>Intro</h3>
<p>These are my jots as I installed Linux Mint 18.1 on a Gigabyte GB-BACE-3160 Compact PC with a 240 GB SSD hard disk and 8 GB RAM, for the purpose of driving my TV in the living room. Not all issues are solved yet.</p>
<h3>General notes</h3>
<ul>
<li>Use ssh -X. It allows X-windows to open on the calling computer.</li>
<li>Uname: Linux tv 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux</li>
<li>Mint 18.1 (&#8220;Serena&#8221;) is a derivative of Ubuntu 16.04 (&#8220;Xenial&#8221;). This can be verified by looking at /etc/apt/sources.list.d/official-package-repositories.list.</li>
<li>There are a lot of intel_* utilities to look at installed.</li>
<li>Unsolved problem: System boots up with kswap0 taking 100% CPU, and no desktop comes up. The problem seems to be that since there&#8217;s no swap on my system + the &#8220;cinnamon&#8221; process running at 100%, requesting more and more memory until it runs out, and kswap0 tries to fix it.<br />
<strong>WORKAROUND: Kill, as root, the &#8220;mdm&#8221; process, father of the X window tree.</strong> This restarts cinnamon.<br />
Bad omen: cinnamon gets stuck sometimes and sometimes not, even in subsequent overlayfs mode bootups (so all files in the filesystems were the same initially).<br />
There is nothing that stands out in .xsession-errors on a failed boot vs. a successful one (from cold or after killing mdm).</li>
<li>There&#8217;s still an issue with mouse pointer traces (in particular going on and off the shutdown confirmation dialog box), and it seems to be an HDMI-only issue. The disappearing and sluggish mouse seems to have been solved by disabling the splash on Grub (which plays with the DRM).</li>
<li>Desktop background image:
<pre>$ gsettings get org.gnome.desktop.background picture-uri
'/usr/share/backgrounds/linuxmint/default_background.jpg'</pre>
</li>
</ul>
<h3>Installation flow</h3>
<ul>
<li>BIOS is invoked by pressing the &#8220;Delete&#8221; button (constantly) during powerup</li>
<li>Changed the OS in the BIOS to Linux (not clear why it matters)</li>
<li>Always power on when AC power is applied: In the BIOS menu, Chipset &gt; Restore AC Power Loss set to &#8220;Power on&#8221;.</li>
<li>Pushed USB stick with Linux Mint 18.1 Cinnamon. Booted with no issues</li>
<li>Installed ssh for remote access (ssh daemon starts immediately after installation)
<pre># apt-get update
# apt-get install ssh
# passwd mint</pre>
</li>
<li>Set partition table manually: First partition for boot, 250 MB. Second partition for LVM, 120 GB. Leaving half the disk unpartitioned. LVM can easily use disk space from another partition in the future, if that&#8217;s needed. So it read in the end (fdisk):
<pre>Command (m for help): p
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x34449fd0

Device     Boot  Start       End   Sectors  Size Id Type
/dev/sda1         2048    514047    512000  250M 83 Linux
/dev/sda2       514048 252172287 251658240  120G 8e Linux LVM</pre>
</li>
<li>Created one big logical volume on /dev/sda2:
<pre># pvcreate /dev/sda2
  Physical volume "/dev/sda2" successfully created
# vgcreate vg_ssd2 /dev/sda2
  Volume group "vg_ssd2" successfully created
# lvcreate vg_ssd2 -l 100%FREE -n lv_root
  Logical volume "lv_root" created.</pre>
</li>
<li>Launched the &#8220;Install Linux Mint&#8221;</li>
<li>During installation, enabled installation of third party software (mp3 and media stuff). Installation type: &#8220;Something else&#8221; to pick what goes where. No swap partition. Installation went through cleanly</li>
<li>Installed git (&#8220;apt-get install git&#8221;) and created a repository in root</li>
<li>Installed the ssh daemon (apt-get install ssh)</li>
<li>Stop the Linux splash. Give me some real boot text output, and this probably also solves some weird issues with the graphics card (mouse pointer traces and sluggish mouse response?):<br />
Edit /etc/default/grub, changing GRUB_CMDLINE_LINUX_DEFAULT=&#8221;quiet splash&#8221; to GRUB_CMDLINE_LINUX_DEFAULT=&#8221;", and then update the actual GRUB2 file from the /etc/grub.d and the file just edited into /boot/grub/grub.cfg&nbsp;</p>
<pre># update-grub</pre>
</li>
<li>Also, make Grub&#8217;s menu always appear, since pressing Shift at bootup doesn&#8217;t work on this platform. So edit /etc/default/grub once again, uncommenting (explained in Ubuntu&#8217;s <a href="https://help.ubuntu.com/community/Grub2" target="_blank">GRUB2 doc</a>):
<pre>GRUB_HIDDEN_TIMEOUT=0</pre>
<p>and setting</p>
<pre>GRUB_TIMEOUT=2
GRUB_RECORDFAIL_TIMEOUT=2</pre>
<p>and once again, run update-grub. The GRUB_RECORDFAIL_TIMEOUT part is required for all the times the computer is turned off abruptly (which is fine with an overlayfs). Otherwise GRUB sticks to 30 seconds all the time.</p>
<p>For more advanced GRUB trickery, see <a title="Installing GRUB 2 manually with rescue-like techniques" href="https://billauer.se/blog/2024/07/installing-grub-rescue/" target="_blank">this post</a>.</li>
<li>DIDN&#8217;T: The kernel console boot output is given with some weird blocks instead of characters (The Matrix style) until the framebuffer module is initialized, and the screen goes into graphical mode, after which all looks OK. This can be fixed by uncommenting
<pre>#GRUB_TERMINAL=console</pre>
<p>in /etc/default/grub, and running update-grub. The result is that these two seconds of kernel messages that are OK, but GRUB&#8217;s own menu is shown painfully slow. So I remain with the Matrix kernel.</li>
<li><strong><a href="https://support.plesk.com/hc/en-us/articles/213909965-How-to-disable-AppArmor-" target="_blank">Ditch</a> <a href="https://help.ubuntu.com/lts/serverguide/apparmor.html" target="_blank">Apparmor</a></strong>,  because it messes up things with overlayroot, and probably would cause  all kind of weirdnesses regardless, exactly like SELinux did in the past  (no chkconfig in Xenial).
<pre>$ sudo update-rc.d apparmor remove</pre>
</li>
<li><strong>Fix /bin/sh symlink</strong>: By default, it goes to /bin/dash (someone had a bad sense of humor). Change it /bin/bash. Won&#8217;t make any difference in the matters of this post, but it will bite sometime in the long term.</li>
<li>Add LSB (Linux Standard Base), among others for getting  ld  symlinks in /lib64/. Once again, won&#8217;t make any difference right now, but it should be there:
<pre># apt-get install lsb-core</pre>
</li>
<li>Add group eli manually:
<pre># addgroup --gid <span style="color: #888888;">nnn</span> eli</pre>
</li>
<li>And user:
<pre># adduser --gid <span style="color: #888888;">nnn</span> --uid <span style="color: #888888;">nnnn</span> eli
Adding user `eli' ...
Adding new user `eli' (<span style="color: #888888;">nnnn</span>) with group `eli' ...
Creating home directory `/home/eli' ...
Copying files from `/etc/skel' ...</pre>
</li>
<li>Allow no-password access of all members of sudo group (only added NOPASSWD part). From /etc/sudoers:
<pre>%sudo   ALL=(ALL:ALL) NOPASSWD: ALL</pre>
</li>
<li>Enable auto login: Pick the &#8220;Login Window&#8221; GUI application</li>
<li>Assign a fixed address on DHCP daemon and a host name at /etc/hosts</li>
<li>Install NFS client:
<pre># apt-get install nfs-common</pre>
</li>
<li>Copy my own .bashrc stuff into &#8220;eli&#8221; and &#8220;root&#8221; users</li>
<li>Install Xemacs:
<pre># apt-get install xemacs21</pre>
</li>
<li>Allowing X-sessions over ssh from root user, following <a href="http://unix.stackexchange.com/questions/110558/su-with-error-x11-connection-rejected-because-of-wrong-authentication/118295" target="_blank">this post</a>. As root,
<pre># xauth merge /home/eli/.Xauthority
xauth:  file /root/.Xauthority does not exist
# cd ~/
# ln -s /home/eli/.Xauthority</pre>
<p>Note that I symlinked the file only because it didn&#8217;t exist before, and copying it makes the trick only until the next reboot.</li>
<li>Set the power options (never turn off screen) and screensaver (ditto, it&#8217;s done separately)</li>
<li>Install kodi, <span style="text-decoration: line-through;">MythTV</span> and mplayer (vlc was already installed):
<pre>$ sudo apt-get install --install-suggests kodi
$ <span style="text-decoration: line-through;">sudo apt-get install --install-suggests mythtv</span>
$ sudo apt-get install --install-suggests mplayer</pre>
</li>
<li>Install PVRs (mythtv and dvbviewer were probably redundant)
<pre># apt-get install kodi-pvr-iptvsimple
<span style="text-decoration: line-through;"># apt-get install --install-suggests kodi-pvr-dvbviewer
# apt-get install kodi-pvr-mythtv</span>
# apt-get install kodi-pvr-hts</pre>
</li>
<li>Install DVB command-line utilities, which didn&#8217;t prove very useful  (previously dvb-utils)
<pre># apt-get install dvb-apps</pre>
</li>
<li>Install w_scan, useful for DVB channel scanning
<pre># apt-get install w-scan</pre>
</li>
<li>After changing the resolution to 1920x1080 the menu panel at the bottom was too low down, making it almost invisible. This was the Samsung monitor&#8217;s fault, which needed to be adjusted to show the full screen.</li>
<li>(No need to install kernel headers nor Make / compiler. All included out of the box)</li>
<li>Install apt-file:
<pre>$ sudo apt-get install apt-file
$ apt-file update</pre>
</li>
<li>Installed intel-graphics-update-tool_2.0.2 (I messed up a bit with it, see below. Problem was that I attempted to install 2.0.3, which relates to Ubuntu 16.10, but Mint 18.1 is Ubuntu 16.04).  It refused, as it looked at /etc/lsb-release, founding out that the distro is Mint. So <a href="https://billauer.se/blog/2017/02/i915-brix-drm-graphics/" target="_blank">I faked it</a>.
<pre>$ sudo dpkg -i intel-graphics-update-tool_2.0.2_amd64.deb
$ sudo apt-get -f install
$ sudo intel-graphics-update-tool</pre>
</li>
<li>Some DVB command line tests (see separate post)</li>
<li>Overlay root (see separate post)</li>
<li>Turn off ureadahead service (for faster boot, but does it make sense on a SSD device?)
<pre># systemctl disable ureadahead</pre>
</li>
<li>Install Tvheadend (see <a href="https://billauer.se/blog/2017/03/tvheadend-linux/" target="_blank">separate post</a>)</li>
<li><span style="text-decoration: line-through;">Add Kodi and Terminal as Startup Applications (using the desktop&#8217;s Menu &gt; Startup Applications).</span> Don&#8217;t. It&#8217;s important to see the desktop screen so the computer&#8217;s mode is clear.</li>
</ul>
<h3>Kodi setup</h3>
<p>General note: Kodi remembers the navigation position in sub-menus when a category is entered. If things get too confusing, just restart Kodi, so the navigation paths in the docs match.</p>
<ul>
<li>Change setting level to Advanced</li>
<li>System &gt; Settings &gt; Enable TV</li>
<li>Enable and Configure PVR IPTV Simple Client with a local file playlist (System &gt; Settings &gt; Add-ons &gt; My add-ons &gt; PVR Clients &gt; PVR IPTV Simple Client). Grab a playlist from  http://localhost:9981/playlist and append hand-picked entries. In the  EPG Settings tab, set Location to Remote Path, and XMLTV URL to  http://localhost:9981/xmltv. This requires a recent (post-4.0.9) version  of Tvheadend.</li>
<li>On exit, use Ctrl-Alt-F1 and then Ctrl-Alt-F7 to get back from the blank screen it leaves (if necessary)</li>
<li><strong>Don&#8217;t</strong> install a TVheadend plugin. It got the original Tvheadend stuck, and the newer one requires picking a channel twice to view it. Besides, the Simple Client covers all needs with a single playlist.</li>
</ul>
<h3>Fixing graphics issues</h3>
<p>Downloaded intel-graphics-update-tool_2.0.3_amd64.deb from <a href="https://01.org/linuxgraphics" target="_blank">Intel Graphics for Linux</a> and ran</p>
<pre>$ sudo dpkg -i intel-graphics-update-tool_2.0.3_amd64.deb</pre>
<p>but that failed due to a dependency problem:</p>
<pre>Selecting previously unselected package intel-graphics-update-tool.
(Reading database ... 207385 files and directories currently installed.)
Preparing to unpack intel-graphics-update-tool_2.0.3_amd64.deb ...
Unpacking intel-graphics-update-tool (2.0.3) ...
dpkg: dependency problems prevent configuration of intel-graphics-update-tool:
 intel-graphics-update-tool depends on libpackagekit-glib2-18 (&gt;= 0.9.4); however:
  Package libpackagekit-glib2-18 is not installed.
 intel-graphics-update-tool depends on fonts-ancient-scripts; however:
  Package fonts-ancient-scripts is not installed.

dpkg: error processing package intel-graphics-update-tool (--install):
 dependency problems - leaving unconfigured
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu5) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Errors were encountered while processing:
 intel-graphics-update-tool</pre>
<p>Rumor has it that apt-get -f install can fix that, but it said:</p>
<pre>$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
  intel-graphics-update-tool
0 upgraded, 0 newly installed, 1 to remove and 128 not upgraded.</pre>
<p>Remove? Why? What have I done? How about this:</p>
<pre>$ sudo apt-get install --fix-missing
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 intel-graphics-update-tool : Depends: libpackagekit-glib2-18 (&gt;= 0.9.4) <span style="color: #ff0000;"><strong>but it is not installable</strong></span>
                              Depends: fonts-ancient-scripts but it is not installed</pre>
<p>So I ran apt-get -f install and dropped intel-graphics-update-tool.</p>
<h3>Directories that change</h3>
<p>In the event of restoring the entire root filesystem from backup, try to retain these:</p>
<ul>
<li>/.git (the main git repository)</li>
<li>/home/eli (of course)</li>
<li>/home/eli/.kodi (included in /home/eli, but this is where Kodi keeps its info)</li>
<li>/home/hts/ (where Tvheadend keeps its settings and logs)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2017/03/brix-linux-media-center-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tvheadend jots</title>
		<link>https://billauer.se/blog/2017/03/tvheadend-linux/</link>
		<comments>https://billauer.se/blog/2017/03/tvheadend-linux/#comments</comments>
		<pubDate>Sun, 12 Mar 2017 14:59:03 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[DVB]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=5151</guid>
		<description><![CDATA[This is a lot of random jots as I set up Tvheadend. As it was a bit of a battle, things may not be consistent below. There are some details below specific to my own environment (e.g. LAN addresses). Environment: Linux Mint 18.1 running a 4.4.0-53-generic kernel, receiving DVB-T in Haifa, Israel with a HD-901T2 [...]]]></description>
			<content:encoded><![CDATA[<p>This is a lot of random jots as I set up Tvheadend. As it was a bit of a battle, things may not be consistent below. There are some details below specific to my own environment (e.g. LAN addresses).</p>
<p>Environment: Linux Mint 18.1 running a 4.4.0-53-generic kernel, receiving DVB-T in Haifa, Israel with a <a title="Linux / DVB: Playing with a HD-901T2 DVB-T2 USB stick" href="https://billauer.se/blog/2017/03/linux-dvb-israel-digital-tv-2/" target="_blank">HD-901T2 DVB-T2 USB stick</a>.</p>
<h3>Installation</h3>
<p>This is the backend server for accessing the DVB tuner. Any software  that is used to view live TV expects some kind of backend like this.</p>
<p>Add TVheadend repository, following <a href="https://tvheadend.org/projects/tvheadend/wiki/AptRepository" target="_blank">this guide</a>: The following file added as /etc/apt/sources.list.d/tvheadend.list:</p>
<pre>deb https://dl.bintray.com/tvheadend/deb xenial stable</pre>
<p>and loaded the key:</p>
<pre># apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
Executing: /tmp/tmp.3BLJZuWTSs/gpg.1.sh --keyserver
hkp://keyserver.ubuntu.com:80
--recv-keys
379CE192D401AB61
gpg: requesting key D401AB61 from hkp server keyserver.ubuntu.com
gpg: key D401AB61: public key "Bintray (by JFrog) &lt;bintray@bintray.com&gt;" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)</pre>
<p>and as usual,</p>
<pre># apt-get update</pre>
<p>And install</p>
<pre># apt-get install tvheadend xmltv-util</pre>
<p>ignoring the lack of verification (living on the edge):</p>
<pre>WARNING: The following packages cannot be authenticated!
  tvheadend
Install these packages without verification? [y/N] y</pre>
<p>xmltv-util was added since it was suggested when requesting the installation of tvheadend.</p>
<p>As part of the installation of Tvheadend, I was prompted for a  username a password for the dedicated tvheadend user. This is the  user/password pair for accessing the web interface, and not the Linux  user which is generated during the installation (named &#8220;hts&#8221; was  created, with no password assigned, i.e. impossible to login with  password).</p>
<p>And then configure the server by connecting to port 9981 with a plain web browser.</p>
<p>Following <a href="http://docs.tvheadend.org/configure_tvheadend/" target="_blank">this guide</a>:</p>
<ul>
<li>Went for the DVB Inputs tab, where /dev/dvb/adapter0 was found.  <span style="text-decoration: line-through;">Uhhh, there are three entries, two for Panasonic MN88473 (with DVB-C and DVB-T each) and an entry for Realtek RTL2832 (DVB-T).</span> Picked the Realtek DVB-T #0 entry, as the Panasonic adapters can&#8217;t supply BER and SNR (<a href="https://billauer.se/blog/2017/03/tvheadend-udev-usb-dvb/" target="_blank">and I killed it</a>),  as indicated in the debug output when this is attempted. Ticked the  &#8220;enabled&#8221; checkbox. &#8220;Initial Scan&#8221;  and &#8220;Idle scan&#8221; should be ticked as  well. Click Save.</li>
<li>Went to the Networks Tab, and created a new DVB-T network, named it   Idan Plus. Check &#8220;Skip Initial scan&#8221; (it slows down startup). Set  Pre-defined Muxes to Israel:  il-All.</li>
<li>Going back to the DVB Inputs tab, associate the DVB-T entry with the   Network just created (drop-down menu for Networks). Click Save.</li>
<li>Under &#8220;Muxes&#8221;, monitor the scan status on the 538 MHz mux (for   Haifa) should go from PEND to IDLE and the result to &#8220;OK&#8221;. It takes a   couple of minutes or so before anything happens.</li>
<li>Disable the failed mux (not sure if it matters)</li>
<li>Go to Services, and find a nice list of them.</li>
<li>Map channels: On the Channel/EPG tab, click on the &#8220;Map Services&#8221; button, and accept the defaults.</li>
<li><span style="text-decoration: line-through;">Add an access entry for kodi: Set the username to e.g.  kodiclient,  set a password. Allow all interfaces except admin, set the  streaming  profile to htsp, and check all functionalities (video  recorder to All  DVR-rw).</span></li>
<li>Add an access entry for no-password users: Set the network prefix to  &#8220;10.1.1.0/24;10.10.0.0/16;127.0.0.1/32&#8243; with no credential request: Set  the username to *,  and the  password to * (that is, a single &#8220;*&#8221; char  each). Allow all interfaces, set the streaming  profile  to htsp, and  check all functionalities (video recorder to All  DVR-rw).</li>
</ul>
<p>This is what a <strong>failed scan</strong> looks like (on tvheadend&#8217;s debug output):</p>
<pre>2017-03-10 11:03:37.000 [   INFO] mpegts: 514MHz in Idan Plus - tuning on Realtek RTL2832 (DVB-T) : DVB-T #0
2017-03-10 11:03:37.000 [   INFO] opentv-ausat: registering mux 514MHz in Idan Plus
2017-03-10 11:03:37.004 [   INFO] subscription: 0002: "scan" subscribing to mux "514MHz", weight: 5, adapter: "Realtek RTL2832 (DVB-T) : DVB-T #0", network: "Idan Plus", service: "Raw PID Subscription"
2017-03-10 11:03:40.055 [WARNING] linuxdvb: Unhandled signal scale: 0
2017-03-10 11:03:40.069 [WARNING] linuxdvb: Unable to provide UNC value.
2017-03-10 11:03:42.000 [   INFO] mpegts: 514MHz in Idan Plus - scan no data, failed
2017-03-10 11:03:42.000 [   INFO] subscription: 0002: "scan" unsubscribing
2017-03-10 11:03:42.002 [   INFO] mpegts: 538MHz in Idan Plus - tuning on Realtek RTL2832 (DVB-T) : DVB-T #0
2017-03-10 11:03:42.002 [   INFO] opentv-ausat: registering mux 538MHz in Idan Plus
2017-03-10 11:03:42.009 [   INFO] subscription: 0004: "scan" subscribing to mux "538MHz", weight: 5, adapter: "Realtek RTL2832 (DVB-T) : DVB-T #0", network: "Idan Plus", service: "Raw PID Subscription"
2017-03-10 11:03:47.000 [   INFO] <span style="color: #ff0000;"><strong>mpegts: 538MHz in Idan Plus - scan no data, failed</strong></span>
2017-03-10 11:03:47.000 [   INFO] subscription: 0004: "scan" unsubscribing</pre>
<p>THIS IS THE SETTING FOR THE OLD Sin Hon TDH 601 / HD809 USB dongle. Just skip.</p>
<ul>
<li><span style="text-decoration: line-through;">Went for the DVB Inputs tab, where /dev/dvb/adapter0 was  found. Picked the DVB-T #0 entry (there was a DVB-C entry as well, but  this is for cable TV frequencies). Ticked the &#8220;enabled&#8221; checkbox.  &#8220;Initial Scan&#8221; and &#8220;Idle scan&#8221; should be ticked as well. Click Save.</span></li>
<p><span style="text-decoration: line-through;"> </span></p>
<li><span style="text-decoration: line-through;">Went to the Networks Tab, and created a new DVB-T network,  named it Idan Plus. Uncheck &#8220;Skip Initial scan&#8221;. Set Pre-defined Muxes  to Israel: il-All.</span></li>
<p><span style="text-decoration: line-through;"> </span></p>
<li><span style="text-decoration: line-through;">Going back to the DVB Inputs tab, associate the DVB-T entry  with the Network just created (drop-down menu for Networks). Click Save.</span></li>
<p><span style="text-decoration: line-through;"> </span></p>
<li><span style="text-decoration: line-through;">Under &#8220;Muxes&#8221;, monitor the scan status on the 538 MHz mux  (for Haifa) should go from PEND to IDLE and the result to &#8220;OK&#8221;. It takes  a couple of minutes or so before anything happens.</span></li>
<p><span style="text-decoration: line-through;"> </span></p>
<li><span style="text-decoration: line-through;">Disable the failed mux (not sure if it matters)</span></li>
<p><span style="text-decoration: line-through;"> </span></p>
<li><span style="text-decoration: line-through;">Go to Services, and find a nice list of them.</span></li>
<p><span style="text-decoration: line-through;"> </span></p>
<li><span style="text-decoration: line-through;">Map channels: On the Channel/EPG tab, click on the &#8220;Map Services&#8221; button, and accept the defaults.</span></li>
<p><span style="text-decoration: line-through;"> </span></p>
<li><span style="text-decoration: line-through;">Add an access entry for kodi: Set the username to e.g.  kodiclient, set a password. Allow all interfaces except admin, set the  streaming profile to htsp, and check all functionalities (video recorder  to All DVR-rw).</span></li>
<p><span style="text-decoration: line-through;"> </span></ul>
<p><span style="text-decoration: line-through;"> </span></p>
<pre># service tvheadend stop</pre>
<p>or, alternatively:</p>
<pre># systemctl stop tvheadend.service</pre>
<p>(and start for turning it on). After stopping, running the service from console, as root:</p>
<pre># /usr/bin/tvheadend -f -u hts -g video</pre>
<p>This launches a deamon (-f means &#8220;fork as daemon&#8221;), after changing the user ID and group as given by the flags.</p>
<p>To run it in the foreground, with debug messages to console,</p>
<pre># /usr/bin/tvheadend --trace --debug -d -u hts -g video</pre>
<p>Which outputs during a successful scan of Idan Plus in Haifa:</p>
<pre>2017-02-06 14:24:58.000 [   INFO] mpegts: 538MHz in Idan Plus - tuning on Silicon Labs Si2168 : DVB-T #0
2017-02-06 14:24:58.001 [   INFO] opentv-ausat: registering mux 538MHz in Idan Plus
2017-02-06 14:24:58.007 [   INFO] subscription: 0007: "scan" subscribing to mux "538MHz", weight: 5, adapter: "Silicon Labs Si2168 : DVB-T #0", network: "Idan Plus", service: "Raw PID Subscription"
2017-02-06 14:24:59.028 [WARNING] eit: invalid checksum (len 489, errors 1)
2017-02-06 14:24:59.698 [WARNING] mpegts: mux 514MHz in Idan Plus changed from DVBT freq 514000000 bw 8MHz cons QAM/16 hier NONE code_rate 2/3:NONE guard 1/4 trans 8k plp_id -1
2017-02-06 14:24:59.698 [WARNING] mpegts: mux 514MHz in Idan Plus changed to   DVBT freq 514000000 bw 8MHz cons QAM/16 hier NONE code_rate 2/3:2/3 guard 1/4 trans 8k plp_id -1
2017-02-06 14:24:59.700 [WARNING] mpegts: mux 538MHz in Idan Plus changed from DVBT freq 538000000 bw 8MHz cons QAM/16 hier NONE code_rate 2/3:NONE guard 1/4 trans 8k plp_id -1
2017-02-06 14:24:59.700 [WARNING] mpegts: mux 538MHz in Idan Plus changed to   DVBT freq 538000000 bw 8MHz cons QAM/16 hier NONE code_rate 2/3:2/3 guard 1/4 trans 8k plp_id -1
2017-02-06 14:25:03.000 [   INFO] mpegts: 538MHz in Idan Plus - scan complete
2017-02-06 14:25:03.000 [   INFO] subscription: 0007: "scan" unsubscribing
2017-02-06 14:25:03.004 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0027/39] (missing in PAT/SDT)
2017-02-06 14:25:03.004 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0026/38] (missing in PAT/SDT)
2017-02-06 14:25:03.004 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0025/37] (missing in PAT/SDT)
2017-02-06 14:25:03.004 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0023/35] (missing in PAT/SDT)
2017-02-06 14:25:03.004 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0022/34] (missing in PAT/SDT)
2017-02-06 14:25:03.004 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0021/33] (missing in PAT/SDT)
2017-02-06 14:25:03.004 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0020/32] (missing in PAT/SDT)
2017-02-06 14:25:03.004 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 001F/31] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0014/20] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0013/19] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0012/18] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0011/17] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 0010/16] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 000F/15] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 000E/14] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 000D/13] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 000C/12] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 000B/11] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: disabling service Idan Plus/538MHz/{PMT:0} [sid 000A/10] (missing in PAT/SDT)
2017-02-06 14:25:03.005 [   INFO] mpegts: 514MHz in Idan Plus - tuning on Silicon Labs Si2168 : DVB-T #0
2017-02-06 14:25:03.005 [   INFO] opentv-ausat: registering mux 514MHz in Idan Plus
2017-02-06 14:25:03.012 [   INFO] subscription: 0009: "scan" subscribing to mux "514MHz", weight: 5, adapter: "Silicon Labs Si2168 : DVB-T #0", network: "Idan Plus", service: "Raw PID Subscription"
2017-02-06 14:25:08.000 [   INFO] mpegts: 514MHz in Idan Plus - scan no data, failed
2017-02-06 14:25:08.000 [   INFO] subscription: 0009: "scan" unsubscribing</pre>
<p>An .m3u8 playlist can be obtained with http://localhost:9981/playlist (or was it <a href="https://tvheadend.org/boards/5/topics/3997?r=6040#message-6040" target="_blank">http://localhost:9981/playlist/channels</a>?). Anyhow, if Tvheadend doesn&#8217;t like the URL, it goes &#8220;1 Unknown code&#8221;).</p>
<p>The playlist can be used with e.g. VLC connect to to play channels,  possible several different channels  from the same DVB adapter, if they  share the same broadcast frequency (  = same mux in Tvheadend  terminology).</p>
<h3>Where tvheadend keeps its configuration</h3>
<p>Short answer: /home/hts/.hts/tvheadend/. Don&#8217;t get scared by all those SHA1-named files. It&#8217;s not a git repo. These are plain, readable, text files which are easy to understand.</p>
<p>In particular, the DVR timers are stored in /home/hts/.hts/tvheadend/dvr/timerec/, one file for each timer task. Really simple. The file names don&#8217;t change when the configuration changes, so I guess these files can be tracked with version control.</p>
<h3>Source digging</h3>
<p>Grabbing the repository:</p>
<pre>$ git clone https://github.com/tvheadend/tvheadend</pre>
<p>Using &#8220;git blame&#8221; on src/webui/webui.c, it&#8217;s evident that Jaroslav Kysela added the /xmltv feature on Oct. 28th 2015 (as he <a href="https://tvheadend.org/issues/2527#note-6" target="_blank">said himself</a>), and there are functional changes running as far as commit ID a87689803093e303ac4d458d35ac92c1bfc41f96 of Nov 11th 2015, which does XML escaping.</p>
<p><a href="https://gist.github.com/gabonator/c65bcea34d3e51647a7b" target="_blank">This post</a> shows some JSON API as well.</p>
<h3>Upgrade tvheadend</h3>
<p>Since Kodi&#8217;s HTSP Tvheadend client worked horribly, I went for IPTV simple client from one of those <a href="https://www.strongiptv.co.uk/">IPTV providers in the UK</a>. But in order to get the EPG feature working, I need a Tvheadend version that exports an XMLTV file through http. Ironically, the upgrade improved things with the HTSP client significantly, but there was still a need to double-click a channel twice to zap.</p>
<p>Change /etc/apt/sources.list.d/tvheadend.list to</p>
<pre>deb https://dl.bintray.com/tvheadend/deb xenial <span style="color: #ff0000;"><strong>unstable</strong></span></pre>
<p>and go</p>
<pre># apt-get update
# apt-get install tvheadend</pre>
<p>Ignore warning that the package can&#8217;t be authenticated, and go ahead installing (upgrading, in my case). The new revision was 4.1-2405~geb495a0~xenial, according to &#8220;About&#8221; in the Web UI, which is git commit eb495a0984245c37a4474c7d3984acdd34edc071 from Jan 2nd, 2017. So not the absolutely latest, but definitely covers the /xmltv feature.</p>
<p>Files that were updated: /usr/bin/tvheadend, files under /usr/share/doc/tvheadend and a lot under /usr/share/tvheadend, and the man page (plus minus, this is based upon files an overlay filesystem).</p>
<p>Alternatively, this is the manual installation of the same. Look for <a href="https://dl.bintray.com/tvheadend/deb/pool/4.1/4.1-2405~geb495a0/" target="_blank">tvheadend_4.1-2405~geb495a0~xenial_amd64.deb</a> (it&#8217;s on my hard disk as well, under /storage/tv-mediacenter-stuff). Remove old version and install new:</p>
<pre># apt-get remove tvheadend
# dpkg -i tvheadend_4.1-2405~geb495a0~xenial_amd64.deb</pre>
<p>This revision works great.</p>
<h3>Some useful access URLs</h3>
<p>Assuming that the server is on localhost:</p>
<ul>
<li>Obtain m3U playlist of all live TV channels: http://localhost:9981/playlist</li>
<li>Obtain XMLTV file for EPG: http://localhost:9981/xmltv (or better, http://localhost:9981/xmltv/channels)</li>
<li>Watch TV channels directly from a browser (rather crude look, but works): http://localhost:9981/tv.html</li>
<li>Recorder log: http://localhost:9981/simple.html</li>
</ul>
<p>And as mentioned above, there as several URLs for JSON formatted info on <a href="https://gist.github.com/gabonator/c65bcea34d3e51647a7b" target="_blank">this post</a>. I suppose I&#8217;ll add more as I come across these&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2017/03/tvheadend-linux/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>EDID info from mini HDMI2AV module (HDMI to RCA CVBS)</title>
		<link>https://billauer.se/blog/2017/03/edid-hdmi2av-rca-cvbs/</link>
		<comments>https://billauer.se/blog/2017/03/edid-hdmi2av-rca-cvbs/#comments</comments>
		<pubDate>Sun, 12 Mar 2017 06:42:59 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[DVB]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=5138</guid>
		<description><![CDATA[This is the information obtained with xrandr from the HDMI to AV converter  (Composite Video + Audio on RCA plugs) shown above: Screen 0: minimum 8 x 8, current 1280 x 720, maximum 32767 x 32767 DP1 disconnected (normal left inverted right x axis y axis) DP2 disconnected (normal left inverted right x axis y [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://billauer.se/blog/wp-content/uploads/2017/03/hdmi2av.jpg"><img class="aligncenter size-medium wp-image-5139" title="HDMI to AV converter  (Composite Video + Audio on RCA plugs)" src="https://billauer.se/blog/wp-content/uploads/2017/03/hdmi2av-300x240.jpg" alt="HDMI to AV converter (Composite Video + Audio on RCA plugs)" width="300" height="240" /></a></p>
<p>This is the information obtained with xrandr from the HDMI to AV converter  (Composite Video + Audio on RCA plugs) shown above:</p>
<pre>Screen 0: minimum 8 x 8, current 1280 x 720, maximum 32767 x 32767
DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
HDMI3 connected primary 1280x720+0+0 (normal left inverted right x axis y axis) 708mm x 398mm
 1280x720      60.00*+  59.94 
 1920x1080     60.00    59.94 
 1600x1200     60.00 
 1680x1050     59.88 
 1400x1050     59.95 
 1600x900      60.00 
 1280x1024     60.02 
 1440x900      59.90 
 1280x960      60.00 
 1280x800      59.91 
 1024x768      60.00 
 800x600       60.32 
 720x480       60.00    59.94 
 640x480       60.00    59.94 
VIRTUAL1 disconnected (normal left inverted right x axis y axis)</pre>
<p>And with &#8220;verbose&#8221; flag:</p>
<pre>Screen 0: minimum 8 x 8, current 1280 x 720, maximum 32767 x 32767
DP1 disconnected (normal left inverted right x axis y axis)
 Identifier: 0x43
 Timestamp:  919743
 Subpixel:   unknown
 Clones:   
 CRTCs:      1 2
 Transform:  1.000000 0.000000 0.000000
 0.000000 1.000000 0.000000
 0.000000 0.000000 1.000000
 filter:
 Broadcast RGB: Automatic
 supported: Automatic, Full, Limited 16:235
 audio: auto
 supported: force-dvi, off, auto, on
DP2 disconnected (normal left inverted right x axis y axis)
 Identifier: 0x44
 Timestamp:  919743
 Subpixel:   unknown
 Clones:   
 CRTCs:      1 2
 Transform:  1.000000 0.000000 0.000000
 0.000000 1.000000 0.000000
 0.000000 0.000000 1.000000
 filter:
 Broadcast RGB: Automatic
 supported: Automatic, Full, Limited 16:235
 audio: auto
 supported: force-dvi, off, auto, on
DP3 disconnected (normal left inverted right x axis y axis)
 Identifier: 0x45
 Timestamp:  919743
 Subpixel:   unknown
 Clones:   
 CRTCs:      0
 Transform:  1.000000 0.000000 0.000000
 0.000000 1.000000 0.000000
 0.000000 0.000000 1.000000
 filter:
 Broadcast RGB: Automatic
 supported: Automatic, Full, Limited 16:235
 audio: auto
 supported: force-dvi, off, auto, on
HDMI1 disconnected (normal left inverted right x axis y axis)
 Identifier: 0x46
 Timestamp:  919743
 Subpixel:   unknown
 Clones:   
 CRTCs:      1 2
 Transform:  1.000000 0.000000 0.000000
 0.000000 1.000000 0.000000
 0.000000 0.000000 1.000000
 filter:
 aspect ratio: Automatic
 supported: Automatic, 4:3, 16:9
 Broadcast RGB: Automatic
 supported: Automatic, Full, Limited 16:235
 audio: auto
 supported: force-dvi, off, auto, on
HDMI2 disconnected (normal left inverted right x axis y axis)
 Identifier: 0x47
 Timestamp:  919743
 Subpixel:   unknown
 Clones:   
 CRTCs:      1 2
 Transform:  1.000000 0.000000 0.000000
 0.000000 1.000000 0.000000
 0.000000 0.000000 1.000000
 filter:
 aspect ratio: Automatic
 supported: Automatic, 4:3, 16:9
 Broadcast RGB: Automatic
 supported: Automatic, Full, Limited 16:235
 audio: auto
 supported: force-dvi, off, auto, on
HDMI3 connected primary 1280x720+0+0 (0x11d) normal (normal left inverted right x axis y axis) 708mm x 398mm
 Identifier: 0x48
 Timestamp:  919743
 Subpixel:   unknown
 Gamma:      1.0:1.0:1.0
 Brightness: 1.0
 Clones:   
 CRTC:       0
 CRTCs:      0
 Transform:  1.000000 0.000000 0.000000
 0.000000 1.000000 0.000000
 0.000000 0.000000 1.000000
 filter:
 EDID:
 00ffffffffffff00328d000000000000
 2d170103e87341782aee91a3544c9926
 0f505421080081008140818090409500
 a9c0b300a940011d007251d01e206e28
 5500c48e2100001ef339801871382d40
 582c4500c48e2100001e000000fd001e
 551e6414000a202020202020000000fc
 0048444d493241560a202020002001d6
 02031841458403020110230907078301
 000065030c001000011d007251d01e20
 6e28550010090000001e011d007251d0
 1e206e28550010090000001e8c0ad08a
 20e02d10103e96001009000000180000
 00000000000000000000000000000000
 00000000000000000000000000000000
 0000000000000000000000000000001d
 aspect ratio: Automatic
 supported: Automatic, 4:3, 16:9
 Broadcast RGB: Automatic
 supported: Automatic, Full, Limited 16:235
 audio: auto
 supported: force-dvi, off, auto, on
 1280x720 (0x11d) 74.250MHz +HSync +VSync *current +preferred
 h: width  1280 start 1390 end 1430 total 1650 skew    0 clock  45.00KHz
 v: height  720 start  725 end  730 total  750           clock  60.00Hz
 1920x1080 (0x4b) 148.500MHz +HSync +VSync
 h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  67.50KHz
 v: height 1080 start 1084 end 1089 total 1125           clock  60.00Hz
 1920x1080 (0x10b) 148.352MHz +HSync +VSync
 h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  67.43KHz
 v: height 1080 start 1084 end 1089 total 1125           clock  59.94Hz
 1600x1200 (0x114) 162.000MHz +HSync +VSync
 h: width  1600 start 1664 end 1856 total 2160 skew    0 clock  75.00KHz
 v: height 1200 start 1201 end 1204 total 1250           clock  60.00Hz
 1680x1050 (0x115) 119.000MHz +HSync -VSync
 h: width  1680 start 1728 end 1760 total 1840 skew    0 clock  64.67KHz
 v: height 1050 start 1053 end 1059 total 1080           clock  59.88Hz
 1400x1050 (0x13b) 101.000MHz +HSync -VSync
 h: width  1400 start 1448 end 1480 total 1560 skew    0 clock  64.74KHz
 v: height 1050 start 1053 end 1057 total 1080           clock  59.95Hz
 1600x900 (0x13c) 108.000MHz +HSync +VSync
 h: width  1600 start 1624 end 1704 total 1800 skew    0 clock  60.00KHz
 v: height  900 start  901 end  904 total 1000           clock  60.00Hz
 1280x1024 (0x117) 108.000MHz +HSync +VSync
 h: width  1280 start 1328 end 1440 total 1688 skew    0 clock  63.98KHz
 v: height 1024 start 1025 end 1028 total 1066           clock  60.02Hz
 1440x900 (0x119) 88.750MHz +HSync -VSync
 h: width  1440 start 1488 end 1520 total 1600 skew    0 clock  55.47KHz
 v: height  900 start  903 end  909 total  926           clock  59.90Hz
 1280x960 (0x11a) 108.000MHz +HSync +VSync
 h: width  1280 start 1376 end 1488 total 1800 skew    0 clock  60.00KHz
 v: height  960 start  961 end  964 total 1000           clock  60.00Hz
 1280x800 (0x11b) 71.000MHz +HSync -VSync
 h: width  1280 start 1328 end 1360 total 1440 skew    0 clock  49.31KHz
 v: height  800 start  803 end  809 total  823           clock  59.91Hz
 1280x720 (0x11f) 74.176MHz +HSync +VSync
 h: width  1280 start 1390 end 1430 total 1650 skew    0 clock  44.96KHz
 v: height  720 start  725 end  730 total  750           clock  59.94Hz
 1024x768 (0x122) 65.000MHz -HSync -VSync
 h: width  1024 start 1048 end 1184 total 1344 skew    0 clock  48.36KHz
 v: height  768 start  771 end  777 total  806           clock  60.00Hz
 800x600 (0x126) 40.000MHz +HSync +VSync
 h: width   800 start  840 end  968 total 1056 skew    0 clock  37.88KHz
 v: height  600 start  601 end  605 total  628           clock  60.32Hz
 720x480 (0x129) 27.027MHz -HSync -VSync
 h: width   720 start  736 end  798 total  858 skew    0 clock  31.50KHz
 v: height  480 start  489 end  495 total  525           clock  60.00Hz
 720x480 (0x12a) 27.000MHz -HSync -VSync
 h: width   720 start  736 end  798 total  858 skew    0 clock  31.47KHz
 v: height  480 start  489 end  495 total  525           clock  59.94Hz
 640x480 (0x12e) 25.200MHz -HSync -VSync
 h: width   640 start  656 end  752 total  800 skew    0 clock  31.50KHz
 v: height  480 start  490 end  492 total  525           clock  60.00Hz
 640x480 (0x12f) 25.175MHz -HSync -VSync
 h: width   640 start  656 end  752 total  800 skew    0 clock  31.47KHz
 v: height  480 start  490 end  492 total  525           clock  59.94Hz
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
 Identifier: 0x49
 Timestamp:  919743
 Subpixel:   no subpixels
 Clones:   
 CRTCs:      3
 Transform:  1.000000 0.000000 0.000000
 0.000000 1.000000 0.000000
 0.000000 0.000000 1.000000
 filter:</pre>
<p>This was done with the switch in &#8220;PAL&#8221; position, but I&#8217;m not sure it matters.</p>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2017/03/edid-hdmi2av-rca-cvbs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tvheadend starting slowly with a HD-901T2 DVB-T2 USB stick: The udev solution</title>
		<link>https://billauer.se/blog/2017/03/tvheadend-udev-usb-dvb/</link>
		<comments>https://billauer.se/blog/2017/03/tvheadend-udev-usb-dvb/#comments</comments>
		<pubDate>Sat, 11 Mar 2017 09:48:33 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[DVB]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[systemd]]></category>
		<category><![CDATA[udev]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=5133</guid>
		<description><![CDATA[The problem Having A HD-901T2 DVB-T2 stick on a Linux Mint 18.1 running a 4.4.0-53-generic kernel, Tvheadend started painfully slow. It took more than a minute before the web interface was available. And here&#8217;s why: Mar 11 10:22:35 tv systemd[1]: Starting tvheadend.service... Mar 11 10:22:35 tv tvheadend[6019]: * Starting Tvheadend tvheadend Mar 11 10:22:35 tv [...]]]></description>
			<content:encoded><![CDATA[<h3>The problem</h3>
<p>Having A HD-901T2 DVB-T2 stick on a Linux Mint 18.1 running a 4.4.0-53-generic kernel, Tvheadend started painfully slow. It took more than a minute before the web interface was available. And here&#8217;s why:</p>
<pre>Mar 11 10:22:35 tv systemd[1]: Starting tvheadend.service...
Mar 11 10:22:35 tv tvheadend[6019]:  * Starting Tvheadend tvheadend
Mar 11 10:22:35 tv tvheadend[6019]:    ...done.
Mar 11 10:22:35 tv systemd[1]: Started tvheadend.service.
Mar 11 10:22:35 tv tvheadend[6030]: main: Log started
Mar 11 10:22:35 tv tvheadend[6030]: config: loaded
Mar 11 10:22:35 tv tvheadend[6030]: scanfile: DVB-T - loaded 43 regions with 1106 networks
Mar 11 10:22:35 tv tvheadend[6030]: scanfile: DVB-S - loaded 1 regions with 112 networks
Mar 11 10:22:35 tv tvheadend[6030]: scanfile: DVB-C - loaded 17 regions with 56 networks
Mar 11 10:22:35 tv tvheadend[6030]: scanfile: ATSC - loaded 2 regions with 14 networks
Mar 11 10:22:40 tv tvheadend[6030]: linuxdvb: adapter added /dev/dvb/adapter0
Mar 11 10:22:40 tv kernel: [ 5333.042417] usb 1-4: DVB: adapter 0 frontend 0 frequency 0 out of range (174000000..862000000)
Mar 11 10:24:23 tv tvheadend[6030]: <span style="color: #ff0000;"><strong>linuxdvb: unable to open /dev/dvb/adapter0/frontend1</strong></span></pre>
<p>So that&#8217;s it: Tvheadend fails with /dev/dvb/adapter0/frontend1 somehow, and that failure takes time (the driver&#8217;s access timeouts?) and blocks the setup of other functionalities. The thing is that frontend1 is in fact the front end for the Panasonic MN88473 DVB-T/T2/C demodulator, and is redundant, because Tvheadend&#8217;s interface with the DVB stick is through /dev/dvb/adapter0/frontend0 (Realtek RTL2832).</p>
<p>The elegant solution is to make the offending device file inaccessible using udev. Since udev doesn&#8217;t rename device files that are created by the kernel for a long time, playing with its permissions is the way out. If Tvheadend is denied access to /dev/dvb/adapter0/frontend1, it won&#8217;t mess with it.</p>
<p>I have <a href="https://billauer.se/blog/2011/06/udev-dok-disk-on-key-usb-stick/" target="_blank">old post</a> on udev hacking, and <a title="systemd: Reacting to USB NIC hotplugging (post-up scripting)" href="https://billauer.se/blog/2019/11/systemd-udev-ifup-usb-nic/" target="_blank">one on udev rules for a NIC</a>, by the way.</p>
<p>You may skip the following section, and go directly to &#8220;The fix&#8221;, if the gory details seem boring.</p>
<h3>Analyzing the udev situation</h3>
<p>Plugging in the DVB stick into the computer with</p>
<pre># <strong>udevadm monitor --udev --property</strong></pre>
<p>running makes a lot of output, but this among others:</p>
<pre>UDEV  [90.760633] add      /devices/pci0000:00/0000:00:14.0/usb1/1-4/dvb/dvb0.frontend1 (dvb)
ACTION=add
DEVNAME=/dev/dvb/adapter0/frontend1
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-4/dvb/dvb0.frontend1
DVB_ADAPTER_NUM=0
DVB_DEVICE_NUM=1
DVB_DEVICE_TYPE=frontend
ID_FOR_SEAT=dvb-pci-0000_00_14_0-usb-0_4
ID_PATH=pci-0000:00:14.0-usb-0:4
ID_PATH_TAG=pci-0000_00_14_0-usb-0_4
MAJOR=212
MINOR=4
SEQNUM=2829
SUBSYSTEM=dvb
TAGS=:uaccess:seat:
USEC_INITIALIZED=90759736</pre>
<p>And looking at the device itself:</p>
<pre>$ <strong>udevadm info -a -n /dev/dvb/adapter0/frontend1
</strong>
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-3/dvb/dvb0.frontend1':
    KERNEL=="dvb0.frontend1"
    SUBSYSTEM=="dvb"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-3':
    KERNELS=="1-3"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="500mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 2"
    ATTRS{bcdDevice}=="0100"
    ATTRS{bmAttributes}=="80"
    ATTRS{busnum}=="1"
    ATTRS{configuration}=="USB2.0-Bulk&amp;Iso"
    ATTRS{devnum}=="3"
    ATTRS{devpath}=="3"
    ATTRS{idProduct}=="0131"
    ATTRS{idVendor}=="15f4"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="astrometadvbt2"
    ATTRS{maxchild}=="0"
    ATTRS{product}=="dvbt2"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="removable"
    ATTRS{speed}=="480"
    ATTRS{urbnum}=="18880"
    ATTRS{version}==" 2.00"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{authorized_default}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="0404"
    ATTRS{bmAttributes}=="e0"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{devnum}=="1"
    ATTRS{devpath}=="0"
    ATTRS{idProduct}=="0002"
    ATTRS{idVendor}=="1d6b"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 4.4.0-53-generic xhci-hcd"
    ATTRS{maxchild}=="7"
    ATTRS{product}=="xHCI Host Controller"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{serial}=="0000:00:14.0"
    ATTRS{speed}=="480"
    ATTRS{urbnum}=="52"
    ATTRS{version}==" 2.00"

  looking at parent device '/devices/pci0000:00/0000:00:14.0':
    KERNELS=="0000:00:14.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0330"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x22b5"
    ATTRS{dma_mask_bits}=="64"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="115"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{local_cpus}=="f"
    ATTRS{msi_bus}=="1"
    ATTRS{numa_node}=="-1"
    ATTRS{subsystem_device}=="0x1000"
    ATTRS{subsystem_vendor}=="0x1458"
    ATTRS{vendor}=="0x8086"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""</pre>
<p>Only the first two entries are interesting: The others climb up through the USB port, the PCIebus and finally the PCI root port.</p>
<h3>The fix</h3>
<p>So I set up this file as /etc/udev/rules.d/50-dvb-rename.rules</p>
<pre>SUBSYSTEM=="dvb", ATTRS{idVendor}=="15f4", ATTRS{idProduct}=="0131", KERNEL=="dvb*.frontend1", MODE:="0000", GROUP:="root"</pre>
<p>And refreshed the udev system:</p>
<pre># udevadm control --reload</pre>
<p>Don&#8217;t get discouraged by /etc/udev/ being almost empty: The systemd rules have moved to /lib/udev/, and following systemd conventions, local fixes should be in /etc/udev/.</p>
<p>That didn&#8217;t work exactly as I expected, but good enough (after replugging the DVB stick):</p>
<pre>$ ls -l /dev/dvb/adapter0/
total 0
crw-rw----+ 1 root video 212, 0 Mar 11 10:50 demux0
crw-rw----+ 1 root video 212, 1 Mar 11 10:50 dvr0
crw-rw----+ 1 root video 212, 3 Mar 11 10:50 frontend0
<span style="color: #ff0000;"><strong>c---rw----</strong></span>+ 1 root root  212, 4 Mar 11 10:50 frontend1
crw-rw----+ 1 root video 212, 2 Mar 11 10:50 net0</pre>
<p>WTF? Note that the MODE assignment is with a := which is supposed to prevent overruling. And still, it&#8217;s group accessible. Where did that come from? Anyhow, that&#8217;s why the group is set to root. That fixed the problem with Tvheadend, which now finishes initializing 12 seconds after systemd announces its launch.</p>
<h3>More udev rambling</h3>
<p>I went on a bit on this. Nothing really for TLDRers.</p>
<p>Tesring (doesn&#8217;t really require root privileges, but the actions won&#8217;t take place):</p>
<pre># udevadm test -a add $(udevadm info -q path -n /dev/dvb/adapter0/frontend1)</pre>
<p>or stating the path explicitly:</p>
<pre># udevadm info -q path -n /dev/dvb/adapter0/frontend1
/devices/pci0000:00/0000:00:14.0/usb1/1-4/dvb/dvb0.frontend1
# udevadm test -a add /devices/pci0000:00/0000:00:14.0/usb1/1-4/dvb/dvb0.frontend1
<span style="color: #888888;">[ ... ]</span>
GROUP 0 /etc/udev/rules.d/50-dvb-rename.rules:4
MODE 0 /etc/udev/rules.d/50-dvb-rename.rules:4
IMPORT builtin 'path_id' /lib/udev/rules.d/71-seat.rules:49
RUN 'uaccess' /lib/udev/rules.d/73-seat-late.rules:15
handling device node '/dev/dvb/adapter0/frontend1', devnum=c212:4, mode=0, uid=0
, gid=0
set permissions /dev/dvb/adapter0/frontend1, 020000, uid=0, gid=0
preserve already existing symlink '/dev/char/212:4' to '../dvb/adapter0/frontend
1'
created db file '/run/udev/data/c212:4' for '/devices/pci0000:00/0000:00:14.0/usb1/1-4/dvb/dvb0.frontend1'
<span style="color: #888888;">[ ... ]</span></pre>
<p>And here comes the big surprise: After the test, the frontend1&#8242;s permission was actually 0000 as required! So who&#8217;s fiddling with the permission after udev?</p>
<pre>$ ls -l /dev/dvb/adapter0/total 0
crw-rw----+ 1 root video 212, 0 Mar 11 10:50 demux0
crw-rw----+ 1 root video 212, 1 Mar 11 10:50 dvr0
crw-rw----+ 1 root video 212, 3 Mar 11 10:50 frontend0
<span style="color: #ff0000;"><strong>c---------</strong></span>+ 1 root root  212, 4 Mar 11 10:53 frontend1
crw-rw----+ 1 root video 212, 2 Mar 11 10:50 net0</pre>
<p>If anyone knows, please comment below. For my current purpose, I could work this around by changing the group.</p>
<p>And if I&#8217;m at it: When Tvheadend runs, all device files in /dev/dvb/adapter0/ appear to have been deleted. They return when the Tvheadend is stopped. Does anyone have an idea on how and why?</p>
<p>Unlike what one might have expected, there was no need to update the initramfs. The attributes of frontend1 were the same (as the replug above, not the test) after a reboot:</p>
<pre># mount -o remount,rw /boot/
# update-initramfs -u -v</pre>
<p>which didn&#8217;t make any difference, as expected.</p>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2017/03/tvheadend-udev-usb-dvb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux / DVB / Command line: Watching multiple channels with single DVB adapter</title>
		<link>https://billauer.se/blog/2017/03/ffplay-demux-dvb/</link>
		<comments>https://billauer.se/blog/2017/03/ffplay-demux-dvb/#comments</comments>
		<pubDate>Fri, 10 Mar 2017 18:35:09 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[DVB]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=5127</guid>
		<description><![CDATA[Some (or all?) DVB adapters can be set to submit the entire MPEG-TS stream to the host, without filtering specific channels (actually, PIDs). This allows viewing more channel at a time. This is demonstrated below with ffplay, even though ffplay tends to get stuck when it goes to a live stream. It&#8217;s also not possible [...]]]></description>
			<content:encoded><![CDATA[<p>Some (or all?) DVB adapters can be set to submit the entire MPEG-TS stream to the host, without filtering specific channels (actually, PIDs). This allows viewing more channel at a time. This is demonstrated below with ffplay, even though ffplay tends to get stuck when it goes to a live stream.</p>
<p>It&#8217;s also not possible to view multiple channels with ffplay like this, because the device file can be opened only by a single instance of ffplay (or there&#8217;s a device or resource busy error). So in short, this is really just a proof of concept. Tvheadend does this anyhow. But the point there is to do it low-level style.</p>
<p>What I had: A HD-901T2 DVB-T2 stick on a Linux Mint 18.1 running a 4.4.0-53-generic kernel.</p>
<p>First, a scan should be done with dvbv5-scan, which creates a dvb_channel.conf file (shown in <a title="Linux / DVB: Playing with command-line utilities" href="https://billauer.se/blog/2017/02/linux-dvb-israel-digital-tv/" target="_blank">this post</a>)</p>
<p>Using the -P flag to disable channel filtering:</p>
<pre>$ dvbv5-zap <strong><span style="color: #ff0000;">-P</span></strong> -c dvb_channel.conf -r 'Ch 10'
using demux '/dev/dvb/adapter0/demux0'
reading channels from file 'dvb_channel.conf'
service has pid type 06:  2642 2641 2640
tuning to 538000000 Hz
<strong><span style="color: #ff0000;">pass all PID's to TS</span></strong>
  dvb_set_pesfilter 8192
       (0x00)
Lock   (0x1f)
Lock   (0x1f)
DVR interface '/dev/dvb/adapter0/dvr0' can now be opened
Lock   (0x1f) Signal= 92.55% C/N= 33.62dB postBER= 0</pre>
<p>Note that the specification of &#8216;Ch 10&#8242; in the command was merely a lazy way to set the frequency and other technical parameters.</p>
<p>Without stopping dvbv5-zap, go</p>
<pre>$ ffplay /dev/dvb/adapter0/dvr0 2&gt;log</pre>
<p>and quit as soon as an image window appears. It&#8217;s a lot of mumbo-jumbo, but there&#8217;s a stream list somewhere in the middle &#8212; the example I captured is given at the end of this post.</p>
<p>So, to watch Channel 2:</p>
<pre>$ ffplay -vst p:2 /dev/dvb/adapter0/dvr0</pre>
<p>The p:2 specifier matches the &#8220;Program 2&#8243; in the stream list. ffplay automatically matches the audio channel (even though -ast wasn&#8217;t specified).</p>
<p>Note that it&#8217;s ffplay that does the demuxing. This works (even better, actually) if the data stream is copied into a file first (with cat, for example) and then the file is played.</p>
<p>It also possible to handpick the streams with the PIDs, as listed in the dvb_channel.conf file (or in the stream list, as hex numbers in the square brackets).  For example, watching channel 99:</p>
<pre>$ ffplay -vst i:2689 -ast i:2690 /dev/dvb/adapter0/dvr0</pre>
<p>or, equivalently</p>
<pre>$ ffplay -vst i:0xa81 -ast i:0xa82 /dev/dvb/adapter0/dvr0</pre>
<h3>ffplay stream list</h3>
<p>As  captured in Haifa on March 10th 2017:</p>
<pre>  Program 1
    Metadata:
      service_name    : ?Ch 1
      service_provider: ?Idan +
    Stream #0:30[0x401](heb): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:12[0xa01]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:31[0xa02]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 2
    Metadata:
      service_name    : ?Ch 2
      service_provider: ?Idan +
    Stream #0:0[0xa21]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0xa22]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
    Stream #0:2[0xa23]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
    Stream #0:3[0xa30](heb): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:4[0xa31](rus): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:5[0xa32](ara): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
  Program 3
    Metadata:
      service_name    : ?Ch 10
      service_provider: ?Idan +
    Stream #0:6[0xa41]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:29[0xa42]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
    Stream #0:28[0xa43]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
    Stream #0:32[0xa50](heb): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:33[0xa51](rus): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:34[0xa52](ara): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
  Program 4
    Metadata:
      service_name    : ?Ch 33
      service_provider: ?Idan +
    Stream #0:22[0xa61]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:23[0xa62]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 5
    Metadata:
      service_name    : ?Ch 99
      service_provider: ?Idan +
    Stream #0:11[0xa81]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:26[0xa82]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
    Stream #0:35[0xa90](heb): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
  Program 6
    Metadata:
      service_name    : ?Ch 23
      service_provider: ?Idan +
    Stream #0:8[0xe01]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:27[0xe02]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 21
    Metadata:
      service_name    : Aleph
      service_provider: Idan +
    Stream #0:19[0xb01]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 22
    Metadata:
      service_name    : Bet
      service_provider: Idan +
    Stream #0:18[0xb11]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 23
    Metadata:
      service_name    : Gimmel
      service_provider: Idan +
    Stream #0:7[0xb21]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 24
    Metadata:
      service_name    : Dalet
      service_provider: Idan +
    Stream #0:9[0xb31]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 25
    Metadata:
      service_name    : Moreshet
      service_provider: Idan +
    Stream #0:25[0xb41]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 26
    Metadata:
      service_name    : 88FM
      service_provider: Idan +
    Stream #0:13[0xb51]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 27
    Metadata:
      service_name    : Musica
      service_provider: Idan +
    Stream #0:16[0xb61]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 28
    Metadata:
      service_name    : Reka
      service_provider: Idan +
    Stream #0:20[0xb71]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 29
    Metadata:
      service_name    : Galatz
      service_provider: Idan +
    Stream #0:24[0xb81]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 30
    Metadata:
      service_name    : Galgalatz
      service_provider: Idan +
    Stream #0:14[0xb91]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 36
    Metadata:
      service_name    : Radios
      service_provider: Idan +
    Stream #0:15[0xbf1]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 41
    Metadata:
      service_name    : Kol Barama
      service_provider: Idan +
    Stream #0:21[0xc41]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 42
    Metadata:
      service_name    : Lev HaMdina
      service_provider: Idan +
    Stream #0:17[0xc51]: Audio: aac_latm (HE-AACv2) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 45
    Metadata:
      service_name    : CLASSICAL bu
      service_provider: Idan +
    Stream #0:10[0xc81]: Audio: aac_latm (HE-AAC) ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
  Program 7
    Metadata:
      service_name    : Idan+test_2
      service_provider: Idan+</pre>
<p>So this list leaves no doubt that all channels were passed on to ffplay.</p>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2017/03/ffplay-demux-dvb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux / DVB: Playing with a HD-901T2 (&#8220;Astrometa&#8221;) DVB-T2 USB stick</title>
		<link>https://billauer.se/blog/2017/03/linux-dvb-israel-digital-tv-2/</link>
		<comments>https://billauer.se/blog/2017/03/linux-dvb-israel-digital-tv-2/#comments</comments>
		<pubDate>Fri, 10 Mar 2017 18:27:58 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[DVB]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=5125</guid>
		<description><![CDATA[This is the successful version of a previous post, using a DVB USB stick that works, for a change. Fix this, or it will wobble Literally. The USB plug of this device is poorly designed, so the metal frame doesn&#8217;t attach well to female connector. As a result, every little vibration makes the USB stick [...]]]></description>
			<content:encoded><![CDATA[<p>This is the successful version of a <a title="Linux / DVB: Playing with command-line utilities" href="https://billauer.se/blog/2017/02/linux-dvb-israel-digital-tv/" target="_blank">previous post</a>, using a DVB USB stick that works, for a change.</p>
<h3>Fix this, or it will wobble</h3>
<p>Literally. The USB plug of this device is poorly designed, so the metal frame doesn&#8217;t attach well to female connector. As a result, every little vibration makes the USB stick disconnect and possibly reconnect to the computer. If that happens in the middle of watching (or recording) something, bad luck. See &#8220;USB disaster&#8221; below for what it looks like in the logs.</p>
<p>The solution is simple: Chop a USB cable, and connect the side that goes to the computer (Type A Male, typically) directly to the board. Not elegant, but reliable (with some hot glue properly used).</p>
<p>The trick is to spot which wire should go where. A simple multimeter can be used to figure that out, or, if you like living on the edge, rely on the coloring of the wires, which is standard. Nothing stops a cable manufacturer from swapping wires, but they rarely do. What you really want to verify is that the red wire is +5V, and the black is GND. Having the white and green wires swapped will make the board fail to work (it will be detected as low-speed device, and hence fail to enumerate) but with no permanent damage.</p>
<p>This is what it looked like on my board, minus hot glue that I applied afterwards (click to enlarge):</p>
<p><a href="https://billauer.se/blog/wp-content/uploads/2017/03/fullboard.jpg"><img class="aligncenter size-medium wp-image-5324" title="USB stick board after soldering cable to board" src="https://billauer.se/blog/wp-content/uploads/2017/03/fullboard-300x168.jpg" alt="USB stick board after soldering cable to board" width="300" height="168" /></a>and a closeup:</p>
<p><a href="https://billauer.se/blog/wp-content/uploads/2017/03/closeup.jpg"><img class="aligncenter size-medium wp-image-5325" title="USB stick board after soldering cable to board, closeup" src="https://billauer.se/blog/wp-content/uploads/2017/03/closeup-300x180.jpg" alt="USB stick board after soldering cable to board, closeup" width="300" height="180" /></a></p>
<h3>Plugging in the card:</h3>
<pre>$ <strong>dmesg</strong>
<span style="color: #888888;">[ ... ]</span>
[ 2466.203556] usb 1-2: dvb_usb_v2: found a 'Astrometa DVB-T2' in warm state
[ 2466.287494] usb 1-2: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer
[ 2466.287522] DVB: registering new adapter (Astrometa DVB-T2)
[ 2466.305556] i2c i2c-9: Added multiplexed i2c bus 10
[ 2466.305567] rtl2832 9-0010: Realtek RTL2832 successfully attached
[ 2466.310149] mn88473: module is from the staging directory, the quality is unknown, you have been warned.
[ 2466.313533] mn88473 9-0018: Panasonic MN88473 successfully attached
[ 2466.313551] usb 1-2: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...
[ 2466.313718] usb 1-2: DVB: registering adapter 0 frontend 1 (Panasonic MN88473)...
[ 2466.322520] r820t 10-003a: creating new instance
[ 2466.335747] r820t 10-003a: Rafael Micro r820t successfully identified
[ 2466.335780] r820t 10-003a: attaching existing instance
[ 2466.343872] r820t 10-003a: Rafael Micro r820t successfully identified
[ 2466.351883] media: Linux media interface: v0.10
[ 2466.365085] Linux video capture interface: v2.00
[ 2466.388370] rtl2832_sdr rtl2832_sdr.1.auto: Registered as swradio0
[ 2466.388382] rtl2832_sdr rtl2832_sdr.1.auto: Realtek RTL2832 SDR attached
[ 2466.388386] rtl2832_sdr rtl2832_sdr.1.auto: SDR API is still slightly experimental and functionality changes may follow
[ 2466.395405] Registered IR keymap rc-empty
[ 2466.395640] input: Astrometa DVB-T2 as /devices/pci0000:00/0000:00:14.0/usb1/1-2/rc/rc0/input11
[ 2466.395932] rc0: Astrometa DVB-T2 as /devices/pci0000:00/0000:00:14.0/usb1/1-2/rc/rc0
[ 2466.401023] IR NEC protocol handler initialized
[ 2466.402794] IR RC5(x/sz) protocol handler initialized
[ 2466.405693] IR RC6 protocol handler initialized
[ 2466.408419] IR JVC protocol handler initialized
[ 2466.414092] IR Sharp protocol handler initialized
[ 2466.414716] IR MCE Keyboard/mouse protocol handler initialized
[ 2466.418597] input: MCE IR Keyboard/Mouse (dvb_usb_rtl28xxu) as /devices/virtual/input/input12
[ 2466.418906] usb 1-2: dvb_usb_v2: schedule remote query interval to 200 msecs
[ 2466.418972] lirc_dev: IR Remote Control driver registered, major 244
[ 2466.422821] rc rc0: lirc_dev: driver ir-lirc-codec (dvb_usb_rtl28xxu) registered at minor = 0
[ 2466.422827] IR LIRC bridge handler initialized
[ 2466.424978] IR XMP protocol handler initialized
[ 2466.426269] IR Sony protocol handler initialized
[ 2466.426274] IR SANYO protocol handler initialized
[ 2466.429076] usb 1-2: dvb_usb_v2: 'Astrometa DVB-T2' successfully initialized and connected
[ 2466.429300] usbcore: registered new interface driver dvb_usb_rtl28xxu</pre>
<p>Seems pretty good. Judging by the device ID (15f4:0131 per lsusb), it&#8217;s exactly the device mentioned in <a href="http://blog.palosaari.fi/2013/10/naked-hardware-14-dvb-t2-usb-tv-stick.html" target="_blank">Antti&#8217;s blog</a>.</p>
<pre>$ <strong>dvb-fe-tool</strong>
Device Realtek RTL2832 (DVB-T) (/dev/dvb/adapter0/frontend0) capabilities:
     CAN_FEC_1_2
     CAN_FEC_2_3
     CAN_FEC_3_4
     CAN_FEC_5_6
     CAN_FEC_7_8
     CAN_FEC_AUTO
     CAN_GUARD_INTERVAL_AUTO
     CAN_HIERARCHY_AUTO
     CAN_INVERSION_AUTO
     CAN_MUTE_TS
     CAN_QAM_16
     CAN_QAM_64
     CAN_QAM_AUTO
     CAN_QPSK
     CAN_RECOVER
     CAN_TRANSMISSION_MODE_AUTO
DVB API Version 5.10, Current v5 delivery system: DVBT
Supported delivery system:
    [DVBT]</pre>
<p>Scanning went fine too:</p>
<pre>$ <strong>dvbv5-scan /usr/share/dvb/dvb-t/il-All</strong>
Cannot calc frequency shift. Either bandwidth/symbol-rate is unavailable (yet).
Scanning frequency #1 514000000
       (0x00)
Scanning frequency #2 538000000
Lock   (0x1f)
Service Ch 1, provider Idan +: digital television
Service Ch 2, provider Idan +: digital television
Service Ch 10, provider Idan +: digital television
Service Ch 33, provider Idan +: digital television
Service Ch 99, provider Idan +: digital television
Service Ch 23, provider Idan +: digital television
Service Idan+test_2, provider Idan+: digital television
WARNING  Channel Idan+test_2 (service ID 7) not found on PMT. Skipping it.
Service Aleph, provider Idan +: digital radio
Service Bet, provider Idan +: digital radio
Service Gimmel, provider Idan +: digital radio
Service Dalet, provider Idan +: digital radio
Service Moreshet, provider Idan +: digital radio
Service 88FM, provider Idan +: digital radio
Service Musica, provider Idan +: digital radio
Service Reka, provider Idan +: digital radio
Service Galatz, provider Idan +: digital radio
Service Galgalatz, provider Idan +: digital radio
Service Radios, provider Idan +: digital radio
Service Kol Barama, provider Idan +: digital radio
Service Lev HaMdina, provider Idan +: digital radio
Service CLASSICAL bu, provider Idan +: digital radio</pre>
<p>And some info:</p>
<pre>$ <strong>dvb-fe-tool -g</strong>
FREQUENCY = 538000000
MODULATION = QAM/16
BANDWIDTH_HZ = 8000000
INVERSION = OFF
CODE_RATE_HP = 2/3
CODE_RATE_LP = 1/2
GUARD_INTERVAL = 1/4
TRANSMISSION_MODE = 8K
HIERARCHY = NONE
DELIVERY_SYSTEM = DVBT
$ <strong>dvb-fe-tool -m</strong>
       (0x00) Signal= 92.55% C/N= 32.98dB postBER= 0
       (0x00) Signal= 92.55% C/N= 32.98dB postBER= 0
       (0x00) Signal= 92.55% C/N= 32.98dB postBER= 0
       (0x00) Signal= 92.55% C/N= 32.98dB postBER= 0
       (0x00) Signal= 92.55% C/N= 32.98dB postBER= 0</pre>
<p>Hmmm&#8230; Why isn&#8217;t it locked? And the data doesn&#8217;t change as I move the antenna around.</p>
<p>On the other hand,</p>
<pre>$ <strong>dvbv5-zap -c dvb_channel.conf -r 'Ch 10'</strong>
using demux '/dev/dvb/adapter0/demux0'
reading channels from file 'dvb_channel.conf'
service has pid type 06:  2642 2641 2640
tuning to 538000000 Hz
video pid 2625
  dvb_set_pesfilter 2625
audio pid 2626
  dvb_set_pesfilter 2626
       (0x00)
Lock   (0x1f)
Lock   (0x1f)
DVR interface '/dev/dvb/adapter0/dvr0' can now be opened
Lock   (0x1f) Signal= 92.55% C/N= 38.67dB postBER= 0</pre>
<p>Much better. I have a lock, and both the signal level and C/N change as I move the antenna. Actually, disconnecting the antenna and short-circuiting the input jack yields</p>
<pre>Lock   (0x1f) Signal= 92.94% C/N= 28.19dB postBER= 1.01x10^-3</pre>
<p>so with a momentary non-zero BER as shown above, so it looks like it&#8217;s legit.</p>
<p>So I have zero BER? I should see TV perfectly, then?</p>
<pre>$ <strong>mplayer -cache 800 /dev/dvb/adapter0/dvr0</strong>
MPlayer 1.2.1 (Debian), built with gcc-5.3.1 (C) 2000-2016 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing /dev/dvb/adapter0/dvr0.
Cache fill: 16.00% (131072 bytes)   

libavformat version 56.40.101 (external)
Cache empty, consider increasing -cache and/or -cache-min. [performance issue]
TS file format detected.
Cache empty, consider increasing -cache and/or -cache-min. [performance issue]
Cache empty, consider increasing -cache and/or -cache-min. [performance issue]
Cache empty, consider increasing -cache and/or -cache-min. [performance issue]
Cache empty, consider increasing -cache and/or -cache-min. [performance issue]</pre>
<p>Oh no. What&#8217;s really weird is that going</p>
<pre>$ cat /dev/dvb/adapter0/dvr0 &gt; this</pre>
<p>and in parallel</p>
<pre>$ ffplay this</pre>
<p>Actually <strong>does</strong> play TV more or less live (see <a title="Linux / DVB / Command line: Watching multiple channels with single DVB adapter" href="https://billauer.se/blog/2017/03/ffplay-demux-dvb/" target="_blank">this post</a> for more on ffplay in this context). But</p>
<pre>$ <strong>mplayer this</strong>
MPlayer 1.2.1 (Debian), built with gcc-5.3.1 (C) 2000-2016 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing this.
libavformat version 56.40.101 (external)
TS file format detected.
VIDEO MPEG2(pid=2625) AUDIO MPA(pid=2626) NO SUBS (yet)!  PROGRAM N. 0
<span style="color: #ff0000;"><strong>MPEG: FATAL: EOF while searching for sequence header.</strong></span>
Video: Cannot read properties.
Load subtitles in ./</pre>
<p>No sequence header? The clip is a minute long! Googling around, I found <a href="https://lists.mplayerhq.hu/pipermail/mplayer-users/2012-October/085496.html" target="_blank">this tip</a>, saying maybe there&#8217;s no <a href="https://en.wikipedia.org/wiki/MPEG_transport_stream#PAT" target="_blank">PAT/PMT</a> in the stream, and suggested adding  &#8220;-demuxer lavf&#8221; flags to mplayer. That turned out to be corect:</p>
<pre>$ mplayer -demuxer lavf this</pre>
<p>Plays the clip, but</p>
<pre>$ mplayer -demuxer lavf -cache 800 /dev/dvb/adapter0/dvr0</pre>
<p>still complains about the cache being empty, like before. Only difference: When I hit CTRL-C, it plays the channel for a split second and closes. So I gave up this direction for now.</p>
<p>In hindsight, I don&#8217;t think I every tried to copy with my <a href="https://billauer.se/blog/2017/02/linux-dvb-israel-digital-tv/" target="_blank">previous dongle</a>. Maybe it worked, after all, even though there was a crucial difference: I never managed to get Tvheadend to display a picture either with the previous dongle. And with this one Tvheadend works like a charm.</p>
<p>I will never know, as I messed it up in the end.</p>
<h3>USB disaster</h3>
<p>See &#8220;Fix this, or it will wobble&#8221; at the top of this post on how to fix this issue.</p>
<p>It can start with a few like these:</p>
<pre>Mar 10 10:44:21 tv kernel: [ 6133.433107] rtl2832 9-0010: i2c reg read failed -32</pre>
<p>But after some time (an hour or so of playback)  ends with a full scale spontaneous disconnection of the USB device (without me touching anything, needless to say):</p>
<pre>Mar 11 13:48:01 tv kernel: [ 1793.806742] usb 1-4: USB disconnect, device number 7
Mar 11 13:48:02 tv tvheadend[3325]: linuxdvb: Realtek RTL2832 (DVB-T) : DVB-T #0 - FE_READ_STATUS error No such device
Mar 11 13:48:02 tv kernel: [ 1794.805814] usb 1-4: dvb_usb_v2: rc.query() failed=-110
Mar 11 13:48:02 tv kernel: [ 1794.805885] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:02 tv acpid: input device has been disconnected, fd 7
Mar 11 13:48:02 tv acpid: input device has been disconnected, fd 6
Mar 11 13:48:02 tv kernel: [ 1794.933688] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:02 tv kernel: [ 1794.933706] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:02 tv kernel: [ 1794.933713] r820t 10-003a: r820t_write: i2c wr failed=-19 reg=0c len=1: f0
Mar 11 13:48:02 tv kernel: [ 1794.933720] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:02 tv kernel: [ 1794.937964] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:03 tv kernel: [ 1795.729720] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:03 tv kernel: [ 1795.772054] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:03 tv kernel: [ 1795.772069] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:03 tv kernel: [ 1795.772077] r820t 10-003a: r820t_read: i2c rd failed=-19 reg=00 len=4: f0 e1 2b ff
Mar 11 13:48:03 tv kernel: [ 1795.774643] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:03 tv kernel: [ 1795.933712] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:04 tv kernel: [ 1796.772180] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:04 tv kernel: [ 1796.772190] r820t 10-003a: r820t_read: i2c rd failed=-19 reg=00 len=4: f0 e1 2b ff
Mar 11 13:48:04 tv kernel: [ 1796.774426] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:04 tv kernel: [ 1796.933718] rtl2832 9-0010: i2c reg read failed -19
Mar 11 13:48:05 tv kernel: [ 1797.772322] rtl2832 9-0010: i2c reg read failed -19</pre>
<p>sometimes along with a kernel warning regarding the USB hub work thread:</p>
<pre>Mar 11 11:25:37 tv kernel: [  480.125459] INFO: task kworker/2:1:91 blocked for more than 120 seconds.
Mar 11 11:25:37 tv kernel: [  480.125485]       Tainted: G         C OE   4.4.0-53-generic #74-Ubuntu
Mar 11 11:25:37 tv kernel: [  480.125495] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Mar 11 11:25:37 tv kernel: [  480.125506] kworker/2:1     D ffff880270613788     0    91      2 0x00000000
Mar 11 11:25:37 tv kernel: [  480.125547] Workqueue: usb_hub_wq hub_event
Mar 11 11:25:37 tv kernel: [  480.125561]  ffff880270613788 ffff880071e34a98 ffff880270f28c80 ffff8802705f8c80
Mar 11 11:25:37 tv kernel: [  480.125581]  ffff880270614000 ffff880272614108 ffff880071e34a98 ffff880071e34000
Mar 11 11:25:37 tv kernel: [  480.125599]  ffff880071e34aa0 ffff8802706137a0 ffffffff81831f75 ffff8802751a0800
Mar 11 11:25:37 tv kernel: [  480.125619] Call Trace:
Mar 11 11:25:37 tv kernel: [  480.125645]  [&lt;ffffffff81831f75&gt;] schedule+0x35/0x80
Mar 11 11:25:37 tv kernel: [  480.125695]  [&lt;ffffffffc08adaf1&gt;] dvb_unregister_frontend+0xd1/0x130 [dvb_core]
Mar 11 11:25:37 tv kernel: [  480.125718]  [&lt;ffffffff810c3ec0&gt;] ? wake_atomic_t_function+0x60/0x60
Mar 11 11:25:37 tv kernel: [  480.125745]  [&lt;ffffffffc096f41d&gt;] dvb_usbv2_exit+0x13d/0x3c0 [dvb_usb_v2]
Mar 11 11:25:37 tv kernel: [  480.125769]  [&lt;ffffffffc096f714&gt;] dvb_usbv2_disconnect+0x74/0xf0 [dvb_usb_v2]</pre>
<p>After this, &#8220;lsusb&#8221; gets stuck with no output. Something really bad happened on the USB interface.</p>
<p>This renders the DVB stick useless. Luckily, there&#8217;s a simple solution. If you have a soldering iron, that is.</p>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2017/03/linux-dvb-israel-digital-tv-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Raspberry Pi 3 notes</title>
		<link>https://billauer.se/blog/2017/01/raspberry-pi-sdtv-hdmi/</link>
		<comments>https://billauer.se/blog/2017/01/raspberry-pi-sdtv-hdmi/#comments</comments>
		<pubDate>Sun, 15 Jan 2017 06:01:07 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[DVB]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux kernel]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=5049</guid>
		<description><![CDATA[These are messy, random notes that I took while setting up my little Raspberry Pi 3. Odds are that by the time you read this, I&#8217;ve replaced it with a mini-PC. So if you ask a question, my answer will probably be &#8220;I don&#8217;t remember&#8221;. Even though the Pi is cool, it didn&#8217;t supply what [...]]]></description>
			<content:encoded><![CDATA[<p>These are messy, random notes that I took while setting up my little Raspberry Pi 3. Odds are that by the time you read this, I&#8217;ve replaced it with a mini-PC. So if you ask a question, my answer will probably be &#8220;I don&#8217;t remember&#8221;.</p>
<p>Even though the Pi is cool, it didn&#8217;t supply what I really wanted from it, which is simultaneous output on SDTV and HDMI. It also turns out that it&#8217;s unable to handle a large portion of the video streams and apps out there on the web, seemingly because the lack of processing power vs. the resolution of these streams (running Kodi, which I suppose is the best optimized application for the Pi). So as a catch-all media center attached to a TV set, it&#8217;s rather useless.</p>
<h3>Starting</h3>
<ul>
<li>Used the 2016-11-25-raspbian-jessie.zip image</li>
<li>Raspbian: To get remote access over ssh, do &#8220;service ssh start&#8221; and login as &#8220;pi&#8221; with password &#8220;raspberry&#8221;. Best to remove these before really working. To make ssh permanent, go
<pre># systemctl enable ssh</pre>
</li>
<li>Cheap USB charger from Ebay didn&#8217;t hold the system up, and a reboot occurred every time the system attempted to boot up. The original LG G4  charger is strong enough, though.</li>
<li>Kodi installed cleanly with
<pre># apt-get update
# apt-get install --install-suggests kodi
# apt-get install --install-suggests vlc</pre>
</li>
<li>&#8230; but it seems like vlc doesn&#8217;t use video acceleration, and I tried a lot to make it work. It didn&#8217;t. So it&#8217;s quite useless.</li>
<li>Enabling Composite output: Use a four-lead 3.5mm plug (a stereo plug doesn&#8217;t work). The Samsung screen refused to work, but Radiance detected the signal OK.<br />
I used old Canon Powershot&#8217;s video cable, <strong>but attached to the RED</strong> plug for video, and not the yellow.<br />
In /boot/config.txt, uncomment&nbsp;</p>
<pre>sdtv_mode=2</pre>
<p>however composite video is <strong>disabled</strong> when an HDMI monitor is detected, and Q&amp;A&#8217;s on the web seem to suggest that simultaneous outputs is not possible. Following <a href="https://www.raspberrypi.org/documentation/configuration/config-txt.md" target="_blank">this page</a>, I tried setting (so that the HDMI output matches)</p>
<pre>hdmi_group=1
hdmi_mode=21</pre>
<p>and got 576i (PAL) on the HDMI output but the signals on the composite output were dead (checked with a scope).</li>
<li>Added &#8220;eli&#8221; as a user:
<pre># adduser --gid 500 --uid 1010 eli</pre>
</li>
<li>Add &#8220;eli as sudoer&#8221;. Add the file /etc/sudoers.d/010_eli-nopasswd saying
<pre>eli ALL=(ALL) NOPASSWD: ALL</pre>
</li>
<li>Manually edit /etc/groups, find all the places it says &#8220;pi&#8221; and add &#8220;eli&#8221; &#8212; so they have some groups. Compare &#8220;id&#8221; outputs.</li>
<li>Add <a href="https://billauer.se/blog/2016/02/ssh-remote-login-keys/" target="_blank">ssh keys</a> for password-less access (use ssh-copy-id)</li>
<li>Change the timezone
<pre>$ sudo raspi-config</pre>
<p>pick &#8220;4 Internationalisation Options&#8221; and change the timezone to Jerusalem</li>
<li>Set &#8220;eli&#8221; as the default login: One possibility would have been to change the config script (usr/bin/raspi-config) as suggested on <a href="http://raspberrypi.stackexchange.com/questions/12538/boot-into-the-gui-after-changing-default-user" target="_blank">this page</a>. Or change /etc/lightdm/lightdm.conf so it says
<pre>autologin-user=eli</pre>
<p>as for console login, the key line in raspi-config is</p>
<pre>ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service</pre>
<p>so the change is to edit  /etc/systemd/system/autologin@.service so it says</p>
<pre>ExecStart=-/sbin/agetty --autologin eli --noclear %I $TERM</pre>
</li>
<li>Turn off scrrensaver / blanking: First check the current situation (from an ssh session, therefore specific about display)
<pre>$ xset -display :0 q
Keyboard Control:
  auto repeat:  on    key click percent:  0    LED mask:  00000000
  XKB indicators:
    00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off
    03: Compose:     off    04: Kana:        off    05: Sleep:       off
    06: Suspend:     off    07: Mute:        off    08: Misc:        off
    09: Mail:        off    10: Charging:    off    11: Shift Lock:  off
    12: Group 2:     off    13: Mouse Keys:  off
  auto repeat delay:  500    repeat rate:  33
  auto repeating keys:  00ffffffdffffbbf
                        fadfffefffedffff
                        9fffffffffffffff
                        fff7ffffffffffff
  bell percent:  50    bell pitch:  400    bell duration:  100
Pointer Control:
  acceleration:  20/10    threshold:  10
Screen Saver:
  prefer blanking:  yes    allow exposures:  yes
  timeout:  600    cycle:  600
Colors:
  default colormap:  0x20    BlackPixel:  0x0    WhitePixel:  0xffffff
Font Path:
  /usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,built-ins
<span style="color: #ff0000;"><strong>DPMS (Energy Star):
  Standby: 600    Suspend: 600    Off: 600
  DPMS is Enabled
  Monitor is On</strong></span></pre>
<p>So turn it off, according to <a href="http://raspberrypi.stackexchange.com/questions/752/how-do-i-prevent-the-screen-from-going-blank" target="_blank">this</a> thread. Edit /etc/kbd/config to say (in different places of the file)</p>
<pre>BLANK_TIME=0
POWERDOWN_TIME=0</pre>
<p>and then append these lines to ~/.config/lxsession/LXDE-pi/autostart (this is a per-user thing):</p>
<pre>@xset s noblank
@xset s off
@xset -dpms</pre>
</li>
</ul>
<h3>More jots</h3>
<ul>
<li>The script that warns against the unchanged password for &#8220;pi&#8221; user is at /etc/xdg/lxsession/LXDE-pi/sshpwd.sh, and is launched by /etc/xdg/autostart/pprompt.desktop</li>
<li>For some info on how to run a power fail safe system by mounting most of the filesystem as readonly, see <a href="https://wiki.debian.org/ReadonlyRoot" target="_blank">this page</a>.</li>
<li>Obtaining the .config file (from the <a href="https://www.raspberrypi.org/documentation/linux/kernel/building.md" target="_blank">kernel build</a> guide):<br />
On Raspberry&#8217;s official kernel, check out git ID 4eb9a81002485a7abfa53a334dde5bc10328079f (as 4.4.34), and go&nbsp;</p>
<pre>$ make ARCH=arm bcm2709_defconfig</pre>
</li>
</ul>
<h3>Kodi setup</h3>
<ul>
<li>Change setting level to Advanced</li>
<li>System &gt; Settings &gt; Enable TV</li>
<li>System &gt; Settings &gt; System &gt; Power savings, set Shutdown function to <strong>Minimise</strong> (actually, it didn&#8217;t help regarding the blackout of the screen on exit)</li>
<li><strong>Enable </strong>and Configure PVR IPTV Simple Client</li>
<li>On exit, use Ctrl-Alt-F1 and then Ctrl-Alt-F7 to get back from the blank screen it leaves (/bin/chvt should do this as well?)</li>
</ul>
<h3>Video issues</h3>
<p>I wanted to get a simultaneous SDTV / HDMI output. Everyone says it&#8217;s impossible, but I wanted to give it a try. I mean, it&#8217;s the drivers that say no-no, but one can find a combination of registers that gets it working. The alternative is an external HDMI splitter, and then an HDMI to CVBS converter. Spoiler: I gave up in the end. Not saying it&#8217;s impossible, only that it&#8217;s not worth the bother. So:</p>
<p>Broadcom implements the <a href="https://en.wikipedia.org/wiki/OpenMAX" target="_blank">OpenMAX API</a>, which seems to have a limited set of  GPGPU capabilities. For example see firmware/opt/vc/src/hello_pi/hello_fft/ in Raspberry&#8217;s official <a href="https://github.com/raspberrypi" target="_blank">git repo</a>. The QPU is documented in VideoCoreIV-AG100-R.pdf, and there&#8217;s an open source assembler for it, <a href="http://maazl.de/project/vc4asm/doc/" target="_blank">vc4asm.</a> and possibly <a href="https://github.com/jetpacapp/qpu-asm" target="_blank">this one</a> is better, mentioned on <a href="https://petewarden.com/2014/08/07/how-to-optimize-raspberry-pi-code-using-its-gpu/" target="_blank">this page</a>. Also look at <a href="https://rpiplayground.wordpress.com/" target="_blank">this blog</a>.</p>
<p><a href="http://elinux.org/Raspberry_Pi_VideoCore_APIs" target="_blank">This page</a> details the VideoCore interface for Raspberry.</p>
<p>An utility for switching between HDMI/SDTV outputs (in hindsight, I would go for the official tvservice instead, but this is what I did):</p>
<pre>$ git clone https://github.com/adammw/rpi-output-swapper.git</pre>
<p>But that didn&#8217;t work:</p>
<pre>eli@raspberrypi:~/rpi-output-swapper $ make
cc -Wall -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I./ -g -c video_swap.c -o video_swap.o -Wno-deprecated-declarations
cc -o video_swap.bin -Wl,--whole-archive video_swap.o -L/opt/vc/lib/ -lbcm_host -lvcos -lvchiq_arm -Wl,--no-whole-archive -rdynamic
rm video_swap.o
eli@raspberrypi:~/rpi-output-swapper $ sudo ./video_swap.bin --status
failed to connect to tvservice</pre>
<p>which comes from this part in tvservice_init():</p>
<pre>    if ( vc_vchi_tv_init( vchi_instance, &amp;vchi_connections, 1) != 0) {
        fprintf(stderr, "failed to connect to tvservice\n");
        exit(-4);
    }</pre>
<p>which is implemented in userland/interface/vmcs_host/vc_vchi_tvservice.c, header file vc_tvservice.h in same directory (Raspberry&#8217;s official <a href="https://github.com/raspberrypi" target="_blank">git repo</a>).</p>
<p>After a lot of back and forth, I compared with the official repo&#8217;s <a href="https://github.com/raspberrypi/userland/tree/master/host_applications/linux/apps/tvservice" target="_blank">tvservice utitlity</a> and discovered that it doesn&#8217;t check vc_vhci_tv_init()&#8217;s return value. So I ditched the check on video_swap as well, and it worked. But the results on the screen were so messy, that I didn&#8217;t want to pursue this direction.</p>
<p>In what follows, some things I found out while trying to solve the problem: The program opens /dev/vchiq on bcm_host_init(), and performs a lot of ioctl()&#8217;s on it. The rest of tvservice_init() until the error message causes no system calls at all!</p>
<p>/dev/vchiq had major/minor 248/0 on my system. According to /proc/devices, it belongs to the vchiq module (not a big surprise&#8230;). Drivers are at drivers/misc/vc04_services/interface/vchiq_arm/ Seemingly with vchiq_arm.c as the top level file, and are enabled with CONFIG_BCM2708_VCHIQ.</p>
<p><a href="https://github.com/nezticle/RaspberryPi-BuildRoot/wiki/VideoCore-Tools" target="_blank">There&#8217;s a utility</a>, <a href="http://www.elinux.org/RPI_vcgencmd_usage" target="_blank">vcgencmd</a> , for setting a lot of different things, log levels among them, but I didn&#8217;t manage to figure out where the log messages go to.</p>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2017/01/raspberry-pi-sdtv-hdmi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
