Project

General

Profile

TVHeadend Raspberry Pi and Transcoding

Added by lord slash about 10 years ago

Hi guys, I've setup a TVHeadend back end with my raspberry pi and raspbian, where I stream the italian tv to my home in Germany. The system works perfectly during the day, but in the evening the DSL bandwidth is not enough (I need around 4000kbps and I have 3000kbps).

Therefore I would like to try the TVHeadend transcoding option. According to this: https://tvheadend.org/boards/4/topics/13635?r=13637 I should compile after enabling the transcoding in the configuration file src/plumbing/transcoding.c The problem is that in this file there is no uint32_t transcoding_enabled at all. I tried a ./configure --enable-libffmpeg_static and then make and make install, but in the TVHeadend transcoding option is not there :(

What happened to the uint32_t transcoding_enabled ?? How should I compile in order to get transcoding work on my pi? By the way, I have TVHeadend 3.9.1879. Thanks in advance for the help!


Replies (160)

RE: TVHeadend Raspberry Pi and Transcoding - Added by Prof Yaffle about 10 years ago

Transcoding is built in now. There's no need to twiddle the code.

If you're using Rasbian or some other Debian-alike, you may get away with this:

AUTOBUILD_CONFIGURE_EXTRA=--enable-libffmpeg_static ./Autobuild.sh -t precise-amd64 <or i386 if you're on a 32-bit platform>

... to produce a .deb that you can install with sudo dpkg -i <file>

RE: TVHeadend Raspberry Pi and Transcoding - Added by lord slash about 10 years ago

i'm using raspbian but why should i write precise-amd64 <or i386 if i'm on a raspberry pi (arm processor)?!

RE: TVHeadend Raspberry Pi and Transcoding - Added by Prof Yaffle about 10 years ago

There's actually a very good reason - it's because I'm immensely stupid and wasn't thinking. You'd build for ARM, of course.

You don't need to build a .deb - if you've enabled static ffmpeg then all the code should be there. Also, there's no longer a need to 'enable' transcoding, you instead set up a new profile and then use it in the URL and/or assign it to the user as which XBMC connects.

RE: TVHeadend Raspberry Pi and Transcoding - Added by lord slash about 10 years ago

Hold on, then why don't I see in Configuration-General the option to enable transcoding?

RE: TVHeadend Raspberry Pi and Transcoding - Added by Prof Yaffle about 10 years ago

Because it's not needed any more - it's there by default. If you define a streaming profile and reference it, then it should work. Build it and they'll come...

RE: TVHeadend Raspberry Pi and Transcoding - Added by lord slash about 10 years ago

uhmmm.. how should I define this streaming profile? Configuration - Stream - Stream profile is correct? How should I configure it? If I click on "Add" i can select between HTSP, Matroska and Pass (MPEG TS Pass Through).. Right now all the 3 are by default added and enabled, but default is "Pass".. What should I do? Sorry but there is no documentation at all where to look (or maybe I'm Blind :D ) thanks

Edit: I'm seeing from the screenshot on another thread that this is the way it should look like: https://tvheadend.org/attachments/download/2453/Screenshot%20-%20051114%20-%2010_53_06.png but I don't have any of the options below (container, resolution, video codec, audio codec, subtitles ecc..) is it possible that i compiled it wrong?

RE: TVHeadend Raspberry Pi and Transcoding - Added by lord slash about 10 years ago

lord slash wrote:

uhmmm.. how should I define this streaming profile? Configuration - Stream - Stream profile is correct? How should I configure it? If I click on "Add" i can select between HTSP, Matroska and Pass (MPEG TS Pass Through).. Right now all the 3 are by default added and enabled, but default is "Pass".. What should I do? Sorry but there is no documentation at all where to look (or maybe I'm Blind :D ) thanks

Edit: I'm seeing from the screenshot on another thread that this is the way it should look like: https://tvheadend.org/attachments/download/2453/Screenshot%20-%20051114%20-%2010_53_06.png but I don't have any of the options below (container, resolution, video codec, audio codec, subtitles ecc..) is it possible that i compiled it wrong?

Edit 2: I stopped the TVHeadend service and started it from the path of my "transcode" version /home/pi/tvheadend_transcode/build.linux/tvheadend and then I have the options of the screenshot!! But do I now have two TVHeadend versions installed?! I think I messed up a bit with my raspbian (the old one without transcoding starts by default at boot)

RE: TVHeadend Raspberry Pi and Transcoding - Added by Prof Yaffle about 10 years ago

You'd need to uninstall your previous version and use the self-build - or build a deb and install the new version over the old one with dpkg, potentially forcing the installation if the version numbers appear to be the same.

If you're running from build.linux, it's not actually installed yet, as it's merely a local executable. You can keep running it from there or install properly; building the deb and installing makes sure that it starts at boot time and has any needed depdencies which aren't going to get spotted with make install, which is why it's preferred.

RE: TVHeadend Raspberry Pi and Transcoding - Added by lord slash about 10 years ago

First I would like to understand if it actually transcodes something (and if the CPU of my PI can do it) :D
I created a "Test" stream profile where i can play with the settings; on access entries I created an account where the streaming profile is "Test". I am using VLC as front-end to see what and how it works: i open a network stream like this: http://username:password@ipadress:9981/playlist/channels and I start the channel (always the same one, SD channel).

webtv-h264-aac-matroska:
2014-11-05 15:57:56.434 [ INFO] transcode: 0001: 1:MPEG2VIDEO 720x576 > H264 480x384 (libx264)
2014-11-05 15:57:56.436 [ INFO] transcode: 0001: 2:MPEG2AUDIO > AAC (aac)
Illegal instruction

webtv-h264-aac-mpegts
2014-11-05 15:59:54.242 [WARNING] TS: Italy/690/LA7 Transport error indicator (total 1)
2014-11-05 15:59:54.295 [ INFO] transcode: 0001: 1:MPEG2VIDEO 720x576 > H264 480x384 (libx264)
2014-11-05 15:59:54.297 [ INFO] transcode: 0001: 2:MPEG2AUDIO > AAC (aac)
2014-11-05 15:59:54.454 [WARNING] TS: Italy/690/LA7: MPEG2VIDEO #6112 Corrupted PES header (errors 1)
2014-11-05 15:59:55.062 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.065 [WARNING] TS: Italy/690/LA7: MPEG2VIDEO
#6112 Continuity counter error (total 1)
2014-11-05 15:59:55.083 [WARNING] TS: Italy/690/LA7: MPEG2AUDIO @ #6113 Continuity counter error (total 1)
2014-11-05 15:59:55.153 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.156 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.177 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.247 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.270 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.273 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.364 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.367 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.410 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.457 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.504 [ ERROR] libav: Invalid frame dimensions 0x0.
2014-11-05 15:59:55.507 [ ERROR] libav: Invalid frame dimensions 0x0.
Illegal instruction

webtv-vp8-vorbis-webm
2014-11-05 16:01:44.216 [WARNING] TS: Italy/690/LA7 Transport error indicator (total 1)
2014-11-05 16:01:44.228 [ ERROR] libav: invalid mb type in P Frame at 0 6
2014-11-05 16:01:44.231 [ ERROR] libav: Warning MVs not available
2014-11-05 16:01:44.233 [ NOTICE] libav: concealing 1395 DC, 1395 AC, 1395 MV errors in P frame
2014-11-05 16:01:44.365 [ NOTICE] libav: v1.3.0

This one works!!! The bandwidth is strongly reduced (800kbps instead of 4000), but my CPU goes quickly to 100% :(
I will make more experiments from my XBMC, but I was wondering if i shouldn't say to VLC that I'm using H264 (I don't know actually know how/where)

RE: TVHeadend Raspberry Pi and Transcoding - Added by lord slash about 10 years ago

So far I didn't get it work..
I don't really know how to test if transcoding works.. I tried with http://ip:9961/tv.html my channel is listed, but when I click on it it tells me "unknown error" (but the VLC plugin for chrome doesn't work also with non-transcoded tvheadend stream, I don't know why. On the other hand, with non-transcoded stream it works on XBMC and VLC, but with transcoded stream it doesn't (i should probably somehow say h264 aac but I don't know where.. can you help me?

RE: TVHeadend Raspberry Pi and Transcoding - Added by Prof Yaffle about 10 years ago

I'd need to hand over to someone who actually uses transcoding, I'm afraid - I don't, so I don't know how best to guide you. It may be an issue with the CODECs you're choosing; there may be some more information in the logs; you may be able to switch on trace ( --trace=<module> ) when starting tvheadend to get more insight into what's happening.

VLC will tell you what you're receiving in Tools -> Codec Information; XBMC will tell you if you hit 'o' on the keyboard during playback.

RE: TVHeadend Raspberry Pi and Transcoding - Added by lord slash about 10 years ago

do you know someone who actually uses successfully transcoding and could help me? I've heard about an IRC channel, but on which server/channel?

RE: TVHeadend Raspberry Pi and Transcoding - Added by Prof Yaffle about 10 years ago

#hts on freenode - there are a couple of guys on there who've been playing with/using it.

RE: TVHeadend Raspberry Pi and Transcoding - Added by Gerald Silver about 10 years ago

Hi, I have also tried transcoding on my pi but unfortunately without success :( I have wasted a lot of time, but I could not do it.

If you had configured tha transcoding optin in your RPI successfully, would you shared the solution with me\us?

RE: TVHeadend Raspberry Pi and Transcoding - Added by lord slash about 10 years ago

so far no success.. i was thinking about tanscoding only audio (to spare a bit of bandwidth and not saturate my CPU) but so far I had no time to try it...

RE: TVHeadend Raspberry Pi and Transcoding - Added by Anonymous over 9 years ago

Hi there,

I'm using a PI B and tvheadend works great to stream TV in a LAN network. But as lord slash mentioned the upload/download
ratio of the steam is quite high (3000-4000 kb/s) so for web watching this is to high.
I guess the only option would be to compress the stream or transcode it into a different format.
I have built Tvheadend with ./configure --enable-libffmpeg_static

Does the tvheadend Kodi plugin support only the mpeg2 pass through option or does it support any other transcoded steam format ?
Tried any of the webtv transcoding options and got the same errors on all codes like lord slash.
So here we are 7 months later, I'm on Tvheadend 4.1.56 and it is breaking on the same errors.

Now let's assume the transcoding would work, does the PI have enough power to transcode a live stream ?
What are the theoretical bandwidth savings with the 3 available webtv codes ?

Thanks for any help or answer

May 25 11:05:39 pi-tvserver tvheadend[6960]: mpegts: 490MHz in DVB-T UK - tuning on Realtek RTL2832 (DVB-T) : DVB-T #0
May 25 11:05:39 pi-tvserver tvheadend[6960]: subscription: 0005: "192.168.0.18 [ user | XBMC Media Center ]" subscribing on channel "BBC ONE Lon", weight: 100, adapter: "Realtek RTL2832 (DVB-T) : DVB-T #0", network: "DVB-T UK", mux: "490MHz", service: "BBC ONE Lon", profile="webtv-h264-aac-mpegts", hostname="192.168.0.18", username="user", client="XBMC Media Center" 
May 25 11:05:39 pi-tvserver tvheadend[6960]: subscription: 0003: "epggrab" unsubscribing
May 25 11:05:39 pi-tvserver tvheadend[6960]: transcode: 0001: 1:MPEG2VIDEO 704x576 ==> H264 470x384 (libx264)
May 25 11:05:39 pi-tvserver tvheadend[6960]: transcode: 0001: 2:MPEG2AUDIO ==> AAC (aac)
May 25 11:05:40 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:40 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:40 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:40 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:40 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:40 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:40 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:40 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:40 pi-tvserver tvheadend[6960]: transcode: 0001: Detected framedrop in audio
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: Invalid frame dimensions 0x0.
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: ignoring invalid SAR: 16/11
May 25 11:05:41 pi-tvserver tvheadend[6960]: libav: warning: first frame is no keyframe

RE: TVHeadend Raspberry Pi and Transcoding - Added by Klaus D. over 9 years ago

Now let's assume the transcoding would work, does the PI have enough power to transcode a live stream ?

I tried it on a RPi2. Unfortunately, the Pi is not powerful enough to transcode a video stream in realtime using the CPU.

RE: TVHeadend Raspberry Pi and Transcoding - Added by Anonymous over 9 years ago

Klaus D. wrote:

Now let's assume the transcoding would work, does the PI have enough power to transcode a live stream ?

I tried it on a RPi2. Unfortunately, the Pi is not powerful enough to transcode a video stream in realtime using the CPU.

Ok so when a Pi2 which is 6x faster than a Pi1 is not powerful enough then we might have a problem here :( What about the hardware GPU transcoding ? As far as I know the is no mature software for this yet, but did anyone try to use Tvheadend with H.264 OpenMax ?

I found this page:
http://raspberrypi.stackexchange.com/questions/3936/what-speed-can-i-expect-from-the-hardware-h264-encoding

but would it be possible to see the codec in the Tvheadend stream profiles?

RE: TVHeadend Raspberry Pi and Transcoding - Added by renne - about 9 years ago

The information in forums are quite fuzzy, but it seems current versions of GStreamer (>= 1.0) contain the "GSTOpenMax"-Plugin which can decode AND encode h.264 on the OpenMax-stack of the RPI (and other ARM devices). Adding GStreamer-support in the TVHeadend transcoding should enable real-time transcoding at least for SD-resolutions.

[[https://blankstechblog.wordpress.com/2015/01/25/hardware-video-encoding-progess-with-the-raspberry-pi/]]

RE: TVHeadend Raspberry Pi and Transcoding - Added by Kris Van Bruwaene about 9 years ago

Aren't all these problems with mpeg2 transcoding due to the fact that the RPI needs a payed key to decode (so presumably transcode as well) mpeg2?

RE: TVHeadend Raspberry Pi and Transcoding - Added by renne - about 9 years ago

You need the MPEG2 license for MPEG2 hardware-decoding, of course. What we want to do is h.264-encoding in hardware. The RPi(2) is shipped with a h.264 hardware-decoder AND encoder including the license. The one and only problem is to interface an application like TVHeadend with the OpenMax hardware stack. It seems GSTreamer can do this.

TVHeadend uses FFMPEG for transcoding, not GSTreamer.

SD: MPEG2 Transport Stream -> OpenMax MPEG2 decoder -> RAW Frames -> OpenMax h.264 encoder

or

HD: h.264 Transport Stream -> OpenMax h.264 decoder -> RAW Frames -> OpenMax h.264 encoder with lower bitrate

RE: TVHeadend Raspberry Pi and Transcoding - Added by Maury Markowitz about 9 years ago

Realistically, if we have hardware decode/encode working properly, is a realtime, on-the-fly transcode of an ATSC stream from MPEG2 to h.264 something the RPi2 could handle? I'm talking about live streams of HD television, not offline recodes for DVR.

RE: TVHeadend Raspberry Pi and Transcoding - Added by renne - about 9 years ago

According to [[https://blankstechblog.wordpress.com/2015/01/25/hardware-video-encoding-progess-with-the-raspberry-pi/]] GSTreamer needed about 160% runtime to recode 720p60 from MPEG2 to h.264. The question for live-streaming would be if GSTreamer/the GST-OpenMax-Plugin can be optimized enough for live-streaming.

It's definitely an option for non-realtime re-coding as h.264-re-coding would allow to watch non-h.264 videos in browsers like the video window of TVHeadend.

RE: TVHeadend Raspberry Pi and Transcoding - Added by Maury Markowitz about 9 years ago

Most excellent Redmine. This suggest my goal of realtime transcoding to iOS devices is not realistic (for now).

So... has anyone used TVH with one of the transcoding hardware solutions like the SiliconDust EXTEND? I suspect that will work fine, although it would up the price of my system (I need two).

RE: TVHeadend Raspberry Pi and Transcoding - Added by Tony Brook over 8 years ago

So, I have this successfully set up and it seems to run OK. I've only been running it for a few hours, so time will tell.
I'm using a Pi3 though. I've compiled from source and this seemed to work. I've attached the debs.
Install using
sudo dpkg -i tvheadend_4.1-2116~gf59669c_armhf.deb && sudo dpkg -i tvheadend-dbg_4.1-2116~gf59669c_armhf.deb

(1-25/160)