Skip to content
Snippets Groups Projects
Commit 9df9309d authored by Peter Große's avatar Peter Große Committed by Martin Storsjö
Browse files

dashenc: calculate stream bitrate from first segment if not available


Bandwidth information is required in the manifest, but not always
provided by the demuxer. In that case calculate the bandwith based
on the size and duration of the first segment.

Signed-off-by: default avatarPeter Große <pegro@friiks.de>
Signed-off-by: default avatarMartin Storsjö <martin@martin.st>
parent e519dcd9
No related branches found
No related tags found
No related merge requests found
...@@ -834,6 +834,16 @@ static int dash_flush(AVFormatContext *s, int final, int stream) ...@@ -834,6 +834,16 @@ static int dash_flush(AVFormatContext *s, int final, int stream)
if (ret < 0) if (ret < 0)
break; 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); 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); av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d written to: %s\n", i, os->segment_index, full_path);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment