Log in

View Full Version : Is it better to convert a video in RGB24 before an upscaling ?


SuperLumberjack
24th March 2020, 18:11
Hello everybody,

I didn't want to create a new topic just for this question, but I didn't find a good one to ask it.

My question is simple :

My source is a MKV in 1080p in a YUV 4:2:0 color space.

If I want to upscale it in a 2160p resolution, is it better to convert it in RGB24 before the upscaling ? (In fact, I just put the MKV in VirtualDub and export the video in RGB24, because it's easier and I always got some missing frames with the "DirectShowSource" function.)

I could export the video in a lossless YUV too, but here is the problem !

I use the plugin Resize8 with the Spline36 alogorithm to upscale my video.
I use this line in my AVS script :

Resize8(3840, 2160, kernel="Spline36", kernel_c="Spline36")

The advantage ot the Resize8 plugin is that it uses a anti-ringing filter by default. The drawback due to this AR filter is : more the difference between the resolution of the source and the output resolution is important, more some artefacts will appear.

(http://avisynth.nl/index.php/Resize8)

With the luma, there is no problem if I double the resolution, but with the chroma, it's different, because if I'm right, with a source in YUV 4:2:0, the chroma is upscaled from a 540p resolution to 2160p. So, some defaults appear due to the anti-ringing filter.

But if I come from the MKV that I exported before in a RGB24 color space, with the upscaling, it will be like this :

chroma in 540p > chroma in 1080p with PointResize > chroma in 2160p with the Resize8 filter and Spline36

There are less artefacts due to the anti-ringing filter, but more aliasing.

Am I right ?

And so, I want to know please : what do you think about that ?

What is the best solution for you ?


I hope that I would have been enough clear :p


Thanks for yout help ! ;)

(Sorry for my English ! It's always a bit hard to explain these kind of things in another language.)

MeteorRain
24th March 2020, 19:35
AVS is a full functional video frameserver. It can convert RGB on the fly.

You shouldn't be using DSS when there are many better options available, such as ffms2 and lsmash.

Whether it's better to use RGB, I'll let others to answer.

SuperLumberjack
24th March 2020, 20:37
Yes, I compared for a long time some screenshots of the different methods and I think it's better with RGB too.

Thanks for your answer ! ;)

Asmodian
24th March 2020, 22:21
The benefit is simply that you can use anti-ringing for the upscale? The first scaling is the most important. You want to use the highest quality kernel you can for the first scaling step because the next step uses it as its source so any artifacts introduced will get magnified (aliasing is also an artifact). Using point resize before converting to RGB seems like a poor choice. Also, if your final output is YUV you do not want extra color space conversions, YUV -> RGB -> YUV is lossy.

dither tools (http://avisynth.nl/index.php/Dither_tools) is a good option for upscaling with anti-ringing in AVS.
Edit: Resize8 also supports YUV. I am no longer sure why you are converting to RGB first. :confused:

If your goal is simply watching it using madVR would be even better.

SuperLumberjack
24th March 2020, 23:49
Hello ! Thanks for you answer ! ;)

Yes, the great benefit of the Resize8 plugin is definitely the anti-ringing filter !

I compared with all the existent algorithms I think and visually, it's the Spline36 algorithm with the anti-ringing filter that I prefer. But only if I double the resolution, because after, if the output resolution is too big compared to the source, as I said, some new artifacts appear due to the AR filter.

I know that we must avoid the color space conversions as much as possible, but visually, I found that it's better to convert the source image to the RGB color space, because with YUV, it becomes a bit messy with the chroma.

I even compared by zooming the picture with each result. For me, the most credible result is as I did.

But yes, theoretically, I would think like you. By the way, I hesitated and it's why I created this topic. But concretely, I think it's different. I don't know why, but sometimes, which is not logical gives the most pleasant results ! :p

I even tried the classic "Spline36Resize" with the source in YUV, but I still prefer the result of the video converted to RGB24 and then upscaled with "Resize8(3840, 2160, kernel="Spline36", kernel_c="Spline36")" and converted to the YV12 format again.

I think that it's more a question of compromise than an exact science.

But I'm still open to suggestions ! ;)

And my goal was to get something similar in 2160p on YouTube to the 1080p source visually. Not better ! In fact, if the compression wasn't as bad on YouTube, I would rather stay with the 1080p resolution...

Katie Boundary
25th March 2020, 00:07
AVIsynth has a bug that causes chroma planes to move left or right when you resize in any YUV or YCbCr colorspace. The more extreme the resize, the more the chroma plane moves. Always convert to RGB before resizing, unless you are using an external filter like Simpleresize or Arearesize.

SuperLumberjack
25th March 2020, 01:39
Thanks for you answer ! It's very useful to know ! ;)

wonkey_monkey
25th March 2020, 10:08
Hold up there, SuperLumberjack. There are some good reasons for converting to RGB but I'd take anything Katie Boundary says with a pinch of salt.

For example:

AVIsynth has a bug that causes chroma planes to move left or right when you resize in any YUV or YCbCr colorspace.

That's not true. It doesn't exist in non-horizontally subsampled colourspaces, e.g. YV24, and it might well be fixed entirely in Avisynth+ (the existence of which KB probably rejects on theological grounds for all we know).

SuperLumberjack
25th March 2020, 11:42
Hello wonkey_monkey,

Thanks for your answer ! ;)

So you recommend to convert the video to the YV24 color space instead of RGB24. I know it's logical.

But if I simply converted to RGB24 it's because visually, it will be almost identical. And YouTube doesn't care about the precision of the color... :o I noticed some minor differences in the green colors for example, whereas the color matrix is the good one (BT.709). In all cases, the result is bad with YouTube and has nothing to do with the source file.

And the issue with the anti-ringing filter stay the same with the chroma.

I suppose there is no perfect method :( But as I said, I stay open to suggestions ;)

wonkey_monkey
25th March 2020, 12:20
So you recommend to convert the video to the YV24 color space instead of RGB24. I know it's logical.

I recommend nothing! But it's probably worth trying to see if you like it.

The main reason I have for converting to RGB is that you can then account for gamma with whatever you do next - if the filter supports it. But that's pretty rare.

SuperLumberjack
25th March 2020, 13:05
OK ! Thanks for your help ! :)

SuperLumberjack
26th March 2020, 17:29
Just a question : Does somebody know how to avoid a cut audio with VirtualDub when the video stream and the audio stream haven't the same length ?

I have for example a video that I want to export with VirtualDub, but the video stream has a duration of 10 seconds and the audio stream 12 seconds. The issue is that I lost 2 seconds of the audio stream.

Thanks for your help ! ;)

StainlessS
26th March 2020, 20:11
You must be doing something wrong, maybe a trim at end of script or something. [EDIT: Maybe not something wrong, see NOTE at end of post]


Colorbars(pixel_type="YV12")

A = Last.Trim(0,-200).KillVideo # 200 frames worth of audio
V = Last.Trim(0,-100).KillAudio # 100 frames of video

AudioDub(V,A) # V about 3 secs, A about 6 secs
info

https://i.postimg.cc/x86QHYqd/Pic.jpg (https://postimg.cc/WqqxLBGR)

Works fine, post the script that you were trying [EDIT: Dont bother posting script if you update as per below, and it works ok].

EDIT: NOTE, Trim() chops or pads audio (with silence) to same length as video [an older version of Avs+ messed Trim() up a bit, suggest update to current AVS+].
EDIT: Latest Avs+ v3.50 (Likely a new one soon):- https://github.com/AviSynth/AviSynthPlus/releases

SuperLumberjack
26th March 2020, 20:44
Hello StainlessS,

Thanks for your answer ! :)

In fact, the issue with the sound isn't only with an AVS script, it's the same if I just open the original clip in VirtualDub.

It seams that VirtualDub prefers to ignore the fact that the duration of the audio can be longer than the duration of the video.

But I found an alternative. I put the clip in MKVMerge to create a MKV and then, when I open the MKV in VirtualDub, the duration is good ! :p

But the video is flipped vertically (I just add "FlipVertical" in my AVS script) and I have to convert the clip in AVI once again before I open it in a script, because I always have problems when I open a MKV in a script, so I prefer to use the AVI format.

StainlessS
26th March 2020, 21:12
You using Vdub2 (latest) ?
Maybe the extra audio was just file appended to the video clip, so VDub stops at the break [when direct load into VD].

EDIT: Did you test the provided script with your VDub ? (and did you need update).
Given script does work as shown, and so long as Info shows correct lengths, then current VDub2 should work fine from AVS+.

EDIT: Did you view Info on your loaded clip to check video, audio lengths. [ie does the source filter work properley, again may be a file appended clip]

SuperLumberjack
26th March 2020, 21:43
I have the build 41585 of VD2.

Sorry, I forgot to test your script, so I did it and I got the exact same result than you.

It's strange yes, because with my clip, for the video stream, it shows this in the file information :

Length: 153 frames (0:10.21)

And for the audio it shows this :

Length: 485859 samples (0:12.85)


But it cuts at 10 seconds in VirtualDub.

StainlessS
26th March 2020, 22:24
My version VDub2 is 44015 and Latest is 44282, so I'm updating, maybe you should too:- https://sourceforge.net/projects/vdfiltermod/files/

EDIT: Suggest REMOVE current vdub2, and if prompted, remove settings, then reinstall. [Maybe some setting is set to trim to video length, or something]

hello_hello
26th March 2020, 22:31
AVIsynth has a bug that causes chroma planes to move left or right when you resize in any YUV or YCbCr colorspace. The more extreme the resize, the more the chroma plane moves. Always convert to RGB before resizing, unless you are using an external filter like Simpleresize or Arearesize.

He's using Resize8.
http://avisynth.nl/index.php/Resize8
Resize8() works just like AviSynth's internal resizers but with some extra features:
Chroma placement is correctly handled by it, while AviSynth resizers doesn't.

SuperLumberjack,
Maybe try nnedi3. It seems to be a popular way to upscale animation, although I can't vouch for how better or worse it is for normal video as I rarely upscale.
The idea is to use it to double the resolution, (or quadruple it if need be), then downscale to the desired resolution using your preferred resizer. It can also correct any chroma shift.

nnedi3_rpow2(2, cshift="Spline36Resize", fwidth=3840, fheight=2160)

For the audio problem, is adding blank frames to the end of the video an option?

Colorbars(pixel_type="YV12")
AV = last
A = AV.Trim(0,-200).KillVideo # 200 frames worth of audio
V1 = AV.Trim(0,-100).KillAudio # 100 frames of video
V2 = BlankClip(AV).Trim(0,-100).KillAudio # 100 blank frames
V = V1 + V2
AudioDub(V,A)

SuperLumberjack
26th March 2020, 22:57
My version VDub2 is 44015 and Latest is 44282, so I'm updating, maybe you should too:- https://sourceforge.net/projects/vdfiltermod/files/

EDIT: Suggest REMOVE current vdub2, and if prompted, remove settings, then reinstall. [Maybe some setting is set to trim to video length, or something]

:thanks: I will try tomorrow ! ;)


He's using Resize8.
http://avisynth.nl/index.php/Resize8
Resize8() works just like AviSynth's internal resizers but with some extra features:
Chroma placement is correctly handled by it, while AviSynth resizers doesn't.

SuperLumberjack,
Maybe try nnedi3. It seems to be a popular way to upscale animation, although I can't vouch for how better or worse it is for normal video as I rarely upscale.
The idea is to use it to double the resolution, (or quadruple it if need be), then downscale to the desired resolution using your preferred resizer. It can also correct any chroma shift.

nnedi3_rpow2(2, cshift="Spline36Resize", fwidth=3840, fheight=2160)

For the audio problem, is adding blank frames to the end of the video an option?

Colorbars(pixel_type="YV12")
AV = last
A = AV.Trim(0,-200).KillVideo # 200 frames worth of audio
V1 = AV.Trim(0,-100).KillAudio # 100 frames of video
V2 = BlankClip(AV).Trim(0,-100).KillAudio # 100 blank frames
V = V1 + V2
AudioDub(V,A)

Hello. Thanks for your answer ! :)

I already did some experiments with nnedi3, some time ago... (some people know and I'm still sorry for them :p )

But I prefer to use a classic resizer, because I want to have a similar image to the source. My goal is just to take advantage of the better bitrate of the 2160p resolution on YouTube. In fact, if it wasn't so bad in 1080p, I would stay with the 1080p resolution.

Thanks for the tips oh adding blank frames to the end of the video ;) But if I need to do this each time, it's a bit complicated :(

StainlessS
26th March 2020, 23:15
it's a bit complicated
Not really

Colorbars(pixel_type="YV12").ShowFrameNumber

A = Last.Trim(0,-200).KillVideo # 200 frames worth of audio
V = Last.Trim(0,-100).KillAudio # 100 frames of video

FC = V.FrameCount
AFrames = Round(A.AudioDuration * V.FrameRateNumerator / V.FrameRateDenominator) # Number of Video frames to match audio length
RepeatEnd = AFrames-FC # Number of times to repeat last video frame (0 = same as original)
V = (RepeatEnd > 0) ? V.Loop(RepeatEnd+1, FC-1,FC-1) : V # Only if Video len < Audio Len

AudioDub(V,A)
#Trim(0,0) # When sure that its working, UnComment for Exact V A Match,
info

hello_hello
27th March 2020, 00:32
Thanks for the tips oh adding blank frames to the end of the video ;) But if I need to do this each time, it's a bit complicated :(

It shouldn't be if you make it a function.

The audio doesn't need to be specified if the video clip contains the audio.

Colorbars(pixel_type="YV12")
AV = last
A = AV.Trim(0,-200)
V = AV.Trim(0,-100)
AddFrames(V,A)

It's not thoroughly tested, but it should be okay. If you have a source containing video and audio and you want to add blank frames to match the audio duration.

AVISource("D:\SomeVideo.avi")
AddFrames()

Edit: Updated version to make specifying the audio separately optional.

function AddFrames(clip Video, clip "Audio") {

Audio = default(Audio, Video)
Video = Video.KillAudio()
Video_Num = float(FrameRateNumerator(Video))
Video_Den = float(FrameRateDenominator(Video))
Additional_Duration = AudioDuration(Audio) - (Video_Den * FrameCount(Video) / Video_Num)
Additional_Frames = (Additional_Duration > 0) ? round(Additional_Duration * Video_Num / Video_Den) : 0
Blank_Frames = (Additional_Frames > 0) ? BlankClip(Video).Trim(1, 1).Loop(Additional_Frames) : nop()

New_Video = (Additional_Frames > 0) ? Video + Blank_Frames : Video

return AudioDubEx(New_Video, Audio) }

Another Edit: Assuming you're adding the audio separately in VirtualDub and using VirtualDub to combine the encoded video and audio, you'd still need to specify the audio in the script, but return only the video, unless VirtualDub ignores the audio in a script when it's used as the video source anyway, but something like this for the video script should suffice:

X = Video
Y = Audio
AddFrames(X, Y)
KillAudio()

StainlessS
27th March 2020, 00:58
How bout this

# MAKE DEMO TEST CLIPS
Colorbars(pixel_type="YV12")
ShowFrameNumber
A = Last.Trim(0,-200).KillVideo # 200 frames worth of audio
V = Last.Trim(0,-100).KillAudio # 100 frames of video
VA = AudioDub(V,A) # Both Video and Audio. 100 frames of video, 200 frames worth of audio.
VA # Last = VA, ie Short video + Long Audio
# Return Info # UNCOMMENT to Show Demo clip with LONG audio (We assinged VA to Last)

BLANK=False # Default FALSE is to repeat last frame until len video matched to len audio, else TRUE blank frames till matched

# Alternatvie ways of calling the function
#AppendFramesToMatchAudio(VA, Blank=BLANK) # Single clip in VA (Audio taken from VA clip within the AppendFramesToMatchAudio function)
#AppendFramesToMatchAudio(VA,VA,Blank=BLANK) # Single clip, take Video from 1st VA, and Audio from 2nd VA
#AppendFramesToMatchAudio(V, A ,Blank=BLANK) # Separate V and A clips.
AppendFramesToMatchAudio( Blank=BLANK) # Get both Video and Audio from special Last clip (we assigned VA to Last earlier).

return last.info

Function AppendFramesToMatchAudio(clip V,clip "A",Bool "Blank") { # https://forum.doom9.org/showthread.php?p=1905137#post1905137
A = Default(A,V.KillVideo) # Audio Clip 'A' is Optional, Audio taken from video clip 'V' if clip 'A' not supplied.
Blank = Default(Blank,False) # Default is to repeat last frame until len video matched to len audio, else TRUE blank frames till matched
FC = V.FrameCount
Assert(V.HasVideo && FC>0,"AppendFramesToMatchAudio: Has No Video")
Assert(A.HasAudio && A.AudioDuration>0.0,"AppendFramesToMatchAudio: Has No Audio")
AFrames = Round(A.AudioDuration * V.FrameRateNumerator / V.FrameRateDenominator) # Number of Video frames to match audio length
RepeatEnd = AFrames-FC # Number of times to repeat last video frame (0 = same as original)
V = (RepeatEnd <= 0) ? V [* Audio Is same or shorter than video, Do Nothing *]
\ : (!Blank) ? V.Loop(RepeatEnd+1, FC-1,FC-1) [* Repeat last frame until length matched *]
\ : V + V.BlankClip(Length=RepeatEnd) [* Blank frames until length matched *]
AudioDubEx(V,A)
Trim(0,0) # Chop/Pad audio to same Duration as Video, Here, will usually Pad audio with silence if was shorter than video.
Return Last # Output Video and Audio Duration always match as close as possible.
}

hello_hello
27th March 2020, 01:22
StainlessS.... always has to go one better. :)

StainlessS
27th March 2020, 01:24
Praise indeed, thanks very much :)

SuperLumberjack
27th March 2020, 01:24
Thanks StainlessS and hello_hello ! :)

But for me, this kind of scripts are too complicated ! :D

At my level, it's easier to create a MKV and convert it again in AVI :p

I need to entirely understand what I do to use it :o (except in exceptional cases, when I have no other choice)

But thank you, I appreciate your help ! ;)

I would need more lives to learn more things ! :p

By the way, I tested the latest version of VirtualDub2 and it changed anything.

hello_hello
27th March 2020, 01:27
Is it normal for a muxing program to truncate the audio to match the video when combining them? Something tells me it is, but it's not something I've thought about in a while.

StainlessS
27th March 2020, 01:32
Is it normal for a muxing program to truncate the audio to match the video when combining them?
I would think would keep same lengths as input, unless eg extra audio was simple file append to VA clip.

scripts are too complicated
What is difficult about this (all of the extra stuff was just to demo the problem and fix it [EDIT: You could also see the fix whether Blank=True or false])

BLANK=False # False=Repeat last frame of video till end of audio, Else if True, then use blank ie black frame until end of audio.
AviSource(".\SomeVideoClip.avi")
AppendFramesToMatchAudio(Blank=BLANK)

EDIT: You should actually try any demo that I provide instead of saying "I dont understand it", if you did try, then maybe you would understand it.
EDIT: Script function updated, maybe easier to understand.

EDIT:
I tested the latest version of VirtualDub2 and it changed anything.
What does that mean ?

hello_hello
27th March 2020, 01:37
Thanks StainlessS and hello_hello ! :)

But for me, this kind of scripts are too complicated ! :D

It's not hard. Save one/both of the above functions as a script with an avsi extension and put it in the Avisynth plugins folder so it auto loads, then just use it in your script.
For the StainlessS version, the function itself begins at the Function line in his earlier post.

If the function(s) auto-load, this would add blank frames so the video duration matches the audio duration, if the audio duration is greater.

Colorbars(pixel_type="YV12")
AddFrames()

For the StainlessS version, the last frame is repeated rather than being blank, unless you specify otherwise, so it'd be:

Colorbars(pixel_type="YV12")
AppendFramesToMatchAudio(Blank=true)

If the video clip doesn't include the audio, you need to add them individually to the script ie:

X = SomeVideoSource("D:\SomeVideo.mkv")
Y = SomeAudioSource("D:\SomeAudio.mp3")
AddFrames(X,Y)

or if you were using FFMS2 (http://avisynth.nl/index.php/FFmpegSource) to open an MKV containing video and audio:

X = FFVideoSource("D:\SomeVideo.mkv") # outputs video only
Y = FFAudioSource("D:\SomeVideo.mkv") # outputs audio only
AppendFramesToMatchAudio(X,Y, true)

or

FFMS2("D:\SomeVideo.mkv", atrack=-1) # outputs video and audio
AddFrames()


That sort of thing.

SuperLumberjack
27th March 2020, 15:42
What is difficult about this (all of the extra stuff was just to demo the problem and fix it [EDIT: You could also see the fix whether Blank=True or false])

BLANK=False # False=Repeat last frame of video till end of audio, Else if True, then use blank ie black frame until end of audio.
AviSource(".\SomeVideoClip.avi")
AppendFramesToMatchAudio(Blank=BLANK)


Thanks ! I understand this better because it's shorter ! :D



What does that mean ?

Sorry, I wanted to say that nothing has changed ! :p


It's not hard. Save one/both of the above functions as a script with an avsi extension and put it in the Avisynth plugins folder so it auto loads, then just use it in your script.
For the StainlessS version, the function itself begins at the Function line in his earlier post.

If the function(s) auto-load, this would add blank frames so the video duration matches the audio duration, if the audio duration is greater.

Colorbars(pixel_type="YV12")
AddFrames()

For the StainlessS version, the last frame is repeated rather than being blank, unless you specify otherwise, so it'd be:

Colorbars(pixel_type="YV12")
AppendFramesToMatchAudio(Blank=true)

If the video clip doesn't include the audio, you need to add them individually to the script ie:

X = SomeVideoSource("D:\SomeVideo.mkv")
Y = SomeAudioSource("D:\SomeAudio.mp3")
AddFrames(X,Y)

or if you were using FFMS2 (http://avisynth.nl/index.php/FFmpegSource) to open an MKV containing video and audio:

X = FFVideoSource("D:\SomeVideo.mkv") # outputs video only
Y = FFAudioSource("D:\SomeVideo.mkv") # outputs audio only
AppendFramesToMatchAudio(X,Y, true)

or

FFMS2("D:\SomeVideo.mkv", atrack=-1) # outputs video and audio
AddFrames()


That sort of thing.

Thanks ! I understand now. Sometimes I'm a bit afraid and I'm slow to understand when I see an enormous script :D

Generally, I try to stay very basic ! :p

StainlessS
27th March 2020, 19:10
Investigation due to this post: (the little blue arrow after SuperLumberJack's name is a link to his post)
Just a question : Does somebody know how to avoid a cut audio with VirtualDub when the video stream and the audio stream haven't the same length ?

I have for example a video that I want to export with VirtualDub, but the video stream has a duration of 10 seconds and the audio stream 12 seconds. The issue is that I lost 2 seconds of the audio stream.


Here Colorbars MKV in 7z (~1.5MB, expand to 9MB):- http://www.mediafire.com/file/gxwuqnkn3oh5ahg/Video3secs_Audio6secs.7z/file
with 3.33 secs video and 6.67 secs audio, in 6.67 secs container.
Plays in player (potplayer) showing video half length on timeline, but continues video repeating last video frame for remainder of clip (to match container and audio len).
When loaded into VDub2, VDub does indeed play with video frames extended to match audio length, and also saves AVI file with extended video frames.

Here MKV in Potplayer showing half timeline in light grey:

https://i.postimg.cc/8zx7W55w/Half-Timeline.jpg (https://postimages.org/)


With Avisynth, loading same MKV, chops short to end of video clip with DirectShowSource, FFmpegSource2[script function], but loads OK full len audio with
AudioDubEx(ffvideosource(FN),ffaudiosource(FN)), however when loaded into VDub2, is then chopped short.


FN=".\Video3secs_Audio6secs.mkv"

#DirectShowSource(FN) # V=3.33 : A=3.33
#FFmpegSource2(FN) # V=3.33 : A=3.33

AudioDubEx(ffvideosource(FN),ffaudiosource(FN)) # V=3.33 : A=6.67 # Load into VDub2, V=3.33 : A=3.33

Info


Avs script with

FN=".\Video3secs_Audio6secs.mkv"
AudioDubEx(ffvideosource(FN),ffaudiosource(FN))
info

loaded into Potplayer, plays with extended frames to match full audio lenth [info shows video=3.33 audio=6.67].
[Unlike potplayer with MKV, does not show video half length on timeline]

https://i.postimg.cc/h42nYtmr/Half-Timeline.jpg (https://postimages.org/)

I dont know which is correct [if there is a correct one], but there is a difference.

Light grey half length on timeline probably only means "buffered so far", so image for MKV means only half length video buffered, and for avs
fully buffered (as is all light grey).

The MKV image which does not get chopped in VDub, shows 3 seconds duration on timeline, whereas the avs which does get chopped in VD shows 6 seconds ???

EDIT: Removed a coupla screw-ups and re-ordered a bit.

hello_hello
27th March 2020, 22:28
StainlessS,
I don't use Potplayer, and I'm still not 100% sure I followed your post, but here's how your mkv worked for me. I used the "Export/Save Old Format AVI" output method, because apparently the VD2 File/Save option is missing for the version I downloaded, or I'm too stupid to work out how to mux the video and audio. Are we still required to use the External Encoder method for that? I don't use VD2 much. Anyway....

SuperLumberjack,
I found the VirtualDub "cut the audio" option. It's under the "Video/Select Range" menu. It seems to make no difference when opening the MKV directly (although I didn't change the specified frame range), but when opening it via a script including the audio it does, although it only shows the video duration on the timeline, and it could've been me doing a silly, but even though the setting "sticks" after opening a new script, I'm not sure it always worked the first time. You might have to open the menu and check and uncheck that option sometimes, or maybe it was just me.

It looks like when the source file is the MKV, VD2 repeats the last video frame until the audio ends. MPC-HC shows 7 seconds as the duration for the output AVI. When the source is the script outputting video and audio (no extra frames being added by a function) MPC-HC only shows 3 seconds for the duration, but keeps playing the audio after the video ends (when the VD2 "cut the audio" option is unchecked). If you want it to show the whole duration, you'd need to use one of the functions to add frames so the video matches the audio.

Edit: I haven't tried, but maybe you could open a script that includes audio with VD2 the usual way, then open it again as a separate audio file using the "Audio/Audio From Other File" menu. I don't know if it'll change the way VD2 behaves in respect to repeating the last video frame to match the audio duration when the source is a script, but it might be worth a look.

StainlessS
27th March 2020, 22:54
I usually just use the F7 File\Save Video\ option to save V + A.
I found the "cut the audio" option. It's under the "Video/Select Range" menu.
Thats the one what dunnit, you be a Brainiac !!!
SuperLumberJack, HH nailed it for you :)

Still, bit weird that MKV does not chop audio and avs does [with defaults].

HH, current version VD2 is 44282, Shekh dont advertise much (or at all) when he puts up a new version VD2, you gotta go look for yourself.
I love the new VD2, great app and especially the Avs Script Editor [although the script window sometimes tends to be awkard and not go behind
other windows when you click somewhere else, likes to be on top most of the time, but then dont we all :) ].

Once I've hacked out a working-ish script in Ps-Pad [ie it dont crash], I then switch to VD2 for remaining editing.
[and back to Ps-Pad if eg text replacing or formatting(eg Tabs to SPACES for D9 post), or something better suited to text editor]

hello_hello
27th March 2020, 23:15
StainlessS,

I'm using the latest version, but the F7 shortcut is displayed as "Save Video" under the File menu, and given immediately below that is the "Save Audio" menu, I assumed they saved the video and audio individually, so I ignored them. Now I know. Cheers.

I guess the different behaviour when opening the MKV directly and opening it via a script, in respect to the number of frames, comes down to how many frames VD2 sees in the source, and the decoder is probably responsible for that. Maybe ffmpeg is repeating the last frame automaticaly to match the video duration when decoding the MKV, so that's what VD2 sees?

StainlessS
27th March 2020, 23:23
I assumed they saved the video and audio individually
Yeh, I figured as much.

#DirectShowSource(FN) # V=3.33 : A=3.33
#FFmpegSource2(FN) # V=3.33 : A=3.33

AudioDubEx(ffvideosource(FN),ffaudiosource(FN)) # V=3.33 : A=6.67 # Load into VDub2, V=3.33 : A=6.67 # Save from VDub without HH fix V=3.33 : A=3.33 # with HH fix V=3.33 A=6.67

Durations shown above, was only the setting that you gave that made the difference [and only to Avs, I did not try change for mkv, it did not chop audio anyway even though set to chop audio].

EDIT: MKV always saves as V=6.67 A=6.67 with HH fix at either setting, and with Select Range Apply Video Edits to Audio (next to HH fix) at either setting. [Although I did not do any video editing before save]

hello_hello
27th March 2020, 23:38
Yeh, I figured as much.

#DirectShowSource(FN) # V=3.33 : A=3.33
#FFmpegSource2(FN) # V=3.33 : A=3.33

AudioDubEx(ffvideosource(FN),ffaudiosource(FN)) # V=3.33 : A=6.67 # Load into VDub2, V=3.33 : A=6.67 # Save from VDub without HH fix V=3.33 : A=3.33

Durations shown above, was only the setting that you gave that made the difference [and only to Avs, I did not try change for mkv, it did not chop audio anyway even though set to chop audio].

It does chop the AVS audio for me (I double checked), but maybe that relates to what I mentioned before about the setting not always "sticking" when you first open a script.

I was using this script. FFMS4 is just my version of FFMS2, created to fix some annoyances.

https://i.postimg.cc/wM1fJDDv/Video3secs-Audio6secs-FFMS4-avs-snapshot.jpg

#ASYNTHER FFMS4
FFMS4("D:\Video3secs_Audio6secs\Video3secs_Audio6secs.mkv", VTrack=-1, ATrack=-1, Cache=true, FPSNum=-1, FPSDen=1, Threads=1, TimeCodes="", RFFMode=0)


#FFmpegSource2(FN) # V=3.33 : A=3.33

Should that be
FFmpegSource2(FN, ATrack=-1)

StainlessS
27th March 2020, 23:42
thats what I said,
was only the setting that you gave that made the difference [and only to Avs,
No diff to mkv
EDIT:
EDIT: MKV always saves as V=6.67 A=6.67 with HH fix at either setting,

hello_hello
27th March 2020, 23:52
I think I edited an earlier post (so maybe you missed it) to offer a theory that it's ffmpeg repeating the last frame when decoding the MKV and nothing VirtualDub2 itself is doing. It'd explain why the non-existent frames show in the timeline and under the "Video/Select Range" menu. Therefore to cut the audio for the MKV, you'd have to remove the frames being added by the decoder.

StainlessS
28th March 2020, 00:36
ffmpeg repeating the last frame when decoding the MKV and nothing VirtualDub2 itself is doing.
In file Infomation for MKV, shows for caching input driver V=3.33 A=6.67.
https://i.postimg.cc/X78FWcxF/VD-FI.jpg (https://postimages.org/)

Repeating last frome where video is short is pretty standard practice.

SuperLumberjack
28th March 2020, 02:56
SuperLumberjack,
I found the VirtualDub "cut the audio" option. It's under the "Video/Select Range" menu.

:goodpost:

Yes, indeed, that's the one ! :p

:thanks:

Thanks to both of you ! ;)

This option... it's easy to understand ! :D

But it would have been great if this option was enabled by default... :( But I will not complain ! :p

hello_hello
28th March 2020, 05:51
I'd still be adding extra frames though. If you're uploading to YouTube, do you know they won't cut the audio if you don't?

SuperLumberjack
28th March 2020, 11:47
I'd still be adding extra frames though. If you're uploading to YouTube, do you know they won't cut the audio if you don't?

Yes, I know ! :p

In fact, it's not because of YouTube. It's because when I export the video upscaled from the script, here the audio is cut.

So I need to avoid this ;)