Embedding timed text metadata in MP4

3.8k views Asked by At

Is it possible to manually embed timed text metadata into MP4 files? I have a TTML / SRT file with the metadata. I just need to embed the text data without doing any encoding the video / audio.

EDIT: We used to do the metadata injecting using on Wowza server which we use for live streaming. What I need to do is manually inject the metadata in to prerecorded MP4 files without running the video through Wowza.

Here is one such video file that was processed by Wowza:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'metadata-back.mp4':
  Metadata:
    major_brand     : f4v 
    minor_version   : 0
    compatible_brands: isommp42m4v 
    creation_time   : 2015-04-16 11:12:39
  Duration: 00:00:11.70, start: 0.000000, bitrate: 1373 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv), 640x480 [SAR 1:1 DAR 4:3], 1352 kb/s, 28.60 fps, 30 tbr, 90k tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2015-04-16 11:12:39
      handler_name    : WowzaStreamingEngine
      encoder         : WowzaStreamingEngine
    Stream #0:1(eng): Audio: speex (spex / 0x78657073), 16000 Hz, mono, s16, 17 kb/s (default)
    Metadata:
      creation_time   : 2015-04-16 11:12:39
      handler_name    : WowzaStreamingEngine
    Stream #0:2(eng): Data: none (amf0 / 0x30666D61), 0 kb/s (default)
    Metadata:
      creation_time   : 2015-04-16 11:12:39
      handler_name    : WowzaStreamingEngine

Now if I run the command ffmpeg -i new-meta.mp4 -i sub.srt -c copy -c:s mov_text -movflags +faststart out.mp4 and if I run ffmpeg -i out.mp4, I get this:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.4.101
  Duration: 00:00:07.27, start: 0.000000, bitrate: 925 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1366x768 [SAR 1:1 DAR 683:384], 920 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
    Metadata:
      handler_name    : SubtitleHandler

Now as you can see the text is embedded with a different codec (is this the right term?). Also I dont see an audio track as well.

Hope my question is clear enough. I need a way to embed metadata (from srt / ttml) into an MP4 video it should be embedded in amf format (again is this the right term?)

1

There are 1 answers

1
llogan On
ffmpeg -i in.mp4 -i subs.srt -c copy -c:s mov_text -movflags +faststart out.mp4

Support for 3GPP TS 26.245 Timed Text ("mov_text") in MP4 may vary according to the player.