Message ID | 1487777969-16201-1-git-send-email-przemyslaw.sobala@grupawp.pl |
---|---|
State | Superseded |
Headers | show |
On Wednesday, February 22, 2017, Przemysław Sobala < przemyslaw.sobala@gmail.com> wrote: > From: Przemysław Sobala <przemyslaw.sobala@gmail.com <javascript:;>> > > Provides a way to change bandwidth (bitrate) parameter after CRF H.264 > encoding (details: http://ffmpeg.org/pipermail/libav-user/2017-February/ > 010141.html) > > Signed-off-by: Przemysław Sobala <przemyslaw.sobala@grupawp.pl > <javascript:;>> > --- > libavformat/dashenc.c | 42 ++++++++++++++++++++++++++++++------------ > 1 file changed, 30 insertions(+), 12 deletions(-) > > diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c > index fa56505..011d2ea 100644 > --- a/libavformat/dashenc.c > +++ b/libavformat/dashenc.c > @@ -561,6 +561,30 @@ static int write_manifest(AVFormatContext *s, int > final) > return 0; > } > > +static int set_bitrate(AVFormatContext *s) > +{ > + DASHContext *c = s->priv_data; > + int i; > + > + for (i = 0; i < s->nb_streams; i++) { > + OutputStream *os = &c->streams[i]; > + > + os->bit_rate = s->streams[i]->codecpar->bit_rate; > + if (os->bit_rate) { > + snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), > + " bandwidth=\"%d\"", os->bit_rate); > + } else { > + int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ? > + AV_LOG_ERROR : AV_LOG_WARNING; > + av_log(s, level, "No bit rate set for stream %d\n", i); > + if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT) > + return AVERROR(EINVAL); > + } > + } > + > + return 0; > +} > + > static int dash_init(AVFormatContext *s) > { > DASHContext *c = s->priv_data; > @@ -597,6 +621,10 @@ static int dash_init(AVFormatContext *s) > if (!c->streams) > return AVERROR(ENOMEM); > > + ret = set_bitrate(s); > + if (ret < 0) > + return ret; > + > for (i = 0; i < s->nb_streams; i++) { > OutputStream *os = &c->streams[i]; > AVFormatContext *ctx; > @@ -604,18 +632,6 @@ static int dash_init(AVFormatContext *s) > AVDictionary *opts = NULL; > char filename[1024]; > > - os->bit_rate = s->streams[i]->codecpar->bit_rate; > - if (os->bit_rate) { > - snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), > - " bandwidth=\"%d\"", os->bit_rate); > - } else { > - int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ? > - AV_LOG_ERROR : AV_LOG_WARNING; > - av_log(s, level, "No bit rate set for stream %d\n", i); > - if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT) > - return AVERROR(EINVAL); > - } > - > ctx = avformat_alloc_context(); > if (!ctx) > return AVERROR(ENOMEM); > @@ -981,6 +997,8 @@ static int dash_write_trailer(AVFormatContext *s) > { > DASHContext *c = s->priv_data; > > + set_bitrate(s); > + > if (s->nb_streams > 0) { > OutputStream *os = &c->streams[0]; > // If no segments have been written so far, try to do a crude > -- > 2.7.4 > > Any comment on this? -- Best regards Przemysław Sobala
23 lut 2017 21:39 "Przemysław Sobala" <przemyslaw.sobala@gmail.com> napisał(a): On Wednesday, February 22, 2017, Przemysław Sobala < przemyslaw.sobala@gmail.com> wrote: > From: Przemysław Sobala <przemyslaw.sobala@gmail.com> > > Provides a way to change bandwidth (bitrate) parameter after CRF H.264 > encoding (details: http://ffmpeg.org/pipermail/li > bav-user/2017-February/010141.html) > > Signed-off-by: Przemysław Sobala <przemyslaw.sobala@grupawp.pl> > --- > libavformat/dashenc.c | 42 ++++++++++++++++++++++++++++++------------ > 1 file changed, 30 insertions(+), 12 deletions(-) > > diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c > index fa56505..011d2ea 100644 > --- a/libavformat/dashenc.c > +++ b/libavformat/dashenc.c > @@ -561,6 +561,30 @@ static int write_manifest(AVFormatContext *s, int > final) > return 0; > } > > +static int set_bitrate(AVFormatContext *s) > +{ > + DASHContext *c = s->priv_data; > + int i; > + > + for (i = 0; i < s->nb_streams; i++) { > + OutputStream *os = &c->streams[i]; > + > + os->bit_rate = s->streams[i]->codecpar->bit_rate; > + if (os->bit_rate) { > + snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), > + " bandwidth=\"%d\"", os->bit_rate); > + } else { > + int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ? > + AV_LOG_ERROR : AV_LOG_WARNING; > + av_log(s, level, "No bit rate set for stream %d\n", i); > + if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT) > + return AVERROR(EINVAL); > + } > + } > + > + return 0; > +} > + > static int dash_init(AVFormatContext *s) > { > DASHContext *c = s->priv_data; > @@ -597,6 +621,10 @@ static int dash_init(AVFormatContext *s) > if (!c->streams) > return AVERROR(ENOMEM); > > + ret = set_bitrate(s); > + if (ret < 0) > + return ret; > + > for (i = 0; i < s->nb_streams; i++) { > OutputStream *os = &c->streams[i]; > AVFormatContext *ctx; > @@ -604,18 +632,6 @@ static int dash_init(AVFormatContext *s) > AVDictionary *opts = NULL; > char filename[1024]; > > - os->bit_rate = s->streams[i]->codecpar->bit_rate; > - if (os->bit_rate) { > - snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), > - " bandwidth=\"%d\"", os->bit_rate); > - } else { > - int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ? > - AV_LOG_ERROR : AV_LOG_WARNING; > - av_log(s, level, "No bit rate set for stream %d\n", i); > - if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT) > - return AVERROR(EINVAL); > - } > - > ctx = avformat_alloc_context(); > if (!ctx) > return AVERROR(ENOMEM); > @@ -981,6 +997,8 @@ static int dash_write_trailer(AVFormatContext *s) > { > DASHContext *c = s->priv_data; > > + set_bitrate(s); > + > if (s->nb_streams > 0) { > OutputStream *os = &c->streams[0]; > // If no segments have been written so far, try to do a crude > -- > 2.7.4 > > Any comment on this? -- Best regards Przemysław Sobala ping? -- Regards Przemysław Sobala
On Wed, Mar 01, 2017 at 11:48:47PM +0100, Przemysław Sobala wrote: > 23 lut 2017 21:39 "Przemysław Sobala" <przemyslaw.sobala@gmail.com> > napisał(a): > > On Wednesday, February 22, 2017, Przemysław Sobala < > przemyslaw.sobala@gmail.com> wrote: > > > From: Przemysław Sobala <przemyslaw.sobala@gmail.com> > > > > Provides a way to change bandwidth (bitrate) parameter after CRF H.264 > > encoding (details: http://ffmpeg.org/pipermail/li > > bav-user/2017-February/010141.html) > > > > Signed-off-by: Przemysław Sobala <przemyslaw.sobala@grupawp.pl> > > --- > > libavformat/dashenc.c | 42 ++++++++++++++++++++++++++++++------------ > > 1 file changed, 30 insertions(+), 12 deletions(-) > > > > diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c > > index fa56505..011d2ea 100644 > > --- a/libavformat/dashenc.c > > +++ b/libavformat/dashenc.c > > @@ -561,6 +561,30 @@ static int write_manifest(AVFormatContext *s, int > > final) > > return 0; > > } > > > > +static int set_bitrate(AVFormatContext *s) > > +{ > > + DASHContext *c = s->priv_data; > > + int i; > > + > > + for (i = 0; i < s->nb_streams; i++) { > > + OutputStream *os = &c->streams[i]; > > + > > + os->bit_rate = s->streams[i]->codecpar->bit_rate; > > + if (os->bit_rate) { > > + snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), > > + " bandwidth=\"%d\"", os->bit_rate); > > + } else { > > + int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ? > > + AV_LOG_ERROR : AV_LOG_WARNING; > > + av_log(s, level, "No bit rate set for stream %d\n", i); > > + if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT) > > + return AVERROR(EINVAL); > > + } > > + } > > + > > + return 0; > > +} > > + > > static int dash_init(AVFormatContext *s) > > { > > DASHContext *c = s->priv_data; > > @@ -597,6 +621,10 @@ static int dash_init(AVFormatContext *s) > > if (!c->streams) > > return AVERROR(ENOMEM); > > > > + ret = set_bitrate(s); > > + if (ret < 0) > > + return ret; > > + > > for (i = 0; i < s->nb_streams; i++) { > > OutputStream *os = &c->streams[i]; > > AVFormatContext *ctx; > > @@ -604,18 +632,6 @@ static int dash_init(AVFormatContext *s) > > AVDictionary *opts = NULL; > > char filename[1024]; > > > > - os->bit_rate = s->streams[i]->codecpar->bit_rate; > > - if (os->bit_rate) { > > - snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), > > - " bandwidth=\"%d\"", os->bit_rate); > > - } else { > > - int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ? > > - AV_LOG_ERROR : AV_LOG_WARNING; > > - av_log(s, level, "No bit rate set for stream %d\n", i); > > - if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT) > > - return AVERROR(EINVAL); > > - } > > - > > ctx = avformat_alloc_context(); > > if (!ctx) > > return AVERROR(ENOMEM); > > @@ -981,6 +997,8 @@ static int dash_write_trailer(AVFormatContext *s) > > { > > DASHContext *c = s->priv_data; > > > > + set_bitrate(s); > > + > > if (s->nb_streams > 0) { > > OutputStream *os = &c->streams[0]; > > // If no segments have been written so far, try to do a crude > > -- > > 2.7.4 > > > > > Any comment on this? please describe what this does in the commit message instead of linking to some mail, i had no idea before i opened it in my browser but the link might not be eternally valid, these mailman numbers for example can get messed up, it should not happen but URLs are always risky [...]
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index fa56505..011d2ea 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -561,6 +561,30 @@ static int write_manifest(AVFormatContext *s, int final) return 0; } +static int set_bitrate(AVFormatContext *s) +{ + DASHContext *c = s->priv_data; + int i; + + for (i = 0; i < s->nb_streams; i++) { + OutputStream *os = &c->streams[i]; + + os->bit_rate = s->streams[i]->codecpar->bit_rate; + if (os->bit_rate) { + snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), + " bandwidth=\"%d\"", os->bit_rate); + } else { + int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ? + AV_LOG_ERROR : AV_LOG_WARNING; + av_log(s, level, "No bit rate set for stream %d\n", i); + if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT) + return AVERROR(EINVAL); + } + } + + return 0; +} + static int dash_init(AVFormatContext *s) { DASHContext *c = s->priv_data; @@ -597,6 +621,10 @@ static int dash_init(AVFormatContext *s) if (!c->streams) return AVERROR(ENOMEM); + ret = set_bitrate(s); + if (ret < 0) + return ret; + for (i = 0; i < s->nb_streams; i++) { OutputStream *os = &c->streams[i]; AVFormatContext *ctx; @@ -604,18 +632,6 @@ static int dash_init(AVFormatContext *s) AVDictionary *opts = NULL; char filename[1024]; - os->bit_rate = s->streams[i]->codecpar->bit_rate; - if (os->bit_rate) { - snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), - " bandwidth=\"%d\"", os->bit_rate); - } else { - int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ? - AV_LOG_ERROR : AV_LOG_WARNING; - av_log(s, level, "No bit rate set for stream %d\n", i); - if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT) - return AVERROR(EINVAL); - } - ctx = avformat_alloc_context(); if (!ctx) return AVERROR(ENOMEM); @@ -981,6 +997,8 @@ static int dash_write_trailer(AVFormatContext *s) { DASHContext *c = s->priv_data; + set_bitrate(s); + if (s->nb_streams > 0) { OutputStream *os = &c->streams[0]; // If no segments have been written so far, try to do a crude