ffmpeg | branch: master | Rodger Combs <rodger.co...@gmail.com> | Tue Sep 26 14:02:44 2017 -0300| [3b9ef13588360b16c22ece7521ebd9b11f9ffb17] | committer: James Almer
Merge commit '9df9309d233f59d9706444a1e24ac24139f2640d' * commit '9df9309d233f59d9706444a1e24ac24139f2640d': dashenc: calculate stream bitrate from first segment if not available Merged-by: Rodger Combs <rodger.co...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3b9ef13588360b16c22ece7521ebd9b11f9ffb17 --- libavformat/dashenc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index ca24015115..089a3e7b01 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -754,6 +754,16 @@ static int dash_flush(AVFormatContext *s, int final, int stream) break; } } + + if (!os->bit_rate) { + // calculate average bitrate of first segment + int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / (os->max_pts - os->start_pts); + if (bitrate >= 0) { + os->bit_rate = bitrate; + snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), + " bandwidth=\"%d\"", os->bit_rate); + } + } add_segment(os, filename, os->start_pts, os->max_pts - os->start_pts, start_pos, range_length, index_length); av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d written to: %s\n", i, os->segment_index, full_path); } ====================================================================== diff --cc libavformat/dashenc.c index ca24015115,21acb9006c..089a3e7b01 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@@ -747,13 -830,20 +747,23 @@@ static int dash_flush(AVFormatContext * find_index_range(s, full_path, start_pos, &index_length); } else { ff_format_io_close(s, &os->out); - ret = ff_rename(temp_path, full_path); - if (ret < 0) - break; + + if (use_rename) { + ret = avpriv_io_move(temp_path, full_path); + if (ret < 0) + break; + } } + + if (!os->bit_rate) { + // calculate average bitrate of first segment + int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / (os->max_pts - os->start_pts); + if (bitrate >= 0) { + os->bit_rate = bitrate; + snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), + " bandwidth=\"%d\"", os->bit_rate); + } + } add_segment(os, filename, os->start_pts, os->max_pts - os->start_pts, start_pos, range_length, index_length); av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d written to: %s\n", i, os->segment_index, full_path); } _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog