osumoclement / script.black.bars.never

An addon to automatically remove black bars in KODI
GNU General Public License v3.0
12 stars 2 forks source link

Add option to toggle addon #3

Open TwilightMercy opened 1 year ago

TwilightMercy commented 1 year ago

Hi,

Great add-on and improvement to watching experience!

I have 2 questions:

  1. About android support - disabling hardware acceleration for the add-on to work will affect something?

Regardless the add-on - what’s the recommended setting for it?

And is there a progress with the fix for Android support?

  1. Is it possible to some how toggle on and off the black bar removal?

Currently the addon has no settings or windows, just enable/disable.

I was thinking about manually adding to Estuary skin player, a button that can toggle off and on the black bars removal, so it will be easier to choose how to watch the video during playback.

osumoclement commented 1 year ago

Hi,

Great add-on and improvement to watching experience!

Thank you! 🙂

  1. Most Android devices do not have the processing strength to handle video decoding on high bitrate files smoothly or even at all. And in my observations, HDR won't work without hardware acceleration. The addon works pretty much automatically, so once you enable it there isn't any configuration needed. Right now Kodi cannot capture screenshots due to a limitation in how Android does hardware acceleration - without this ability the addon can't work. There are workarounds, but this is not something that's actively being worked on by Kodi as far as I'm aware.

  2. This is a good idea that I have received from many users. I think a way to implement this would be having the addon expose a Toggle function which users would then be free to map onto buttons/key or into skins like you suggest with Estuary. I will definitely add this functionality in the next release.

TwilightMercy commented 1 year ago

Thank you very much! Once you’ll add the toggle option, could you write me here the path or how to use/call it?

And will the on/off toggle work during video playback and remove/bring the black bars without issues?

osumoclement commented 1 year ago

Sure, will do. The toggle should work during playback without issue

TwilightMercy commented 1 year ago

Great!

I’m planning to add the toggle to Estuary player OSD as a button here near the right side buttons:

image

Do you have any idea for small and fit icon to use for it? I noticed that the addon has no true dedicated icon.png

osumoclement commented 1 year ago

I think an icon like this would work well. For the addon I plan to get a nice icon (and other graphics) created in future definitely

TwilightMercy commented 1 year ago

Thank you very much, I’ll try it out.

By the way, is it possible for you to configure a repository URL, or File manager direct URL to the addon .zip file, for easy download of the add-on inside Kodi?

osumoclement commented 1 year ago

A repository would be nice. I'll configure that in the next release

TwilightMercy commented 1 year ago

I tried the monitor icon you sent, but it has transparent background so the icon is not visible in the player.

I went with 3 three options to choose from:

image

image

image

osumoclement commented 1 year ago

In order of preference - 1st one, then third and finally 2nd

TwilightMercy commented 1 year ago

Now it looks better : )

https://github.com/osumoclement/script.black.bars.never/assets/29895680/84ff11cc-ee28-40fd-b1b9-7906045f5aa7

osumoclement commented 1 year ago

Yes 🙂

TwilightMercy commented 1 year ago

Great, so the button's UI is ready 🙂

I have 2 questions:

  1. In terms of "onclick" code for the button in Estuary's OSD player -

From my experience with different addon which I created a button shortcut to it, it uses "RunScript" function, will it be similar with your toggle function? Example:

<onclick>RunScript(script.black.bars.never,<<function_name>>)</onclick>


  1. Currently when the addon is enabled, it removes the black bars,

Will it be possible to use the toggle button to activate it, so by default it won't remove the bars? (OFF), and only by clicking on the button it will remove the black bars? Or maybe a setting to the add-on if it's ON or OFF by default when playing media?

Thanks!

osumoclement commented 1 year ago
  1. Yes, I'll do it the same way
  2. I'll add a setting to the addon so that the default behavior can be configured. Then I will expose two methods - one to toggle on and off so it can be done outside the addon, and another to query the status of the addon if it's on or off.

I will try to implement these tomorrow

TwilightMercy commented 1 year ago
  1. Great : )

  2. I'm planning to use one button as seen in the video to toggle on and off the addon, and if possible - It will be easier and more comfortable for me, to use the same permanent function for the button.

Maybe in addition to the 3 separate functions (toggle ON, toggle OFF, query status),

Can you write one function that toggles the addon ON/OFF each use? It will:

A. query the current status B. if status is on - toggle off, if status is off - toggle on

Thank you for your fast response : )

osumoclement commented 1 year ago

Can you write one function that toggles the addon ON/OFF each use?

Yes, that's how I will implement

TwilightMercy commented 1 year ago

Thank you very much

osumoclement commented 1 year ago

Hey, I have added the features. In your case, to check status try status argument, and to toggle on and off try toggle argument. I haven't tested this feature so just try and let me know if it works. Also there's now an addon setting to change default behavior if it should work automatically or not

TwilightMercy commented 1 year ago

Thank you!

You mean: <onclick>RunScript(script.black.bars.never,toggle)</onclick>

?

osumoclement commented 1 year ago

Yes

TwilightMercy commented 1 year ago

I’ll try the function in few hours when I’ll be on my PC.

I don’t see the new version in Releases

osumoclement commented 1 year ago

It's not in releases. Just download from the code homepage

TwilightMercy commented 1 year ago

Got it! It's not possible with one radiobutton getting the sync with addon status easily, the solution is two seperate buttons - but only one is visible according to addon status.

Tested and working code:

<!-- IMAX: OFF -->
<control type="radiobutton" id="700452">
  <description>script.black.bars.never Toggle OFF</description>
  <include content="OSDButton">
    <param name="texture" value="imax_off_white.png"/>
  </include>
  <visible>String.IsEqual(Window(10000).Property(blackbarsnever_status), off)</visible>
  <onclick>RunScript(script.black.bars.never,toggle)</onclick>
</control>
<!-- IMAX: ON -->
<control type="radiobutton" id="700453">
  <description>script.black.bars.never Toggle ON</description>
  <include content="OSDButton">
    <param name="texture" value="imax_on_green.png"/>
  </include>
  <visible>String.IsEqual(Window(10000).Property(blackbarsnever_status), on)</visible>
  <onclick>RunScript(script.black.bars.never,toggle)</onclick>
</control>

All is working perfectly now with the player button.

Only thing left to know if there's any progress with Android devices workaround : ) I saw your comment in your addon's post in Kodi forum:

However, your post has given me an idea that is so outrageous it just might work as a workaround for Android 🙂

Hoping for good news!

osumoclement commented 1 year ago

I am glad it now works for your skin. Enjoy!

Yes, will soon have a workaround for Android 🙂

osumoclement commented 1 year ago

Hi, there's a new release with the workaround. I tested on one file and it worked 😆

TwilightMercy commented 1 year ago

I see, nice workaround : ) I guess that the screenshot is more specific to zoom level, but the aspect ratio information should be reliable?

osumoclement commented 1 year ago

Yeah, the screenshot should be more accurate but this workaround isn't too bad. As long as your media doesn't have an altered aspect ratio, it should be decent enough.

TwilightMercy commented 1 year ago

If the media aspect ratio is already made for full screen (no black bars), the addon will still zoom when enabled?

osumoclement commented 1 year ago

Yes, that's the caveat. The reason is because hard coded black bars advertise a full screen aspect ratio (the black bars are part of the video). So Kodi (or another player) does not know there are black bars, that's where the idea of using screenshot to capture a frame and manually confirm comes from.

So ideally, Android users are supposed to combine this workaround together with toggling to quickly verify whenever in doubt.

Also there's new code I have uploaded just now

TwilightMercy commented 1 year ago

I see, I will be able to test on Android in a few hours.

is configuring a repository for Kodi possible? it will be more comfortable for installing and updating versions

osumoclement commented 1 year ago

How does it work? Do I choose one of the popular repos and send my addon, if so how?

TwilightMercy commented 1 year ago

How does it work? Do I choose one of the popular repos and send my addon, if so how?

It’s a bit complicated than that. It should be set in your own Github Repo. I tried yesterday to upload the addon to my build repo: https://github.com/kodi7rd/repository

But it didn’t show up in Kodi because the addon is labeled as “script.XXXX...”, and they usually don’t show up.

The solution is to transition the addon name + id to plugin.program.black.bars.never

if that’s acceptable for you

osumoclement commented 1 year ago

Okay, do you have a link to guides on how to create own repos? Also I have discovered a problem with Android, there's a missing dependency. So not working until I find a fix

osumoclement commented 1 year ago

There's a new release which should work for Android

TwilightMercy commented 1 year ago

I will do some tests in my repo to test something and I’ll update you.

About the IMDB API: image

Suggestion: If possible, get IMDb ID from media for 100% accuracy? I think that from other addons the parameter exists

TwilightMercy commented 1 year ago

I've tested now 1.0.7 on Android with workaround setting enabled:

Unfortunately, it doesn't work yet. when enabling the toggle, this is an error popup. Error from log:

error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'AttributeError'>
                                                   Error Contents: 'NoneType' object has no attribute 'select'
                                                   Traceback (most recent call last):
                                                     File "C:\Users\twilight\AppData\Roaming\Kodi\addons\script.black.bars.never\addon.py", line 174, in <module>
                                                       p = Player()
                                                     File "C:\Users\twilight\AppData\Roaming\Kodi\addons\script.black.bars.never\addon.py", line 30, in __init__
                                                       self.abolishBlackBars()
                                                     File "C:\Users\twilight\AppData\Roaming\Kodi\addons\script.black.bars.never\addon.py", line 128, in abolishBlackBars
                                                       aspectratio = int(getOriginalAspectRatio(title))
                                                     File "C:\Users\twilight\AppData\Roaming\Kodi\addons\script.black.bars.never\imdb.py", line 16, in getOriginalAspectRatio
                                                       if soup.css.select('.ipc-metadata-list-summary-item__t'):
                                                   AttributeError: 'NoneType' object has no attribute 'select'
                                                   -->End of Python script error report<--
osumoclement commented 1 year ago

Damn, I will solve soon. I have been testing on my computer and apparently there's some stuff which can't be installed in Kodi system

TwilightMercy commented 1 year ago

All good : )

https://github.com/osumoclement/script.black.bars.never/issues/3#issuecomment-1599490641

Example from subtitles addon code: (Works perfect with other addons)

image

osumoclement commented 1 year ago

I will try it out, would be the better solution. And if there's no IMDB number that's when I fallback to filename

osumoclement commented 1 year ago

Try it out, works now

TwilightMercy commented 1 year ago

Thank you, I will be able to test in few hours

This is now fixed, but without using IMDb ID yet right?

osumoclement commented 1 year ago

Right now just using Title. I have tried but the code gives no IMDb ID. Maybe the code you sent is unique to a specific skin? Cause I also can't find any documentation on official KODI that mentions IMDb ID

TwilightMercy commented 1 year ago

Thank you! sorry if bothering with a lot with messages, only to improve this great addon : ) (and to bypass stupid Android limit)

osumoclement commented 1 year ago

No problem, the addon is now much better and that has always been the goal.

TwilightMercy commented 1 year ago

Error from log:

error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'TypeError'>
                                                   Error Contents: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
                                                   Traceback (most recent call last):
                                                     File "C:\Users\twilight\AppData\Roaming\Kodi\addons\script.black.bars.never\addon.py", line 176, in <module>
                                                       p = Player()
                                                     File "C:\Users\twilight\AppData\Roaming\Kodi\addons\script.black.bars.never\addon.py", line 30, in __init__
                                                       self.abolishBlackBars()
                                                     File "C:\Users\twilight\AppData\Roaming\Kodi\addons\script.black.bars.never\addon.py", line 130, in abolishBlackBars
                                                       aspectratio = int(original_aspectratio)
                                                   TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
                                                   -->End of Python script error report<--
osumoclement commented 1 year ago

Ah, I have found the problem. This one has multiple aspect ratios and so IMDB lists it differently. Needs more code to handle this. Check if other videos work

TwilightMercy commented 1 year ago

multiple aspect ratios that changes during the movie?

osumoclement commented 1 year ago

Yes. If you search title and click on Technical Specs you'll see it has two aspect ratios. And movies like Grand Budapest Hotel have 3 aspect ratios even 🤣

This is a weird situation with these kinds of movies.

  1. For Android workaround method, I don't think there is anything the addon can do because it can't tell when aspect ratio changes. If video has multiple aspect ratios, I will just notify the user that the video has multiple aspect ratios. Maybe then I will change toggle so that it cycles through the aspect ratios? So when user notices aspect has changed, they press a key and it cycles until they find one that fits?

  2. For the other method that analyzes frames, maybe I could make it run every 5 seconds, but who knows how badly this may affect performance

JDRIVO commented 1 year ago

This addon worked on Android last I tried, the code may be of use to you.

https://github.com/milaq/kodi_addon_blackbarsremover/issues/2

osumoclement commented 1 year ago

Thank you, will have a look

TwilightMercy commented 1 year ago

Yes. If you search title and click on Technical Specs you'll see it has two aspect ratios. And movies like Grand Budapest Hotel have 3 aspect ratios even 🤣

I see. that's really complicating the situation.


As general way to handle this for both methods (Android workaround + normal method) I suggest:

When video playback starts, pop up notification to notify for multiple aspect ratios. Example:

For this movie - https://www.imdb.com/title/tt10954600/technical/?ref_=tt_spec_sm

"Current playing media has X aspect ratios: (maybe print it exactly from IMDb website:)" image

(If too long for side notification - maybe pop up a window with all information, then user press OK to close it)

And then change the "toggle" (mapped to keybind, or in my build case - as button in skin player) - to support toggling between aspects ratios if more than 1 is available. Example for toggle statuses: OFF, ON (Aspect ratio 1), ON (Aspect Ratio 2), OFF, etc...

And for each toggle notify for the current aspect ratio used.


  1. For Android workaround method, I don't think there is anything the addon can do because it can't tell when aspect ratio changes. If video has multiple aspect ratios, I will just notify the user that the video has multiple aspect ratios. Maybe then I will change toggle so that it cycles through the aspect ratios? So when user notices aspect has changed, they press a key and it cycles until they find one that fits?

For android workaround - the method I suggested above ("toggle" functions toggle between OFF status and different aspect ratios)


  1. For the other method that analyzes frames, maybe I could make it run every 5 seconds, but who knows how badly this may affect performance

For normal method - one option is to toggle manually between aspect ratios like written above,

Or option two like you said is to analyze frames each X seconds and adjust aspect ratio. (for this case - toggle function should toggle only between OFF and ON, since the aspect ratio is changed automatically.)

In terms of performance - from what I experienced it changes the aspect ratio based on the screenshot pretty fast, but maybe start with every 30 seconds?

I can test the behavior for PC or Android TV devices with movies with multiple aspect ratios.


About IMDb ID:

I'm 100% sure it should be no problem to get IMDb ID from playback, many of the common addons send them.