Rafostar / clapper

Level up your video experience with a modern and user-friendly media player.
https://rafostar.github.io/clapper/
GNU General Public License v3.0
794 stars 37 forks source link

Allow applications to add a custom/fallback title #500

Closed d-k-bo closed 4 weeks ago

d-k-bo commented 1 month ago

I'm currently working on adding an integrated video player to Televido using libclapper(-gtk). First of all, thank your for your great work making this possible!

Unfortunately, most of the media that is available via Televido doesn't provide a title tag. This means that ClapperGtk.Titlelabel can't be used to show a reasonable title and MPRIS just displays “Unknown Title”.

As the video title is known from external data, it would be nice if Clapper.MediaItem:title was writable or if there was a different property to provide a fallback title if the media doesn't contain a title tag.

Rafostar commented 1 month ago

I'm currently working on adding an integrated video player to https://github.com/d-k-bo/televido/pull/20 using libclapper(-gtk).

Hi, thanks for checking out the Clapper project! :smile:

As the video title is known from external data

Applications that "know" the title should use taginject element. Just create it from GStreamer element factory, fill its tags property, then set it as Clapper player video-filter before playing.

This way both ClapperGtk.TitleLabel and MPRIS should display the title you want. You have to set scope to be "global" as this is media title and not stream/track title, so this will require GStreamer 1.24 from you.

provide a fallback title if the media doesn't contain a title tag

In future (taginject) will also handle situations where video has the same tag as the one you injected by setting merge-mode property (from next GStreamer version), so you control which title should be preferred when both are available.

A quick code snippet (python3) for reference:

taginject = Gst.ElementFactory.make('taginject', None)
taginject.props.tags = "title=(string)\"Big Buck Bunny\""
taginject.props.scope = Gst.TagScope.GLOBAL

video.props.player.props.video_filter = taginject

This functionality description is something probably worth adding to the Clapper API documentation :sweat_smile:

d-k-bo commented 4 weeks ago

Wow, thank you, that works flawlessly! I'm impressed that this can be solves in 4 lines of code (well, it translates to 13 lines in my case, but most of it is boilerplate).

I wasn't aware that you could inject GStreamer elements using Clapper.Player:video-filter, especially since forgot that this is considered a “filter” in the GStreamer terminology.