Skip to content

Subtitles and mp4 metadata

Mark Van den Borre edited this page Dec 28, 2017 · 11 revisions

Mp4 metadata? AtomicParsley or mp4tags

To embed non-subtitle metadata (like the title, penta id, ...) into an mp4 file:

AtomicParsley test.mp4 --TVShowName "FOSDEM" --TVEpisodeNum 1234 --TVSeason 18 --overWrite```

Or use mp4v2-utils:
```apt-get install mp4v2-utils
mp4tags -album 'FOSDEM 2018' -song 'Embedding mp4 tags in blah using llvm' -season 18 -episode 1234 -year 2018 -longdesc 'Ik heb eerbied voor jouw grijze haaaaareeeeen. Ze beschermen je lieve geziiiiiicht.' seektest.mp4```

Then check if metadata have been recorded into the mp4 correctly:
```AtomicParsley test.mp4 -t```


## Web based playback with subtitles? vtt format

Vtt is the w3c standard format for web based subtitle playback.
* One can export subtitles in .vtt directly from amara.org.
* Ffmpeg can convert existing subtitles to .vtt:
```ffmpeg -i test.srt test.vtt```

## Web based playback with subtitles? Use javascript
In theory, html5 should support subtitle track playback without any javascript. In practice, there are still a few rough edges.

We use the clappr java script based player for streaming. Clappr has quite good builtin support for subtitle playback. An example:

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr@latest/dist/clappr.min.js"></script>
<script> var player = new Clappr.Player({ parentId: '#player', source: 'http://clappr.io/highline.mp4', poster: 'http://clappr.io/poster.png', height: 360, width: 640, playback: { crossOrigin: 'anonymous', // Required if track loaded from another domain externalTracks: [ {lang: 'en', label: 'English', src: 'https://static.playmedia-cdn.net/clappr/en.vtt'}, ], }, }); </script> ```

Offline playback with subtitles? Embed the subtitle track in the mp4

Embedding a subtitle track into an mp4 file is easy. ffmpeg -i infile.mp4 -i infile.srt -c copy -c:s mov_text outfile.mp4 ...or more explicitly: ffmpeg -i infile.mp4 -i infile.srt -c:v copy -c:a copy -c:s mov_text outfile.mp4

Clone this wiki locally