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
Audio with cover art should be opened as audio instead of video #687
base: master
Are you sure you want to change the base?
Audio with cover art should be opened as audio instead of video #687
Conversation
Thank you for preparing this fix. However, I still think this might be a breaking change. @alexander-schranz how would you like to proceed here? File a new major version or don't you think it is a breaking change? |
foreach ($streams->videos() as $videoStream) { | ||
$videoDisposition = $videoStream->get('disposition'); | ||
if ($videoDisposition['attached_pic'] !== 1) { | ||
$hasVideo = true; |
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.
minor nit: You can add a break;
after this to not iterate unnecessarily.
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.
thanks. done. vibhavsinha@7b57207
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.
There is a missing closing brace in this fix. It opens 3 and only closes 2
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.
The code has been changed since the last comment here. I am sure it is balanced now. The reason for opening 3 and closing 2 is because the subtracted chunk also had one opening bracket. Hence, the added chunk should also have one extra opening brace.
src/FFMpeg/FFMpeg.php
Outdated
$hasVideo = false; | ||
foreach ($streams->videos() as $videoStream) { | ||
$videoDisposition = $videoStream->get('disposition'); | ||
if ($videoDisposition['attached_pic'] !== 1) { |
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 find this a little bit strange, should we not use instead a mime_type check on pathfile to check if its a video or audio file. I could think that there are videos without a attached_pic disposition so I would not depend on that.
Also it feels for me the false position to fix it as $streams->videos() should not return none video file atleast I would not expect that.
@romainneutron do you remember why this was done before over count($streams->videos())
instead of checking for mimetype?
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 it is possible to reply for @romainneutron yet due to the current circumstances, I'd be happy to bring this a little bit forward. :)
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.
@alexander-schranz It is a valid idea to use the mime_type for identifying the audio and video formats. But I can guess why it might not have been chosen for this project.
There are way too many formats for audio and video both. And I am sure there are some which can be used to hold only one stream of either type. Keeping a list of mime types will limit us to a subset of formats supported, and it will be different from ffmpeg behavior.
AFAIK ffmpeg does not differentiate between audio and video files. It only uses the mime_type to parse the container structure. After parsing container, it works only with stream information.
7b57207
to
b2b867f
Compare
|
I would appreciate this fix as well. |
What's in this PR?
$ffmpeg->open()
method to sendVideo
if and only if at least one video stream is not marked asattatched_pic
.Why?
Fixes #323
FFMmpeg::open() has 'media type' bug with MP3s (image metadata)
Fffmpeg source uses this function to detect if a video stream is actually a valid video stream or just a cover art.
https://github.com/FFmpeg/FFmpeg/blob/release/4.2/libavformat/movenc.c#L149-L154
I did not use the patch in #402 (comment) because the
codec_type
can be eitherpng
orjpeg
. If thecodec_type
isjpeg
, that stream can be either a cover art or just aMotionJPEG
video stream. Hence, it was not the right way to detect this.BC Breaks/Deprecations
No.
There is a small chance that some code depends on this behavior to detect audio with cover images.
To Do