woodruffw / ff2mpv

A Firefox/Chrome add-on for playing URLs in mpv.

Home Page:https://addons.mozilla.org/en-US/firefox/addon/ff2mpv/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Define and select stream quality

JoseHidalgo opened this issue · comments

Hi everybody. I use ff2mpv every day, on both Firefox and Brave, and I'm REALLY HAPPY with it. So thank you for that!

Here's a feature that I'd really like: to be able to define and select the stream quality (at least for YouTube videos).

I'm talking about these parameters:

  • Video resolution (e.g. 1080p)
  • Frames per second (e.g. 60)
  • Video codec (e.g. H264, VP9)
  • Audio codec (e.g. AAC)
  • Audio bitrate (e.g. 128 Kbps)

Here's an example of a random YouTube video with all available stream qualities:

2023 08 30 - 01 44 09

This feature would work as follows:

  1. The extension preferences page would allow the user to define a "default stream quality" with all its parameters.

  2. Right-click on the ff2mpv icon would display a context menu with all available streams (like the previous pic).
    Left-click on any available stream would start the streaming.
    This would only be useful when looking for a stream quality that differs from the default.

Example 1:

  • I go to ff2mpV preferences page
  • I define a "Default stream quality" as follows:
    => Video resolution: 1080p
    => Frames per second: 60
    => Video codec: H264
    => Audio codec: Not defined => I don't care
    => Audio bitrate: Not defined => I don't care
  • Then left-clicking on ff2mpv's button starts the streaming with the defined default stream quality

Example 2:

  • Now for a particular video I want to change the stream quality (only for that particular video)
  • So I just right-click on ff2mpv's button. The context menu appears with all available qualities for the video in the active tab.
  • I left-click on any of the available context menu lines, and the streaming starts with that stream quality
  • But the default stream quality remains as previously defined for all future videos

I hope I've been clear enough. Feel free to ask if that's not the case. Cheers guys! :)

Thank you for the kind words! I'm happy to hear that you've found the extension useful.

For some context, there have been some related issues raised before:

Behaviorally, your proposal sounds fine to me, and it seems like there's some demand from other users.

That being said, I think there are a few technical hurdles that need to be overcome:

  1. How is ff2mpv going to get the list of supported qualities/formats/etc. for a given URL? Is it going to "probe" that URL first via yt-dlp --list-formats (or similar) and then parse that? Or is the idea that there would be a fixed list of "common" formats, with the hope that most URLs would fall into one?
    • Note that doing the "probe" would involve both a native message round-trip and a network round trip, so it could be quite slow -- probably too slow to do in a context menu, but maybe something that could be done asynchronously in a preferences page.
  2. How is the extension going to model "don't care" preferences? I can see this very quickly becoming a search space/constraint solving problem, with possible surprising results for users (e.g. selecting a default stream that yt-dlp itself wouldn't select).

I'd be curious to hear ideas for solving these, especially the first -- I've thought about that one a bit and wasn't able to come up with something that keeps ff2mpv relatively small and lightweight.

OK, here are some thoughts, good or bad:

A list of "common" formats would be enough for me personally. So if that seems easier to achieve, I could settle for that. But I believe a lot of people have specific needs, so what's "common" for somebody may not apply to somebody else.

Probing and parsing seems like the most complete solution (also possibly the most complicated). That's what some other apps do. For instance JDownloader2 from where my screen cap comes (I used it before ff2mpv, to download videos and play them locally - those same videos are unplayable in my browser because my current rig is too old... hence ff2mpv ! ;) ).

The probing/parsing process can be a bit slow (not too slow either - JDownloader2 takes only a couple seconds). But would it be technically possible to start the process in the background, at least for YouTube, as soon as the active tab contains a YouTube URL? That would be enough in most cases, because it often takes a couple of seconds for the user to right-click on the icon anyway. So yes, definitely asynchronous, but not necessarily in a preferences page.

About the "Not defined" (the "I don't care" was just a personal comment ^^), to me it means "if there are several choices for that parameter, pick the best one".

Anyway, thanks for taking this into consideration. I believe it will make ff2mpv even better. :)

A list of "common" formats would be enough for me personally. So if that seems easier to achieve, I could settle for that. But I believe a lot of people have specific needs, so what's "common" for somebody may not apply to somebody else.

Yeah, this is a problem: I think (without evidence) that 99% of people are using this extension primarily to watch videos on YouTube, so a set of hardcoded "common" formats would be fine for them. However, I don't actually know that it's 99%, and I don't want to harm even 1% by giving them weird format errors due to mismatches on other sites.

I think "probe-and-parse" is probably the right solution here, but "only a couple of seconds" is unfortunately probably way too slow for a browser extension: whatever we do here needs to be responsive within a context menu. Maybe there's some way we could pre-cache these.

commented

You can specify the formats and other parameters in mpv's config.

Yes. We've also merged #108, which will (when released) offer the ability to select different "profiles" directly from the extension. So I'm closing this.