Technology
Leave a comment

Installing FFmpeg on FreeNAS 9.3.1

After getting my media files organized on FreeNAS, I wanted to make some quick video trimming.

Usually, I do this with avidemux. But in accessing over WiFi, just loading a file into avidemux takes several minutes. So I have this idea of doing it on the FreeNAS box itself using command line interface (CLI).

Since I have nothing prepared on the FreeNAS box, I needed to take quite a few steps.

Creating a Jail

I know I will need to install packages or ports on FreeNAS. The recommended way is to do this within a jail, rather than at the FreeNAS OS level. This is partly because FreeNAS is very often installed in small USB stick with not a lot of space. This does not affect my build because I used a 128GB SSD as boot device. However, it is also safer to do it in a jail. If I screw anything up (which is likely), then just delete the jail and start again.

To create the jail and enable SSH, I follow the official documentation here. The one advanced setting I change is ipv4 IP address, as I don’t want it getting that from DHCP.

It took about 30 minutes to download the jail template, since it is the first time I create a jail manually. After that, the process didn’t actually take very long.

Right after jail creation, I also added storage for the jail to access the files that need editing.

Installing FFmpeg

Looking at the ports list, I’m not sure which of the avidemux I need. So, I decided to go with FFmpeg instead since I have used that before and it is CLI-only, which is all I need today.

The following are done via SSH. It might be possible to do with via the jail shell access in FreeNAS GUI, but the process is quite long and I recommend SSH to avoid any hiccups.

Following instruction from this thread, here is what I did:

portsnap fetch extract

This populates the ports tree on  /usr/ports . Without this, the following steps do not work. (I tried, and it failed.)

cd /usr/ports/multimedia/ffmpeg
make config
make install clean

At first, the process did not complete. It failed with error message: “You must upgrade the ports-mgmt/pkg port first”.

After a quick googling, I issued the following commands which fix it.

cd /usr/ports/ports-mgmt/pkg
make deinstall reinstall

After that, go back to /usr/ports/multimedia/ffmpeg and run

make install clean

again.

It will install a big bunch of dependencies. (More if you choose additional options in make config) For each of the dependency, it also ask for options.

Then there’re the dependencies of dependencies. This part takes a good 30-40 minutes for me. It should be much quicker the next time I want to install something, as it is getting a lot of the build tools this time.

Ready for simple cutting

A command like this:

ffmpeg -i input.mkv -ss 00:01:30.0 -c copy -to 00:03:50.0 output.mkv

accomplish the task way way faster than anything I could have done remotely from my Windows 10 client machine.

Job done!

Leave a Reply

Your email address will not be published. Required fields are marked *