Project

General

Profile

TVHeadend build and install on Ubuntu 22.04 64 bit x86_64 platform for beginners

Added by Jonas Lang about 2 years ago

I am setting out below what instructions I used to build TVHeadend from source on Ubuntu 22.04 64 bit based on the x86_64 architecture in a simple copy/paste format.Obviously this is aimed at the TVH beginner who wants to build a version of TVH to run on their own particular machine based on the x86_64 architecture.

This was the build process I followed:

You need to install build tools,Git and any possible missing dependencies.

sudo apt install build-essential git libpcre2-dev pkg-config libssl-dev bzip2 wget libavahi-client-dev zlib1g-dev libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavresample-dev gettext cmake libiconv-hook-dev liburiparser-dev debhelper libcurl4-gnutls-dev 

You need to clone the TVH Git

git clone https://github.com/tvheadend/tvheadend.git ~/build/tvheadend/master

Next change to the folder that the Git clone is located in

cd ~/build/tvheadend/master

Then run the autobuild.sh script like this..This command builds Tvheadend with transcoding built-in.

AUTOBUILD_CONFIGURE_EXTRA=--enable-libffmpeg_static\ --enable-trace\ --enable-debug ./Autobuild.sh

You may be missing dependencies.If so the output from the Autobuild script will tell you which ones need to be installed. All you have to do is copy/paste the name of each missing package and use the following command to install them.

If as already reported the build process complains it can't find Python, check with the following command if it is actually installed. Ubuntu 22.04 base installation usually comes with Python 3 installed.

python3 --version

If the system reports that Python 3 is indeed installed we need to inform the Autobuild script of this fact. This useful utility will create automatic symlinks pointing the autobuild script to the fact that Python 3 is installed so the autobuild script can continue.

sudo apt install python-is-python3

Now continue on and install any of the missing packages reported by the autobuild script.

sudo apt install [ _any of the missing dependencies that the build process reported missing_ ]

Once all the missing dependencies are installed run the autobuild script again. It could take 20-30 minutes to complete.

AUTOBUILD_CONFIGURE_EXTRA=--enable-libffmpeg_static\ --enable-trace\ --enable-debug ./Autobuild.sh

Once the build is complete you will be back at the terminal prompt.The build files will look something like this.You will see them in /build/tvheadend.Take note of the name of the .deb file that build created.That's the file you will be installing.

tvheadend_4.3-373~gcb5f6a1_amd64.deb
tvheadend-dbg_4.3-373~gcb5f6a1_amd64.deb

Finally you can then install them both by running dpkg like this..

cd ~/build/tvheadend
sudo dpkg -i tvheadend*4.3-373~gcb5f6a1_amd64.deb

I suggest you restart you computer once the above is complete. Once restarted you should be ready to configure TVH. It will be located at port 9981

I've been usinf TVH for many years but have never built it myself. I've now got a copy of TVH tailored for my computer which also includes transcoding.

Just to conclude this post

To stay up to date with the latest code (commit) from the TVH Github you can use the following procedure

I followed this procedure to keep my build version up to date with the master version

To get the latest of the TVH code (commit) enter the following

cd ~/build/tvheadend/master

This will navigate you to the folder where your own local version of the TVH code is located

Next we will need to fetch the latest code (commit) from the TVH Github

git pull origin master

Next we need to build TVH again with the latest TVH code (commit)

AUTOBUILD_CONFIGURE_EXTRA=--enable-libffmpeg_static\ --enable-trace\ --enable-debug ./Autobuild.sh

Now your should see your new build by doing the following

cd
cd ~/build/tvheadend
ls 

Take note of the name of the newly built deb package as you will need it to install it.

The following steps will stop the current TVH service daemon and remove TVH but not all your configuration.

sudo systemctl stop tvheadend
sudo apt remove tvheadend -y

Finally you can now install your freshly built TVH package you built earlier. I'll use the deb package name I created earlier but you will get the actual name of your build from the ls command you used above.

sudo dpkg -i  tvheadend_4.3-2038~g5f9404117_amd64.deb

You should now have your latest build of TVH running which can be accessed in the usual way at port 9981 with all your previous configuration settings in place


Replies (45)

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Martin Davies about 2 years ago

Hi Jonas,

Many thanks for this. It worked for me.

I did encounter a couple of problems but got it working in the end.

I did have to run the command..

sudo apt install python-is-python3

..to get the compilation to work.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Jonas Lang about 2 years ago

Did you not already have Python 3 installed. What other difficulties did you experience.

I ensured I kept things as simple and clear as possible all set out in simple copy/paste format to suit the beginner.

Many of the build related posts here are either old and/or cluttered to such an extent it’s difficult to follow them. The self build option is far better than relying on someone to maintain a repository.

Glad it helped. If you feel you have anything to add to the post fire away.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Jonas Lang about 2 years ago

What version of Python3 did you install. Did you install Python3-requests too.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Sean Warner about 2 years ago

Hi Jonas,

Thanks a lot for posting these instructions.

I run Tvheadend on a Pi 4 in Ubuntu server 22.04.

I currently get a pre built Tvheadend from an unofficial PPA provided by Michael Marley which I set up using instructions here, https://tvheadend.org/projects/tvheadend/wiki/AptRepositories

What changes would I need to make to your instructions to build from source for Ubuntu server 22.04 on a Pi 4 which I believe is arm64?

Also, I don't know much about this, but can I build it using your commands on my Intel laptop running Arch/Manjaro and then transfer the .deb files to Ubuntu or do I need to run your commands on my Pi?

Cheers,

Flex

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Jonas Lang about 2 years ago

I don’t have an RPi4 that I could build test but all you need to do is change your build target. @Dave Pickles has outlined in detail here how he achieved it for a Raspbian 64 bit install. Adjust the settings in AUTOBUILD_CONFIGURE_EXTRA to the version you require to target your build at. https://tvheadend.org/boards/5/topics/43309?r=45167

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Martin Davies about 2 years ago

Jonas Lang wrote:

What version of Python3 did you install. Did you install Python3-requests too.

I have python 3.10.6 installed. python3-requests is already installed.

I've got the 4.3 tvheadend installation working but I've got a problem with some muxes failing their scan. I'll write a separate note once I've done more investigation. I'm not sure what the problem is. Some muxes scan and identify channels correctly but others fail. There doesn't seem to be a clear pattern.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Jonas Lang about 2 years ago

Ok. I’ll check the autobuild script on that Python issue you had. I use Python so it wouldn’t have shown up in my build process.

The failed mux scanning sounds more like a hardware issue. Is the pass/fail pattern showing between higher and lower band Muxes. Assuming you are using a universal LNB have you the correct settings in TVH to reflect this.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Jonas Lang about 2 years ago

Martin Davies wrote:

Jonas Lang wrote:

What version of Python3 did you install. Did you install Python3-requests too.

I have python 3.10.6 installed. python3-requests is already installed.

I've got the 4.3 tvheadend installation working but I've got a problem with some muxes failing their scan. I'll write a separate note once I've done more investigation. I'm not sure what the problem is. Some muxes scan and identify channels correctly but others fail. There doesn't seem to be a clear pattern.

By any chance did you keep a copy of your build log.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Sean Warner about 2 years ago

Jonas Lang wrote:

I don’t have an RPi4 that I could build test but all you need to do is change your build target. @Dave Pickles has outlined in detail here how he achieved it for a Raspbian 64 bit install. Adjust the settings in AUTOBUILD_CONFIGURE_EXTRA to the version you require to target your build at. https://tvheadend.org/boards/5/topics/43309?r=45167

Thanks for this. But I'm not sure what target to put in the AUTOBUILD_CONFIGURE_EXTRA command. Here is my system:

ubuntu@ubuntu:~$ uname -a
Linux ubuntu 5.15.0-1015-raspi #17-Ubuntu SMP PREEMPT Mon Sep 12 13:14:51 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

The tvheadend git autobuild script page https://github.com/tvheadend/tvheadend/tree/master/Autobuild has some script options but none look like what I need for Ubuntu 22.04 Server on a Pi 4.

Why does yours not specify a target after ./Autobuild.sh ??

I've seen ..../Autobuild.sh -t xenial-arm64.sh in some places and @dave pickles uses

./Autobuild.sh -t raspbianbuster-armhf
but I'm not running Raspbian Buster on my Pi 4 and others (like yourself) don't mention a target at all? Maybe you only need to do that if cross-compiling? I would prefer to build on my Manjaro intel laptop and run it on the Pi but if that's too complicated I guess I'd settle for just building on the Pi.

It all seems very intimidating to me, I could be facing walls of cryptic errors messages for days.

Cheers,

Flex

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Jonas Lang about 2 years ago

I was talking about building on your laptop for the RPI4.

If you are building on the RPI4 you can see there are builds for the different processors. Part of the build process is a check on what processor is being used so you’ll get the relevant latest build built for your board.

My instructions should generally cover most Debian based distributions but all I can confirm working is what I built mine on.

Remember the autobuild script does all the heavy lifting and advises you if you are missing something that you can install and build again. The messages are not cryptic.

The best thing to do is go ahead and start the build process. What harm can it do and post back if you get stuck along the way.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Jonas Lang about 2 years ago

Martin Davies wrote:

Hi Jonas,

Many thanks for this. It worked for me.

I did encounter a couple of problems but got it working in the end.

I did have to run the command..

sudo apt install python-is-python3

..to get the compilation to work.

As I suspected.The autobuild script is targeting Python to complete the build and not Python 3. python-is-python3 will create symlinks pointing the build process to Python 3 when it looks for Python. The devs may want to change the build script to reflect. I've changed my instructions above to reflect this.I ran the build again using these changes and deb package built with no errors.

Hopefully others can now use these build instructions just to confirm all is in order.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Sean Warner about 2 years ago

Jonas Lang wrote:

The best thing to do is go ahead and start the build process. What harm can it do and post back if you get stuck along the way.

Hi again,

OK I tried running your commands by ssh'ing in to my Ubuntu 22.04 running on a Pi 4.
When I tried the first command I got:

E: Package 'libavresample-dev' has no installation candidate

I could not sudo apt install libavresample-dev either, it doesn't seem to exist in apt for Ubuntu 22.04.
I substituted it for libswresample-dev and all that command did proceed successfully.

I then got to..

AUTOBUILD_CONFIGURE_EXTRA=--enable-libffmpeg_static\ --enable-trace\ --enable-debug ./Autobuild.sh

But after about 20mins got the error:

"configure: error: cannot guess build type; you must specify one" 

Just to recap, these are my system details (Ubuntu 22.04 on a Pi 4, arm64):

ubuntu@ubuntu:~/build/tvheadend/master$ uname -a
Linux ubuntu 5.15.0-1015-raspi #17-Ubuntu SMP PREEMPT Mon Sep 12 13:14:51 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
ubuntu@ubuntu:~/build/tvheadend/master$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS" 

I then tried:

AUTOBUILD_CONFIGURE_EXTRA=--enable-libffmpeg_static\ --enable-trace\ --enable-debug ./Autobuild.sh -t bullseye-arm64.sh

But got...
target bullseye-arm64.sh not supported

Likewise:

target xenial-arm64.sh not supported

I edited xenial-arm64.sh and made a jammy-arm64.sh like this:

AUTOBUILD_CONFIGURE_EXTRA="${AUTOBUILD_CONFIGURE_EXTRA:-} --arch=arm64" 
DEBDIST=jammy
source Autobuild/debian.sh

I then tried:

AUTOBUILD_CONFIGURE_EXTRA=--enable-libffmpeg_static\ --enable-trace\ --enable-debug ./Autobuild.sh -t jammy-arm64.sh

AND

AUTOBUILD_CONFIGURE_EXTRA=--enable-libffmpeg_static\ --enable-trace\ --enable-debug ./Autobuild.sh -j$(nproc) -t jammy-arm64.sh

But each time I got back:

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Autobuild/jammy-arm64.sh

nothing added to commit but untracked files present (use "git add" to track)
target jammy-arm64.sh not supported

Maybe I just need to install Ubuntu on my intel laptop and run your commands from that.

Flex

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Jonas Lang about 2 years ago

As I mentioned above I don’t have an RPI to test build. I linked that Dave Pickles post to highlight what he did successfully on an RPI4. https://tvheadend.org/boards/5/topics/43309

Yes I suggest you try replicate my hardware setup and use the build instructions I outlined above. Once you succeed and get a feel for it you could probably attempt a cross compile for the RPI4.

I’m building on an i7 on Ubuntu 22.04 I’ve also built it on a Core 2 Duo successfully too.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Dave Pickles about 2 years ago

Rather than fighting the automation it might be simpler to compile manually.

        cd /tmp
        mkdir -p makepkg
        cd makepkg
        git clone https://github.com/tvheadend/tvheadend.git
        cd tvheadend

        echo "LANGUAGES_ALL = en_GB" > Makefile.common

        ./configure \
                --prefix=/usr \
                --enable-ffmpeg_static \
                --disable-ffmpeg
        make -j3
        make install

Adjust the languages line to your needs. There are lots of options for the ./configure command to fine-tune the build; enter ./configure --help to see them all.

Code compiled on an Intel laptop will definitely not run on a Pi4!

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Martin Davies about 2 years ago

Jonas Lang wrote:

By any chance did you keep a copy of your build log.

Not sure. If you let me know where to look I'll report back.

[apologies for the delayed response - I replied by email but the response bounced.]

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Jonas Lang about 2 years ago

Dave Pickles wrote:

Rather than fighting the automation it might be simpler to compile manually.
[...]
Adjust the languages line to your needs. There are lots of options for the ./configure command to fine-tune the build; enter ./configure --help to see them all.

Code compiled on an Intel laptop will definitely not run on a Pi4!

Thanks for joining in on this Dave Pickles.

As can be seen from the title of my post this post was in response to my experience of trying to build TVH for my own i7 PC with onboard Intel graphics running on Ubuntu 22.04 64bit.

I spent a considerable amount of time trawling through numerous posts with many irrelevant comments until I found enough information to successfully compile TVH for my own setup. I decided to share my working solution here for the benefit of other beginners in the shape of simple copy/paste commands. I was hoping others would try this out and report back for the benefit of other beginners

I knew that as soon this post would be seen the immediate response would be “can I use these instructions to build TVH for my RPI4”. Again I don’t own one of these so I’ve no way of knowing.

Now that you have joined the discussion could you possibly provide a similar process for building for the RPI4. Believe me there’s plenty of demand for it. The danger of providing build instructions for the RPI4 in the body of this post is it will get completely lost and won’t show up in a search.

There’s so many new RPI4 users coming across TVH for the first time with little or no Linux experience who would appreciate some form of automated solution for building and installing TVH on an RPI4. Contrary to what I’ve read here and elsewhere TVH is far from dead.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Dave Pickles about 2 years ago

I was replying to Sean Warner, who is trying to build Tvheadend for Ubuntu on Pi4.

The automation scripts create a package for the chosen architecture and distribution which the user can then install. Sean's problem is that there is no automated build for Ubuntu on Pi4, and trying to create one seems to lead to even more problems. Hence the suggestion to build and install directly on the target machine. I've successfully done the same for Arch Linux on Pi2.

The ideal solution would be for the project to create a new release from the current development branch. The various distributions would then take on the task of packaging it. Unfortunately there seems to be no-one with the time + inclination + knowledge to do that.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Jonas Lang about 2 years ago

That’s exactly what I was referring to.

My instructions did not include build instructions for anything other than the x86_64 architecture. That’s what I tested those build instructions on. I’ve just completed a fresh build of TVH this evening using them. I did mention that they could possibly be amended to use for building on the RPI4 but as you’ve pointed out this does not appear to be the case.

Maybe a fresh post on the subject of building for the RPI4 using Ubuntu would attract more interest from RPI4 owners on the forum.

I’m glad to see someone like yourself is back contributing on the forum again. The forum could certainly do with your input. It was going down quicker than a lead balloon.

RE: TVHeadend build and install on Ubuntu 22.04 64 bit x86_64 platform for beginners - Added by Flole Systems about 2 years ago

I actually have quite a lot of builds already going through in my fork which will "soon" be merged into master and then build the new official packages. Unfortunately some builds for old os's aren't able to upload to the repo yet due to old python but other than that it's building for more than 40 targets, including various raspberry pi os's. The fix for the python issue is the same for all those that are failing right now so once that's fixed things will move pretty fast, I just need to find some time to do it.

RE: TVHeadend build and install on Ubuntu 22.04 64 bit x86_64 platform for beginners - Added by Jonas Lang about 2 years ago

I for one truly appreciate the efforts yourself and others are making to continue to support TVH development across multiple platforms. It’s not easy and very time consuming to continue supporting this project on a voluntary basis. Hopefully others here will bear this in mind when commenting on your efforts. Thanks again.

RE: TVHeadend build and install on Ubuntu 22.04 64 bit x86_64 platform for beginners - Added by Jonas Lang about 2 years ago

Just updated my original post to include simple copy/paste instructions to keep your local version of the TVH code in line with the GitHub master once you’ve built your first version . You’ll never have to be without the latest TVH Github master commit.

RE: TVHeadend build from source and install on Ubuntu 22.04 64 bit AMD64 processor for beginners - Added by Jonas Lang about 2 years ago

Dave Pickles wrote:

Rather than fighting the automation it might be simpler to compile manually.
[...]
Adjust the languages line to your needs. There are lots of options for the ./configure command to fine-tune the build; enter ./configure --help to see them all.

Code compiled on an Intel laptop will definitely not run on a Pi4!

Dave Pickles

I used your manual build instructions to build TVH 4.3.0 on Ubuntu 18.04 on an old Core 2 Duo laptop. It went reasonably well and is up and running now.

Two questions I have. The build didn’t daemonise TVH. I had to start it from the CLI. Is there an option to include a daemonised service at build. Also does the build process you outlined have a make uninstall option available.

RE: TVHeadend build and install on Ubuntu 22.04 64 bit x86_64 platform for beginners - Added by Dave Pickles about 2 years ago

The build didn’t daemonise TVH. I had to start it from the CLI. Is there an option to include a daemonised service at build.

Ah, you need a systemd service file. This is the one I use:

[Unit]
Description=tvheadend
Requires=video.mount
After=network.target video.mount

[Service]
Type=forking
PIDFile=/run/tvheadend.pid
ExecStart=/usr/bin/tvheadend -f -p /run/tvheadend.pid -u hts -g video
ExecStop=/usr/bin/rm /run/tvheadend.pid
Restart=always
RestartSec=30

[Install]
WantedBy=multi-user.target

Adjust the ExecStart line for your needs. The two lines containing 'video.mount' ensure that Tvheadend isn't started until the disk used for recordings (mounted at /video) is online; again adjust as needed. Name this file tvheadend.service and save it in /etc/systemd/service/. Now you can enable Tvheadend to start at boot with systemctl enable service tvheadend .

Also does the build process you outlined have a make uninstall option available.

This process completely bypasses the package management of the distribution so there isn't an uninstall option.

RE: TVHeadend build and install on Ubuntu 22.04 64 bit x86_64 platform for beginners - Added by Jonas Lang about 2 years ago

Thanks Dave

Yes I created a Systemd service earlier something along those lines to launch TVH and have it running as a service.

It’s definitely an informative way of building TVH and quite straightforward once you’ve had a go. Definitely gives a better idea of all the build options available. I’m going to try again just to get up to speed on the process and familiarise myself with it.

I assume you need to manually remove the install but again I’ll do a bit more reading up on the process.

Once again thanks for the pointers. It’s easy once you eventually know how.

RE: TVHeadend build and install on Ubuntu 22.04 64 bit x86_64 platform for beginners - Added by D M almost 2 years ago

I have tried all the guides I could find. I used different machines and they all fail when they got to this line. Does anyone know how I can fix this?

CC              src/htsmsg.o
CC              src/htsmsg_binary.o
src/htsmsg_binary.c: In function htsmsg_binary_des0:
src/htsmsg_binary.c:80:39: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
   80 |       ((char *)f->_hmf_name)[namelen] = 0;
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~

(1-25/45)