sidxindex: Write mimeType=audio/mp4 for audio-only representations

Message ID 1416757274-14290-1-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö Nov. 23, 2014, 3:41 p.m.
This fixes playback with dash.js, when the input is one separate
mp4 file per track.
---
 tools/sidxindex.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Luca Barbato Nov. 23, 2014, 7:07 p.m. | #1
On 23/11/14 16:41, Martin Storsjö wrote:
> This fixes playback with dash.js, when the input is one separate
> mp4 file per track.
> ---
>   tools/sidxindex.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/sidxindex.c b/tools/sidxindex.c
> index da41d09..cb1b6c9 100644
> --- a/tools/sidxindex.c
> +++ b/tools/sidxindex.c
> @@ -327,7 +327,7 @@ static int output_mpd(struct Tracks *tracks, const char *filename)
>           for (i = 0; i < nb_tracks[set]; ) {
>               struct Track *first_track = adaptation_sets[set][i];
>               int width = 0, height = 0, sample_rate = 0, channels = 0, bitrate = 0;
> -            fprintf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"video/mp4\" codecs=\"", i);
> +            fprintf(out, "\t\t\t<Representation id=\"%d\" codecs=\"", i);
>               for (j = i; j < nb_tracks[set]; j++) {
>                   struct Track *track = adaptation_sets[set][j];
>                   if (strcmp(track->name, first_track->name))
> @@ -345,7 +345,8 @@ static int output_mpd(struct Tracks *tracks, const char *filename)
>                       fprintf(out, ",");
>                   fprintf(out, "%s", track->codec_str);
>               }
> -            fprintf(out, "\" bandwidth=\"%d\"", bitrate);
> +            fprintf(out, "\" mimeType=\"%s/mp4\" bandwidth=\"%d\"",
> +                    (sample_rate && !width) ? "audio" : "video", bitrate);
>               if (width > 0 && height > 0)
>                   fprintf(out, " width=\"%d\" height=\"%d\"", width, height);
>               if (sample_rate > 0)
>

Ok.
Martin Storsjö Nov. 23, 2014, 7:31 p.m. | #2
On Sun, 23 Nov 2014, Martin Storsjö wrote:

> This fixes playback with dash.js, when the input is one separate
> mp4 file per track.
> ---
> tools/sidxindex.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/sidxindex.c b/tools/sidxindex.c
> index da41d09..cb1b6c9 100644
> --- a/tools/sidxindex.c
> +++ b/tools/sidxindex.c
> @@ -327,7 +327,7 @@ static int output_mpd(struct Tracks *tracks, const char *filename)
>         for (i = 0; i < nb_tracks[set]; ) {
>             struct Track *first_track = adaptation_sets[set][i];
>             int width = 0, height = 0, sample_rate = 0, channels = 0, bitrate = 0;
> -            fprintf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"video/mp4\" codecs=\"", i);
> +            fprintf(out, "\t\t\t<Representation id=\"%d\" codecs=\"", i);
>             for (j = i; j < nb_tracks[set]; j++) {
>                 struct Track *track = adaptation_sets[set][j];
>                 if (strcmp(track->name, first_track->name))
> @@ -345,7 +345,8 @@ static int output_mpd(struct Tracks *tracks, const char *filename)
>                     fprintf(out, ",");
>                 fprintf(out, "%s", track->codec_str);
>             }
> -            fprintf(out, "\" bandwidth=\"%d\"", bitrate);
> +            fprintf(out, "\" mimeType=\"%s/mp4\" bandwidth=\"%d\"",
> +                    (sample_rate && !width) ? "audio" : "video", bitrate);

I'd probably simplify this even further into

width ? "video" : "audio"

Then you still get video/mp4 for video and video+audio. The behaviour for 
the case when neither of them exist doesn't matter since non-audio/video 
tracks are filtered out already earlier.

// Martin
Luca Barbato Nov. 23, 2014, 7:33 p.m. | #3
On 23/11/14 20:31, Martin Storsjö wrote:
> On Sun, 23 Nov 2014, Martin Storsjö wrote:
>
>> This fixes playback with dash.js, when the input is one separate
>> mp4 file per track.
>> ---
>> tools/sidxindex.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/sidxindex.c b/tools/sidxindex.c
>> index da41d09..cb1b6c9 100644
>> --- a/tools/sidxindex.c
>> +++ b/tools/sidxindex.c
>> @@ -327,7 +327,7 @@ static int output_mpd(struct Tracks *tracks, const
>> char *filename)
>>         for (i = 0; i < nb_tracks[set]; ) {
>>             struct Track *first_track = adaptation_sets[set][i];
>>             int width = 0, height = 0, sample_rate = 0, channels = 0,
>> bitrate = 0;
>> -            fprintf(out, "\t\t\t<Representation id=\"%d\"
>> mimeType=\"video/mp4\" codecs=\"", i);
>> +            fprintf(out, "\t\t\t<Representation id=\"%d\" codecs=\"",
>> i);
>>             for (j = i; j < nb_tracks[set]; j++) {
>>                 struct Track *track = adaptation_sets[set][j];
>>                 if (strcmp(track->name, first_track->name))
>> @@ -345,7 +345,8 @@ static int output_mpd(struct Tracks *tracks, const
>> char *filename)
>>                     fprintf(out, ",");
>>                 fprintf(out, "%s", track->codec_str);
>>             }
>> -            fprintf(out, "\" bandwidth=\"%d\"", bitrate);
>> +            fprintf(out, "\" mimeType=\"%s/mp4\" bandwidth=\"%d\"",
>> +                    (sample_rate && !width) ? "audio" : "video",
>> bitrate);
>
> I'd probably simplify this even further into
>
> width ? "video" : "audio"
>
> Then you still get video/mp4 for video and video+audio. The behaviour
> for the case when neither of them exist doesn't matter since
> non-audio/video tracks are filtered out already earlier.
>

even better.

Patch

diff --git a/tools/sidxindex.c b/tools/sidxindex.c
index da41d09..cb1b6c9 100644
--- a/tools/sidxindex.c
+++ b/tools/sidxindex.c
@@ -327,7 +327,7 @@  static int output_mpd(struct Tracks *tracks, const char *filename)
         for (i = 0; i < nb_tracks[set]; ) {
             struct Track *first_track = adaptation_sets[set][i];
             int width = 0, height = 0, sample_rate = 0, channels = 0, bitrate = 0;
-            fprintf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"video/mp4\" codecs=\"", i);
+            fprintf(out, "\t\t\t<Representation id=\"%d\" codecs=\"", i);
             for (j = i; j < nb_tracks[set]; j++) {
                 struct Track *track = adaptation_sets[set][j];
                 if (strcmp(track->name, first_track->name))
@@ -345,7 +345,8 @@  static int output_mpd(struct Tracks *tracks, const char *filename)
                     fprintf(out, ",");
                 fprintf(out, "%s", track->codec_str);
             }
-            fprintf(out, "\" bandwidth=\"%d\"", bitrate);
+            fprintf(out, "\" mimeType=\"%s/mp4\" bandwidth=\"%d\"",
+                    (sample_rate && !width) ? "audio" : "video", bitrate);
             if (width > 0 && height > 0)
                 fprintf(out, " width=\"%d\" height=\"%d\"", width, height);
             if (sample_rate > 0)