MediaInfoLib icon indicating copy to clipboard operation
MediaInfoLib copied to clipboard

MXF identified as MPEG2-PS when using JS/WASM sample

Open vectronic opened this issue 5 years ago • 2 comments

I have an MXF file which is incorrectly being parsed as an MPEG2-PS file (output results attached) when uploading at:

https://mediaarea.net/MediaInfoOnline

The problem file is correctly identified using the MediaInfo CLI. (output results attached)

I have also attached the mediatrace for the working scenario. I cannot get some code to work which uses the buffer method AND also outputs mediatrace. If I could have, I expect that would have been useful.

The sample file is quite large and also confidential, I can provide access to it if you need in a less public message.

What I have worked out is the following:

  • when opening via the CLI, the MXF file parser is selected based on the ".mxf" extension, and parsing proceeds as expected.
  • when opening via browser or buffers, the multiple file parsing logic is used to select a parser. The MPEG2-PS parser is tried before the MXF parser. It is accepted for this MXF, but not any others. If I disable the MPEG2-PS parser then the MXF parser is selected and parsing proceeds as normal.

What I haven't been able to identify is where or why in the code base, the MPEG2-PS parser rejects other MXF files, but accepts this one?!

As I said, this is reproducible using the installed CLI and the online service, however I was also using the following hacked example app where I ran the same file through the file based and buffer based interfaces and got the different format identification results:

int main(int argc, char* argv_ansi[])
{
    MediaInfo MI;
    MI.Open(__T("problem1.mxf"));
    STRINGOUT(MI.Get(Stream_General, 0, __T("Format")));

    FILE* F = fopen("problem1.mxf", "rb");

    unsigned char* From_Buffer = new unsigned char[10 * 1024 * 1024];
    size_t From_Buffer_Size;

    fseek(F, 0, SEEK_END);
    long F_Size = ftell(F);
    fseek(F, 0, SEEK_SET);

    MI.Open_Buffer_Init(F_Size, 0);
    do {
        From_Buffer_Size = fread(From_Buffer, 1, 10 * 1024 * 1024, F);
        size_t Status = MI.Open_Buffer_Continue(From_Buffer, From_Buffer_Size);
        if (Status & 0x08) {
            break;
        }
        if (MI.Open_Buffer_Continue_GoTo_Get()!=(MediaInfo_int64u)-1) {
            fseek(F, (long)MI.Open_Buffer_Continue_GoTo_Get(), SEEK_SET);
            MI.Open_Buffer_Init(F_Size, ftell(F));
        }
    }
    while (From_Buffer_Size > 0);
    MI.Open_Buffer_Finalize();
    STRINGOUT(MI.Get(Stream_General, 0, __T("Format")));
}

correct-result.txt incorrect-result.txt cli-working-mediatrace.txt

vectronic avatar Jul 03 '20 22:07 vectronic

@JeromeMartinez sorry to ping, but wondering if you had a chance to read this issue and if you have any ideas? I am happy to dig further and help with a fix, but I would need a bit of direction in where to look.

Thanks Nick

vectronic avatar Jul 10 '20 15:07 vectronic

Didn't take the time yet to dig in it (I have some stuff to finish for sponsors first) but in my todo-list.

JeromeMartinez avatar Jul 10 '20 15:07 JeromeMartinez