Skip to content

Commit

Permalink
Fix mp4 data atom parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Jun 13, 2023
1 parent ea40a33 commit 24fdf0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
_build
*~
.*.sw*
17 changes: 13 additions & 4 deletions src/metadataMP4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,19 @@ let parse f : metadata =
remaining := !remaining - chunk (tag :: l)
done
| ["data"; tag; "ilst"; "meta"; "udta"; "moov"] -> (
let value = R.read f (len - 8) in
match List.assoc_opt tag tagn with
| Some tag -> ans := (tag, value) :: !ans
| None -> ())
if len < 16 then raise Invalid;
let data_type = R.int32_be f in
let _ = R.read f 4 in
let value = R.read f (len - 16) in
match (data_type, List.assoc_opt tag tagn) with
| 1, Some tag -> ans := (tag, value) :: !ans
| 2, Some tag ->
ans :=
( tag,
MetadataCharEncoding.Naive.convert ~source:`UTF_16BE value
)
:: !ans
| _ -> ())
| _ -> R.drop f (len - 8));
len
in
Expand Down

0 comments on commit 24fdf0b

Please sign in to comment.