Difference between revisions of "MPEG"

From VideoLAN Wiki
Jump to navigation Jump to search
(→‎Further reading: New section, misc.)
 
(50 intermediate revisions by 12 users not shown)
Line 1: Line 1:
 
{{wikipedia|MPEG}}
 
{{wikipedia|MPEG}}
MPEG refers to a set of standards created by the [http://www.chiariglione.org/mpeg/|Moving Picture Experts Group]. MPEG refers to several video, audio and [[container]] formats.
+
MPEG refers to a set of standards created by the [http://www.chiariglione.org/about Moving Picture Experts Group]. MPEG refers to several video, audio and [[container]] formats; see the full list at the [[Codec]] page.
 
 
An MPEG file is a file using an MPEG container (these are called ''ts'' and ''ps'', and also ''mp4'' for MPEG-4).  
 
  
 +
An MPEG file is a file using an MPEG container (these are called ''mpeg1'', ''ts'', ''ps'', and ''mp4'' for MPEG-4).
  
 
== Creating an MPEG File with VLC ==
 
== Creating an MPEG File with VLC ==
 
To make an MPEG file, you need to:
 
To make an MPEG file, you need to:
* Pick a container (see [[#Muxers|below]])
+
* Pick a container (see [[#Container_formats|below]])
* Transcode the audio and video to formats able to be held in the container: in general this is the MPEG video and audio formats only. Check the [http://www.videolan.org/streaming/features.html compatibility information] in the official documentation.
+
* Transcode the audio and video to formats able to be held in the container: in general this is the MPEG video and audio formats only. Check the [https://www.videolan.org/streaming/features.html compatibility information] in the official documentation, but be warned that while VLC allows any codec and mux, most other players support only a few combinations!
You can do this using the Wizard, or by running vlc from a [[command prompt]]
+
 
<blockquote>
+
== <span id="MPEG-1"></span><span id="MPEG-2"></span> MPEG-1 and 2 ==
vlc ''file.avi'' --sout='#transcode{vcodec=mp2v, acodec=mpga}:std{access=file, mux=ps,url=''file.mpg''}'
+
{{see also|H.262/MPEG-2 Part 2}}
</blockquote>
+
{{wikipedia|MPEG-1|MPEG-2}}
 +
 
 +
* Muxer: '''ts''', '''ps''', '''mpeg1'''
 +
 
 +
MPEG-1 is a video and audio compression format, used in [[Video CD]]s. It is compatible with a large number of software and hardware devices.
 +
 
 +
Here is an example of how to transcode an [[AVI]] into a portable MPEG-1 video from the [[command prompt]]
 +
{{%}} vlc ''file.avi'' --sout='#transcode{vcodec=mp1v, acodec=mpga}:std{access=file, mux=mpeg1,url=''file.mpg''}'
 +
 
 +
MPEG-2 is used in digital television and [[DVB]]. It is also used as the format for [[DVD]]s.  The biggest advantage of this format over MPEG-1 is in its support for interlaced pictures; MPEG-2 can cleanly [[compress]] [[interlaced]] video, while MPEG-1 internally only works on progressive-scan video, so interlacing must be faked.
 +
 
 +
Here is an example of how to transcode an AVI into an MPEG-2 video from the [[command prompt]]
 +
{{%}} vlc ''file.avi'' --sout='#transcode{vcodec=mp2v, acodec=mpga}:std{access=file, mux=ps,url=''file.mpg''}'
 +
 
 +
=== Transcoding and Streaming ===
 +
 
 +
{{Bug|1965}} formerly required supplying a framerate of 25 in order to [[transcode]] and stream an MPEG-1 or MPEG-2 payload.<br />
 +
'''This has been fixed since 2.0.0.'''
 +
 
 +
''HINT:'' Use an MPEG-TS (transport) stream container if you are streaming MPEG through the network (see [[#Container formats|Container Formats]]).
 +
 
 +
=== Video ===
 +
{{codec video|id=mp1v}}
 +
{{codec video|id=mp2v|altid=mpgv}}
 +
{{codec video|id=mp4v}}
 +
{{codec video|id=h264}}
 +
Codecs for MPEG-1 Video, MPEG-2 Video, MPEG-4 Video and H.264 Video (MPEG-4 AVC).
 +
 
 +
=== Audio ===
 +
{{codec audio|id=mpga|info=MP2 audio.}}
 +
{{codec audio|id=mp3|info=[[MP3]] audio.}}
 +
{{codec audio|id=mp4a|info=[[AAC]] audio.}}
 +
Codecs for MPEG Layer 1/2 audio, MPEG Layer 3 audio and MPEG-4 AAC audio
 +
 
 +
=== Container formats ===
 +
MPEG-2 specified 2 [[container]] formats, ts and ps. Containers hold video and audio information in them, and package them up so it can be sent over a network or stored on disk.
 +
* '''ts''' (Transport Stream) should be used to store or send data where data loss will probably occur, such as over a network.
 +
* '''ps''' (Program Stream) should be used to store or send data where data loss is not likely, such as on a DVD.
 +
 
 +
Both ps and ts can transport MPEG-4 Video, but only ts can send MPEG-4 Audio. In addition, MPEG-4 specifies its own container format, '''mp4''' (see [[MPEG-4]])
  
 +
==== <span id="TS"></span> TS, MPEG2 Transport Stream ====
 +
{{mux|id=ts|encoder=y}}
  
== MPEG-1 and 2 ==
+
===== Module options =====
{{wikipedia|MPEG-1}}
+
{{Transcluded|Documentation:Modules/ts}}
{{wikipedia|MPEG-2}}
+
{{:Documentation:Modules/ts}}
  
* Video codec: '''mp1v''', '''mp2v'''
+
===== Accepted video codecs =====
* Audio codec: '''mpga''', '''mp2a''', '''mp3'''
+
* [[mp1v]]: MPEG-1 video
* Muxer: '''ts''', '''ps'''
+
* [[mpgv]]: MPEG-1 or MPEG-2 video
 +
* [[mp4v]]: MPEG-4 video (ASP)
 +
* [[h264]]: H.264, MPEG-4 AVC
 +
* [[Dirac|drac]]: Dirac
 +
* [[jpeg]]
 +
* [[ms]]: MS codecs (nonstandard?)
  
MPEG-1 is a video and audio compression format, used in [[Video CD]]s. It is compatible with a large number of software and hardware devices.
+
===== Accepted audio codecs =====
 +
* [[MP1]], [[MP2]], [[MP3]]
 +
* [[mp4a]]: MPEG-4 Audio (MP4)
 +
* [[a52]]
 +
* [[lpcm]]
 +
* [[dts]]
 +
 
 +
===== Accepted subtitle codecs =====
 +
* [[spu]]
 +
* [[subt]]
 +
* [[telx]]
 +
 
 +
==== <span id="PS"></span> PS, aka MPEG Program Stream ====
 +
{{mux|id=ps|encoder=y}}
 +
 
 +
===== Module options =====
 +
{{Transcluded|Documentation:Modules/ps}}
 +
{{:Documentation:Modules/ps}}
  
MPEG-2 is used in digital television and [[DVB]]. It is also used as the format for [[DVD]]s.
+
===== Accepted video codecs =====
 +
* [[mpgv]]: MPEG-1 or MPEG2
 +
* [[mp4v]]: MPEG-4
  
=== MPEG-1 Audio ===
+
===== Accepted audio codecs =====
MPEG-1 also contains several audio compression formats:
+
* [[mpga]]: MP1, MP2 or MP3
* '''mpga''' is MP1 or MPEG-1 (Part 3) Layer 1
+
* [[mp4a]]: MPEG-4 (MP4)
* '''mp2a''' is MP2 or MPEG-1 (Part 3) Layer 2
+
* [[dts]]
* '''mp3''' is [[MP3]] or MPEG-1 (Part 3) Layer 3
+
* [[a52]]
 +
* [[lpcm]]
  
=== Muxers ===
+
===== Accepted subtitle codecs =====
MPEG-2 specified 2 [[container]] formats, ts and ps. Containers hold video and audioinformation in them, and package them up so it can be sent over a network or stored on disk.
+
* [[spu]]
* '''ts''' should be used to store or send data where data loss will probably occur, such as over a network.
+
* [[ogt]]
* '''ps''' should be used to store or send data where data loss is not likely, such as on a DVD.
+
* [[cvd]]
  
Both ps and ts can transport MPEG-4 Video, but only ts can send MPEG-4 Audio. In addition, MPEG-4 specifies it's own muxer, '''mp4''' (see [[#MPEG-4|below]])
+
{{clear}}
  
== MPEG-3 ==
+
== <span id="MPEG-3"></span> MPEG-3 ==
 
{{wikipedia|MPEG-3}}
 
{{wikipedia|MPEG-3}}
 
A largely unused audio and video compression format.
 
A largely unused audio and video compression format.
* Note that [[MP3]] is actually '''MPEG-1 Layer 3'''.
+
* Note that the amazingly common [[MP3]] audio files are actually '''MPEG-1 Layer 3''' audio, not MPEG-3.
 +
{{clear}}
  
 +
== MPEG-4 ==
 +
{{See|MPEG-4}}
  
== MPEG-4 ==
+
== Source code ==
{{wikipedia|MPEG-4}}
+
{{file|modules/mux/mp4/mp4.c|output muxer}}
* Video codec: '''mp4v''' ('''m4v''')
+
{{file|modules/demux/mpeg/ps.c|input demuxer}}
* Audio codec: '''mp4a''' ('''m4a''') - this is [[AAC]].
+
{{file|modules/demux/mpeg/ts.c|input demuxer}}
* Muxer: '''mp4'''
+
{{file|modules/demux/mpeg/ps.h|input demuxer}}
MPEG-4 is a flexible audio and video compression format. The format describes audio and video compression, with a container format for streaming across networks and saving to disk. It also contains optional extra features, including [[DRM]] and [[subtitles]]. These extra features are only included in software if needed.
+
 
 +
== Further reading ==
 +
* [https://sound.media.mit.edu/resources/mpeg4/audio/ sound.media.mit.edu - The MPEG Audio Web Page]

Latest revision as of 03:56, 16 May 2019

MPEG refers to a set of standards created by the Moving Picture Experts Group. MPEG refers to several video, audio and container formats; see the full list at the Codec page.

An MPEG file is a file using an MPEG container (these are called mpeg1, ts, ps, and mp4 for MPEG-4).

Creating an MPEG File with VLC

To make an MPEG file, you need to:

  • Pick a container (see below)
  • Transcode the audio and video to formats able to be held in the container: in general this is the MPEG video and audio formats only. Check the compatibility information in the official documentation, but be warned that while VLC allows any codec and mux, most other players support only a few combinations!

MPEG-1 and 2

  • Muxer: ts, ps, mpeg1

MPEG-1 is a video and audio compression format, used in Video CDs. It is compatible with a large number of software and hardware devices.

Here is an example of how to transcode an AVI into a portable MPEG-1 video from the command prompt

% vlc file.avi --sout='#transcode{vcodec=mp1v, acodec=mpga}:std{access=file, mux=mpeg1,url=file.mpg}'

MPEG-2 is used in digital television and DVB. It is also used as the format for DVDs. The biggest advantage of this format over MPEG-1 is in its support for interlaced pictures; MPEG-2 can cleanly compress interlaced video, while MPEG-1 internally only works on progressive-scan video, so interlacing must be faked.

Here is an example of how to transcode an AVI into an MPEG-2 video from the command prompt

% vlc file.avi --sout='#transcode{vcodec=mp2v, acodec=mpga}:std{access=file, mux=ps,url=file.mpg}'

Transcoding and Streaming

Bug #1965 formerly required supplying a framerate of 25 in order to transcode and stream an MPEG-1 or MPEG-2 payload.
This has been fixed since 2.0.0.

HINT: Use an MPEG-TS (transport) stream container if you are streaming MPEG through the network (see Container Formats).

Video

mp1v
This is a video codec. The name to use at the command line is mp1v.
mp2v
This is a video codec. The name to use at the command line is mp2v, but you can also use mpgv.
mp4v
This is a video codec. The name to use at the command line is mp4v.
h264
This is a video codec. The name to use at the command line is h264.

Codecs for MPEG-1 Video, MPEG-2 Video, MPEG-4 Video and H.264 Video (MPEG-4 AVC).

Audio

mpga
This is an audio codec. The name to use at the command line is mpga.
mp3
This is an audio codec. The name to use at the command line is mp3.
mp4a
This is an audio codec. The name to use at the command line is mp4a.

Codecs for MPEG Layer 1/2 audio, MPEG Layer 3 audio and MPEG-4 AAC audio

Container formats

MPEG-2 specified 2 container formats, ts and ps. Containers hold video and audio information in them, and package them up so it can be sent over a network or stored on disk.

  • ts (Transport Stream) should be used to store or send data where data loss will probably occur, such as over a network.
  • ps (Program Stream) should be used to store or send data where data loss is not likely, such as on a DVD.

Both ps and ts can transport MPEG-4 Video, but only ts can send MPEG-4 Audio. In addition, MPEG-4 specifies its own container format, mp4 (see MPEG-4)

TS, MPEG2 Transport Stream

ts
VLC can encode and decode this container.
The module name to use at the command line is ts.
Module options
Transcluded from Documentation:Modules/ts
  • ts-standard <string> auto,mpeg,dvb,arib,atsc,tdmb : Selects mode for digital TV standard. This feature affects EPG information and subtitles default value: auto
  • ts-extra-pmt <string> : Allows a user to specify an extra pmt (pmt_pid=pid:stream_type[,...]) default value: NULL
  • ts-trust-pcr <boolean> : Use the stream PCR as a reference default value: enabled
  • ts-es-id-pid <boolean> : Set the internal ID of each elementary stream handled by VLC to the same value as the PID in the TS stream, instead of 1, 2, 3, etc. Useful to do '#duplicate{..., select="es=<pid>"}' default value: enabled
  • ts-csa-ck <string> : CSA encryption key. This must be a 16 char string (8 hexadecimal bytes) default value: NULL
  • ts-csa2-ck <string> : The even CSA encryption key. This must be a 16 char string (8 hexadecimal bytes) default value: NULL
  • ts-csa-pkt <integer> : Specify the size of the TS packet to decrypt. The decryption routines subtract the TS-header from the value before decrypting default value: 188
  • ts-split-es <boolean> : Separate teletex/dvbs pages into independent ES. It can be useful to turn off this option when using stream output default value: enabled
  • ts-seek-percent <boolean> : Seek and position based on a percent byte position, not a PCR generated time position. If seeking doesn't work property, turn on this option default value: disabled
  • ts-cc-check <boolean> : Detect discontinuities and drop packet duplicates. (bluRay sources are known broken and have false positives) default value: enabled
  • ts-pmtfix-waitdata <boolean> : Only create ES on program sending data default value: enabled
  • ts-patfix <boolean> : Try to generate PAT/PMT if missing default value: enabled
  • ts-pcr-offsetfix <boolean> : Try to fix too early PCR (or late DTS) default value: enabled
Accepted video codecs
  • mp1v: MPEG-1 video
  • mpgv: MPEG-1 or MPEG-2 video
  • mp4v: MPEG-4 video (ASP)
  • h264: H.264, MPEG-4 AVC
  • drac: Dirac
  • jpeg
  • ms: MS codecs (nonstandard?)
Accepted audio codecs
Accepted subtitle codecs

PS, aka MPEG Program Stream

ps
VLC can encode and decode this container.
The module name to use at the command line is ps.
Module options
Transcluded from Documentation:Modules/ps
  • ps-trust-timestamps <boolean> : Normally we use the timestamps of the MPEG files to calculate position and duration. However sometimes this might not be usable. Disable this option to calculate from the bitrate instead default value: enabled
Accepted video codecs
Accepted audio codecs
Accepted subtitle codecs

MPEG-3

A largely unused audio and video compression format.

  • Note that the amazingly common MP3 audio files are actually MPEG-1 Layer 3 audio, not MPEG-3.

MPEG-4

See MPEG-4

Source code


Further reading