News:

--

Main Menu

Resize Filter UI Improvement

Started by butterw, July 23, 2020, 08:28:06 PM

Previous topic - Next topic

butterw

Sure, and sharp bicubic is a good default.

I don't use this resize interface very often, but each time I do, I feel like it needs basic improvements.
Maybe adding a textbox to the right of error X/Y with the output Aspect Ratio would be feasible ?
ex: AR: 1.778 (16/9)
Currently to get the desired result you have too know the right output resolutions. An average user will often get it wrong.

eumagga0x2a

Quote from: butterw on January 02, 2021, 08:32:14 PMMaybe adding a textbox to the right of error X/Y with the output Aspect Ratio would be feasible ?
ex: AR: 1.778 (16/9)

It wouldn't be difficult to show (storage width / storage height) as a float, but how should this help the user?? For the use case of output display using square pixels only?

Quote from: butterw on January 02, 2021, 08:32:14 PMCurrently to get the desired result you have too know the right output resolutions.

By specifying the desired display aspect ratio or display width in muxers which support this (MKV, WebM, MP4 and MOV), the necessary pixel aspect ratio is automatically calculated based on pixel size of the source. No effort on user side required.

butterw

#17
Quote from: eumagga0x2a on January 02, 2021, 08:53:00 PM
Quote from: butterw on January 02, 2021, 08:32:14 PMMaybe adding a textbox to the right of error X/Y with the output Aspect Ratio would be feasible ?
ex: AR: 1.778 (16/9)

It wouldn't be difficult to show (storage width / storage height) as a float, but how should this help the user?? For the use case of output display using square pixels only?

I only use square pixels (PAR=1 ?) I don't know what the buttons at the top of the interface do. Probably the output Width/Height*PAR should be displayed if possible. This output display would avoid having to copy/paste out the values and manually calculate the AR for each suggested set of values. The error X/Y display is one thing that does work well in this interface.

Quote
Quote from: butterw on January 02, 2021, 08:32:14 PMCurrently to get the desired result you have too know the right output resolutions.
By specifying the desired display aspect ratio or display width in muxers which support this (MKV, WebM, MP4 and MOV), the necessary pixel aspect ratio is automatically calculated based on pixel size of the source. No effort on user side required.

You also need to know the output AR to use DAR. You have to be near the desired ratio to apply DAR, otherwise you get a significant AR error.
 
Output Format > configure > DAR is in a different somewhat hidden, interface so it seems easy to forget about.
One thing missing seems to be a 9/16 DAR (increasingly popular in mobile/internet videos).
I don't know what display width does in avidemux.

I do personally prefer mod-16 exact ratios: no possible issues down the line (video players, muxers, editors, etc.). 
I've checked rotation and it doesn't round-trip. Meaning a mp4 file with a rotation tag doesn't get auto-rotated when it is opened in avidemux.
Is mp4 container DAR preserved though a basic remux with ffmpeg, or a conversion to mkv ? If the user goes through the trouble of setting parameters, they need to stick by default.

eumagga0x2a

Quote from: butterw on January 02, 2021, 11:05:40 PMI only use square pixels (PAR=1 ?)

If you never need to create a DVD video or work with output of HDV camcorders, this is fine.

Quote from: butterw on January 02, 2021, 11:05:40 PMI don't know what the buttons at the top of the interface do.

The menus apply a factor to width or height in pixels to account for PAR specific to selected scenario. If you work with square pixels only, why are you concerned about aspect ratio at all? Whatever dimensions you set will work right, just keep aspect ratio locked. The whole complexity arises only from anamorphic video.

Quote from: butterw on January 02, 2021, 11:05:40 PMYou also need to know the output AR to use DAR. You have to be near the desired ratio to apply DAR, otherwise you get a significant AR error.

This setting in the muxers creates anamorphic video, yes.

Quote from: butterw on January 02, 2021, 11:05:40 PMOne thing missing seems to be a 9/16 DAR (increasingly popular in mobile/internet videos).

As you noticed later down the post, this one simply doesn't exist. It is 16/9 rotated.

Quote from: butterw on January 02, 2021, 11:05:40 PMI've checked rotation and it doesn't round-trip. Meaning a mp4 file with a rotation tag doesn't get auto-rotated when it is opened in avidemux.

Correct, this is by design. The only metadata which will round-trip ATM is color info (matrix coeficients, color primaries, transfer characteristic, color range) from MKV to MKV in copy mode.

butterw

#19
Container DAR was created for anamorphic (DVD) videos yes. But it can also be used to fix videos that don't have a perfect ratio (ex: near 9/16) to avoid padding at playback (with a negligible AR error).
These container parameters can be useful to fix a video (ex: rotation), but I don't use them if I'm (re)-encoding because I know they are not well supported in editors.

Resizing implies there is re-encoding. To be useful the GUI needs to help with the following:
1. the output dimensions should really be mod-16 (or at least mod-8).
2. the AR error should be small
3. the output AR also needs to be a perfect (or at least near perfect) ratio, and currently the GUI provides no info on this point.

There are very few mod-16 perfect ratios, and it isn't the only AR that users have to deal with. So having an output display would be helpful ex: 1.778.
I never encounter non-square pixel so I can't comment on whether it is a perfect solution for this use case, but at least it does no harm and it seems simple enough to implement.

butterw

Quote from: xyzzy on December 03, 2020, 09:21:41 AMHave a go at it.  It really shouldn't be that hard.  I'd never worked on a Qt graphical app before and fixed up the x265 options with one night of hacking.

Is it possible to modify/recompile an existing filter plugin and it's ui without recompiling the whole of avidemux ?
As long as the I/O remains unchanged, I would assume the modified plugin could be used with an existing build of Avidemux ?
I'm using the VC++ 2.7.7 version on Win10, what software configuration would be required for this (and is there a guide) ?
 

eumagga0x2a


butterw

Some user feedback on the GUI changes, based on testing of the latest Win64 dev build (210118):
- The change with cutting/deleting at the end seems to work well. 
- [resize GUI] the default should be mod-16 values rather than no-rounding
- [resize GUI] The interface as tested provides very little useful info if AR Locked is unchecked.
My suggestion would be to always display the numerical value of output AR next to X/Y error as discussed in my forum post. When the interface is opened it also shows the source AR, which is key to determine if AR should be Locked.
- [crop GUI] displaying the numerical value of Output AR would be useful (or the source AR in the keep-AR box)
- [crop GUI] being able to move around the crop Window would be nice (crop values would need to adjust once it's done...)
- [mplayer eq2] the luma histogram is a great addition, if possible the 16-235 limit bands could be dashed or colored

butterw

#23
!!! Since v2.7.7 the resize GUI no longer allows to force a mod value (ex: mod-16) if lock Aspect Ratio is unchecked.

EDIT:
with TinyPy  width and height are not taken into account when full parameters are not provided. Is this a bug ?
adm.addVideoFilter("swscale", "width=640", "height=360", "algo=1") returns 1, the filter is added but does not resize, I would expect the provided width and height values to be enforced by default.

The full command which does work is available in the saved project:
adm.addVideoFilter("swscale", "width=640", "height=360", "algo=1", "sourceAR=0", "targetAR=0", "lockAR=True", "roundup=2")
roundup sets the GUI parameter for rounding
- 0: no rounding
- 1: mod-16 rounding
- 2: mod-8 rounding
It would be good if parameter reference for filters was provided somewhere (what they do, their default values and range).

Is it possible to specify a single dimension (w or h), lockAR and mod-8 rounding ?



butterw

#24
Quote from: butterwIs it possible to specify a single dimension (w or h), lockAR and mod-8 rounding ?
It seems you currently must specify both w and h, but it's possible specify for instance the same value for both and the filter will then auto-update if the resize filter interface is opened in the GUI.

EDIT: Its possible to write a resize wrapper function with TinyPy, but it could only know the resolution of the input video, which would be different from the current resolution if a crop filter has been applied.


butterw

Can swscale filter downsize a video of arbitrary dimensions to a minimal dimension (ex: wh_min=288), via script ? 
- with Mod-8 output Resolution
- while preserving Aspect Ratio (small error acceptable)

eumagga0x2a

If you invoke swsResize from a tinyPy script, you need to calculate output dimensions in Python. All the aspect ratio preserving and dimensions roundup happens in the Qt configuration dialog only, which is not involved here.

alexstorm

#27
I wonder what content you all are working with.  If it's original master from a current camera, then the aspect ratio 16:9  or 1.77777778 is correct.  Older master content will match the camera.  But any other content that is a republished version is not necessarily correct.  Some aspect ratios of this type of content is correct but many are slightly to terribly wrong, stretched or squashed, for many reasons.

At any specific height, the exact correct ratio might be a length that is a fraction and is not available.  You can't enlarge the video to a fraction of a pixel. And with encoders the target width has to be even, to boot.  By the way, this happens about 99% of the time.  So, if you showed an exact fraction ratio it would only match what you expect perhaps 1 in 100 times.

This is the reason why acceptable height sizes are in use online: 480, 720, 1080... and even these numbers don't have an even numbered matching width for ever aspect ratio.

I use the swsResize a lot when getting content from anything other than a camera or post production master video.

I crop out black bars, look up the correct original aspect ratio, take the new height of the cropped video and use my interactive chart to find the best pixel match.  That works most of the time, but for old content already transferred once to digitial that might have additional cropped pixels bringing it back to the original aspect ration might actually go too far.  In those cases you can search for something in a frame that should a circle, like someone iris looking right into the camera, cars passing by with a straight on look at the tire, a straight on look for a clock, or even a match the opening company logos and then tweak the width a little more to fine tune.  If this was to also show the new aspect ratio that fixes everything, it might say some very large fraction and really not be useful.

For example:  The number of pixels widths for content 480 pixels of height is:

1:1.7777778 (16:9) width: 853.3333296... which is unusable, so 854 which is 1.7791666... (pretty close - for HD TV screen it's 1 pixel too wide)

1:1.85 width: 888 (this one actual works, but ironically it's never used on DVD's because post production chooses to show any movie in 1.85 with thin top and bottom black bars so it works on widescreen TV's. If you wish to convert to a copy that keeps the black bars, then 888 is exact.  If you want to crop out the black bars, then the next best pixel combo is 944 x 510 which would be exact for HD TV and 1 pixel too tall for 4K TV... good enough. This assumes playback on the TV with a browser, not through DVD or blu-ray.  The exact ratio of 944 x 510 is: 1.85098039... )

1:2.35 width: 1128 (also works fine, but never used because again, content released in 2.35 uses black bars. the next best pixel size is 912 x 388 which is still accurate at 4K. The ratio, however is 2.3505154...)

So, you are not going to get the fractions or exact ratio numbers you expect if they were printed inside the UI area of sysResize.  How much use is it to see such numbers?  I suppose you could play with the pixel height and width and try to get it as close as possible.  It's not that easy.  I prefer to use the calculators on my page: https://www.producerelease.com/blu-ray/parcalc.htm#v

You can enter the width and the target ratio in the first calculator.  The table below tells how close the width / height combination gets to the target ratio.  There is a right arrow where you can scan upwards to see if the next few sizes get any closer.  You want gold or blue results.

It all get comically complex, pretty quick.  If anyone is interested, you are welcome to use the calculators on my page, mentioned above.

---

The first calculator on the page takes height and target ratio and finds width. It is most useful for cropping content to get rid of black bars and then resizing it exactly right to playback with the correct aspect ratio.  The trick is to find the right pixel ratio in even whole numbers which is what is needed to run the encoder. The lower right arrow button opens the next group of pixel sizes.  You can often find a better ratio match using this arrow button.


The second calculator is further down the page and it takes width and target ratio and finds height.  There is also a list of recommended pixels sizes for each ratio, which is sort of all you need anyway.

The third calculator at the bottom of the page, is really only for forcing the width so the player knows what width to use.  It doesn't work for prepping videos for uploading to the Internet social media or for playback in a browser.  Only full featured video players can pick up on the forced width command.  If all you use is VLC to watch everything, you can use this calculator and force the width.  It does NOT apply to this forum post of using sysResize.

butterw

- 16/9 480p should be avoided if possible. 854x480 is low Aspect Ratio error even if it isn't a perfect ratio, but the main issue is that it is only mod-2.

- Cropped videos can end up having any ratio, even if the initial capture was done at 16/9.

- Because of smartphone cameras and screens, portrait mode video is increasingly popular.
In photography, the most commonly used AR for this are 4/5=0.8 and 3/4=0.75. The AR crop in my photo app swaps between landscape and portrait mode (AR=4/3 will mean 4/3 with x>y or 3/4 with x<y). Why can't Avidemux crop filter UI do this ?

- The current swsResize UI isn't much help at all. In a GUI using an external calculator shouldn't be required. Adding a display of output AR to the crop and resize filters is a trivial to implement improvement.

- On mobile devices players, if container DAR correction isn't supported, it may be possible to stretch the video to fit the screen (Width). Black sidebars in portrait mode are very ugly.