[Tutorial] Adding Lossless (FFV1) codec in Video AI UI (v3.3.1 or above)

Hi all.
Topaz changed the encoders UI starting from version 3.3.1. that also means they changed the “json” files structure. pre v3.3.1 , everything was under encoders.json file as a flat file.
starting from v3.3.1 Topaz split the encoding into two separated files:

  1. video-encoders.json - everything to do with video codecs
  2. audio-codecs.json - everything to do with the transcoding / converting of audio (not relevant if selected in the UI “copy” audio)

Both files are located at: %programdata%\Topaz Labs LLC\Topaz Video AI\models (C:\ProgramData\Topaz Labs LLC\Topaz Video AI\models)

This post is to provide you the steps needed to configure the FFV1 Lossless compression encoding in Video AI if you wish to export your video(s) in a lossless compression codec.
This is very useful if you are planning later on to post process your video in an external tool (e.g. color grading, etc.) of if you planning to run multiple Video AI processes on the same video.
that way you minimize the video quality loss on each pass / process.

Even though this tutorial is mainly focused on how to add FFV1 Lossless compression, you could use the same steps to add other lossless compression encoders that ffmpeg supports, such as: UT Video, HuffYUV, FFvHuff, Lagarith, etc. or any other Encoders you whis which are not necessarily lossless.
I chose FFV1 as it is very popular and works very well. (I tested few lossless compressions - mentioned above - and honestly i couldn’t tell the difference between them when it comes to quality).

Step 1. Since FFV1 only exports in “avi” (default), “mkv” or “mov” containers, we need to add the “avi” extension support in the audio-codecs.json file under the PCM section (lossless usually works with PCM audio track). “mkv” & “mov” already exists there, so no need to touch/add those.

This step is only relevant / needed if in TVAI you planning to use the “convert” audio option.
It is not needed if you are going to use the “copy” audio option, which basically just ports over your existing audio track untouched to your new processed video (prefered way In my opinion, always works best for me.).
If “copy” audio is what you are planning to use, then you can skip this step and head off directly to “Step 2”.

image

Open/edit (using notepad) the audio-codecs.json file and scroll down to the PCM entry and add to the extension list the “avi” extension to the existing list of extensions there.

here how it looks like:

Original, before the change:

image

After the change (adding “avi”):

image

Now you would be able and select “convert” audio for the default FFV1 container, the “avi”.

image

NOTE: You might need to complete “Step 2” (or Step 3), to actually see it in the UI.

Step 2. The next step is to add the FFV1 itself into TVAI (Topaz Video AI).
to do this open/edit the “video-encoders.json” file and add the following anywhere in between any other codecs.

FFV1-8bit-420.txt (388 Bytes)

    {
    "id": "ffv1-8bit-win",
    "encoder": "FFV1",
    "profile": "8-bit (4:2:0)",
    "ffmpegOpts": "-c:v ffv1 -coder 0 -context 0 -g 1 -level 3 -slices 4 -slicecrc 1 -pix_fmt yuv420p",
    "ext": [
      "avi",
      "mkv",
      "mov"
    ],
    "transcode": "pcm_s24le",
    "os": "windows",
    "minSize": [2,2],
    "maxSize": [8192,8192],
    "maxBitDepth": 8
  },

I placed mines between the “h265-main10-osx” and “h264-high-win-amd”. But you can place it anywhere you like.
Since most videos we work with (usually old videos) are 8-bit / 4:2:0 I added only one profile for 8-bit / 4:2:0 chroma subsampling.
Other higher chroma subsampling (e.g. 4:2:2, or 10-bit, etc.) is only needed If you have an original source with full color information (and if TVAI supports higher color information).
99% of the times you won’t need them and the 8-Bit / 4:2:0 is what you will use.
Later in this post I’ll post the full chroma subsampling / profiles that FFV1 supports as an optional step if you wish to add those as well.

Here how it looks like in notepad:

You now can select the Lossless compression codec in your output settings

image

You can also set it as your default codec in “preferences” , that way it will always be the codec of choice by default.


Step 3 (optional). If you want to have all FFV1 available chroma subsampling / profiles for FFV1 available for your selection, you can copy/paste this to your “video-encoders.json” instead of only the 8bit / 4:2:0 in “Step 2”. and ffmpeg will try to retain this information.

FFV1-Fullrange.txt (1.9 KB)

I am not sure Topaz Video AI supports those profiles color space for actual AI enhancements, but maybe in the future they will.

here how it would look like:
image

image

P.S. Once you edit the file and verify that it is working correctly, I suggest you backup your “audio-encoders.json / video-encoders.json ” file with the new FFV1 settings, as Topaz deletes the json files when you update “Topaz Video AI” to a new version.
That way you can just repeat the process of copy/paste again from your backed up/old file into the new updated version file(s) each time you update your VAI.

Don’t just copy the old backed up files as is and overwriting the new ones, because newer versions might introduce new enhancements in the json files of the newer released version. By you just copy the older files as is, overwriting the new ones, you will lose the new functionality at best and might break your Video AI at worse.
Just repeat Steps “1” and “2” (or “3”) from your backed-up files.

NOTE: This tutorial works on Windows OS, as I don’t have a macOS to test it out and i don’t know if macOS supports FFV1 lossless or not.
If you want to give it a shot, you can try it on your macOS. make sure to replace the OS from "os": "windows", to "os": "osx", in the video-encoders.json file for the FFV1 portion you just imported.
Or try those files (I changed it for you already).

FFV1-8bit-420-osx.txt (384 Bytes)
FFV1-Fullrange-osx.txt (1.9 KB)

12 Likes

Always good to have a well explained tutorial at hand…
Nice work @Akila :100:

2 Likes

Thanks for taking the time to post so clearly these instructions. :+1:

Edit: Just a note that FFV does support .mov as a container.

3 Likes

Are you sure? because in Hybrid I am getting the following error when trying to export in “mov”

image

Reference:

I’m 100% sure, I’ve been using FFV in a mov container for ages.

1 Like

I added “mov” to the tutorial / scripts.
that might help macOS users to be able and use this as well.

3 Likes

Thanx for taking the time :slight_smile: json editing is possible for quite a while, other encoders and filters could be implemented like this, too.

ffv1 is - in my oppinion - a very usefull intermediate codec, very robust and versaitayle. We had it on the wishlist for quite a while - my hopes are Topaz makes this a regular option by default.

1 Like

Indeed Supi Man…
I think some time ago you’ve asked for it to be implemented in a topic in the Ideas section of the forum… but I could be wrong.

Yes, in the back of my mind, I have the same memory… Somewhere… :slight_smile:

1 Like

Hi, do you know how could I add the actual CPU encoding? Not QSV, actual CPU. Encodings like: x264, x265, svtav1 etc.

For x264, x265 only with the CLI and by pipping to a pre install Ffmpeg version… Check here how to :point_right: Topaz's ffmpeg binary doesn't contain libx264 or libx265 - #5 by 07broom.fibulae
For Av1 also with the CLI but it’s Ffmpeg encoding ( libaom-av1 ) and it’s slooooooow like a snail. For AV1 I advice to use an external encoder capable of splitting the given video file into chunks because is faster

2 Likes

I’d recomend av1an using svt-av1

2 Likes

master-of-zen Av1an ? Didn’t tried that one… yet. Looks interesting :+1:

1 Like

Hello,

FFV1 is now included as a default encoder option in Video AI 3.4.2.

1 Like

You didn’t add .mov container tho :wink:

Wow, that is amazing Ida.