Log in

View Full Version : How to Import All of a Video File (Subs, Audios) and Upscale?


sternrecall
15th August 2024, 18:10
Hello everyone,

I have been working on remastering some MKVs for some time now and recently started to encode some of them with Handbrake. The issues that I have been having with Handbrake are that I cannot get proper deinterlacing (and in cases where content is telelaced it fails to properly fix that too) and often with SD content Handbrake msses up the colors. I read on a few blogs that Avisynth+ is the best software to use for making 1:1 backups of videos with modern improvements (deinterlacing, detelelacing, setting a default subtrack, etc) and have been playing around with it.

I currently have figured out how to deinterlace well using AviSynth+ and AvsPmod. I can confirm that deinterlacing is not only working as expected, but giving a much better end result than in Handbrake (often mouth animations look terrible). The issue I am running into is that I cannot seem to figure out how to fully import all of my MKV file (all audio and subtracks) so that I can set the default subtitle track like you can in Handbrake, thus allowing me to achieve a kind of "remaster" of the original MKV file with only outdated things removed (interlacing, etc) but things like chapter markers, subs, and audio all kept. Is AviSynth+ the right tool for the job here? If not, is there another program you all can recommend?

I have also been trying to play around with upscaling some of my older SD content to a simple 1080p and had some success with Brovicon. However, it doesn't seem to support detelelacing nor keeping all subs and audios in the final MKV. I looked at external filters and the previous forum posts and came up with this script.

# Load plugins.
Loadplugin("C:\Special Program Files\AviSynth+\plugins64+\ffms2.dll")

Version()
SetFilterMTMode("QTGMC",2)

# Import all audio and subtitle tracks.
video = FFMPEGSource2("E:\cybermedia\video\Test.mkv")

# Deinterlace.
ConvertToYV12()
AssumeBFF()
QTGMC()

# Crisp up image.
LSFmod()

return video

But this doesn't seem to have an effect (even though the default should cover what I am looking for). I also looked at AIUpscale, but it also has little to no impact I can see.

I apologize for the noob post. It is likely I am also barking up the wrong tree and actually need a different tool. At any rate, I greatly appreciate any and all help.

Emulgator
15th August 2024, 20:22
StaxRip should be able to achieve that in one go, having all needed tools under the hood, but a learning curve is involved.
And there is Hybrid.

Most of the time I am happier with inspecting the intermediates, maybe stabilising these in Vegas Pro, upscaling in Topaz, adding/correcting subs using SubtitleEdit...
Some more steps needed:
You would demux all assets before any AviSynth processing using your trusted demuxer. Mkvtoolnix should do.
Then build your AviSynth restoration script in AVSPmod and feed this to your preferred video encoder.
I haven't tried AIUpscale to the max. extent, was happy with Topaz.
In achieving HFR AI under AviSynth is very capable now, and I prefer RIFE model 48 now over Topaz.
Restore audio on a different DAW, subs as you like, then remux all assets again into your desired .mkv

hello_hello
18th August 2024, 00:05
I currently have figured out how to deinterlace well using AviSynth+ and AvsPmod. I can confirm that deinterlacing is not only working as expected, but giving a much better end result than in Handbrake (often mouth animations look terrible). The issue I am running into is that I cannot seem to figure out how to fully import all of my MKV file (all audio and subtracks) so that I can set the default subtitle track like you can in Handbrake, thus allowing me to achieve a kind of "remaster" of the original MKV file with only outdated things removed (interlacing, etc) but things like chapter markers, subs, and audio all kept. Is AviSynth+ the right tool for the job here? If not, is there another program you all can recommend?

If I'm only re-encoding the video, I usually do it using Avisynth and then add the rest of the streams with MKVToolNixGUI.
If you encode the video, open it in MKVToolNix, and then add the original source file, you can de-select the original video stream and remux, effectively replacing the original video with the encoded version. Of course you can pick which streams you want to keep from the source file and set defaults in the process etc.

By the way, you can't use SetFilterMTMode() for functions. Only plugins.
https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/syntax/syntax_internal_functions_multithreading_new.html#setfiltermtmode
filter: name of the filter you want to set an MT Mode for. You cannot set the MT mode on script function calls, only on binary filters.

The default MT mode is 2 anyway, but you might want to try auto-loading or importing this script.
https://publishwith.me/ep/pad/view/ro.rDkwcdWn4k9/latest
As the more common plugins register their MT mode automatically these days, if you want to set an MT mode for a plugin it'd probably pay to use the force option, otherwise it won't make any difference for a plugin that's registered it's MT mode.

SetFilterMTMode(""NNEDI3", 2, force=true)

And don't forget to add Prefetch to enable multi-threading.
https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/syntax/syntax_internal_functions_multithreading_new.html#prefetch


This line from your script only decodes the video.
Video = FFMPEGSource2("E:\cybermedia\video\Test.mkv")
as does
Video = FFVideoSource("E:\cybermedia\video\Test.mkv")

To decode the audio too.
Video = FFMPEGSource2("E:\cybermedia\video\Test.mkv", atrack=-1)

By the way, none of the filters in your script will be doing anything other than producing error messages, as you assigned the video to a variable that isn't being passed along. You need to do something like this:

Loadplugin("C:\Special Program Files\AviSynth+\plugins64+\ffms2.dll")
FFMPEGSource2("E:\cybermedia\video\Test.mkv")
ConvertToYV12()
AssumeBFF()
QTGMC()
LSFmod()

or this:

Loadplugin("C:\Special Program Files\AviSynth+\plugins64+\ffms2.dll")
Video = FFMPEGSource2("E:\cybermedia\video\Test.mkv")
Video = Video.ConvertToYV12()
Video = Video.AssumeBFF().QTGMC()
Video = Video.LSFmod()
return Video

The first version will produce the same result as the second, as Avisynth automatically assigns clips to a variable called "last" when they're not assigned to another variable in the script. The first version works like this, with the Last variable updated after each filter:

Loadplugin("C:\Special Program Files\AviSynth+\plugins64+\ffms2.dll")
FFMPEGSource2("E:\cybermedia\video\Test.mkv")
Last.ConvertToYV12()
Last.AssumeBFF()
Last.QTGMC()
Last.LSFmod()

Katie Boundary
21st August 2024, 18:53
Unfortunately, the current subtitle tool environment is still quite shit.