-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Format filter: Rotation-independent measurements longside
and shortside
to help with portrait video
#30737
Comments
|
That would be a better work-around for YouTube, thanks for the idea! Still, rather than use a single-usecase special workaround, I'd prefer to express my actual intent, so it will work for other websites as well. |
We seem to have different ideas about what to strive for in user interface design. At first I wondered why such a simple addition warrants that much resistance. So I tried to make my own patch and share it here, for the benefit of all who value good UID. Then I found the parts of code where to add it. I see now. Maybe some time in the future someone will have enough time to refactor it so it will be easy to maintain, so the patch I intended to offer would have a better chance of being applicable to future versions as well. In current master (6508688) it seems to be I might even do the refactor, but I fear my effort will be met with the same attitude. My refactor would be aimed at:
|
Once we can agree on structuring the code base in a way that makes additions like this one trivial, we should also consider how we can extend this easy-to-maintain extensibility to documentation. Documentation for my suggested criteria would have to affect at least part of the "FORMAT SELECTION" in In an ideal world, my patch could deliver code and docs in close proximity, to increase chances that both will be kept in sync and the patch for both will be compatoble even with far-distant versions. |
I'll save us the effort of discussing whether the addition would be valid even in absence of more examples. If you like my refactor idea anyway, I might still invest the effort, just so I can provide my own patch for those who see the holy light. |
At least in my own projects, I strive to make it easy for others (and future me) to extend and reuse my code, independent of whether I understand or approve a particular usecase at the time. In my experience, my attempt to make my code easy to maintain (e.g. git friendly and having code locations easy to describe and locate accross versions) often helped make my own new patches trivial to apply even if a branch had been stale on a side track for years. |
Imagine there could be, in the future, any derived numeric criterion that future-you might agree would be a good idea to support. (Maybe aspect ratio?)
Thus, the best patch I can currently come up with that would work without said refactoring, would be this one. In an ideal world, my patch would instead have been 2 lines of python formulas and two lines of documentation about those formulas. |
longside
and shortside
longside
and shortside
to help with portrait video
Oh. Maybe we had a big misunderstanding. Is your point about more examples of portrait videos on YouTube? Or do you need proof that nowadays it's a commonplace phenomenon accross several video platforms? I had considered the latter universal knowledge. |
I see. I did not intend to force devs to hunt for example URLs. I had imagined that we have some code module that calculates derived criteria based on extractor results. Such a module can first be tested with example data from existing real video tests, then tested with invented data or modified versions of the previous tests' input data, in this case, with swapped height/width. In case of this feature request here, the latter approach would not require additional URLs and would thus be robust against breakage of those URLs. |
I provided them here, earlier:
At least for YouTube, I can provide some more already:
Would you like even more YouTube examples? |
Could you elaborate what features the potential new examples should have that these don't? Do you mean I should provide combinations of video URLs where a single qualityLabel would not fit all of them? Remember I explained above how this feature could be tested independent of any real, and thus potentially-breaking, URL examples. I might still continue to play the bureaucracy game as long as it leads to useful results, e.g. in the previous case, a tool to find vertical videos on YouTube. Someone might someday use it for something actually productive. One problem with qualityLabels is that it doesn't convey the actual intent. Configuration that forces users to write stuff far from what they actually meant, is a common source of latent bugs. |
Thank you for the clarification. Now that I know what kind of examples you're looking for, I can search for them. Do we have documentation on how to use qualityLabel? I tried to guess the correct invocation, but both I don't currently have a way to search for tiny portrait videos on YouTube, but I'm willing to construct pathological cases using Twitter videos. Once I know how your qualityLabel idea is meant to be used, I can probably try it on this and this video.
My current patch is not intended for merge into the main project. It obvously lacks tests, and I had to use bad coding style to make it change as few lines as possible.
Then we had a misunderstanding. My current aim here is twofold:
|
You seem to have missed the condition at the start of my sentence with the twitter links: "Once I know […]" Use case: Download the videos…
With my requested feature, the required options in the config file would be:
And the command would be:
Using my patch (still not meant to be merged because it's a bad solution), this exact command downloaded 7 videos. Whether a solution with qualityLabel could work similarly easily, we'll probably only find out once it's implemented in the format selector. In an ideal world, adding the qualityLabel criterion would have been a one-line addition to the format selector code. (Plus one line of documentation.) In that ideal world, I'd probably even have done added it, just to see if it will work with the Twitter links. |
Since all the posts with objections seem to have magically vanished, I guess I can re-open the issue. |
I can see how these could be useful, more than a portrait/landscape flag. See PR #30742. |
Thank you. Let's hope someone will submit a clean and elegant implementation. |
Not trying to argue against addition of these fields, but you could just do:
|
@pukkandan Thank you for your suggestion. Indeed my first local stopgap, before I made the above patch, was a script that took the meaningful expression and calculated all the combinatorial explosion required. This combinatorial explosion is the reason why in my later use case I added the criterion "in such a way that maintaining the config is easy for the user." |
I'm trying to write tests for this feature, so we can evaluate potential implementations. In my current attempt, to learn how to use our test environment, I started with adding trivial tests that current master should easily pass, using just height and width as size criteria. However,
|
You are not letting youtube-dl sort the formats. See youtube-dl/test/test_YoutubeDL.py Lines 59 to 64 in 6508688
|
@pukkandan Indeed, that fixed it. Thanks you! |
The sorting caues really strange behavior. It seems like it would sort strictly by height, rather than by area size / total pixel count. |
All formats of a video should have same aspect ratio, so that is fine. Unless an extractor indicates otherwise, the sorting is done based on these criteria (in order): youtube-dl/youtube_dl/extractor/common.py Lines 1428 to 1445 in 6508688
|
Before yt-dlp (more specifically #25959), I used to have a script to generate The "combinatorial explosion required" is a fundamental flaw with youtube-dl's format filtering options. Adding new fields will only solve your very specific issue (and only partially?), while others still have to resort to gigantic format strings (#26735, #26444 etc) btw, instead of in youtube-dl/youtube_dl/YoutubeDL.py Lines 1612 to 1633 in 6508688
|
So my intuition was right.
With "should have", do you mean that all currently supported extractors can never return results with mixed aspect ratio? In my world, the purpose of the tests is to detect bugs early. Ideally, before they clash with a harsh reality. (In this case, it would be when a video provider starts adding cut-off square video.) Shouldn't we take this opportunity to make it prefer higher total pixel count? |
@mk-pmb Next time Steven Penny bothers you, just block him. Though if you choose to reply to him anyway, you may want to quote him in full, in case he deletes his own comments later. He does that a lot. (I am not sure why @dirkf chooses to tolerate this missing stair instead of banning him from the repo, but whatever, it’s not my decision to make.) For posterity (extracted from the GitHub API: <https://api.github.com/users/89z/events>)@89z at 2022-03-13T01:29:44Z:
@89z at 2022-03-13T15:34:48Z:
@89z at 2022-03-13T15:46:22Z:
@89z at 2022-03-13T16:43:59Z:
@89z at 2022-03-13T16:55:06Z:
@89z at 2022-03-13T17:34:27Z:
@89z at 2022-03-13T18:42:00Z:
@89z at 2022-03-13T18:50:31Z:
@89z at 2022-03-13T19:01:09Z:
@89z at 2022-03-13T22:04:31Z:
@89z at 2022-03-13T22:44:57Z:
@89z at 2022-03-13T23:36:55Z:
|
Despite the ephemeral posting, his contributions are sometimes worthwhile. Who can say what prompted the tendentious tirade above? |
@fstirlitz
They seemed to see both proposals as different and competing against each other for scarce developer time. Thus it makes sense that the posts disappeared exactly after I pointed out that the road to implementing both features is mostly the same. |
Checklist
Description
I used to filter formats by height, but more and more often, this trips up due to portrait video (height > width).
Rather than making complicated rules about combinations of height and width, I'd like to have rotation-independent measurements
longside
(=max(w,h)
) andshortside
(=min(w,h)
) available for my format filter.Patch
Available, albeit far from ideal, see discussion below.
The text was updated successfully, but these errors were encountered: