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

some mp4 file parsed error! #159

Open
1 task
vaseala opened this issue Aug 14, 2024 · 7 comments
Open
1 task

some mp4 file parsed error! #159

vaseala opened this issue Aug 14, 2024 · 7 comments

Comments

@vaseala
Copy link

vaseala commented Aug 14, 2024

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 vaseala added the bug label Aug 14, 2024
@JeromeMartinez
Copy link

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.

@vaseala
Copy link
Author

vaseala commented Aug 15, 2024

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。

@JeromeMartinez
Copy link

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

@vaseala
Copy link
Author

vaseala commented Aug 19, 2024

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
Copy link
Author

vaseala commented Sep 6, 2024

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

Copy link

github-actions bot commented Oct 7, 2024

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

@github-actions github-actions bot added the stale label Oct 7, 2024
Copy link

github-actions bot commented Nov 7, 2024

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

@github-actions github-actions bot closed this as completed Nov 7, 2024
@buzz buzz reopened this Dec 20, 2024
@buzz buzz added disable-stale and removed stale labels Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants