Melvin Gundlach

Take a look at some of my previous work...

Synology FFmpeg Hardware Transcoding

Recently I needed to convert one of my H.265 4K videos to a H.264 MP4 file for playback on an older device. As the original video was already on the NAS, I thought about converting it right there using the DiskStations's CPU.

FFmpeg was installed on the NAS in two versions. One bundled with the VideoStation app. The other one I downloaded a while ago via the Package Center from the cytec repository. The second one enables transcoding of DTS audio tracks. These FFmpeg installations are intended for the live transcoding for playback in the web browser or the DS Video iOS and Android apps.

I ssh'd into the NAS and changed to the respective directory. I then started FFmpeg to start transcoding the video.

The transcoding generally works, but the abismal speed of way below 1 FPS kept this from beeing a viable solution.

I knew that most Synology DiskStations have a dedicated hardware de- and encoder for live video transcoding. So does mine. My DS 418's hardware transcoding chip supports up to 10-bit 4K 60 FPS H.265 live transcoding. I didn't know at the time but I later found it specifically means transcoding to H.264 or MPEG2. For my case that was enough.

The transcoding speed I saw were nowhere near those 60 FPS, so I figured the special transcoding unit wasn't used. I knew from browser playback in the VideoStation web app that hardware transcoding generally works, so there has to be another tool which is used by the VideoStation transcoding engine.

So my search began. I went into the VideoStation's folder.

Inside, there are a lot of tools.

First of all I tried the FFmpeg version lying there1.

In contrast to the FFmpeg version from the Package Center this one can't convert videos to the H.264 codec. I re-checked.

Seems right. I was reinforced in my theory that there was a seperate tool which utilizes the hardware encoding. I tried some of the other tools in the same directory. I started with cffmpeg.

The profile parameter looked promising. When invocing synovideoconversion I got a similar result.

While this was a great step in the right direction – I could convert video to H.264 using one of the profiles –, but I still didn't know what exactly those profiles mean. I'd prefer to choose the bitrate myself. And while I could choose an audio track, I could't convert it to a specific format using this command.

That's when I found a post by MrEricM in the Synology Forums mentioning syno-gst which can also be found in the same folder as the other tools. Looking into it, it seems to be exactly the tool I was looking for.

It supports converting videos to either H.264 or – for even older devices – MPEG2. I have the choice between several formats for the audio (including just copying it). I can choose the resolution and bitrate of the resulting video track as well as the audio bitrate.

So to converted the 4K HEVC test file to a 1080p H.264 MP4. I used the following command. The bitrates ought to be given in bytes. I added the -rv parameter to get more info in general and especially the progress.

And voilà, the transcoding process worked at about 2x speed, which seems reasonable considering the hardware transcoder supports 4K 60 FPS live transcoding and my test file is a 4K 30 FPS video. I finally got the hardware transcoder to work!

It is important to note though that it only works one way. So sadly I can't use it to convert my older videos to the HEVC format using it. During my following tests I found out about some other limitations and quirks.

Although I can enter in the desired width and height of the target video, the tool selects from one of a few presets which come close to the desired resolution. It is actually enough to provide either the height or the width parameter to make it choose between the presets. Those presets are the following:

I really don't understand Synology's reasons for the chosen presets. The 720p one is obvious to me, but why there's no real 1080p option is a mystery to me. It's also interesting that the resulting H.264 video cannot be bigger than that, so no 4K as the export.

There is a video bitrate parameter (--vb) which accepts vaulues in bits per second. The parameter doesn't seem to work in any way I'd expect though. While higher settings result in higher average bitrates, there's no direct correlation. I compiled a list of some values I tried and the resulting average bitrates of the exported video.

Without providing the bitrate parameter, I get a warning that the value "0" of type 'guint' is invalid or out of range for property 'bitrate' of type 'guint' and the conversion uses the minimum bitrate setting, resulting in an avg. bitrate of 115 Kbit/s. Same thing happens if I provide a value outside of the expected range. I don't know what the specific range is though.

I discovered another odd thing during my tests. While IINA plays the resulting file just fine, QuickTime has some problems resulting in a green screen after the initial frame, unless I skip to an arbitrary position in the video. After that everything plays fine.

I hope I could help someone who's having a similar problem.


1 For an unknown reason this version of FFmpeg requires sudo to work.