MPEGDEMUX(1)
π MPEGDEMUX(1) β like, the mpegdemux manual bestie π
okay so before we even get into it: this is the manual for mpegdemux, and the manual name is literally mpegdemux (it's a section 1 page, obvs, it's a command). grab a snack, we're doing this π
β¨ NAME β¨
mpegdemux β an MPEG1/MPEG2 system stream demultiplexer. yes she demultiplexes. she's that girl. π
π SYNOPSIS π
mpegdemux [options] [input [output]]
like, options first, then input, then output. that's the whole vibe.
π¦ DESCRIPTION π¦
mpegdemux(1) is an MPEG1/MPEG2 system stream demultiplexer. she has two jobs and she slays both: listing what's inside an MPEG system stream, and extracting elementary streams out of it. π
mpegdemux(1) has four primary modes of operation, and honestly each one is a main character in her own right:
- scan β in this mode the MPEG system stream is scanned for elementary streams. like a lil detective π΅οΈβοΈ
- list β in this mode the contents of an MPEG system stream are listed in a textual form. this is useful to get an overview of what's in an MPEG file. it's giving "let me read the menu before I order" π
- demux β in this mode elementary streams are extracted from an MPEG system stream. the system stream packet structure is dissolved in the process. typically each extracted stream is written to its own file. no cap.
- remux β this is like demux, except that the MPEG system stream structure is left intact. this means that the output is again an MPEG system stream with all but the selected elementary streams removed. so it's demux's sibling but with commitment issues resolved πΈ
β¨ OPTIONS β¨
okay here's the full menu, and yes, we are listing every single one, do not skip, do not scroll past, they all matter π«Ά
-a,--ac3β AC3 sound packets in DVD MPEG2 streams have a 3 byte header that is neither part of the MPEG specification nor of the AC3 specification. when this option is used, these 3 bytes are removed to produce a correct AC3 stream. > β οΈ note that this option applies to all selected substreams without checking whether they actually contain an AC3 elementary stream. so she's not checking IDs, bestie, she's just going for it. π-b,--base-name nameβ when demultiplexing more than one stream, the output file names can be set using this option. to generate the output file name for a stream, every#character in name is replaced by a hex digit of the stream id. for example, to extract all video streams in one go, use something like:
$ mpegdemux -d -b video_##.m1v -s 0xc0-0xcf src.mpg
to get files video_c0.m1v, video_c1.m1v, ... π
-c --scanβ scan a system stream for elementary streams. this is the default mode. all streams and substreams are automatically selected when using this option. she does it for you, no notes. β¨-d,--demuxβ demultiplex an MPEG system stream. the demultiplexed streams are written to the output file unless the--base-nameoption is used. if the--base-nameoption is not used, only one stream can be demultiplexed (if more streams are specified, they will be randomly interleaved in the output file). yeah. randomly interleaved. chaos. π-D,--no-dropβ don't drop incomplete packets in demuxing and remuxing mode. keep the lil broken ones, she said. π₯Ί-e,--no-endβ don't print end codes in listing mode. additionally, in remuxing mode, make sure that there is exactly one end code at the end of the stream.-E,--empty-packsβ when streams are removed during remuxing, packs can become empty. including these empty packs in the output is pointless and therefore is not done by default. use this option to force inclusion of all packs. it's the "no, actually, keep the crumbs" flag π-F,--first-ptsβ in scan mode, in addition to each stream's first packet, also list the packet with the lowest presentation time stamp.-h,--no-system-headersβ don't print system headers in listing mode. additionally, in remuxing mode, don't repeat system headers.-i,--invalid specβ select invalid streams. packets of invalid streams are not recognized as packets and their contents are parsed as MPEG system stream data rather than being skipped. this is useful for broken/incomplete streams. the syntax for spec is the same as for-s. additionally, if spec is-then all streams that have not yet been selected by-sare made invalid. so dramatic π³-k,--no-packsβ don't print packs in listing mode.-K,--remux-skippedβ copy bytes that are skipped while looking for a start code. she found them, she's keeping them π-l,--listβ list the system headers, packs and packets in an MPEG system stream.-m,--packet-max-size sizeβ set the maximum packet size to size. packets in the input stream that are larger are considered invalid. as with the-ioption, the packet is not simply skipped but parsed as MPEG system stream data.-p,--substream specβ this option selects private substreams. whenever Private Stream 1 (0xbd) is selected using-s, the substreams within that private stream can be selected using-p. the syntax for spec is the same as for-s. the private stream's private stream. nested. iconic. π§-P,--substream-map id1 id2β remap substream id1 to id2 when remuxing.-r,--remuxβ remultiplex an MPEG system stream. the output MPEG system stream is written to the output file. many options control what is copied from the input to the output and what is discarded. she's a picky eater, respectfully π½οΈ-s,--streams specβ this option selects streams. spec specifies the stream IDs in the following form:
[+|-]<id>[-<id>]{/[+|-]<id>[-<id>]}
where id is either a numeric stream ID or one of all or none. a - in front of an ID range means exclusion. for example the spec:
-s 0xc0-0xcf/-0xc2
selects all video streams (0xc0 - 0xcf) except stream 0xc2. exclusion era. periodt. β¨
-S,--stream-map id1 id2β remap stream id1 to id2 when remuxing.-t,--no-packetsβ don't print packets in listing mode.-u,--spuβ this option is used to extract DVD subtitles. it is necessary because the subtitle streams on DVD don't contain all the timing information (the time stamps in the packet headers are required). if this option is used during demultiplexing, the output files for all substreams are written in the following format:
"SPU " (4 bytes)
PTS (8 bytes, MSB first)
SPU packet
PTS (8 bytes)
SPU packet
and so on π
-x, --splitβ split the remuxed stream at sequence boundaries. this option is only meaningful in remuxing mode. it can not be used together with the-eoption. the individual sequences are written to files whose name was set with the-boption. > π¨ only remuxing mode, and absolutely not with-e. they do not get along.--helpβ print usage information.--versionβ print version information.
πΈ EXAMPLES πΈ
these are the vibes, copy them, use them, love them:
scan a system stream for elementary streams:
$ mpegdemux -c -v src.mpg
list the contents of an MPEG system stream:
$ mpegdemux -l -k -s all -p all src.mpg
extract the first video stream:
$ mpegdemux -d -s 0xe0 src.mpg dst.m1v
extract all audio streams:
$ mpegdemux -d -s 0xc0-0xdf -b audio_##.mpa src.mpg
remove the second video stream:
$ mpegdemux -r -s all/-0xc1 -p all src.mpg dst.mpg
extract the first AC3 audio stream from a DVD MPEG2 system stream:
$ mpegdemux -d -s 0xbd -p 0x80 --ac3 src.mpg dst.ac3
exchange the first and the second audio stream:
$ mpegdemux -r -s all -p all -S 0xc0 0xc1 -S 0xc1 0xc0 src.mpg dst.mpg
π SEE ALSO π
mplex(1) β her bestie, go say hi π
π AUTHOR π
Hampa Hug <hampa@hampa.ch>
okay and the lil sign-off at the bottom of the page, the one that's usually in tiny letters? it says HH, dated 2009-02-13, and the page is MPEGDEMUX(1). that's the whole footer, she's vintage and she's still serving π thank u for coming to my ted talk, go demux something π β¨
π¦ where this page comes from
- debian bookworm: mpegdemux 0.1.4-5
- debian trixie: mpegdemux 0.1.5-2 Β· GPL-2.0-only
- ubuntu jammy: mpegdemux 0.1.4-4
- ubuntu noble: mpegdemux 0.1.5-1 Β· GPL-2.0-only
- ubuntu questing: mpegdemux 0.1.5-2
- ubuntu resolute: mpegdemux 0.1.5-3 Β· GPL-2.0-only
- ubuntu stonking: mpegdemux 0.1.5-3 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms