Merge commit 'c5e7ea13d2d4da0c5da91973a547afff6fe9e011'
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 3 Jan 2015 03:08:04 +0000 (04:08 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 3 Jan 2015 03:08:09 +0000 (04:08 +0100)
* commit 'c5e7ea13d2d4da0c5da91973a547afff6fe9e011':
  dashenc: Use delay_moov

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/dashenc.c

diff --combined libavformat/dashenc.c
@@@ -2,20 -2,20 +2,20 @@@
   * MPEG-DASH ISO BMFF segmenter
   * Copyright (c) 2014 Martin Storsjo
   *
 - * This file is part of Libav.
 + * This file is part of FFmpeg.
   *
 - * Libav is free software; you can redistribute it and/or
 + * FFmpeg is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   *
 - * Libav is distributed in the hope that it will be useful,
 + * FFmpeg is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
 - * License along with Libav; if not, write to the Free Software
 + * License along with FFmpeg; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
@@@ -525,7 -525,7 +525,7 @@@ static int write_manifest(AVFormatConte
      avio_printf(out, "</MPD>\n");
      avio_flush(out);
      avio_close(out);
 -    return ff_rename(temp_filename, s->filename);
 +    return ff_rename(temp_filename, s->filename, s);
  }
  
  static int dash_write_header(AVFormatContext *s)
          AVDictionary *opts = NULL;
          char filename[1024];
  
 -        os->bit_rate = s->streams[i]->codec->bit_rate;
 +        os->bit_rate = s->streams[i]->codec->bit_rate ?
 +                       s->streams[i]->codec->bit_rate :
 +                       s->streams[i]->codec->rc_max_rate;
          if (os->bit_rate) {
              snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
                       " bandwidth=\"%d\"", os->bit_rate);
              goto fail;
          os->init_start_pos = 0;
  
-         av_dict_set(&opts, "movflags", "frag_custom+dash", 0);
+         av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
          if ((ret = avformat_write_header(ctx, &opts)) < 0) {
               goto fail;
          }
          avio_flush(ctx->pb);
          av_dict_free(&opts);
  
-         if (c->single_file) {
-             os->init_range_length = avio_tell(ctx->pb);
-         } else {
-             ffurl_close(os->out);
-             os->out = NULL;
-         }
-         av_log(s, AV_LOG_VERBOSE, "Representation %d init segment written to: %s\n", i, filename);
+         av_log(s, AV_LOG_VERBOSE, "Representation %d init segment will be written to: %s\n", i, filename);
  
          s->streams[i]->time_base = st->time_base;
          // If the muxer wants to shift timestamps, request to have them shifted
@@@ -748,7 -740,7 +742,7 @@@ static int dash_flush(AVFormatContext *
      for (i = 0; i < s->nb_streams; i++) {
          OutputStream *os = &c->streams[i];
          char filename[1024] = "", full_path[1024], temp_path[1024];
-         int64_t start_pos = avio_tell(os->ctx->pb);
+         int64_t start_pos;
          int range_length, index_length = 0;
  
          if (!os->packets_written)
                  continue;
          }
  
+         if (!os->init_range_length) {
+             av_write_frame(os->ctx, NULL);
+             os->init_range_length = avio_tell(os->ctx->pb);
+             if (!c->single_file) {
+                 ffurl_close(os->out);
+                 os->out = NULL;
+             }
+         }
+         start_pos = avio_tell(os->ctx->pb);
          if (!c->single_file) {
              dash_fill_tmpl_params(filename, sizeof(filename), c->media_seg_name, i, os->segment_index, os->bit_rate, os->start_dts);
              snprintf(full_path, sizeof(full_path), "%s%s", c->dirname, filename);
          } else {
              ffurl_close(os->out);
              os->out = NULL;
 -            ret = ff_rename(temp_path, full_path);
 +            ret = ff_rename(temp_path, full_path, s);
              if (ret < 0)
                  break;
          }
@@@ -877,7 -880,7 +882,7 @@@ static int dash_write_packet(AVFormatCo
      }
      os->end_dts = pkt->dts + pkt->duration;
      os->packets_written++;
 -    return ff_write_chained(os->ctx, 0, pkt, s);
 +    return ff_write_chained(os->ctx, 0, pkt, s, 0);
  }
  
  static int dash_write_trailer(AVFormatContext *s)