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

Support Video Files That Contain Embedded Artwork #948

Merged

Conversation

complexlogic
Copy link
Contributor

For some file formats (notably MP4), FFmpeg uses an AVStream structure to logically represent embedded cover art. USDX's current video stream selection logic always selects the first video stream reported by FFmpeg. If the first video stream is cover art, USDX will fail to play the video. See #902.

FFmpeg sets a flag AV_DISPOSITION_ATTACHED_PIC to indicate that an AVStream object represents cover art. This PR updates the stream selection logic to reject video streams that have the flag set. This ensures that an actual video stream will be selected for files that contain embedded cover art.

Fixes #902

Copy link
Member

@barbeque-squared barbeque-squared left a comment

Choose a reason for hiding this comment

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

Test code courtesy of @complexlogic

import mutagen.mp4
import sys

byte_array = None
with open(sys.argv[2], "rb") as f:
    byte_array = f.read()

file = mutagen.mp4.MP4(sys.argv[1])
file['covr'] = [mutagen.mp4.MP4Cover(byte_array, imageformat=mutagen.mp4.MP4Cover.FORMAT_JPEG)]
file.save()

first param = mp4, second = some jpeg

The code looks fine and I verified that it fixes the problem

@barbeque-squared barbeque-squared merged commit 6470caf into UltraStar-Deluxe:master Jan 21, 2025
5 checks passed
@complexlogic complexlogic deleted the embedded_art_fix branch January 21, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TMediaCore_FFmpeg.FindStreamIDs() fails to find video stream if artwork is embedded as stream 0
2 participants