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

Transcoder: Prevent error caused by buggy chapters parsing by mediainfo #485

Merged
merged 4 commits into from
May 13, 2024

Conversation

Arthi-chaud
Copy link
Collaborator

Error handling when parsing chapters' start time. MediaInfo can sometimes give the wrong info

@Arthi-chaud Arthi-chaud added bug Something isn't working transcoder go Pull requests that update Go code labels May 11, 2024
@Arthi-chaud Arthi-chaud requested a review from zoriya May 11, 2024 09:08
@Arthi-chaud Arthi-chaud self-assigned this May 11, 2024
@Arthi-chaud Arthi-chaud force-pushed the fix/parsing-chapters branch from 0d617ff to f6c6e36 Compare May 11, 2024 09:09
Copy link
Owner

@zoriya zoriya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few questions and then I'm gonna test it:

  • Are misplaced chapters only at the beginning of the list (I think so but want to be sure)?
  • Shouldn't more chapters be parsed if the first ones get removed? For the last bugged file I saw, the chapter count was right it was just offset.

transcoder/src/info.go Outdated Show resolved Hide resolved
@zoriya
Copy link
Owner

zoriya commented May 11, 2024

With the spirited away example file:

mediainfo --Output=JSON video/spirited_away\(1\).mp4 | jq '.media.track.[] | select(."@type" == "Menu")'
{
  "@type": "Menu",
  "StreamOrder": "2",
  "ID": "3",
  "Format": "Timed Text",
  "CodecID": "text",
  "Duration": "7476.552",
  "Language": "en",
  "extra": {
    "Encoded_Date": "2021-06-18 01:48:09 UTC",
    "Tagged_Date": "2021-06-18 01:48:09 UTC",
    "Menu_For": "1,2",
    "_00_00_00_000": "Chapter 1",
    "_00_12_29_916": "Chapter 2",
    "_00_20_18_843": "Chapter 3",
    "_00_30_05_804": "Chapter 4",
    "_00_41_08_633": "Chapter 5",
    "_00_51_34_508": "Chapter 6",
    "_01_06_37_952": "Chapter 7",
    "_01_16_39_553": "Chapter 8",
    "_01_24_54_339": "Chapter 9",
    "_01_31_15_261": "Chapter 10",
    "_01_37_45_651": "Chapter 11",
    "_01_41_06_018": "Chapter 12",
    "_01_45_19_104": "Chapter 13",
    "_01_52_50_389": "Chapter 14",
    "_01_55_12_239": "Chapter 15",
    "_02_00_53_580": "Chapter 16",
    "_02_04_34_717": "Chapter 17"
  }
}

our parsing:

{
  "sha": "v1.efcc141700e89ccd6ca6cd9bda60d15fe2f85400",
  "path": "/video/spirited_away(1).mp4",
  "extension": "mp4",
  "size": 606959685,
  "duration": 7476.63,
  "container": "MPEG-4",
  "video": {
    "codec": "AVC",
    "mimeCodec": "avc1.4D4028",
    "language": null,
    "quality": "480p",
    "width": 672,
    "height": 436,
    "bitrate": 478602
  },
  "videos": [
    {
      "codec": "AVC",
      "mimeCodec": "avc1.4D4028",
      "language": null,
      "quality": "480p",
      "width": 672,
      "height": 436,
      "bitrate": 478602
    }
  ],
  "audios": [
    {
      "index": 0,
      "title": "Stereo",
      "language": "en",
      "codec": "AAC",
      "mimeCodec": "mp4a.40.2",
      "isDefault": true,
      "isForced": false
    }
  ],
  "subtitles": [],
  "fonts": [],
  "chapters": [
    {
      "startTime": 0,
      "endTime": 749.916,
      "name": "Chapter 1"
    },
    {
      "startTime": 749.916,
      "endTime": 1218.843,
      "name": "Chapter 2"
    },
    {
      "startTime": 1218.843,
      "endTime": 1805.804,
      "name": "Chapter 3"
    },
    {
      "startTime": 1805.804,
      "endTime": 2468.633,
      "name": "Chapter 4"
    },
    {
      "startTime": 2468.633,
      "endTime": 3094.508,
      "name": "Chapter 5"
    },
    {
      "startTime": 3094.508,
      "endTime": 3997.952,
      "name": "Chapter 6"
    },
    {
      "startTime": 3997.952,
      "endTime": 4599.553,
      "name": "Chapter 7"
    },
    {
      "startTime": 4599.553,
      "endTime": 5094.339,
      "name": "Chapter 8"
    },
    {
      "startTime": 5094.339,
      "endTime": 5475.261,
      "name": "Chapter 9"
    },
    {
      "startTime": 5475.261,
      "endTime": 5865.651,
      "name": "Chapter 10"
    },
    {
      "startTime": 5865.651,
      "endTime": 6066.018,
      "name": "Chapter 11"
    },
    {
      "startTime": 6066.018,
      "endTime": 6319.104,
      "name": "Chapter 12"
    },
    {
      "startTime": 6319.104,
      "endTime": 6770.389,
      "name": "Chapter 13"
    }
  ]
}

So we are missing some chapters

@Arthi-chaud Arthi-chaud force-pushed the fix/parsing-chapters branch from 8e4cb96 to 225b9a0 Compare May 11, 2024 15:20
@Arthi-chaud Arthi-chaud requested a review from zoriya May 13, 2024 19:44
@Arthi-chaud Arthi-chaud force-pushed the fix/parsing-chapters branch from 579784e to 324afc8 Compare May 13, 2024 19:44
Copy link
Owner

@zoriya zoriya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works flawlessly! Thanks!

@zoriya zoriya merged commit b532bb3 into master May 13, 2024
11 checks passed
@zoriya zoriya deleted the fix/parsing-chapters branch May 13, 2024 21:13
@zoriya zoriya added this to the v4.6.0 milestone May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working go Pull requests that update Go code transcoder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants