News:

--

Main Menu

TinyPy - Width and height of filtered video

Started by signy13, June 03, 2020, 05:08:38 AM

Previous topic - Next topic

signy13

Is there any way how to get width and height of video after applying filters in TinyPy script?
I know how to get size of original video
adm=Avidemux()
width=adm.getWidth()
height=adm.getHeight()


I use different resize and crop filters and I would like to create a script which puts another filter (delogo) based on current size of video (after previous resizing and cropping).

eumagga0x2a

No, this is not possible, unfortunately. You will have to implement all the calculations and checks in Python.

signy13

Thank you for your reply.
I am sorry I do not understand how I can implement calculations in Python. Do you mean when I have a movie with set of filters which can change size of resulting video (sw resize, crop etc.), is there any way how to check these filters and get their parameters and calculate the final size of picture from these values?

eumagga0x2a

Quote from: signy13 on June 04, 2020, 10:18:28 AM
Do you mean when I have a movie with set of filters which can change size of resulting video (sw resize, crop etc.), is there any way how to check these filters and get their parameters and calculate the final size of picture from these values?

I assume that you control the parameters used to create resize and crop filters. In this case it is possible to calculate the resulting size (actually, to reimplement the logic in Python) to decide whether to add delogo or not.

signy13

I see... No, I do not control the parameters for setting the resize/crop filters in any script. I do it manually - the filters are set according to movie. For example Full HD movie is just resized (50%). Old 4/3 movie broadcast in Full HD is resized (50%) and cropped. There are movies broadcast in FullHD with black borders so cropping and resizing is based on size of borders.

eumagga0x2a

What is the purpose of using scripting if you have to add resize and crop manually anyway? Just put delogo as the first (well, second, if the video is interlaced) filter in the chain. This will indeed slightly reduce efficiency.

By the way, when resizing and cropping, always think of keeping width and height a multiple of 16 else video compressibility will suffer.

signy13

The purpose of scripting is to help mi with tedious work I do with videos. Not everything is possible to script (like searching proper resize and crop dimensions - I set the result video with multiple of 8 dimensions), but everything what is possible to script is welcomed.

I know that using the filter as a first or second one would be possible, but using it as the last one is more convenient in the process...
I thought that getting know of size of the last script would be possible, because Avidemux can show the resulting dimensions in its filter dialog so it is just about to recognize which filter affecting picture size is the last in the chain and then provide dimensions from from that filter.

I already tried to study Avidemux's source code (because of fixing a bug in Mplayer delogo filter and improving its settings dialogue), but unfortunately its vastness and complicated character is beyond my programming skills.

eumagga0x2a

Quote from: signy13 on June 06, 2020, 06:07:01 PM
I thought that getting know of size of the last script would be possible, because Avidemux can show the resulting dimensions in its filter dialog so it is just about to recognize which filter affecting picture size is the last in the chain and then provide dimensions from from that filter.

There is no interface for that. All information is retrieved from the editor.

Quotebecause of fixing a bug in Mplayer delogo filter and improving its settings dialogue

-v please. Which bug do you mean?

signy13

#8
I bumped into this bug in Avidemux and made a ticket some time ago:
https://sourceforge.net/p/avidemux/bugs/100/
Later on I realized that this bug affects Mplayer itself so originally it is a bug in Mplayer.

Finally, I spent so much time trying to send this short message and reading nonsense about clean talk and "turn on javascript" (my javascipt is turned on), another was when I sent message after preview something like "you have sent this message already" and third one is my favourite: "CleanTalk: Forbidden. You sent forms too often. Please wait a few minutes. Please enable JavaScript.".

eumagga0x2a

Thank you for your PM, now I understand the reason why https://sourceforge.net/p/avidemux/bugs/100/ has ever become relevant. This is because you put delogo after crop in filter chain.

signy13

That PM was out of despair that I was not able to send it as normal reply in this forum (probably because some antispam filter).

I do not think that the MP delogo filter bug has anything to do with the resize filter. If I just use a 960 x 540 video and apply a MP delogo filter and if the filter width is also 960px, the filter ignores two most right pixels and instead of filtering them it uses them as a pattern for filtered area (as you can see in the attachment).

eumagga0x2a

I meant static logos targeted by this filter are usually never very close to the border of the picture (and the FFmpeg equivalent would crash out from an attept to extend the area to the border). Cropping may result in logo touching one or two of the borders. Nevertheless, I would try to look into it during the next release cycle.

Blurring out a ticker like in the attached screenshot doesn't work well with the algorithm used anyway.