-
Notifications
You must be signed in to change notification settings - Fork 32
Subtitles and mp4 metadata
Mark Van den Borre edited this page Dec 28, 2017
·
11 revisions
To embed non-subtitle metadata (like the title, penta id, ...) into an mp4 file:
apt-get install atomicparsley
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.' test.mp4
Then check if metadata have been recorded into the mp4 correctly:
AtomicParsley test.mp4 -t
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
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:
<html>
<head>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr@latest/dist/clappr.min.js"></script>
</head>
<body>
<div id="player"></div>
<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>
</body>
</html>
Embedding a subtitle track into an mp4 file is easy.
...or more explicitly:
ffmpeg -i infile.mp4 -i infile.srt -c:v copy -c:a copy -c:s mov_text outfile.mp4