Stream copying and encoded packet handling
Stream copying passes selected encoded stream data to an output path without decoding and re-encoding its pictures or samples.
Stream copying selects encoded stream data and passes it toward an output without rebuilding and re-encoding the corresponding pictures or samples.
It is not the same as a filesystem copy. A file contains container structures and possibly several media streams; a stream-copying job can choose only some of them and write another container.
One command can use two operations
An original illustrative FFmpeg command is:
ffmpeg -i source.mkv -map 0:v:0 -map 0:a:0 -c:v copy -c:a aac delivery.mp4
The command illustrates option meaning, not an executed conversion or a guarantee that every source can be written this way.
| Option | Meaning in the example |
|---|---|
| -map 0:v:0 | Select the first video stream from input 0 |
| -map 0:a:0 | Select the first audio stream from input 0 |
| -c:v copy | Use the video stream-copy path |
| -c:a aac | Encode the selected audio with the named AAC encoder |
| delivery.mp4 | Choose the output resource/container context |
The video avoids a video encoder. The audio does not avoid an audio encoder. Looking only at the executable's name cannot distinguish those operations.
Packets and frames are different objects
An encoded packet carries data that a decoder interprets. A decoded video frame contains reconstructed picture samples. A raw audio frame contains samples suitable for processing and presentation.
A stream-copy path works on encoded data. A scale, deinterlace or subtitle-painting operation works on pictures and therefore needs another path through decoding and encoding.
That boundary explains why adding -vf scale=1280:720 is not a way to scale a video while keeping -c:v copy. The requested operations require incompatible data representations on that stream.
Copying does not mean identical file bytes
The output muxer writes its own container headers, indexes and packet layout. A bitstream filter can alter encoded framing or associated configuration without producing a new compressed picture generation.
Thus an output hash can differ while the copied media preserves its encoded picture information. A subtitle/image attachment can also be excluded simply because it was not mapped.
Codec names and duration agreement are insufficient evidence of stream copying. The mapping and selected codec-handling path are more direct evidence.
Selection survives as output scope
Stream identifiers and indexes belong to their input or output representation. The first input audio stream does not have to remain stream index 1 after another set of streams is selected and written.
A playback diagnostic should therefore relate output streams back to the chosen input mapping. An output track numbered 0 is not automatically the input track numbered 0.
Remuxing describes the packaging job around these copied streams; Direct Stream describes Emby's relevant video-preserving session category.
See Also
- Remuxing media containers
- Decoding media streams
- Encoding a new media representation
- Streams and Tracks
- Packet Timestamps