wez / atomicparsley

AtomicParsley is a lightweight command line program for reading, parsing and setting metadata into MPEG-4 files, in particular, iTunes-style metadata.
https://github.com/wez/atomicparsley
GNU General Public License v2.0
576 stars 70 forks source link

mp4 file with extra tags results in incorrect output from AtomicParsley #65

Open ghjimmy opened 1 year ago

ghjimmy commented 1 year ago

Looks like if a non standard tag is added by, for example, ffmpeg, AtomicParsley reports on all of the tokes, but called them the empty string. If the example below I've removed the extraneous ffprobe output:

$ AtomicParsley file.mp4 -t
Atom "©nam" contains: Title
Atom "©too" contains: Lavf58.20.100
Atom "©cmt" contains: Comment
Atom "©day" contains: 2023
Atom "desc" contains: Description
$ ffprobe -i file.mp4 -print_format json -show_format
 < deleted >
    "format": {
        "filename": "file.mp4",
        "nb_streams": 2,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "2100.235000",
        "size": "362797503",
        "bit_rate": "1381931",
        "probe_score": 100,
        "tags": {
            "major_brand": "isom",
            "minor_version": "512",
            "compatible_brands": "isomiso2avc1mp41",
            "creation_time": "2023-04-03T03:06:47.000000Z",
            "title": "Title",
            "encoder": "Lavf58.20.100",
            "comment": "Comment",
            "date": "2023",
            "description": "Description"
        }
    }

Now add an extra tag to the file and re-run AtomicParsley and ffprobe again

$ ffmpeg -i file.mp4 -movflags use_metadata_tags -metadata newTag="newTag" -c copy file2.mp4 >/dev/null 2>&1
$ AtomicParsley file2.mp4 -t
Atom "" contains: isom
Atom "" contains: 512
Atom "" contains: isomiso2avc1mp41
Atom "" contains: Description
Atom "" contains: Title
Atom "" contains: newTag
Atom "" contains: Comment
Atom "" contains: 2023
Atom "" contains: Lavf59.27.100
$ ffprobe -i file2.mp4 -print_format json -show_format
 < deleted >
    "format": {
        "filename": "file2.mp4",
        "nb_streams": 2,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "2100.199000",
        "size": "362797671",
        "bit_rate": "1381955",
        "probe_score": 100,
        "tags": {
            "minor_version": "512",
            "major_brand": "isom",
            "compatible_brands": "isomiso2avc1mp41",
            "description": "Description",
            "title": "Title",
            "newTag": "newTag",
            "comment": "Comment",
            "date": "2023",
            "encoder": "Lavf59.27.100"
        }
    }
github-actions[bot] commented 1 year ago

Thanks for filing an issue! Please note that this project is only passively maintained, so your best bet for getting an issue resolved is through a pull request that is easy to verify! Please read this for more information.

howyallare commented 1 year ago

This is a known incompatibility. As an alternative, you can use AtomicParsley to added custom tags using --rDNSatom. However, you'll need to build AP with the fix in PR #63, which fixes a problem in parsing .--rDNSatom values. The PR is a bit messy because the submitter didn't squash commits, but the end result appears to to work.

ghjimmy commented 1 year ago

The issue is a 3rd party program (Topaz Video AI) adding these tags via ffmpeg, and then making the file incompatible for AtomicParsley. Currently, I make a "best guess" at what the tags are from parsing ffprobe and re-add the compatible ones with "AtomicParsley --metaEnema --artwork REMOVE_ALL" but I was hoping there was a workaround in AtomicParsley to parse them correct. I'll look at the PR you mentioned to preserve the extra tags when I write them in a more compatible format. Currently, I just write them as extended attributes to the file itself, just so I can preserve them.

howyallare commented 1 year ago

The use of -movflags use_metadata_tags triggers ffmpeg to write the tags in a form that is unreadable for Windows Explorer, Mp3Tag, Kid3, AtomicParsley and other applications, so no shortcut that I could see. Also, there are some differences in how applications handle reverse DNS tags with multiple values, so some care is required if you're writing tags in different applications.