John Bergqvist
John Bergqvist

Reputation: 1003

FFmpeg: Can't write metadata to a .ts file

I have an input that i'm muxing into a .ts file, however despite what FFmpeg's wiki says (that it supports the title and language metadata keys) for MPEG transport streams), the title isn't propagating to the video & audio:

ffmpeg -i "source" \
-map 0:0 -metadata:s:v:0 title="VIDEO_TITLE" \
-map 0:1 -metadata:s:a:0 language="eng" -metadata:s:a:0 title="AUDIO_TITLE" \
-c copy "output.ts"

The language is, but not the title.

This is what I get when actually muxing:

Output #0, mpegts, to 'output.ts':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbr, 90k tbn, 90k tbc (default)
    Metadata:
      variant_bitrate : 0
      title           : VIDEO_TITLE
    Stream #0:1(zxx): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp
    Metadata:
      variant_bitrate : 0
      comment         : AUDIO_TITLE
      title           : AUDIO_TITLE

However upon completion, it seems the title isn't there. It doesn't show up in mediainfo (or VLC for that matter) either:

Input #0, mpegts, from 'output.ts':
  Duration: 01:00:00.00, start: 1.440000, bitrate: 5120 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101](zxx): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 68 kb/s

If I was to run the same command but give the file an mp4 extension, the metadata is muxed in as expected, but not for a TS file - am I doing something wrong?

Upvotes: 1

Views: 1809

Answers (1)

Gyan
Gyan

Reputation: 93309

The title fields applies to programs and not media streams in a TS file and the key name is actually service_name.

So,

ffmpeg -i "source" \
-metadata service_name="PROGRAM_TITLE" \
-map 0:0 \
-map 0:1 -metadata:s:a:0 language="eng" \
-c copy "output.ts"

FFmpeg will automatically create one program if none have been defined in the command.

Upvotes: 2

Related Questions