Skip to content

Commit

Permalink
mkv: Add initial support for Matroska/WebM (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
darksv authored Jan 29, 2022
1 parent 93727d4 commit 9780210
Show file tree
Hide file tree
Showing 13 changed files with 2,314 additions and 8 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Thom Chiovoloni <chiovolonit@gmail.com>
# Please keep this section sorted in ascending order.

BlackHoleFox [https://github.com/blackholefox]
darksv [https://github.com/darksv]
djugei [https://github.com/djugei]
FelixMcFelix [https://github.com/FelixMcFelix]
Herohtar [https://github.com/herohtar]
Expand Down
10 changes: 6 additions & 4 deletions symphonia-format-mkv/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
[package]
name = "symphonia-format-mkv"
version = "0.0.1"
version = "0.4.0"
description = "Pure Rust MKV/WebM demuxer (a part of project Symphonia)."
homepage = "https://github.com/pdeljanov/Symphonia"
repository = "https://github.com/pdeljanov/Symphonia"
authors = ["Philip Deljanov <philip.deljanov@gmail.com>"]
authors = ["Dariusz Niedoba <dariusz.niedoba@gmail.com>"]
license = "MPL-2.0"
readme = "README.md"
categories = ["multimedia", "multimedia::audio", "multimedia::encoding"]
keywords = ["audio", "media", "demuxer", "mp4", "iso"]
keywords = ["audio", "media", "demuxer", "mkv", "matroska", "webm"]
edition = "2018"

[dependencies]
log = "0.4"
lazy_static = "1.4.0"
symphonia-core = { version = "0.4", path = "../symphonia-core" }
symphonia-metadata = { version = "0.4", path = "../symphonia-metadata" }
symphonia-metadata = { version = "0.4", path = "../symphonia-metadata" }
symphonia-utils-xiph = { version = "0.4", path = "../symphonia-utils-xiph" }
4 changes: 1 addition & 3 deletions symphonia-format-mkv/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Symphonia MKV/WebM Demuxer

This is a placeholder crate for Project Symphonia's MKV/WebM Demuxer.

Please consider contributing!
MKV/WebM demuxer for Project Symphonia.

**Note:** This crate is part of Symphonia. Please use the [`symphonia`](https://crates.io/crates/symphonia) crate instead of this one directly.

Expand Down
48 changes: 48 additions & 0 deletions symphonia-format-mkv/src/codecs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Symphonia
// Copyright (c) 2019-2022 The Project Symphonia Developers.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use symphonia_core::codecs;
use symphonia_core::codecs::CodecType;

use crate::segment::TrackElement;

pub(crate) fn codec_id_to_type(track: &TrackElement) -> Option<CodecType> {
let bit_depth = track.audio.as_ref().and_then(|a| a.bit_depth);

match track.codec_id.as_str() {
"A_MPEG/L1" => Some(codecs::CODEC_TYPE_MP1),
"A_MPEG/L2" => Some(codecs::CODEC_TYPE_MP2),
"A_MPEG/L3" => Some(codecs::CODEC_TYPE_MP3),
"A_FLAC" => Some(codecs::CODEC_TYPE_FLAC),
"A_OPUS" => Some(codecs::CODEC_TYPE_OPUS),
"A_VORBIS" => Some(codecs::CODEC_TYPE_VORBIS),
"A_AAC/MPEG2/MAIN" | "A_AAC/MPEG2/LC" | "A_AAC/MPEG2/LC/SBR" | "A_AAC/MPEG2/SSR"
| "A_AAC/MPEG4/MAIN" | "A_AAC/MPEG4/LC" | "A_AAC/MPEG4/LC/SBR" | "A_AAC/MPEG4/SSR"
| "A_AAC/MPEG4/LTP" | "A_AAC" => Some(codecs::CODEC_TYPE_AAC),
"A_PCM/INT/BIG" => match bit_depth? {
16 => Some(codecs::CODEC_TYPE_PCM_S16BE),
24 => Some(codecs::CODEC_TYPE_PCM_S24BE),
32 => Some(codecs::CODEC_TYPE_PCM_S32BE),
_ => None,
},
"A_PCM/INT/LIT" => match bit_depth? {
16 => Some(codecs::CODEC_TYPE_PCM_S16LE),
24 => Some(codecs::CODEC_TYPE_PCM_S24LE),
32 => Some(codecs::CODEC_TYPE_PCM_S32LE),
_ => None,
},
"A_PCM/FLOAT/IEEE" => match bit_depth? {
32 => Some(codecs::CODEC_TYPE_PCM_F32LE),
64 => Some(codecs::CODEC_TYPE_PCM_F64LE),
_ => None,
},
_ => {
log::warn!("unknown codec: {}", &track.codec_id);
None
}
}
}
Loading

0 comments on commit 9780210

Please sign in to comment.