[FFmpeg-user] Extract HLS from TS

Oliver Fromme oliver at fromme.com
Fri Aug 16 13:45:23 EEST 2024


EnoSat via ffmpeg-user wrote:
 >  Is it possible to extract streams from a TS file if a stream is stored on a certain pide?
 > e.g:pid 900

I'm not sure if I understand your question corrently, but you can
select a stream from an MPEG TS file by PID (program ID) using the
"#pid" or "i:pid" syntax.  See the section "stream specifier" in
the documentation.

For example, the following will extract the stream with PID 1234
from the input TS file and copy it into an MKV container:

    ffmpeg -i input.ts -map 0:i:1234 -c copy output.mkv

(Alternatively ``-map 0:#1234'', but the "#" character has special
meaning to some UNIX shells, so you might have to escape or quote
it.  Therefore I recommend to use the "i:" syntax.)

Note that FFmpeg supports both decimal (like 1234) and hexadecimal
values (0x12ab) for the PID.  If you use a decimal PID, avoid
leading zeroes (like (0765) because this might be interpreted as
an octal expression.  I haven't checked this, though, but typically
programs use a function of the strtol() family with base 0, so it
handles decimal, hexadecimal and octal values automatically.

Therefore, in general, it's better to avoid leading zeroes when
specifying decimal numbers.

Best regards
 -- Oliver


More information about the ffmpeg-user mailing list