Kodi Community Forum
[OLD] HOW-TO watch Live TV in XBMC for Linux with Tvheadend, the easy way! - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Tips, tricks, and step by step guides (https://forum.kodi.tv/forumdisplay.php?fid=110)
+--- Thread: [OLD] HOW-TO watch Live TV in XBMC for Linux with Tvheadend, the easy way! (/showthread.php?tid=51945)



- Gujs - 2010-09-07

Hi Ruud, I already prepared a fix for this. I will try to upload new version today late at night.


- Ruud - 2010-09-07

Gujs Wrote:Hi Ruud, I already prepaired fix for this. I will try to upload new version today late at night.
Thanks, looking forward to this patch.
Thanks for all your work!
regards,
Ruud.


- Ruud - 2010-09-08

Gujs Wrote:Hi Ruud, I already prepared a fix for this. I will try to upload new version today late at night.
Hi Gujs.

just tested your patch and it is not working as expected.
remember that after your previous patch the time was off +2 hours in XBMC but when setting a timer (recording) e.g. 22:00 hours (=+2) then in TVHeadend this recording would show up with the correct recording time being 20:00 hours.

Now with this patch the time in XBMC is correct but when setting the timer / recording for a program starting on 20:00 hours, the recording in TVHeadend will show up at 18:00 hours (= -2 hours).

Hope you can work with this information otherwise please let me know what you need to troubleshoot.

Oh, and when from within XBMC trying to remove a timer I get the message: "PVR server is not compatible.... please try again" -> I am running a unpatched 2.11 tvheadend installation. Could that have something to do with it?

regards,
Ruud.


- decay - 2010-09-09

Hm, launchpad down, just when i wanted to give -svn another try.

I got xbmc live running fine with a htsp:// source but want to try the pvr-testing2 branch. Is it recommended to switch to pvr-testing2 (especially in terms of WAF, is it usable right now?).

Thanks for the great work btw Smile


- decay - 2010-09-09

Cool, got it installed, pvr.hts has been installed, let's see what happens when i get home and able to test a bit.


- decay - 2010-09-09

Ok, working as expected, Live-TV displays fine through the hts addon, EPG shows everything 2h early.

I.e. Running program 1800-1900 shows information from the program running 16-1700.

Same for recording. Tvheadend used is 2.7, should probably upgrade that to 2.11.

edit: forgot to mention that i'm on GMT+2 currently, so it seems a simple timezone matter at the first glance.


- pinthenet - 2010-09-10

I've been experiencing regular crashes with recent pvr_testing packages.
In the latest version (2pvr~10.08~svn33599-lucid1 ) xbmc often crashes when starting a channel. Usually XBMC restarts but yesterday I had to reboot once.

In earlier versions (a week or so ago) it often crashed the first time I tried to select EPG within LiveTV.

I can't spot anything in the log file or crash log yet, but I'm still looking

I realise it's not final software but I'd be interested to know if anyone else has similar issues, in case it's something with my setup.

Thanks
John


- Nick8888 - 2010-09-10

I finally got commercial skipping to work with tvheadend using comskip.exe and wine.

Here's the script for anyone that wants it, just change the variables marked EDIT.

Only use it if you understand what its doing because I will not be responsible if anything goes wrong.

Code:
#!/bin/sh

# Variables
MKVVIDEO=$1    #Full path to recording                /home/user/Videos/News.mkv
b=$2        #Basename of recording                News.mkv
c=$3        #Channel name                    BBC world
C=$4        #Who created this recording            user
t=$5        #Program title                    News
c=$6        #Program description                News and stories...
S=$7        #Start time stamp of recording, UNIX epoch    1224421200
E=$8        #Stop time stamp of recording, UNIX epoch    1224426600
b=$(echo "$b" | sed "s/....$//")    # Remove file ext (4 char)
MKVPATH=$(echo "$MKVVIDEO" | sed "s/....$//")    # Remove file ext (4 char)

TRANSCODEPATH='~/Videos/TranscodedRecordings/'                    # EDIT
EDLFILE="$TRANSCODEPATH$b.edl"
COMSKIPPATH="c:/Program Files/comskip80_032/comskip.exe"            # EDIT
COMSKIPLOGS="/home/nick/.wine/dosdevices/c:/Program Files/comskip80_032/logs/"    # EDIT

MPGVIDEO=$TRANSCODEPATH$b".mpg"    # Add new extention to filename

/bin/sync    # flush diskbuffer

# Transcode to mpg
echo "*****" >/var/log/tvheadendpp.log
echo "*****" >>/var/log/tvheadendpp.log
echo "Starting Transcode to .mpg" >>/var/log/tvheadendpp.log
echo "*****" >>/var/log/tvheadendpp.log
echo "***** INPUT = $MKVVIDEO *****" >>/var/log/tvheadendpp.log
echo "***** OUTPUT = $MPGVIDEO *****" >>/var/log/tvheadendpp.log
echo "*****" >>/var/log/tvheadendpp.log
/usr/bin/whoami >>/var/log/tvheadendpp.log    # for debugging purposes, who is running this script?
/bin/date >>/var/log/tvheadendpp.log
echo "*****" >>/var/log/tvheadendpp.log
echo "*****" >>/var/log/tvheadendpp.log

ffmpeg -v 10 -i "$MKVVIDEO" -vcodec copy -acodec copy "$MPGVIDEO" </dev/null >>/var/log/tvheadendpp.log 2>&1    

echo "*****" >>/var/log/tvheadendpp.log
echo "*****" >>/var/log/tvheadendpp.log


echo "Starting Commercial Flagging" >>/var/log/tvheadendpp.log
echo "*****" >>/var/log/tvheadendpp.log
echo "***** INPUT = "$MPGVIDEO" *****" >>/var/log/tvheadendpp.log
echo "***** OUTPUT = "$EDLFILE" *****" >>/var/log/tvheadendpp.log
echo "*****" >>/var/log/tvheadendpp.log
/usr/bin/whoami >>/var/log/tvheadendpp.log    # for debugging purposes, who is running this script?
/bin/date >>/var/log/tvheadendpp.log
echo "*****" >>/var/log/tvheadendpp.log
echo "*****" >>/var/log/tvheadendpp.log

wine "$COMSKIPPATH" "$MPGVIDEO" </dev/null >>/var/log/tvheadendpp.log 2>&1

echo "*****" >>/var/log/tvheadendpp.log
echo "*****" >>/var/log/tvheadendpp.log

# Move Comskip Log File
echo "Moving Log file to '$COMSKIPLOGS$b.log'" </dev/null >>/var/log/tvheadendpp.log 2>&1

mv "$TRANSCODEPATH$b.log" "$COMSKIPLOGS"

# Move .edl back to MKV Path
echo "Copying edl file to '$MKVPATH.edl'" </dev/null >>/var/log/tvheadendpp.log 2>&1
cp "$EDLFILE" "$MKVPATH.edl"

echo "EDL for $MKVVIDEO:" >>/var/log/tvheadendpp.log

echo "Finished at `date`" >>/var/log/tvheadendpp.log

Based on script by Ruud and a few others on the net.

Run in tvheadend with "~/path/to/script.sh %f %b"

Basically converts mkv to mpg then creates an edl file and copies it to mkv folder. Log file in /var/log/tvheadendpp.log

I didn't trust myself with deleting any files so feel free to add that yourself.
Code:
ffmpeg -v 10 -i "$MKVVIDEO" -acodec copy -vcodec libx264 -vpre veryfast -s hd480 -b 500k "$TRANSCODEPATH$b.edl" </dev/null >>/var/log/posttvheader.log 2>&1
can also be used to transcode the mkv to a smaller mkv after edl completion.

I haven't done much testing with the actual commercial skipping but I have seen it is not working 100%. I think the comskip.ini will have to be tweaked a little too.

I tried with mythcommflag but was never able to get it to work standalone with the --skipdb option (it would work fine with recordings from mythtv which had info in the database but for some reason it would not work with the exact same file with the skipdb option) If anyone has that working I can provide some extra lines of the script to convert the mythtv edl to a xbmc standard.


- Nick8888 - 2010-09-11

Okay, I've found out why comskip isn't finding commercials so well.. it doesn't like the output of and struggles to decode some video/audio:

Code:
ffmpeg -v 10 -i "$MKVVIDEO" -vcodec copy -acodec copy "$MPGVIDEO"

I've changed it to
Code:
ffmpeg -v 10 -i "$MKVVIDEO" -vcodec copy -ab 128k "$MPGVIDEO"

and it now finds all the commercials very accurately but with massive a/v sync issues.

Ive tried experimenting with -copyts 1 and -async 1 but had no luck. I'm hoping someone has a solution to getting tvheadend output to a comskip compatible file.

EDIT: I should add, mythtv's output works flawlessly.. When I re-encode mythtvs output with ffmpeg, it becomes a little more unreliable but still in sync.

EDIT2:
Code:
ffmpeg -v 10 -i "$MKVVIDEO" -vcodec mpeg2video -sameq -acodec copy -f vob -copyts "$MPGVIDEO"
Works flawlessly for me. The above seems to work for ALL files, picking up every commercial break Ive thrown at it so far. Only downside is the longer processing time. ~30mins all up I think for a 2gb recording.

Just testing out the donators version of comskip now to see if it helps at all. Problem with the other settings seems to be some dropped frames or something at the beginning of some mkvs. All the commercial breaks were off by 30secs in those files.


Quote:Output #0, mpeg, to '/home/nick/Recordings/NCIS.2010-09-10.mpg':
Metadata:
encoder : Lavf52.78.3
Stream #0.0(eng): Video: mpeg2video, yuv420p, 720x576 [PAR 64:45 DAR 16:9], q=2-31, 15000 kb/s, 90k tbn, 25 tbc
Stream #0.1(eng): Audio: mp2, 48000 Hz, 2 channels, 256 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
[mpeg @ 0x915ca60] buffer underflow i=1 bufi=0 size=768
Last message repeated 1 times
frame= 555 fps= 0 q=-1.0 size= 16968kB time=52.24 bitrate=2660.8kbits/s
frame= 1011 fps=1011 q=-1.0 size= 30994kB time=70.50 bitrate=3601.3kbits/s
frame= 1617 fps=1078 q=-1.0 size= 49586kB time=94.67 bitrate=4290.7kbits/s

Here's part of my ffmpeg log showing the sync problem. 768(frames) divided by 25(fps) = ~30sec
When comskip tries to find the commercials, the audio and video are out of sync by the same amount and the commercial breaks in the edl occur 30seconds early.

EDIT3: Just realised when playing back the original problematic files in xbmc, while it plays fine, the playtime begins at 0.30 and cannot be skipped back before that time. It does not skip 30seconds of video, rather there is something there which is erroneous. When I transcode the file, the new one has 30 seconds of grey and no sound at the beginning which helps comskip create a valid edl. I'm starting to think its a bug with how tvheadend creates the mkv. Fixing this would save alot of video transcoding time which I am currently doing to make the edl (which are working great!!).


- moontan77 - 2010-09-13

anyone know of any android media players that play tvheadend rtsp streams without transcoding?

with a lot of android tablest due out over the next few months that can handle mpeg2, it would be great to be able to watch tvheadend streams on a tablet. The current archos 5 (which i have) should be able to handle the streams aswell.


- kurai - 2010-09-13

On a slightly off topic tangent ...

One major problem I have with TvHeadend is that it locks up the kernel on USB unplug event when suspending/hibernating.

Does anyone know if VDR has the same issue ?


- tsint - 2010-09-13

Do you have a script to unload/load the tuner modules when you suspend/resume?

This is my sleep script, /etc/pm/sleep.d/66_tuner

Code:
#!/bin/sh

case "$1" in
        suspend)
                /usr/sbin/service tvheadend stop
                rmmod budget_ci
                rmmod budget_core
                rmmod dvb_core
                rmmod tda10023
                echo "stopped tuner!" >> /tmp/tuner.log
        ;;
        resume)
                modprobe budget_ci
                modprobe budget_core
                modprobe dvb_core
                modprobe tda10023
                /usr/sbin/service tvheadend start
                echo "started tuner!" >> /tmp/tuner.log
        ;;
esac

Perhaps this only works if you have a PCI-tuner...


- petie74 - 2010-09-13

Great, thanx for this, always need to fix but never got around to and you help leading me to a Hauppauge PVR-150 solution. Cheers
http://ubuntuforums.org/showthread.php?t=678822


- kurai - 2010-09-13

tsint Wrote:Do you have a script to unload/load the tuner modules when you suspend/resume?

This is my sleep script, /etc/pm/sleep.d/66_tuner

Code:
...

Perhaps this only works if you have a PCI-tuner...

Doh - it never even occured to me to take the (now) obvious route, and create an additional sleep script. :o

Looks like the tvheadend init.d script exits and detaches from modules cleanly, so doesn't even require me to rmmod the stuff for my USB Avermedia A850 tuner.

All works fine now - thanks tsint. Big Grin


- peely - 2010-09-14

decay Wrote:Ok, working as expected, Live-TV displays fine through the hts addon, EPG shows everything 2h early.

I.e. Running program 1800-1900 shows information from the program running 16-1700.

edit: forgot to mention that i'm on GMT+2 currently, so it seems a simple timezone matter at the first glance.

I have the same issue in the UK, XBMC shows the tvheadend EPG data an hour early as we're currently in DST, being GMT + 1. Tvheadend shows the correct data and both my server and client are in the same timezone.

N.