mp4-rs
About Shiguredo's open source software
We will not respond to PRs or issues that have not been discussed on Discord. Also, Discord is only available in Japanese.
Please read https://github.com/shiguredo/oss before use.
時雨堂のオープンソースソフトウェアについて
利用前に https://github.com/shiguredo/oss をお読みください。
概要
Rust で実装された依存 0 かつ Sans I/O な MP4 ファイルの mux/demux ライブラリです。no_std 環境でも利用できます。
特徴
- Sans I/O
- 依存ライブラリ 0
no_std対応- MP4 ファイルの mux/demux
- Fragmented MP4 (fMP4) の mux/demux
- 高レベル API の提供
- C API の提供
- WebAssembly API の提供
- Windows / macOS / Linux 対応
対応コーデック
- 音声
- AAC (
mp4a) - Opus (
Opus) - FLAC (
fLaC)
- AAC (
- 映像
- VP8 (
vp08) - VP9 (
vp09) - AV1 (
av01) - H.264 / AVC (
avc1) - H.265 / HEVC (
hev1,hvc1)
- VP8 (
使い方
MP4 ファイルのデマルチプレックス
Mp4FileDemuxer を使って MP4 ファイルからトラック情報やサンプルを取得できます。
use ;
// デマルチプレクサーを生成する
let mut demuxer = new;
// 必要なデータを段階的に供給する (Sans I/O)
while let Some = demuxer.required_input
// トラック情報を取得する
let tracks = demuxer.tracks?;
// サンプルを時系列順に取得する
while let Ok = demuxer.next_sample
fMP4 セグメントの生成と読み戻し
Fmp4SegmentMuxer でメディアセグメントを生成し、Fmp4SegmentDemuxer で読み戻せます。
use ;
use Fmp4SegmentDemuxer;
// Muxer でメディアセグメントを生成する
let mut muxer = new?;
let segment = muxer.create_media_segment?;
let init_segment = muxer.init_segment_bytes?;
// Demuxer で読み戻す
let mut demuxer = new;
demuxer.handle_init_segment?;
let demuxed = demuxer.handle_media_segment?;
サンプル
demux
MP4 ファイルのトラック情報とサンプル情報を表示します。
fmp4
fMP4 の mux/demux を行うサンプルです。引数なしで実行できます。
WebAssembly サンプル
WebAssembly を使ったサンプルを GitHub Pages に用意しています。
Agent Skills
Agent Skills 形式のスキルを同梱しています。gh skill install コマンドで対応する AI エージェント (Claude Code, Cursor, GitHub Copilot, Gemini CLI 等) にインストールでき、エージェントがこのライブラリの API や規格準拠仕様を理解した上で支援できるようになります。
スキルの内容は skills/shiguredo-mp4/SKILL.md を参照してください。
規格書
- ISO/IEC 13818-7
- ISO/IEC 14496-1
- ISO/IEC 14496-3
- ISO/IEC 14496-12
- ISO/IEC 14496-14
- ISO/IEC 14496-15
- ISO/IEC 14496-30
- 3GPP TS 26.245
- ITU-T H.264
- RFC 6184: RTP Payload Format for H.264 Video
- RFC 6381: The 'Codecs' and 'Profiles' Parameters for "Bucket" Media Types
- VP Codec ISO Media File Format Binding
- RFC 6386: VP8 Data Format and Decoding Guide
- VP9 Bitstream and Decoding Process Specification
- AV1 Codec ISO Media File Format Binding
- AV1 Bitstream & Decoding Process Specification
- Encapsulation of Opus in ISO Base Media File Format
- Encapsulation of FLAC in ISO Base Media File Format
ロードマップ
- AV2 のサポート
- H.266 (VVC) のサポート
- Open Audio Codec (OAC) のサポート
ライセンス
Apache License 2.0
Copyright 2024 Takeru Ohta (Original Author)
Copyright 2024 Shiguredo Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.