4

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?
MaMazav
  • 1,773
  • 3
  • 19
  • 33

2 Answers2

5

Use

ffmpeg -i video.ts -map 0:1 -codec copy -f data stream.txt
Gyan
  • 85,394
  • 9
  • 169
  • 201
  • Is there some way to then decode the resulting txt into a readable info, for example in csv format? – vascobnunes Jun 28 '17 at 15:05
  • 1
    That entirely depends on the format of the data stream. But don't count on ffmpeg for that. – Gyan Jun 28 '17 at 15:40
  • Hi bro, I tried the following cmd:ffmpeg -i input.ts -map 0:2 -codec copy -f data -ignore_unknown -copy_unknown output.txt – Wayne Chen Apr 27 '23 at 06:09
  • it fails as: ``` Output #0, data, to 'output.txt': Metadata: encoder : Lavf58.76.100 Stream #0:0: Unknown: none ([128][0][0][0] / 0x0080) Stream mapping: Stream #0:2 -> #0:0 (copy) [mpegts xxx] probed stream 2 failed size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Output file is empty, nothing was encoded (check -ss/-t/-frames parameters if used) ``` how to fix this? – Wayne Chen Apr 27 '23 at 06:14
  • You can't have both: `-ignore_unknown -copy_unknown`. Keep only the latter. – Gyan Apr 28 '23 at 03:51
2

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
o_ren
  • 772
  • 1
  • 7
  • 14