Skip to content

infer incorrectly identifies mkv as webm #96

Open
@a99984b1799

Description

@a99984b1799

Demo:

$ ffprobe example.mkv
...
Input #0, matroska,webm, from example.mkv:
  Metadata:
    ENCODER         : Lavf60.16.100
  Duration: 00:02:46.10, start: 0.000000, bitrate: 42034 kb/s
  Stream #0:0: Video: hevc (Main), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 1k tbn
...

$ cargo run -- example.mkv
Inferred: Ok(Some(Type { matcher_type: Video, mime_type: "video/webm", extension: "webm" }))
Code
fn main() {
    let inf = std::env::args().nth(1).unwrap();
    println!("Inferred: {:?}", infer::get_from_path(&inf));
}

The current code detects two byte patterns. This file doesn't contain the first one:

$ xxd -d example.mkv | head -n1
00000000: 1a45 dfa3 a342 8681 0142 f781 0142 f281  .E...B...B...B..
$ #                 ^ diverges here

And does contain the second one, but at a different offset (24-31 instead of 31-38):

$ xxd -d example.mkv | grep "6d61 7472 6f73 6b61"
00000016: 0442 f381 0842 8288 6d61 7472 6f73 6b61  .B...B..matroska

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions