mirror of
https://github.com/alfg/mp4-rust.git
synced 2025-01-03 00:48:40 +00:00
fix "mdat size too large" (#80)
* fix "mdat size too large" * fix clippy * Fix clippy::derive-partial-eq-without-eq
This commit is contained in:
parent
0cd2abb60a
commit
c26bdcab59
46 changed files with 89 additions and 83 deletions
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct Avc1Box {
|
pub struct Avc1Box {
|
||||||
pub data_reference_index: u16,
|
pub data_reference_index: u16,
|
||||||
pub width: u16,
|
pub width: u16,
|
||||||
|
@ -153,7 +153,7 @@ impl<W: Write> WriteBox<&mut W> for Avc1Box {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct AvcCBox {
|
pub struct AvcCBox {
|
||||||
pub configuration_version: u8,
|
pub configuration_version: u8,
|
||||||
pub avc_profile_indication: u8,
|
pub avc_profile_indication: u8,
|
||||||
|
@ -262,7 +262,7 @@ impl<W: Write> WriteBox<&mut W> for AvcCBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct NalUnit {
|
pub struct NalUnit {
|
||||||
pub bytes: Vec<u8>,
|
pub bytes: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct Co64Box {
|
pub struct Co64Box {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct CttsBox {
|
pub struct CttsBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
@ -23,7 +23,7 @@ impl CttsBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct CttsEntry {
|
pub struct CttsEntry {
|
||||||
pub sample_count: u32,
|
pub sample_count: u32,
|
||||||
pub sample_offset: i32,
|
pub sample_offset: i32,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use serde::Serialize;
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct DataBox {
|
pub struct DataBox {
|
||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
pub data_type: DataType,
|
pub data_type: DataType,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct DinfBox {
|
pub struct DinfBox {
|
||||||
dref: DrefBox,
|
dref: DrefBox,
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ impl<W: Write> WriteBox<&mut W> for DinfBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct DrefBox {
|
pub struct DrefBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
@ -196,7 +196,7 @@ impl<W: Write> WriteBox<&mut W> for DrefBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct UrlBox {
|
pub struct UrlBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
use crate::mp4box::elst::ElstBox;
|
use crate::mp4box::elst::ElstBox;
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct EdtsBox {
|
pub struct EdtsBox {
|
||||||
pub elst: Option<ElstBox>,
|
pub elst: Option<ElstBox>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct ElstBox {
|
pub struct ElstBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
@ -13,7 +13,7 @@ pub struct ElstBox {
|
||||||
pub entries: Vec<ElstEntry>,
|
pub entries: Vec<ElstEntry>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct ElstEntry {
|
pub struct ElstEntry {
|
||||||
pub segment_duration: u64,
|
pub segment_duration: u64,
|
||||||
pub media_time: u64,
|
pub media_time: u64,
|
||||||
|
|
|
@ -6,7 +6,7 @@ use serde::Serialize;
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct EmsgBox {
|
pub struct EmsgBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct FtypBox {
|
pub struct FtypBox {
|
||||||
pub major_brand: FourCC,
|
pub major_brand: FourCC,
|
||||||
pub minor_version: u32,
|
pub minor_version: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct HdlrBox {
|
pub struct HdlrBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct Hev1Box {
|
pub struct Hev1Box {
|
||||||
pub data_reference_index: u16,
|
pub data_reference_index: u16,
|
||||||
pub width: u16,
|
pub width: u16,
|
||||||
|
@ -153,7 +153,7 @@ impl<W: Write> WriteBox<&mut W> for Hev1Box {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct HvcCBox {
|
pub struct HvcCBox {
|
||||||
pub configuration_version: u8,
|
pub configuration_version: u8,
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use serde::Serialize;
|
||||||
use crate::mp4box::data::DataBox;
|
use crate::mp4box::data::DataBox;
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct IlstBox {
|
pub struct IlstBox {
|
||||||
pub items: HashMap<MetadataKey, IlstItemBox>,
|
pub items: HashMap<MetadataKey, IlstItemBox>,
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ impl<R: Read + Seek> ReadBox<&mut R> for IlstBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct IlstItemBox {
|
pub struct IlstItemBox {
|
||||||
pub data: DataBox,
|
pub data: DataBox,
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct MdhdBox {
|
pub struct MdhdBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{hdlr::HdlrBox, mdhd::MdhdBox, minf::MinfBox};
|
use crate::mp4box::{hdlr::HdlrBox, mdhd::MdhdBox, minf::MinfBox};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct MdiaBox {
|
pub struct MdiaBox {
|
||||||
pub mdhd: MdhdBox,
|
pub mdhd: MdhdBox,
|
||||||
pub hdlr: HdlrBox,
|
pub hdlr: HdlrBox,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
|
||||||
pub struct MehdBox {
|
pub struct MehdBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use serde::Serialize;
|
||||||
use crate::mp4box::ilst::IlstBox;
|
use crate::mp4box::ilst::IlstBox;
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct MetaBox {
|
pub struct MetaBox {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub ilst: Option<IlstBox>,
|
pub ilst: Option<IlstBox>,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct MfhdBox {
|
pub struct MfhdBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{dinf::DinfBox, smhd::SmhdBox, stbl::StblBox, vmhd::VmhdBox};
|
use crate::mp4box::{dinf::DinfBox, smhd::SmhdBox, stbl::StblBox, vmhd::VmhdBox};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct MinfBox {
|
pub struct MinfBox {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub vmhd: Option<VmhdBox>,
|
pub vmhd: Option<VmhdBox>,
|
||||||
|
|
|
@ -115,7 +115,7 @@ pub const HEADER_EXT_SIZE: u64 = 4;
|
||||||
|
|
||||||
macro_rules! boxtype {
|
macro_rules! boxtype {
|
||||||
($( $name:ident => $value:expr ),*) => {
|
($( $name:ident => $value:expr ),*) => {
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum BoxType {
|
pub enum BoxType {
|
||||||
$( $name, )*
|
$( $name, )*
|
||||||
UnknownBox(u32),
|
UnknownBox(u32),
|
||||||
|
@ -194,7 +194,8 @@ boxtype! {
|
||||||
NameBox => 0xa96e616d,
|
NameBox => 0xa96e616d,
|
||||||
DayBox => 0xa9646179,
|
DayBox => 0xa9646179,
|
||||||
CovrBox => 0x636f7672,
|
CovrBox => 0x636f7672,
|
||||||
DescBox => 0x64657363
|
DescBox => 0x64657363,
|
||||||
|
WideBox => 0x77696465
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Mp4Box: Sized {
|
pub trait Mp4Box: Sized {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{mfhd::MfhdBox, traf::TrafBox};
|
use crate::mp4box::{mfhd::MfhdBox, traf::TrafBox};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct MoofBox {
|
pub struct MoofBox {
|
||||||
pub mfhd: MfhdBox,
|
pub mfhd: MfhdBox,
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{mvex::MvexBox, mvhd::MvhdBox, trak::TrakBox, udta::UdtaBox};
|
use crate::mp4box::{mvex::MvexBox, mvhd::MvhdBox, trak::TrakBox, udta::UdtaBox};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct MoovBox {
|
pub struct MoovBox {
|
||||||
pub mvhd: MvhdBox,
|
pub mvhd: MvhdBox,
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct Mp4aBox {
|
pub struct Mp4aBox {
|
||||||
pub data_reference_index: u16,
|
pub data_reference_index: u16,
|
||||||
pub channelcount: u16,
|
pub channelcount: u16,
|
||||||
|
@ -134,7 +134,7 @@ impl<W: Write> WriteBox<&mut W> for Mp4aBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct EsdsBox {
|
pub struct EsdsBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
@ -278,7 +278,7 @@ fn write_desc<W: Write>(writer: &mut W, tag: u8, size: u32) -> Result<u64> {
|
||||||
Ok(1 + nbytes as u64)
|
Ok(1 + nbytes as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct ESDescriptor {
|
pub struct ESDescriptor {
|
||||||
pub es_id: u16,
|
pub es_id: u16,
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ impl<W: Write> WriteDesc<&mut W> for ESDescriptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct DecoderConfigDescriptor {
|
pub struct DecoderConfigDescriptor {
|
||||||
pub object_type_indication: u8,
|
pub object_type_indication: u8,
|
||||||
pub stream_type: u8,
|
pub stream_type: u8,
|
||||||
|
@ -458,7 +458,7 @@ impl<W: Write> WriteDesc<&mut W> for DecoderConfigDescriptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct DecoderSpecificDescriptor {
|
pub struct DecoderSpecificDescriptor {
|
||||||
pub profile: u8,
|
pub profile: u8,
|
||||||
pub freq_index: u8,
|
pub freq_index: u8,
|
||||||
|
@ -550,7 +550,7 @@ impl<W: Write> WriteDesc<&mut W> for DecoderSpecificDescriptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct SLConfigDescriptor {}
|
pub struct SLConfigDescriptor {}
|
||||||
|
|
||||||
impl SLConfigDescriptor {
|
impl SLConfigDescriptor {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{mehd::MehdBox, trex::TrexBox};
|
use crate::mp4box::{mehd::MehdBox, trex::TrexBox};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct MvexBox {
|
pub struct MvexBox {
|
||||||
pub mehd: Option<MehdBox>,
|
pub mehd: Option<MehdBox>,
|
||||||
pub trex: TrexBox,
|
pub trex: TrexBox,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct MvhdBox {
|
pub struct MvhdBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct SmhdBox {
|
pub struct SmhdBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::mp4box::{
|
||||||
stsz::StszBox, stts::SttsBox,
|
stsz::StszBox, stts::SttsBox,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct StblBox {
|
pub struct StblBox {
|
||||||
pub stsd: StsdBox,
|
pub stsd: StsdBox,
|
||||||
pub stts: SttsBox,
|
pub stts: SttsBox,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct StcoBox {
|
pub struct StcoBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct StscBox {
|
pub struct StscBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
@ -23,7 +23,7 @@ impl StscBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct StscEntry {
|
pub struct StscEntry {
|
||||||
pub first_chunk: u32,
|
pub first_chunk: u32,
|
||||||
pub samples_per_chunk: u32,
|
pub samples_per_chunk: u32,
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::mp4box::vp09::Vp09Box;
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{avc1::Avc1Box, hev1::Hev1Box, mp4a::Mp4aBox, tx3g::Tx3gBox};
|
use crate::mp4box::{avc1::Avc1Box, hev1::Hev1Box, mp4a::Mp4aBox, tx3g::Tx3gBox};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct StsdBox {
|
pub struct StsdBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct StssBox {
|
pub struct StssBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct StszBox {
|
pub struct StszBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct SttsBox {
|
pub struct SttsBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
@ -23,7 +23,7 @@ impl SttsBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct SttsEntry {
|
pub struct SttsEntry {
|
||||||
pub sample_count: u32,
|
pub sample_count: u32,
|
||||||
pub sample_delta: u32,
|
pub sample_delta: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
|
||||||
pub struct TfhdBox {
|
pub struct TfhdBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub enum TrackFlag {
|
||||||
// TrackInPreview = 0x000004,
|
// TrackInPreview = 0x000004,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct TkhdBox {
|
pub struct TkhdBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
@ -51,7 +51,7 @@ impl Default for TkhdBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct Matrix {
|
pub struct Matrix {
|
||||||
pub a: i32,
|
pub a: i32,
|
||||||
pub b: i32,
|
pub b: i32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{tfhd::TfhdBox, trun::TrunBox};
|
use crate::mp4box::{tfhd::TfhdBox, trun::TrunBox};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct TrafBox {
|
pub struct TrafBox {
|
||||||
pub tfhd: TfhdBox,
|
pub tfhd: TfhdBox,
|
||||||
pub trun: Option<TrunBox>,
|
pub trun: Option<TrunBox>,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
use crate::mp4box::{edts::EdtsBox, mdia::MdiaBox, tkhd::TkhdBox};
|
use crate::mp4box::{edts::EdtsBox, mdia::MdiaBox, tkhd::TkhdBox};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct TrakBox {
|
pub struct TrakBox {
|
||||||
pub tkhd: TkhdBox,
|
pub tkhd: TkhdBox,
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct TrexBox {
|
pub struct TrexBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct TrunBox {
|
pub struct TrunBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct Tx3gBox {
|
pub struct Tx3gBox {
|
||||||
pub data_reference_index: u16,
|
pub data_reference_index: u16,
|
||||||
pub display_flags: u32,
|
pub display_flags: u32,
|
||||||
|
@ -15,7 +15,7 @@ pub struct Tx3gBox {
|
||||||
pub style_record: [u8; 12],
|
pub style_record: [u8; 12],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct RgbaColor {
|
pub struct RgbaColor {
|
||||||
pub red: u8,
|
pub red: u8,
|
||||||
pub green: u8,
|
pub green: u8,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use serde::Serialize;
|
||||||
use crate::mp4box::meta::MetaBox;
|
use crate::mp4box::meta::MetaBox;
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct UdtaBox {
|
pub struct UdtaBox {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub meta: Option<MetaBox>,
|
pub meta: Option<MetaBox>,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{Read, Seek, Write};
|
||||||
|
|
||||||
use crate::mp4box::*;
|
use crate::mp4box::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct VmhdBox {
|
pub struct VmhdBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
@ -12,7 +12,7 @@ pub struct VmhdBox {
|
||||||
pub op_color: RgbColor,
|
pub op_color: RgbColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct RgbColor {
|
pub struct RgbColor {
|
||||||
pub red: u16,
|
pub red: u16,
|
||||||
pub green: u16,
|
pub green: u16,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::mp4box::*;
|
||||||
use crate::Mp4Box;
|
use crate::Mp4Box;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct Vp09Box {
|
pub struct Vp09Box {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::mp4box::*;
|
||||||
use crate::Mp4Box;
|
use crate::Mp4Box;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)]
|
||||||
pub struct VpccBox {
|
pub struct VpccBox {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::mp4box::{
|
||||||
};
|
};
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct TrackConfig {
|
pub struct TrackConfig {
|
||||||
pub track_type: TrackType,
|
pub track_type: TrackType,
|
||||||
pub timescale: u32,
|
pub timescale: u32,
|
||||||
|
|
32
src/types.rs
32
src/types.rs
|
@ -9,7 +9,7 @@ use crate::*;
|
||||||
pub use bytes::Bytes;
|
pub use bytes::Bytes;
|
||||||
pub use num_rational::Ratio;
|
pub use num_rational::Ratio;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
|
||||||
pub struct FixedPointU8(Ratio<u16>);
|
pub struct FixedPointU8(Ratio<u16>);
|
||||||
|
|
||||||
impl FixedPointU8 {
|
impl FixedPointU8 {
|
||||||
|
@ -30,7 +30,7 @@ impl FixedPointU8 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
|
||||||
pub struct FixedPointI8(Ratio<i16>);
|
pub struct FixedPointI8(Ratio<i16>);
|
||||||
|
|
||||||
impl FixedPointI8 {
|
impl FixedPointI8 {
|
||||||
|
@ -51,7 +51,7 @@ impl FixedPointI8 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
|
||||||
pub struct FixedPointU16(Ratio<u32>);
|
pub struct FixedPointU16(Ratio<u32>);
|
||||||
|
|
||||||
impl FixedPointU16 {
|
impl FixedPointU16 {
|
||||||
|
@ -86,7 +86,7 @@ impl fmt::Display for BoxType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Clone, Copy, Serialize)]
|
#[derive(Default, PartialEq, Eq, Clone, Copy, Serialize)]
|
||||||
pub struct FourCC {
|
pub struct FourCC {
|
||||||
pub value: [u8; 4],
|
pub value: [u8; 4],
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ const HANDLER_TYPE_AUDIO_FOURCC: [u8; 4] = [b's', b'o', b'u', b'n'];
|
||||||
const HANDLER_TYPE_SUBTITLE: &str = "sbtl";
|
const HANDLER_TYPE_SUBTITLE: &str = "sbtl";
|
||||||
const HANDLER_TYPE_SUBTITLE_FOURCC: [u8; 4] = [b's', b'b', b't', b'l'];
|
const HANDLER_TYPE_SUBTITLE_FOURCC: [u8; 4] = [b's', b'b', b't', b'l'];
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum TrackType {
|
pub enum TrackType {
|
||||||
Video,
|
Video,
|
||||||
Audio,
|
Audio,
|
||||||
|
@ -223,7 +223,7 @@ const MEDIA_TYPE_VP9: &str = "vp9";
|
||||||
const MEDIA_TYPE_AAC: &str = "aac";
|
const MEDIA_TYPE_AAC: &str = "aac";
|
||||||
const MEDIA_TYPE_TTXT: &str = "ttxt";
|
const MEDIA_TYPE_TTXT: &str = "ttxt";
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum MediaType {
|
pub enum MediaType {
|
||||||
H264,
|
H264,
|
||||||
H265,
|
H265,
|
||||||
|
@ -277,7 +277,7 @@ impl From<&MediaType> for &str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum AvcProfile {
|
pub enum AvcProfile {
|
||||||
AvcConstrainedBaseline, // 66 with constraint set 1
|
AvcConstrainedBaseline, // 66 with constraint set 1
|
||||||
AvcBaseline, // 66,
|
AvcBaseline, // 66,
|
||||||
|
@ -316,7 +316,7 @@ impl fmt::Display for AvcProfile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum AudioObjectType {
|
pub enum AudioObjectType {
|
||||||
AacMain = 1, // AAC Main Profile
|
AacMain = 1, // AAC Main Profile
|
||||||
AacLowComplexity = 2, // AAC Low Complexity
|
AacLowComplexity = 2, // AAC Low Complexity
|
||||||
|
@ -463,7 +463,7 @@ impl fmt::Display for AudioObjectType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum SampleFreqIndex {
|
pub enum SampleFreqIndex {
|
||||||
Freq96000 = 0x0,
|
Freq96000 = 0x0,
|
||||||
Freq88200 = 0x1,
|
Freq88200 = 0x1,
|
||||||
|
@ -522,7 +522,7 @@ impl SampleFreqIndex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum ChannelConfig {
|
pub enum ChannelConfig {
|
||||||
Mono = 0x1,
|
Mono = 0x1,
|
||||||
Stereo = 0x2,
|
Stereo = 0x2,
|
||||||
|
@ -564,7 +564,7 @@ impl fmt::Display for ChannelConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Default)]
|
#[derive(Debug, PartialEq, Eq, Clone, Default)]
|
||||||
pub struct AvcConfig {
|
pub struct AvcConfig {
|
||||||
pub width: u16,
|
pub width: u16,
|
||||||
pub height: u16,
|
pub height: u16,
|
||||||
|
@ -572,19 +572,19 @@ pub struct AvcConfig {
|
||||||
pub pic_param_set: Vec<u8>,
|
pub pic_param_set: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Default)]
|
#[derive(Debug, PartialEq, Eq, Clone, Default)]
|
||||||
pub struct HevcConfig {
|
pub struct HevcConfig {
|
||||||
pub width: u16,
|
pub width: u16,
|
||||||
pub height: u16,
|
pub height: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Default)]
|
#[derive(Debug, PartialEq, Eq, Clone, Default)]
|
||||||
pub struct Vp9Config {
|
pub struct Vp9Config {
|
||||||
pub width: u16,
|
pub width: u16,
|
||||||
pub height: u16,
|
pub height: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct AacConfig {
|
pub struct AacConfig {
|
||||||
pub bitrate: u32,
|
pub bitrate: u32,
|
||||||
pub profile: AudioObjectType,
|
pub profile: AudioObjectType,
|
||||||
|
@ -603,10 +603,10 @@ impl Default for AacConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Default)]
|
#[derive(Debug, PartialEq, Eq, Clone, Default)]
|
||||||
pub struct TtxtConfig {}
|
pub struct TtxtConfig {}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
pub enum MediaConfig {
|
pub enum MediaConfig {
|
||||||
AvcConfig(AvcConfig),
|
AvcConfig(AvcConfig),
|
||||||
HevcConfig(HevcConfig),
|
HevcConfig(HevcConfig),
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::mp4box::*;
|
||||||
use crate::track::Mp4TrackWriter;
|
use crate::track::Mp4TrackWriter;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct Mp4Config {
|
pub struct Mp4Config {
|
||||||
pub major_brand: FourCC,
|
pub major_brand: FourCC,
|
||||||
pub minor_version: u32,
|
pub minor_version: u32,
|
||||||
|
@ -71,6 +71,7 @@ impl<W: Write + Seek> Mp4Writer<W> {
|
||||||
// TODO largesize
|
// TODO largesize
|
||||||
let mdat_pos = writer.seek(SeekFrom::Current(0))?;
|
let mdat_pos = writer.seek(SeekFrom::Current(0))?;
|
||||||
BoxHeader::new(BoxType::MdatBox, HEADER_SIZE).write(&mut writer)?;
|
BoxHeader::new(BoxType::MdatBox, HEADER_SIZE).write(&mut writer)?;
|
||||||
|
BoxHeader::new(BoxType::WideBox, HEADER_SIZE).write(&mut writer)?;
|
||||||
|
|
||||||
let tracks = Vec::new();
|
let tracks = Vec::new();
|
||||||
let timescale = config.timescale;
|
let timescale = config.timescale;
|
||||||
|
@ -117,10 +118,14 @@ impl<W: Write + Seek> Mp4Writer<W> {
|
||||||
let mdat_end = self.writer.seek(SeekFrom::Current(0))?;
|
let mdat_end = self.writer.seek(SeekFrom::Current(0))?;
|
||||||
let mdat_size = mdat_end - self.mdat_pos;
|
let mdat_size = mdat_end - self.mdat_pos;
|
||||||
if mdat_size > std::u32::MAX as u64 {
|
if mdat_size > std::u32::MAX as u64 {
|
||||||
return Err(Error::InvalidData("mdat size too large"));
|
self.writer.seek(SeekFrom::Start(self.mdat_pos))?;
|
||||||
|
self.writer.write_u32::<BigEndian>(1)?;
|
||||||
|
self.writer.seek(SeekFrom::Start(self.mdat_pos + 8))?;
|
||||||
|
self.writer.write_u64::<BigEndian>(mdat_size)?;
|
||||||
|
} else {
|
||||||
|
self.writer.seek(SeekFrom::Start(self.mdat_pos))?;
|
||||||
|
self.writer.write_u32::<BigEndian>(mdat_size as u32)?;
|
||||||
}
|
}
|
||||||
self.writer.seek(SeekFrom::Start(self.mdat_pos))?;
|
|
||||||
self.writer.write_u32::<BigEndian>(mdat_size as u32)?;
|
|
||||||
self.writer.seek(SeekFrom::Start(mdat_end))?;
|
self.writer.seek(SeekFrom::Start(mdat_end))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue