0

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 anything to the video/audio tracks.

We used to do the metadata injecting using a plugin on Wowza streaming engine 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:

ffmpeg version 2.4.3-1ubuntu1~trusty6 Copyright (c) 2000-2014 the FFmpeg developers
  built on Nov 22 2014 17:07:19 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/usr --extra-version='1ubuntu1~trusty6' --build-suffix=-ffmpeg --toolchain=hardened --extra-cflags= --extra-cxxflags= --libdir=/usr/lib/x86_64-linux-gnu --shlibdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-fontconfig --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-opengl --enable-x11grab --enable-libxvid --enable-libx265 --enable-libdc1394 --enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libx264 --enable-libsoxr --enable-openal --enable-libopencv
  libavutil      54.  7.100 / 54.  7.100
  libavcodec     56.  1.100 / 56.  1.100
  libavformat    56.  4.101 / 56.  4.101
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  1.100 /  5.  1.100
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1b62a60] multiple fourcc not supported
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
At least one output file must be specified

I found with help from stackoverflow that I can use ffmpeg to do the trick.

So I run the command

ffmpeg -i video_without_data.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:

ffmpeg version 2.4.3-1ubuntu1~trusty6 Copyright (c) 2000-2014 the FFmpeg developers
  built on Nov 22 2014 17:07:19 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/usr --extra-version='1ubuntu1~trusty6' --build-suffix=-ffmpeg --toolchain=hardened --extra-cflags= --extra-cxxflags= --libdir=/usr/lib/x86_64-linux-gnu --shlibdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-fontconfig --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-opengl --enable-x11grab --enable-libxvid --enable-libx265 --enable-libdc1394 --enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libx264 --enable-libsoxr --enable-openal --enable-libopencv
  libavutil      54.  7.100 / 54.  7.100
  libavcodec     56.  1.100 / 56.  1.100
  libavformat    56.  4.101 / 56.  4.101
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  1.100 /  5.  1.100
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
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
At least one output file must be specified

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?)

2
  • You should include the complete console output from each command; not just segments.
    – llogan
    Commented Jun 10, 2015 at 16:23
  • oh!!. I've edited my question and added the entire output. Thanks @LordNeckbeard. Hope it helps! :) Commented Jun 10, 2015 at 18:45

1 Answer 1

1

Here's the problem: FFmpeg doesn't have a specific AMF (Action Message Format) muxer/encoder -- at least not currently -- so there's no true way to use it to create an "amf0" data stream in your output file to mirror Wowza's results.

What your current script is doing is taking whatever data's present in your SRT file and muxing it into your video as a subtitle stream in a 3GPP Timed Text (mov_text) format.

If this is the result you're expecting (per the info you gained from Stack Overflow), then it's working as intended. However, your current script is dropping the audio stream due to a lack of -map parameters, which are needed whenever whenever attempting to mux from two or more input files. You should change it to the following:

ffmpeg -i video_without_data.mp4 -i sub.srt -map 0:0 -map 0:1 -map 1 -c copy -c:s mov_text -movflags +faststart out.mp4

If dumping your metadata into a subtitle stream isn't what you intended, you might try using FFmpeg's metadata demuxer/muxer to see if your AMF data can be read from an existing file, then reformatted and muxed into new vids. Details can be found at http://ffmpeg.org/ffmpeg-all.html#Metadata-1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .