"ERROR: video data stream broken"

  • I'm using VDR for maybe 5 years mainly as back-end recording device. Some time ago my VDR started restarting very often so that recording became a mess of many files. I first investigated for possible HW problems - antenna connection, PC - input signal was perfect, same problem on different PC, same for vdr 2.0.4 and vdr 2.1.2. I performed testing with vdr-core only, no plugins. Using Ubuntu 13.10 and before 12.04. I recorded Finnish terrestrial TV channels.
    Finally, after some learning about vdr SW, I found the cause. It is inside the vdr.c line 896 if statement:
    895: // Handle channel and timer modifications:
    896: if (!Channels.BeingEdited() && !Timers.BeingEdited()) {


    The problem occurs when primary device, device-1, is recording a channel not equal to channel 1, e.g. channel 13, and the pids of channel 1 change during the recording channel 13. Current channel was 1 all the time(?). It happens with 1 and more devices, I tested with all devices recording. When channel 1 modifications pass the CHANNELMOD_RETUNE mask following function is called:
    915: cRecordControls::ChannelDataModified(Channel);
    that returns without any action because channel 1 is not the recording channel. Next following sequence leads to switching device 1 to channel 1:
    916: if (Channel->Number() == cDevice::CurrentChannel()) {
    if (!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring()) {
    if (cDevice::ActualDevice()->ProvidesTransponder(Channel)) { // avoids retune on devices that don't really access the transponder
    isyslog("retuning due to modification of channel %d", Channel->Number());
    920: Channels.SwitchTo(Channel->Number());


    I don't quite understand the purpose of this sequence and I haven't time to investigate it. Anyway in my case the currentChannel = 1 all the time, so for channel 1 it meets the if condition and it also passes the 2nd if.
    Well, device 1 is switched to channel 1 even it is recording on channel 13, and after 30s we get timeout in recorder.c line 169, because channel 13 is cut off.


    I got vdr working, at least for me, using a simple correction by commenting out line 920:
    920: // Channels.SwitchTo(Channel->Number());


    Maybe someone with a deeper knowledge about vdr could explain what really happens and propose a proper solution.

  • Hi Klaus,


    Please find the log below. Consider I'm using vdr only as recording device.


    BR, Toomas


    Dec 27 17:45:00 TW-U RUNVDR: Starting RUNVDR
    Dec 27 17:45:00 TW-U RUNVDR: RUNVDR has successfully started
    Dec 27 17:45:00 TW-U VDR: Starting VDR
    Dec 27 17:45:00 TW-U vdr: [14960] VDR version 2.1.2 started
    Dec 27 17:45:00 TW-U vdr: [14960] switched to user 'vdr'
    Dec 27 17:45:00 TW-U vdr: [14960] codeset is 'UTF-8' - known
    Dec 27 17:45:00 TW-U vdr: [14960] found 28 locales in /usr/local/vdr-212/share/locale
    Dec 27 17:45:00 TW-U vdr: [14960] loading /var/lib/vdr/setup.conf
    Dec 27 17:45:00 TW-U vdr: [14960] loading /var/lib/vdr/sources.conf
    Dec 27 17:45:00 TW-U vdr: [14960] loading /var/lib/vdr/diseqc.conf
    Dec 27 17:45:00 TW-U vdr: [14960] loading /var/lib/vdr/scr.conf
    Dec 27 17:45:00 TW-U vdr: [14960] loading /var/lib/vdr/channels.conf
    Dec 27 17:45:00 TW-U vdr: [14960] loading /var/lib/vdr/timers.conf
    Dec 27 17:45:00 TW-U vdr: [14960] loading /var/lib/vdr/svdrphosts.conf
    Dec 27 17:45:00 TW-U vdr: [14960] loading /var/lib/vdr/keymacros.conf
    Dec 27 17:45:00 TW-U vdr: [14960] registered source parameters for 'A - ATSC'
    Dec 27 17:45:00 TW-U vdr: [14960] registered source parameters for 'C - DVB-C'
    Dec 27 17:45:00 TW-U vdr: [14960] registered source parameters for 'S - DVB-S'
    Dec 27 17:45:00 TW-U vdr: [14960] registered source parameters for 'T - DVB-T'
    Dec 27 17:45:00 TW-U vdr: [14962] video directory scanner thread started (pid=14960, tid=14962, prio=high)
    Dec 27 17:45:00 TW-U vdr: [14960] probing /dev/dvb/adapter0/frontend0
    Dec 27 17:45:00 TW-U vdr: [14960] creating cDvbDevice
    Dec 27 17:45:00 TW-U vdr: [14960] new device number 1
    Dec 27 17:45:00 TW-U vdr: [14962] video directory scanner thread ended (pid=14960, tid=14962)
    Dec 27 17:45:00 TW-U vdr: [14961] video directory scanner thread started (pid=14960, tid=14961, prio=high)
    Dec 27 17:45:00 TW-U vdr: [14963] epg data reader thread started (pid=14960, tid=14963, prio=high)
    Dec 27 17:45:00 TW-U vdr: [14963] reading EPG data from /var/cache/vdr/epg.data
    Dec 27 17:45:00 TW-U vdr: [14961] video directory scanner thread ended (pid=14960, tid=14961)
    Dec 27 17:45:00 TW-U vdr: [14963] epg data reader thread ended (pid=14960, tid=14963)
    Dec 27 17:45:00 TW-U vdr: [14960] DVB API version is 0x050A (VDR was built with 0x050A)
    Dec 27 17:45:00 TW-U vdr: [14960] frontend 0/0 provides DVB-T with QPSK,QAM16,QAM64 ("DiBcom 7000PC")
    Dec 27 17:45:00 TW-U vdr: [14966] section handler thread started (pid=14960, tid=14966, prio=low)
    Dec 27 17:45:00 TW-U vdr: [14960] probing /dev/dvb/adapter1/frontend0
    Dec 27 17:45:00 TW-U vdr: [14965] tuner on frontend 0/0 thread started (pid=14960, tid=14965, prio=high)
    Dec 27 17:45:00 TW-U vdr: [14960] creating cDvbDevice
    Dec 27 17:45:00 TW-U vdr: [14960] new device number 2
    Dec 27 17:45:00 TW-U vdr: [14965] cTimeMs: using monotonic clock (resolution is 1 ns)
    Dec 27 17:45:00 TW-U vdr: [14960] frontend 1/0 provides DVB-T with QPSK,QAM16,QAM64 ("DiBcom 7000PC")
    Dec 27 17:45:00 TW-U vdr: [14960] found 2 DVB devices
    Dec 27 17:45:00 TW-U vdr: [14969] section handler thread started (pid=14960, tid=14969, prio=low)
    Dec 27 17:45:00 TW-U vdr: [14960] setting primary device to 1
    Dec 27 17:45:00 TW-U vdr: [14960] device 1 has no MPEG decoder
    Dec 27 17:45:00 TW-U vdr: [14960] assuming manual start of VDR
    Dec 27 17:45:00 TW-U vdr: [14960] SVDRP listening on port 6419
    Dec 27 17:45:00 TW-U vdr: [14968] tuner on frontend 1/0 thread started (pid=14960, tid=14968, prio=high)
    Dec 27 17:45:00 TW-U vdr: [14960] setting current skin to "lcars"
    Dec 27 17:45:00 TW-U vdr: [14960] loading /var/lib/vdr/themes/lcars-default.theme
    Dec 27 17:45:00 TW-U vdr: [14960] switching to channel 1
    Dec 27 17:45:00 TW-U vdr: [14960] setting watchdog timer to 60 seconds
    Dec 27 17:45:00 TW-U vdr: [14960] OSD size changed to 720x480 @ 1
    Dec 27 17:45:00 TW-U vdr: [14960] ERROR: no OSD provider available - using dummy OSD!
    Dec 27 17:45:00 TW-U vdr: [14960] timer 1 (13 2058-2200 'Totuuden anatomia') set to event To 02.01.2014 21:00-22:00 'Totuuden anatomia (12)'
    Dec 27 17:45:00 TW-U vdr: [14960] timer 2 (13 2058-2200 'Scandal') set to event Su 29.12.2013 21:00-21:50 'Scandal (7)'
    Dec 27 17:45:00 TW-U vdr: [14960] timer 3 (13 2058-2210 'Good Wife') set to event Ma 30.12.2013 21:00-22:00 'Good Wife (12)'
    Dec 27 17:45:00 TW-U vdr: [14960] timer 4 (10 2243-2350 'Dallas') set to event Pe 27.12.2013 22:45-23:40 'Dallas (7)'
    Dec 27 17:45:00 TW-U vdr: [14960] timer 5 (10 1233-1900 'Test-27.12-MTV3-tw') set to event Pe 27.12.2013 17:25-17:55 'Kauniit ja rohkeat (7)'


    Dec 27 17:45:00 TW-U vdr: [14960] switching device 1 to channel 10


    Dec 27 17:45:00 TW-U vdr: [14960] timer 5 (10 1233-1900 'Test-27.12-MTV3-tw') start
    Dec 27 17:45:00 TW-U vdr: [14960] Title: 'Kauniit ja rohkeat (7)' Subtitle: '(null)'
    Dec 27 17:45:00 TW-U vdr: [14960] record /Data-U1/video/Test-27.12-MTV3-tw/2013-12-27.12.33.10-0.rec
    Dec 27 17:45:00 TW-U vdr: [14960] recording to '/Data-U1/video/Test-27.12-MTV3-tw/2013-12-27.12.33.10-0.rec/00011.ts'
    Dec 27 17:45:00 TW-U vdr: [14970] recording thread started (pid=14960, tid=14970, prio=high)
    Dec 27 17:45:00 TW-U vdr: [14971] receiver on device 1 thread started (pid=14960, tid=14971, prio=high)
    Dec 27 17:45:00 TW-U vdr: [14972] TS buffer on device 1 thread started (pid=14960, tid=14972, prio=high)
    Dec 27 17:45:00 TW-U vdr: [14960] max. latency time 1 seconds
    Dec 27 17:45:01 TW-U vdr: [14966] channel 10 (MTV3) event Pe 27.12.2013 17:25-17:55 'Kauniit ja rohkeat (7)' status 4
    Dec 27 17:45:02 TW-U vdr: [14966] channel 13 (Liv) event Pe 27.12.2013 17:00-17:55 'Liv D: Tanssikisojen superäidit (S)' status 4
    Dec 27 17:45:25 TW-U vdr: [14960] timer 5 (10 1233-1900 'Test-27.12-MTV3-tw') set to event Pe 27.12.2013 15:15-17:05 'Koirahotelli (7)'


    Dec 27 17:55:50 TW-U vdr: [14969] changing pids of channel 3 from 514+514=2:670=sve@4,672=dut@4:3027=fin,3028=sve:5001 to 514+514=2:670=sve@4:3027=fin,3028=sve:5001
    -> channel 1 PIDs are modified
    Dec 27 17:57:14 TW-U vdr: [14969] changing pids of channel 1 from 512+512=2:650=eng@4,652=dut@4:1027=fin:5000 to 512+512=2:650=fra@4,652=dut@4:1027=fin:5000


    Dec 27 18:00:02 TW-U vdr: [14966] channel 10 (MTV3) event Pe 27.12.2013 18:00-18:30 'Emmerdale (S)' status 4
    Dec 27 18:00:09 TW-U vdr: [14969] changing pids of channel 1 from 512+512=2:650=fra@4,652=dut@4:1027=fin:5000 to 512+512=2:650=fin@4:1027=fin:5000
    Dec 27 18:00:09 TW-U vdr: [14969] changing pids of channel 4 from 516+516=2:690=sve@4,694=dut@4:4027=fin:5000 to 516+516=2:690=deu@4,694=dut@4:4027=fin:5000
    -> device 1 is switched to channel 1
    Dec 27 18:00:09 TW-U vdr: [14960] retuning due to modification of channel 1
    Dec 27 18:00:09 TW-U vdr: [14960] switching to channel 1
    -> 30s
    Dec 27 18:00:39 TW-U vdr: [14970] ERROR: video data stream broken
    Dec 27 18:00:39 TW-U vdr: [14970] initiating emergency exit
    Dec 27 18:00:40 TW-U vdr: [14960] emergency exit requested - shutting down
    Dec 27 18:00:40 TW-U vdr: [14970] recording thread ended (pid=14960, tid=14970)
    Dec 27 18:00:40 TW-U vdr: [14960] buffer stats: 95504 (0%) used
    Dec 27 18:00:40 TW-U vdr: [14960] timer 5 (10 1233-1900 'Test-27.12-MTV3-tw') stop
    Dec 27 18:00:40 TW-U vdr: [14960] saved setup to /var/lib/vdr/setup.conf
    Dec 27 18:00:40 TW-U vdr: [14966] section handler thread ended (pid=14960, tid=14966)
    Dec 27 18:00:40 TW-U vdr: [14965] tuner on frontend 0/0 thread ended (pid=14960, tid=14965)
    Dec 27 18:00:40 TW-U vdr: [14969] section handler thread ended (pid=14960, tid=14969)
    Dec 27 18:00:40 TW-U vdr: [14968] tuner on frontend 1/0 thread ended (pid=14960, tid=14968)
    Dec 27 18:00:40 TW-U vdr: [14960] max. latency time 1 seconds
    Dec 27 18:00:40 TW-U vdr: [14960] emergency exit!
    Dec 27 18:00:40 TW-U vdr: [14960] exiting, exit code 1
    Dec 27 18:00:40 TW-U VDR: VDR got a fault (retval=1), trying to restart
    Dec 27 18:00:42 TW-U VDR: Starting VDR
    Dec 27 18:00:42 TW-U vdr: [15406] VDR version 2.1.2 started


    ... etc same behaviour happens again when channel 1 gets PIDs modification and switches device 1 to channel 1
    even device 1 is recording channel 10

  • Can you please try this patch?



    Klaus

  • Hi Klaus,


    I included your patch and am waiting for channel 1 PID event. But I could already now say that this patch will prevent switching device 1 to channel 1 for my vdr, because my devices haven't decoder - so having the same effect I had when commenting out the actual channel switch.
    But is this OK for the devices with decoder? And what is the purpose of this channel switch?


    BR, Toomas


  • I included your patch and am waiting for channel 1 PID event. But I could already now say that this patch will prevent switching device 1 to channel 1 for my vdr, because my devices haven't decoder - so having the same effect I had when commenting out the actual channel switch.
    But is this OK for the devices with decoder? And what is the purpose of this channel switch?


    The purpose is that in case a channel changes, for instance, its PIDs, the live viewing will follow these changes.
    There are channels that have a "local window" in their programme, where PIDs are switched in order to broadcast a different stream. Without this channel switch the live view would keep on showing the old PIDs. A channel where this behavior can be tested is


    Test-R;ARD:10744:HC56M2S0:S19.2E:22000:401=2:402=deu@3:0:0:28726:1:1051:0


    Since my patch only has an effect on systems where the primary device doesn't have a decoder, it shouldn't make any difference for primary devices with a decoder.


    Klaus

  • Hi Klaus,


    OK now it is tested, your patch works:


    Jan 26 15:04:42 TW-U vdr: [5686] channels-1: channel 1 (Yle TV1) PID-mod = 42: changing pids from 512+512=2:650=fin@4:1027=fin,1050=dut:5000 to 512+512=2:650=eng@4:1027=fin:5000
    Jan 26 15:04:43 TW-U vdr: [5680] vdr-1: channel 1 (Yle TV1) modification = 42 : currentChannel 1


    I have 2 debug loggers that show what happened. Before PID modification 0x42 would have caused switching.
    Well, this is a very old bug, from some reason Finnish TV started changing PIDs of their channels very often so it became annoying only lately, before vdr was restarting not very often.


    BR, Toomas