mediainfo.js icon indicating copy to clipboard operation
mediainfo.js copied to clipboard

some mp4 file parsed error!

Open vaseala opened this issue 1 year ago • 8 comments

Checklist

  • [Y] I have searched the issue tracker for any duplicate issues and confirmed that this bug has not been reported before.
  • [Y ] I have tested the issue with the upstream project MediaInfo and can confirm that the problem only exists in mediainfo.js.
  • [ Y] I have attached all necessary test files, if applicable, so that the issue can be easily reproduced by the developers.
  • [ ] I have added a reproduction repository or a code sandbox that clearly illustrates the issue. Providing a minimal example will greatly help the developers in understanding and resolving the problem.

Bug Description

Steps to Reproduce

My code looks like the following:

import MediainfoJs, { FormatType } from 'mediainfo.js';

async function parseRaw(media_path: string) {
  const total = (await stat(media_path)).size;
  const mediainfo = await MediainfoJs({ format: 'JSON' as FormatType });

  const getBuffer = async (chunkSize: number, offset: number) => {
    const buffers = [] as Buffer[];
    // const {  from, to } = item;
    const to = chunkSize + offset - 1;
    const stream = createReadStream(media_path, { start: offset, end: to });
    for await (const data of stream) {
      buffers.push(data);
    }
    stream.close();
    return Buffer.concat(buffers);
  };

  const data = await mediainfo.analyzeData(() => total, getBuffer);
  console.log('data: ', typeof data);    // string
  console.log('json string:  \n\n\n\n');

  console.log(data);

  console.log(' \n\n\n\n');

  try {
    const rawJson = JSON.parse(data as string);
    return rawJson;
  } catch (err) {
    console.log('err: ', err);
  }
}


These problems only occur in some files. The video file I used for testing is too large to upload. I can send you the video file if needed.

Expected Behavior

Actual Behavior

I got the following Json String, when I parse it to JSON with JSON.parse(), It failed.

{
"creatingLibrary":{"name":"MediaInfoLib","version":"24.06","url":"https://mediaarea.net/MediaInfo"},
"media":{"@ref":"","track":[{"@type":"General","VideoCount":"1",
"AudioCount":"1",
"MenuCount":"1",
"Format":"MPEG-4",
"Format_Profile":"Base Media",
"CodecID":"isom",
"CodecID_Compatible":"isom/iso2/avc1/mp41",
"FileSize":"2229245968",
"Duration":"6761.464",
"OverallBitRate":"2637590",
"FrameRate":"23.976",
"FrameCount":"162113",
"StreamSize":"4582763",
"HeaderSize":"4580707",
"DataSize":"2224665261",
"FooterSize":"0",
"IsStreamable":"Yes",
"Encoded_Application":"Lavf59.33.100"},{"@type":"Video","StreamOrder":"0",
"ID":"1",
"Format":"AVC",
"Format_Profile":"High",
"Format_Level":"4.1",
"Format_Settings_CABAC":"Yes",
"Format_Settings_RefFrames":"4",
"CodecID":"avc1",
"Duration":"6761.464",
"BitRate":"2250000",
"BitRate_Maximum":"31250000",
"Width":"1920",
"Height":"800",
"Sampled_Width":"1920",
"Sampled_Height":"800",
"PixelAspectRatio":"1.000",
"DisplayAspectRatio":"2.400",
"Rotation":"0.000",
"FrameRate_Mode":"CFR",
"FrameRate_Mode_Original":"VFR",
"FrameRate":"23.976",
"FrameRate_Num":"24000",
"FrameRate_Den":"1001",
"FrameCount":"162113",
"ColorSpace":"YUV",
"ChromaSubsampling":"4:2:0",
"BitDepth":"8",
"ScanType":"Progressive",
"StreamSize":"1900113572",
"Encoded_Library":"x264 - core 164 r56 e067ab0",
"Encoded_Library_Name":"x264",
"Encoded_Library_Version":"core 164 r56 e067ab0",
"Encoded_Library_Settings":"cabac=1 / ref=4 / deblock=1:-1:-1 / analyse=0x3:0x133 / me=umh / subme=9 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-3 / threads=24 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=2pass / mbtree=1 / bitrate=2250 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=31250 / vbv_bufsize=31250 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00",
"colour_description_present":"Yes",
"colour_description_present_Source":"Container / Container / Stream",
"colour_range":"Limited",
"colour_range_Source":"Container / Container / Stream",
"colour_primaries":"BT.709",
"colour_primaries_Source":"Container / Container / Stream",
"transfer_characteristics":"BT.709",
"transfer_characteristics_Source":"Container / Container / Stream",
"matrix_coefficients":"BT.709",
"matrix_coefficients_Source":"Container / Container / Stream",
"extra":{"Menus":"0","CodecConfigurationBox":"avcC"}},{"@type":"Audio","StreamOrder":"1",
"ID":"2",
"Format":"AAC",
"Format_AdditionalFeatures":"LC",
"CodecID":"2 / 40 / mp4a-40-2",
"Duration":"6761.440",
"Source_Duration":"6761.483",
"Source_Duration_LastFrame":"-0.011",
"BitRate_Mode":"CBR",
"BitRate":"384000",
"Channels":"6",
"ChannelPositions":"Front: L C R, Side: L R, LFE",
"ChannelLayout":"C L R Ls Rs LFE",
"SamplesPerFrame":"1024",
"SamplingRate":"48000",
"SamplingCount":"324549120",
"FrameRate":"46.875",
"FrameCount":"316943",
"Source_FrameCount":"316945",
"Compression_Mode":"Lossy",
"StreamSize":"324549633",
"Source_StreamSize":"324551681",
"Default":"Yes",
"AlternateGroup":"1",
"extra":{"Menus":"0","Source_Delay":"-43","Source_Delay_Source":"Container"}},{"@type":"Menu","":{}]}]}
}
image image

Environment

  • mediainfo.js version: [0.3.2]
  • Operating System: [macOS Sonoma 14.4.1]
  • Browser (if applicable): []
  • Node.js (if applicable): [v20.12.0]

Additional Information

This problem does not exist in version 0.2.2

vaseala avatar Aug 14 '24 10:08 vaseala

For knowing if it comes from mediainfo.js or MediaInfo library, please test with MediaInfo GUI and say if the JSON has also the same mistake. If so, report in this issue tracker.

JeromeMartinez avatar Aug 14 '24 10:08 JeromeMartinez

For knowing if it comes from mediainfo.js or MediaInfo library, please test with MediaInfo GUI and say if the JSON has also the same mistake. If so, report in this issue tracker.

Test in GUI that the file information can be printed normally image I didn't find how to display the json format, but the text display is normal in the gui。

vaseala avatar Aug 15 '24 00:08 vaseala

Test in GUI that the file information can be printed normally

The text output is not the source of the issue.

I didn't find how to display the json format,

Menu "View", "JSON". Or with the command line version, mediainfo --Output=JSON FileName.ext

JeromeMartinez avatar Aug 15 '24 09:08 JeromeMartinez

Test in GUI that the file information can be printed normally

The text output is not the source of the issue.

I didn't find how to display the json format,

Menu "View", "JSON". Or with the command line version, mediainfo --Output=JSON FileName.ext The json as following:

{
"creatingLibrary":{"name":"MediaInfoLib","version":"24.06","url":"https://mediaarea.net/MediaInfo"},
"media":{"@ref":"/Users/jin/Downloads/Unsung Hero (2024) [1080p] [WEBRip] [5.1] [YTS.MX]/Unsung.Hero.2024.1080p.WEBRip.x264.AAC5.1-[YTS.MX].mp4","track":[{"@type":"General","VideoCount":"1",
"AudioCount":"1",
"MenuCount":"1",
"FileExtension":"mp4",
"Format":"MPEG-4",
"Format_Profile":"Base Media",
"CodecID":"isom",
"CodecID_Compatible":"isom/iso2/avc1/mp41",
"FileSize":"2229245968",
"Duration":"6761.464",
"OverallBitRate":"2637590",
"FrameRate":"23.976",
"FrameCount":"162113",
"StreamSize":"4582763",
"HeaderSize":"4580707",
"DataSize":"2224665261",
"FooterSize":"0",
"IsStreamable":"Yes",
"File_Modified_Date":"2024-06-12 05:08:10 UTC",
"File_Modified_Date_Local":"2024-06-12 13:08:10",
"Encoded_Application":"Lavf59.33.100"},{"@type":"Video","StreamOrder":"0",
"ID":"1",
"Format":"AVC",
"Format_Profile":"High",
"Format_Level":"4.1",
"Format_Settings_CABAC":"Yes",
"Format_Settings_RefFrames":"4",
"CodecID":"avc1",
"Duration":"6761.464",
"BitRate":"2250000",
"BitRate_Maximum":"31250000",
"Width":"1920",
"Height":"800",
"Sampled_Width":"1920",
"Sampled_Height":"800",
"PixelAspectRatio":"1.000",
"DisplayAspectRatio":"2.400",
"Rotation":"0.000",
"FrameRate_Mode":"CFR",
"FrameRate_Mode_Original":"VFR",
"FrameRate":"23.976",
"FrameRate_Num":"24000",
"FrameRate_Den":"1001",
"FrameCount":"162113",
"ColorSpace":"YUV",
"ChromaSubsampling":"4:2:0",
"BitDepth":"8",
"ScanType":"Progressive",
"StreamSize":"1900113572",
"Encoded_Library":"x264 - core 164 r56 e067ab0",
"Encoded_Library_Name":"x264",
"Encoded_Library_Version":"core 164 r56 e067ab0",
"Encoded_Library_Settings":"cabac=1 / ref=4 / deblock=1:-1:-1 / analyse=0x3:0x133 / me=umh / subme=9 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-3 / threads=24 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=2pass / mbtree=1 / bitrate=2250 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=31250 / vbv_bufsize=31250 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00",
"colour_description_present":"Yes",
"colour_description_present_Source":"Container / Stream",
"colour_range":"Limited",
"colour_range_Source":"Container / Stream",
"colour_primaries":"BT.709",
"colour_primaries_Source":"Container / Stream",
"transfer_characteristics":"BT.709",
"transfer_characteristics_Source":"Container / Stream",
"matrix_coefficients":"BT.709",
"matrix_coefficients_Source":"Container / Stream",
"extra":{"Menus":"0","CodecConfigurationBox":"avcC"}},{"@type":"Audio","StreamOrder":"1",
"ID":"2",
"Format":"AAC",
"Format_AdditionalFeatures":"LC",
"CodecID":"mp4a-40-2",
"Duration":"6761.440",
"Source_Duration":"6761.483",
"Source_Duration_LastFrame":"-0.011",
"BitRate_Mode":"CBR",
"BitRate":"384000",
"Channels":"6",
"ChannelPositions":"Front: L C R, Side: L R, LFE",
"ChannelLayout":"C L R Ls Rs LFE",
"SamplesPerFrame":"1024",
"SamplingRate":"48000",
"SamplingCount":"324549120",
"FrameRate":"46.875",
"FrameCount":"316943",
"Source_FrameCount":"316945",
"Compression_Mode":"Lossy",
"StreamSize":"324549633",
"Source_StreamSize":"324551681",
"Default":"Yes",
"AlternateGroup":"1",
"extra":{"Menus":"0","Source_Delay":"-43","Source_Delay_Source":"Container"}},{"@type":"Menu","":null}]}
}

vaseala avatar Aug 19 '24 02:08 vaseala

For knowing if it comes from mediainfo.js or MediaInfo library, please test with MediaInfo GUI and say if the JSON has also the same mistake. If so, report in this issue tracker.

@JeromeMartinez I tested it with the GUI and it can display the JSON data normally

vaseala avatar Sep 06 '24 15:09 vaseala

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Oct 07 '24 02:10 github-actions[bot]

This issue was closed because it has been inactive for 30 days since being marked as stale.

github-actions[bot] avatar Nov 07 '24 02:11 github-actions[bot]

So the difference that seems to produce the error is:

mediainfo.js

["...", {"@type":"Menu","":{}]}]

MediaInfo Lib

["...", {"@type":"Menu","":null}]

Somehow there is an additional ] character in the result of mediainfo.js.

Fd929c2CE5fA avatar Apr 24 '25 17:04 Fd929c2CE5fA