-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Validator] Add Video constraint for validating video files
#59042
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
Conversation
5c003e6 to
4e1502a
Compare
Video constraint for validating video files
src/Symfony/Component/Validator/Tests/Constraints/VideoValidatorTest.php
Outdated
Show resolved
Hide resolved
|
Looks like a PR should be contributed upstream to fix this: Can you submit it? |
dbca1fd to
19518bc
Compare
@nicolas-grekas PR created in the |
src/Symfony/Component/Validator/Tests/Constraints/VideoValidatorTest.php
Outdated
Show resolved
Hide resolved
df0ce8c to
cf56118
Compare
|
I have done this a long time ago. Just why use classes instead of ffprobe directly? $json = shell_exec('ffprobe -hide_banner -loglevel quiet -show_error -show_format -show_streams -print_format json '.$value);
if (!$json) {
throw new LogicException('This validator requires ffprobe installed and enabled in the PATH system variable.');
} |
Tell me you are not promoter of this useless ffmpeg wrapper. |
|
@mindaugasvcs please express yourself in a more friendly manner. You might be right that the wrapper is not needed, but calling the wrapper "useless" or suggesting bad intentions as a hidden "promoter" is detrimental to having a constructive discussion. Open source requires respectful discussions. |
|
@mindaugasvcs I agree that using ffmpeg is not fantastic, I am totally open for better suggestions and good intentions ;) |
First of all, you should not have accepted this PR in the first place as we now both agree the wrapper is not needed. I believe this PR should not be a part of the framework. I asked you long time before about such validator, you gave me no answer back then. And now? WTF?! May I ask to explain yourself? |
|
@mindaugasvcs Let's keep the discussion constructive. If you raised this idea earlier, I understand your frustration. That said, decisions in open source evolve based on contributions. Discussions are only a first step. Here, we have a patch, and that's how things happen. If you have strong technical reasons why this validator should not be part of the framework, let's focus on those. Do you see specific downsides beyond just the existence of the wrapper? |
Reasons why including such a basic video validator is bad idea:
Reasons why this wrapper is bad as implementation of such idea:
|
Spomky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor remarks. Overall it looks good.
|
? |
8398f3c to
5a2ee0a
Compare
7eded7f to
97dfcf8
Compare
nicolas-grekas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the PR to remove any dependency on external libs.
I also added checks to reject videos with several streams and checks for the video codec + container format.
|
Is Symfony framework still community project? |
|
What does this mean @mindaugasvcs ? |
@nicolas-grekas thank you so much for taking over on this PR, so much appreciated, I was very busy sorry. And yes Symfony is the best community project ❤️ |
GromNaN
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just looking at the code, it's clear that this is a complex subject. Glad you created this validator with excellent test coverage.
src/Symfony/Component/Validator/Tests/Constraints/VideoValidatorTest.php
Outdated
Show resolved
Hide resolved
97dfcf8 to
6627071
Compare
|
Thank you @symfonyaml. |
…(nicolas-grekas) This PR was merged into the 6.4 branch. Discussion ---------- [Validator] Update translation for the Video constraint | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Add translations for messages added to #59042 + a few other missing ones. Commits ------- 59b201d [Validator] Update translation for the Video constraint
How many community members were involved in decision making of this PR? And why that downvote? It kind of shows that asking questions around here just isn’t welcome. So yea, the question is more than valid. |
| $streams = $meta['streams'] ?? []; | ||
| $formats = explode(',', strtolower($meta['format']['format_name'] ?? 'unknown')); | ||
|
|
||
| if (!($streams[0]['width'] ?? false) || !($streams[0]['height'] ?? false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huge error here, $streams[0] is allowed to not be the default video stream, you must check the default flag at $stream['disposition']['default'] or calcule it yourself if its not present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, if you found a bug and know the fix, could you please open a PR targeting the oldest maintained branch that has this bug (7.4), with the fix and a non-regression test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you read this conversation from the beginning, you could see that I did mention that video files may contain multiple video streams and that I don't support including such a basic and buggy validator into Symfony. The first stream may not be always the default stream. No body care what I say or write. Now I let the original author to fix his own mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you read the code below, you'll see that we reject videos that have multiple streams.
This means we don't have to care about the default stream.
No bug here.
I appreciate that you care about us providing a video validator that makes sense. But I don't think the rage that your messages express is deserved. Both on your side - it must be stressful to have so much energy to yell at others - and for the others, which don't have to be the recipient of your anger.
Please keep a respectful tone.
Purpose
Inspired by the Image constraint, I've added a new feature to the Validator component for validating Video files using the PHP-FFMpeg library.
This constraint use exactly the same concept as the Image one, with the same options except for the corrupted options (detectcorrupted, corruptedmessage)
I think we can definitely apply more options for video files, but first I just want to check if everyone is okay with this constraint.
Example