mp4box


mp4box
2020-04-25 (土) 18:49:10更新
カテゴリ

mp4box-コマンド一覧

ここで使用したmp4box(ffmpegX0.0.9u版)

$ mp4box -version
MP4Box - GPAC version 0.4.1-DEV
GPAC Copyright: (c) Jean Le Feuvre 2000-2005
               (c) ENST 2005-200X
性質
エンコード済みのストリーム(動画ファイルの成分)にMP4に適したヘッダを付けて.mp4コンテナに収める道具。
・.mp4コンテナ自体、AVIに比して極めて複雑。
・raw streamとヘッダが分離した構造になっている。QuickTimeは上手に隠しているが、mp4boxはわりと剥き身。
・規格外だがac3やmp3音声も可能な模様。

General Options:

$ mp4box -h general

-inter time_in_ms?

interleaves file data (track chunks of time_in_ms)

  • * Note 1: Interleaving is 0.5s by default
  • * Note 2: a value of 0 disables interleaving

-flat?

stores file with all media data first, non-interleaved


-frag time_in_ms?

fragments file (track fragments of time_in_ms)

  • * Note: Always disables interleaving

-out filename?

specifies output file name

  • * Note: By default input (MP4,3GP) file is overwritten

-tmp dirname?

specifies directory for temporary file creation

  • * Note: Default temp dir is OS-dependent

-nosys?

removes all MPEG-4 Systems info except IOD (profiles)

  • * Note: Set by default whith '-add' and '-cat'

-isma?

rewrites the file as an ISMA 1.0 AV file


-ismax?

same as '-isma' and removes all clock references

-3gp?

rewrites as 3GPP(2) file (no more MPEG-4 Systems Info)

  • * Note 1: some tracks may be removed in the process
  • * Note 2: always on for *.3gp *.3g2 *.3gpp

-brand ABCD

sets major brand of file

-ab ABCD?

adds given brand to file's alternate brand list

-rb ABCD?

removes given brand from file's alternate brand list


-cprt string?

adds copyright string to movie

-chap file?

adds chapter information contained in file

-rem trackID:?

removes track from file

-new:?

forces creation of a new destination file
新規ファイルへの書き出しを強制

-lang [tkID=]LAN:?

トラックの言語指定。"LAN"はISO 639-2 コードで指定 (eng, und)


-delay tkID=TIME:?

トラックのスタートディレイ指定。単位ミリセカンド(ms)。

-split time_sec?

splits in files of time_sec max duration

  • * Note: this removes all MPEG-4 Systems media

-splits filesize?

splits in files of max filesize kB.

  • * Note: this removes all MPEG-4 Systems media

-splitx start:end?

extracts a new file from start to end (in seconds)

  • * Note: this removes all MPEG-4 Systems media

Hinting Options

$ mp4box -h hint

-hint:

hints the file for RTP/RTSP

-mtu size:

specifies MTU size in bytes. Default size is 1500

-copy:

copies media data to hint track rather than reference

  • * Note: speeds up server but takes much more space

-tight:

performs tight interleaving (sample based) of hinted file

  • * Note: reduces server disk seek but increases file size

-multi [maxptime]:

-multi [maxptime]:   enables frame concatenation in RTP packets if possible
       maxptime:     max packet duration in ms (optional, default 100ms)

-rate ck_rate:

specifies rtp rate in Hz when no default for payload

  • * Note: default value is 90000 (MPEG rtp rates)

-mpeg4:

forces MPEG-4 generic payload whenever possible

-latm:

forces MPG4-LATM transport for AAC streams

-static:

enables static RTP payload IDs whenever possible

  • * By default, dynamic payloads are always used

MPEG-4 Generic Payload Options

-ocr:

forces all streams to be synchronized

  • * Most RTSP servers only support synchronized streams

-rap:

signals random access points in RTP packets

-ts:

signals AU Time Stamps in RTP packets

-size:

signals AU size in RTP packets

-idx:

signals AU sequence numbers in RTP packets

-iod:

prevents systems tracks embedding in IOD

  • * Note: shouldn't be used with -isma option

-sdp_ex string:

adds sdp string to (hint) track ("-sdp_ex tkID:string") or movie. This will take care of SDP lines ordering

  • * WARNING: You cannot add anything to SDP, cf rfc2327.

-unhint:

removes all hinting information.

Importing Options;インポートオプション

$ mp4box -h import

File importing syntax:

  • "#video" "#audio": base import for most AV files
    • 大半のAVファイルの基本的なインポート
  • "#trackID=ID": track import for IsoMedia and other files
    • IsoMediaファイルなどからトラックをインポート
  • ":dur=D": imports only the first D seconds
    • 最初のD秒間だけをインポート
  • ":lang=LAN": sets imported media language code
    • 言語コードの指定
  • ":delay=delay_ms": sets imported media initial delay in ms
    • 冒頭のディレイの指定。単位ミリセカンド。

-add file:

add file tracks to (new) output file
(新規の)出力ファイルにファイルトラックを追加

-cat file:

concatenates file samples to (new) output file
* Note: creates tracks if needed

ファイルサンプルを結合して(新規の)出力ファイルに書き出す。
* Note:必要な場合は新しくトラックを追加する。

-keepsys:

keeps all MPEG-4 Systems info when using '-add' / 'cat'

'-add' / 'cat'を使った時に、MPEG-4 Systems infoを全部キープする。

以下のオプションはデフォルト、または各トラックごとに指定できる。

トラック毎に指定する場合、書式は

:opt

または、

:opt=val

-dref:

keeps media data in original file

-nodrop:

forces constant FPS when importing AVI video

AVIからvideoをインポートする際に固定FPSを強制する。

-packed:

forces packed bitstream when importing raw ASP
raw ASPをインポートする際にpacked bitstreamを強制する。

※:packed bitstreamはAVIでBフレームを使う為のハッキングの一つ。複数フレームを1枚と偽ってデコーダバッファに進入させるもの。

-sbr:

backward compatible signaling of AAC-SBR

-sbrx:

non-backward compatible signaling of AAC-SBR

  • * Note: SBR AAC cannot be detected at import time

-fps FPS:

映像と字幕(sub)インポート時にフレームレートを強制。
デフォルトは

  • raw H263:15
  • その他:25

■参考
24000/1001fps

-fps 23.976025

30000/1001fps

-fps 29.970030

※float型での指定がより正確。手許(MEncoderで吐いたraw x264のmux)では、23.976指定は23.975fpsとなり一時間程度の実写で地味に口と台詞がずれる。本来は-fps 24000:1001でも良いようだが、24000:1001は24000fps(超はやおくり)になる。詳細はこちら参照。

-mpeg4:

forces MPEG-4 sample descriptions when possible (3GPP2)

-agg N:

aggregates N audio frames in 1 sample (3GP media only)

  • * Note: Maximum value is 15 - Disabled by default

MPEG-4 Scene Encoding Options

$ mp4box -h encode

-mp4:

specify input file is for encoding.

-def:

encode DEF names

-sync time_in_ms:

forces BIFS sync sample generation every time_in_ms

* Note: cannot be used with -shadow

-shadow time_ms:

forces BIFS sync shadow sample generation every time_ms.

* Note: cannot be used with -sync

-log:

generates BIFS encoder log file

-ms file:

specifies file for track importing

Chunk Processing

-inctx file:

specifies initial context (MP4/BT/XMT)

* Note: input file must be a commands-only file

-outctx:

specifies storage of updated context (MP4/BT/XMT)

Meta handling Options

$ mp4box -h meta

-set-meta args:

sets given meta type - syntax: "ABCD[:tk=ID]"

* ABCD: four char meta type (NULL or 0 to remove meta)

* [:tk=ID]: if not set use root (file) meta
if ID is 0 use moov meta
if ID is not 0 use track meta

-add-item args:

adds resource to meta

* syntax: file_path + options (':' separated):
tk=ID: meta adressing (file, moov, track)
name=str: item name
mime=mtype: item mime type
encoding=enctype: item content-encoding type

* file_path "this" or "self": item is the file itself

-rem-item args:

removes resource from meta - syntax: item_ID[:tk=ID]

-set-primary args:

sets item as primary for meta - syntax: item_ID[:tk=ID]

-set-xml args:

sets meta XML data

* syntax: xml_file_path[:tk=ID][:binary]

-rem-xml [tk=ID]:

removes meta XML data

-dump-xml args:

dumps meta XML to file - syntax file_path[:tk=ID]

-dump-item args:

dumps item to file - syntax item_ID[:tk=ID][:path=fileName]

Extracting Options

$ mp4box -h extract

-raw TrackID:

extracts track in raw format when supported

-raws TrackID:

extract each track sample to a file

* Note: "TrackID:N" extracts Nth sample

-nhnt TrackID:

extracts track in nhnt format

-single TrackID:

extracts track to a new mp4 file

-avi TrackID:

extracts visual track to an avi file

-qcp TrackID:

same as '-raw' but defaults to QCP file for EVRC/SMV

-aviraw TK:

extracts AVI track in raw format $TK can be one of "video" "audio" "audioN"

参考

x264+aac.aviを以下のようにすると、

$ mp4box -aviraw video /Volumes/XXX/XXX.avi 

h264 raw videoだけ抽出できた。

Extracting AVI video (format h264) to /Volumes/XXX/XXX_video.h264

以下はXXX_audio.rawを抽出するが、これはmp4boxでmuxできなかった。

$ mp4box -aviraw audio /Volumes/XXX/XXX.avi 

Dumping Options

$ mp4box -h dump

-std:

dumps to stdout instead of file

-info [trackID]

prints movie info / track info if trackID specified

* Note: for non IsoMedia files, gets import options

-bt:

scene to bt format - removes unknown MPEG4 nodes

-xmt:

scene to XMT-A format - removes unknown MPEG4 nodes

-wrl:

scene VRML format - removes unknown VRML nodes

-x3d:

scene to X3D/XML format - removes unknown X3D nodes

-x3dv:

scene to X3D/VRML format - removes unknown X3D nodes

-diso:

scene IsoMedia file boxes in XML output

-drtp:

rtp hint samples structure to XML output

-dts:

prints sample timing to text output

-sdp:

dumps SDP description of hinted file

-dcr:

ISMACryp samples structure to XML output

-ttxt:

Converts input subtitle to GPAC TTXT format

-ttxt TrackID:

Dumps Text track to GPAC TTXT format

-srt:

Converts input subtitle to SRT format

-srt TrackID:

Dumps Text track to SRT format

-stat:

generates node/field statistics for scene

-stats:

generates node/field statistics per MPEG-4 Access Unit

-statx:

generates node/field statistics for scene after each AU

SWF Importer Options

$ mp4box -h swf

MP4Box can import simple Macromedia Flash files (".SWF")
You can specify a SWF input file with '-bt', 'xmt' and '-mp4' options

-static:

all SWF defines are placed in first scene replace

* Note: By default SWF defines are sent when needed

-ctrl:

uses a dedicated stream for movie control

* Note: Forces '-static'

-notext:

removes all SWF text

-nofont:

removes all embedded SWF Fonts (terminal fonts used)

-noline:

removes all lines from SWF shapes

-nograd:

removes all gradients from swf shapes

-quad:

uses quadratic bezier curves instead of cubic ones

-xlp:

support for lines transparency and scalability

-flatten ang:

complementary angle below which 2 lines are merged

* Note: angle '0' means no flattening

ISMA Encryption/Decryption Options

$ mp4box -h crypt

-crypt drm_file:

crypts a specific track using ISMA AES CTR 128

-decrypt [drm_file]

decrypts a specific track using ISMA AES CTR 128

* Note: drm_file can be omitted if keys are in file

-set-kms kms_uri

changes KMS location for all tracks or a given one.

* to adress a track, use 'tkID=kms_uri'

DRM file syntax for GPAC ISMACryp:

File is XML and shall start with xml header
File is a list of "ISMACrypTrack" elements (all at root)

ISMACrypTrack attributes are

TrackID: ID of track to en/decrypt
key: AES-128 key formatted (hex string '0x'+32 chars)
salt: CTR IV salt key (64 bits) (hex string '0x'+16 chars)

Encryption only attributes:

Scheme_URI: URI of scheme used
KMS_URI: URI of key management system

* Note: 'self' writes key and salt in the file
selectiveType: selective encryption type - understood values are:

"None": all samples encrypted (default)
"RAP": only encrypts random access units
"Non-RAP": only encrypts non-random access units
"Rand": random selection is performed
"X": Encrypts every first sample out of X (uint)
"RandX": Encrypts one random sample out of X (uint)

ipmpType: IPMP Signaling Type: None, IPMP, IPMPX
ipmpDescriptorID: IPMP_Descriptor ID to use if IPMP(X) is used

* If not set MP4Box will generate one for you

サポートするフォーマットと拡張子

mp4box -h format

Suppported raw formats and file extensions:

NHNT.media .nhnt .info
MPEG Audio.mp3
ADTS-AAC.aac
MPEG-4 Visual.cmp .m4v
H263 Video.263 .h263
AVC/H264 Video.h264 .h26L .264 .26L
JPEG Images.jpg .jpeg
PNG Images.png
AMR(WB) Audio.amr .awb
EVRC Audio.evc
SMV Audio.smv

※.m4vはraw formatsとして扱う事に注意。Appleが使うコンテナフォーマットとしての.m4vはオープンソース的には混乱を招いた。ISO/IEC規格外の可能性大。参考

Supported containers and file extensions:

AVI.avi
MPEG-PS.mpg .mpeg .vob .vcd .svcd
QCP.qcp
OGG.ogg
ISO-Media filesno extension checking

Supported text formats:

SRT Subtitles.srt
SUB Subtitles.sub
GPAC Timed Text.ttxt
QuickTime TeXML Text.xml (cf QT documentation)

Supported Scene formats:

MPEG-4 XMT-A.xmt .xmta .xmt.gz .xmta.gz
MPEG-4 BT.bt .bt.gz
VRML.wrl .wrl.gz
X3D-XML.x3d .x3d.gz
X3D-VRML.x3dv .x3dv.gz
MacroMedia Flash.swf (very limitted import support only)

リンク

コメント


FrontPage
MPlayer
Manuals
Documents
カテゴリ

■GENERAL
MEMO
LINK
雑談所
最近の更新
popular

■Other Tools
ffmpeg
mkvmerge
mp4box
MPEG Streamclip
QTCoffee
x264cli

■About
About Wiki

edit


blog


本日1
昨日0
累積33938