Merge commit 'b8d2630c5327d2818d05c8a48be0417905d8e0fd'
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 10 May 2015 23:56:02 +0000 (01:56 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 10 May 2015 23:56:11 +0000 (01:56 +0200)
* commit 'b8d2630c5327d2818d05c8a48be0417905d8e0fd':
  dashenc: Reduce the segment duration if cutting out parts with edit lists

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
   */
  
@@@ -507,10 -507,8 +507,10 @@@ static int write_manifest(AVFormatConte
          for (i = 0; i < s->nb_streams; i++) {
              AVStream *st = s->streams[i];
              OutputStream *os = &c->streams[i];
 +
              if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO)
                  continue;
 +
              avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"video/mp4\" codecs=\"%s\"%s width=\"%d\" height=\"%d\">\n", i, os->codec_str, os->bandwidth_str, st->codec->width, st->codec->height);
              output_segment_list(&c->streams[i], out, c);
              avio_printf(out, "\t\t\t</Representation>\n");
          for (i = 0; i < s->nb_streams; i++) {
              AVStream *st = s->streams[i];
              OutputStream *os = &c->streams[i];
 +
              if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO)
                  continue;
 +
              avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"audio/mp4\" codecs=\"%s\"%s audioSamplingRate=\"%d\">\n", i, os->codec_str, os->bandwidth_str, st->codec->sample_rate);
              avio_printf(out, "\t\t\t\t<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"%d\" />\n", st->codec->channels);
              output_segment_list(&c->streams[i], out, c);
      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);
@@@ -702,9 -696,11 +702,11 @@@ static int add_segment(OutputStream *os
          return AVERROR(ENOMEM);
      av_strlcpy(seg->file, file, sizeof(seg->file));
      seg->time = time;
-     if (seg->time < 0) // If pts<0, it is expected to be cut away with an edit list
-         seg->time = 0;
      seg->duration = duration;
+     if (seg->time < 0) { // If pts<0, it is expected to be cut away with an edit list
+         seg->duration += seg->time;
+         seg->time = 0;
+     }
      seg->start_pos = start_pos;
      seg->range_length = range_length;
      seg->index_length = index_length;
@@@ -831,7 -827,7 +833,7 @@@ static int dash_flush(AVFormatContext *
          } 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;
          }
@@@ -937,7 -933,7 +939,7 @@@ static int dash_write_packet(AVFormatCo
      else
          os->max_pts = FFMAX(os->max_pts, pkt->pts + 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)