Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract bytes of specific stream from mpegts file using ffmpeg

I have an mpeg-ts file with a single program. The program consists of some streams - one video stream and some metadata streams.

I would like to extract a specific stream to a separate file. However the metadata is encoded using a codec that ffmpeg doesn't know. I don't really care about this - I just want to extract the data as bytes, without the mpeg-ts container headers. I tried to use codec "copy" but with no success.

I tried the following:

    ffmpeg -i video.ts -map 0:1 -codec copy stream.txt

But ffmpeg says:

    Unable to find a suitable output format for stream.txt

The error above is only because ffmpeg doesn't know how to output a text file. So I tried to output with "rawvideo" container:

    ffmpeg -i video.ts -map 0:1 -codec copy -f rawvideo stream.txt

But:

    Cannot map stream #0:1 - unsupported type

Just to ensure that I can extract a content of an unknown codec I tried the following:

    ffmpeg -i video.ts -map 0:1 -codec copy stream.ts

But again:

    Cannot map stream #0:1 - unsupported type

So my questions are:

  • Can I extract a byte stream of an unknown codec stream? and how?
  • How can I output the byte stream without any container? Should I use the rawvideo?
like image 709
MaMazav Avatar asked Mar 15 '23 19:03

MaMazav


2 Answers

Use

ffmpeg -i video.ts -map 0:1 -codec copy -f data stream.txt
like image 153
Gyan Avatar answered Apr 06 '23 02:04

Gyan


I'm not sure you can do it with ffmpeg. You can get some information with ffprobe but a better bet would be tstools.

tsinfo yourfile.ts > metadata.txt
like image 43
o_ren Avatar answered Apr 06 '23 00:04

o_ren