Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/FFMpeg/FFMpeg.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,15 @@ public function open($pathfile)
throw new RuntimeException(sprintf('Unable to probe "%s".', $pathfile));
}

if (0 < count($streams->videos())) {
$hasVideo = false;
foreach ($streams->videos() as $videoStream) {
$videoDisposition = $videoStream->get('disposition');
if (!$videoDisposition || $videoDisposition['attached_pic'] !== 1) {
$hasVideo = true;
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. done. vibhavsinha@7b57207

Copy link

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

Copy link
Author

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.

break;
}
}
if ($hasVideo) {
return new Video($pathfile, $this->driver, $this->ffprobe);
} elseif (0 < count($streams->audios())) {
return new Audio($pathfile, $this->driver, $this->ffprobe);
Expand Down