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

Add more JPEG image headers #56

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AlexGuo1998
Copy link

When adding cover arts with mp4art --add cover.jpg music.mp4, some JPEG images get added as implicit type:

$ file cover.jpg
cover.jpg: JPEG image data, baseline, precision 8, 400x300, components 3

$ mp4art --add cover.jpg music.mp4
adding cover.jpg -> music.mp4

$ mp4art --list music.mp4
IDX     BYTES  CRC32     TYPE       FILE
----------------------------------------------------------------------
  0     76020  4a9ed6db  implicit   music.mp4

in type.cpp:

mp4v2/src/itmf/type.cpp

Lines 283 to 290 in 4fc9463

static ImageHeader IMAGE_HEADERS[] = {
{ BT_BMP, "\x42\x4d" },
{ BT_GIF, "GIF87a" },
{ BT_GIF, "GIF89a" },
{ BT_JPEG, "\xff\xd8\xff\xe0" },
{ BT_PNG, "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a" },
{ BT_UNDEFINED } // must be last
};

According to https://en.wikipedia.org/wiki/List_of_file_signatures, "\xff\xd8\xff\xe0" can only detect JPEG in JFIF formats.
This commit added support for detecting raw JPEG and JPEG in Exif, so when adding arts, they won't get BasicType undetected.

Original image header `"\xff\xd8\xff\xe0"` can only detect JPEG in JFIF formats.
This commit added support for detecting raw JPEG and JPEG in Exif, so when adding arts, they won't get `BasicType` undetected.
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.

1 participant