Any script for saving previews for selected model in CLI

Hello, I’m looking for a way to save preview enhanced image to a folder for selected model for exact second in commandline.

My use case: Get preview image for Iris and Artemis model for 00:00:02 and 00:00:05 seconds and save to a folder. I’ve checked topaz CLI doc but it is very limited.

Thanks in advance.

You can checkout my script. I probably need to update the documentation.

Not sure if it will do exactly what you want, but it sounds like it will be pretty close.

Oh your script looks awesome to automate using Topaz. Only thing is missing for my use case is the preview of enhanced frame. Any idea how can I do that?

This script is made with one goal in mind: DVD to FHD. It can do some more stuff, but things like 4K you’d have to modify it for that. I made sure it can cut out intros and join the two resulting clips back into one video.
The steps that need to be taken to get from DVD to FHD are: De-DVD, denoise, enhance, encode, join audio, chapters and subtitles back in.
If if had a video file named clip.mkv and wanted to see what a few frames looked like with Artemis Medium, I would make a file called clip.json and fill it with this:

  "-t": "00:00:15.065",
  "-ss": "00:03:06.220",
  "-ff": "True",
  "-r": "23.976",
  "-ahq": "true",
  "-med": "true",
  "-fin": "null",
  "-name": "amq"

This will start at whatever key frame is closest to the timestamp “00:03:06.220” and process 15.065 seconds worth of frames.

Running the Artemis models are a little convoluted in my script because they are mainly meant to be used as a denoiser before running Proteus. Later on I added at way to use them alone on Blu-rays as a denoiser. And if you’re wondering why cutting has to be done by key frames and timestamps, well that’s the first way I found to get ffmpeg to do what I wanted. TVAI has the same difficulties cutting at exact frames because it’s using ffmpeg.

thank you. this what chatgpt gives

import subprocess
import os


input_video_path = “path/to/your/video.mp4” # Replace with the path to your video file
output_folder = “path/to/output/folder” # Replace with your desired output folder
TVAI_path = “path/to/Topaz Video AI/ffmpeg.exe” # Replace with the path to your Topaz Video AI executable

Timestamps for preview

timestamps = [“00:00:02”, “00:00:05”]

Models to apply

models = [“iris-1”, “artemis”] # Replace with the exact model names if different

Ensure output folder exists

if not os.path.exists(output_folder):

Function to apply a model and save the preview image

def generate_preview(timestamp, model):
output_file = os.path.join(output_folder, f"preview_{timestamp.replace(‘:’, ‘’)}_{model}.png")
command = [
“-ss”, timestamp, # Set the start time for processing
“-i”, input_video_path,
“-frames:v”, “1”, # Extract only one frame
“-c:v”, “png”,
], shell=True)

Generate previews

for timestamp in timestamps:
for model in models:
generate_preview(timestamp, model)
print(f"Generated preview for {model} at {timestamp}")

That would still take me a few hours to translate that into something that runs.

Honestly, you can get what you want with the TVAI GUI:

After running your ~5f preview, show in explorer. Go up a folder and copy it to wherever you need it.

But script-wise, there’s quite a bit more that would need to go into it than what that AI spat out.

Are you wanting a script that runs all the models for the timestamp given? I could throw something together… but it would take a few days to get the time.

Yes actually. that’s the goal. But I don’t wanna use GUI since I wanna automate my workflows.

Right, you hit run and it goes to town.
Would you want it to run all models every time, or from a list like the ChatGPT was suggesting?

Both works actually. The output will be the same.

Had some time so I started the script.
Right now I’m planning on walking through all the videos in the folder. I can see how that might not be what you had in mind. I’m guessing you wouldn’t want to process the same timestamp on all the videos.
I can of course change it to only run on one input video.

Got that script to run two models so far. Some models take different parameters. Those will need special cases. Heh, the documentation is missing nyx, iris, prob-3. Anyway those can be added later. For now I could add all the ones that have no parameters.

I’m guessing you wouldn’t want to process the same timestamp on all the videos.

Yes, it is gonna be dynamic.

I’ve checked the code, amazing man. However I couldn’t see a function to get a processed preview at the defined timestamp. Am I missing something or you didn’t add it. Maybe it is because I am unfamiliar with the Python :slight_smile:

I haven’t added it. I need to rework it so that it takes inputs. Would you like command line inputs or txt inputs?
The way I made the other script is it looks at every file in the folder and only processes the ones that have a matching txt file. (Or json)
I can make it to only use command line inputs. It can get pretty long when it comes to models like Proteus.

Oh, I didn’t see your reply. Sorry. I’d like to in commandline, not txt. My plan is, I will provide video_id and path to commandline which will generate previews for each model in exact timestamps. (For example, if one model uses an upscaled preview of a third second, it should be the same frame for other models). Lastly, I will send those previews to myself with telegram or push notification, etc. and I will select the best one for that video and send the request again to my machine and it will generate an upscaled video for my selected model.

Okay that works. What scaling do you want, that either has to be hard coded or added as a parameter.

Parameter would be better actually

I will be using 2x generally

Use that same link to see my changes.
I added command line arguments.

-input "file path"
-output "just a path"
-time "00:00:22.369" (Optional)
-rate "24" (Optional)
-scale "2.5" (Optional)

Let me know what it’s missing. I still only have two models in the list. I think most will work except those that need parameters. Specifically: [‘prap-2’, ‘prob-2’, ‘thd-3’, ‘thf-4’]
I mean to add special cases for those because prob-3 is the one I use the most. I’m thinking I’ll do auto and my go-to manual settings for DVDs. Then of course there’s models like iris and nyx that aren’t even in the list in the documentation. Those will need special cases too.

Here’s the command I ran to test it, as an example.
While in the folder with in it: -input "E:\Dump\d3\D1_t02.mkv" -output "E:\Dump\d3"
It took 43 seconds and made two folders in the output path. D1_t02ahq-12 and D1_t02amq-13. Each has one PNG image in it.

I’m grateful my friend. Thank you! I will try it.