diff mbox

[FFmpeg-devel] movenc: add support for track names in ISML manifests

Message ID 20170210232114.28009-1-jeebjp@gmail.com
State Accepted
Commit 763e8237546ac5e1db812785f7110fea849067f2
Headers show

Commit Message

Jan Ekström Feb. 10, 2017, 11:21 p.m. UTC
This enables having multiple tracks of the same type which would
be treated as different things by the media server (as opposed to
different bit rate versions of the same track). According to the
smooth streaming specification, just setting the systemLanguage
tag is not enough to note that a track with the same attributes
differs from another one.
---
 libavformat/movenc.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Jan Ekström Feb. 12, 2017, 1:10 p.m. UTC | #1
On Sat, Feb 11, 2017 at 1:21 AM, Jan Ekström <jeebjp@gmail.com> wrote:
> ...
>

Poked Martin about this last night, and his comment was:
`<@wbs> JEEB: doesn't look harmful to me, so no objection`

Jan
Michael Niedermayer Feb. 12, 2017, 7:19 p.m. UTC | #2
On Sun, Feb 12, 2017 at 03:10:34PM +0200, Jan Ekstrom wrote:
> On Sat, Feb 11, 2017 at 1:21 AM, Jan Ekström <jeebjp@gmail.com> wrote:
> > ...
> >
> 
> Poked Martin about this last night, and his comment was:
> `<@wbs> JEEB: doesn't look harmful to me, so no objection`

ok, ill apply it

thx

[...]
diff mbox

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index a58b6a4..a286210 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3645,6 +3645,7 @@  static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat
         MOVTrack *track = &mov->tracks[i];
         const char *type;
         int track_id = track->track_id;
+        char track_name_buf[32] = { 0 };
 
         AVStream *st = track->st;
         AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
@@ -3670,6 +3671,23 @@  static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat
         param_write_int(pb, "systemBitrate", manifest_bit_rate);
         param_write_int(pb, "trackID", track_id);
         param_write_string(pb, "systemLanguage", lang ? lang->value : "und");
+
+        /* Build track name piece by piece: */
+        /* 1. track type */
+        av_strlcat(track_name_buf, type, sizeof(track_name_buf));
+        /* 2. track language, if available */
+        if (lang)
+            av_strlcatf(track_name_buf, sizeof(track_name_buf),
+                        "_%s", lang->value);
+        /* 3. special type suffix */
+        /* "_cc" = closed captions, "_ad" = audio_description */
+        if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
+            av_strlcat(track_name_buf, "_cc", sizeof(track_name_buf));
+        else if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
+            av_strlcat(track_name_buf, "_ad", sizeof(track_name_buf));
+
+        param_write_string(pb, "trackName", track_name_buf);
+
         if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
             if (track->par->codec_id == AV_CODEC_ID_H264) {
                 uint8_t *ptr;