[FFmpeg-user] editing video stream with KLV metadata

Moritz Barsnick barsnick at gmx.net
Thu May 3 17:47:46 EEST 2018


Hi Claire,

On Thu, May 03, 2018 at 14:21:29 +0000, Claire Mantel wrote:
> I have a videostream with klv metadata that I want to edit while keeping the metadata.
> I'm wondering if it's possible with ffmpeg?

I assume you mean that which ffmpeg identifies as a KLV data stream? (I
have no knowledge of KLV, by the way.)

> I also tried to retrieve the metadata in a file with
> ffmpeg -ss 00:02:15.0 -i video_out_2018_05_01_14_11_53.ts -f ffmetadata testMetadata.txt
> But that gives a file containing: ;FFMETADATA1 encoder=Lavf58.13.100
> As if it was using data from the video stream and not the data stream.

At this point, I'm not sure whether you mean that stream 0:1 or actual
metadata.

I'm assuming you mean that data stream, as seen in the following
command line:

> ffmpeg -ss 00:02:15.0 -i video_out_2018_05_01_14_11_53.ts -c:v copy -c:d copy EditMetadata.ts
[...]
> Input #0, mpegts, from 'video_out_2018_05_01_14_11_53.ts':
>   Duration: 00:08:14.40, start: 3600.000000, bitrate: 6676 kb/s
>   Program 1
>     Stream #0:0[0x41]: Video: h264 (Constrained Baseline) (HDMV / 0x564D4448), yuv420p(progressive), 1280x720, 22.17 tbr, 90k tbn, 180k tbc
>     Stream #0:1[0x42]: Data: klv (KLVA / 0x41564C4B)
[...]
> Output #0, mpegts, to '4minShakyLowLightMetadata.ts':
>   Metadata:
>     encoder         : Lavf58.13.100
>     Stream #0:0: Video: h264 (Constrained Baseline) (HDMV / 0x564D4448), yuv420p(progressive), 1280x720, q=2-31, 22.17 tbr, 90k tbn, 90k tbc
> Stream mapping:
>   Stream #0:0 -> #0:0 (copy)

ffmpeg isn't even considering copying the data stream. By
implementation, ffmpeg by default extracts/maps exactly one of each
type of stream (video, audio, subtitles, data). For data, I see the
restriction "Data only if codec id match" in the code, which I don't
quite understand.

Anyway, you can either explicitly map both streams:
  -map 0:v -map 0:d
or just ask ffmpeg to map all streams:
  -map 0

At that point, it depends on whether ffmpeg is willing to and capable
of muxing that data stream. Which will give:
>   Stream #0:0 -> #0:0 (copy)
>   Stream #0:1 -> #0:1 (copy)

If not (please try and give us the output), ffmpeg offers this
option:

  ‘-copy_unknown’
      Allow input streams with unknown type to be copied instead of failing if copying such streams is attempted.

I don't know whether you would need it though.

Hope this helps,
Moritz


More information about the ffmpeg-user mailing list