diff options
author | Rodger Combs <rodger.combs@gmail.com> | 2016-04-07 19:36:39 -0500 |
---|---|---|
committer | Rodger Combs <rodger.combs@gmail.com> | 2016-10-24 03:53:23 -0500 |
commit | 42cb050a05020e9da18136b8cd65944b378b74eb (patch) | |
tree | 7e54b13c12922a89a05bcb7181d5c2fd3f5729ff /libavformat/dashenc.c | |
parent | c972a28fc3defe7cacee281fe1a30b9a026737ed (diff) |
lavf/movenc+dashenc: add automatic bitstream filtering
This is disabled by default when the empty_moov flag is enabled
Diffstat (limited to 'libavformat/dashenc.c')
-rw-r--r-- | libavformat/dashenc.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 08480524f6..534fa754b4 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -551,7 +551,7 @@ static int write_manifest(AVFormatContext *s, int final) return avpriv_io_move(temp_filename, s->filename); } -static int dash_write_header(AVFormatContext *s) +static int dash_init(AVFormatContext *s) { DASHContext *c = s->priv_data; int ret = 0, i; @@ -643,7 +643,7 @@ static int dash_write_header(AVFormatContext *s) os->init_start_pos = 0; av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0); - if ((ret = avformat_write_header(ctx, &opts)) < 0) + if ((ret = avformat_init_output(ctx, &opts)) < 0) return ret; os->ctx_inited = 1; avio_flush(ctx->pb); @@ -682,6 +682,20 @@ static int dash_write_header(AVFormatContext *s) av_log(s, AV_LOG_WARNING, "no video stream and no min seg duration set\n"); return AVERROR(EINVAL); } + return 0; +} + +static int dash_write_header(AVFormatContext *s) +{ + DASHContext *c = s->priv_data; + int i, ret; + for (i = 0; i < s->nb_streams; i++) { + OutputStream *os = &c->streams[i]; + if ((ret = avformat_write_header(os->ctx, NULL)) < 0) { + dash_free(s); + return ret; + } + } ret = write_manifest(s, 0); if (!ret) av_log(s, AV_LOG_VERBOSE, "Manifest written to: %s\n", s->filename); @@ -978,6 +992,29 @@ static int dash_write_trailer(AVFormatContext *s) return 0; } +static int dash_check_bitstream(struct AVFormatContext *s, const AVPacket *avpkt) +{ + DASHContext *c = s->priv_data; + OutputStream *os = &c->streams[avpkt->stream_index]; + AVFormatContext *oc = os->ctx; + if (oc->oformat->check_bitstream) { + int ret; + AVPacket pkt = *avpkt; + pkt.stream_index = 0; + ret = oc->oformat->check_bitstream(oc, &pkt); + if (ret == 1) { + AVStream *st = s->streams[avpkt->stream_index]; + AVStream *ost = oc->streams[0]; + st->internal->bsfcs = ost->internal->bsfcs; + st->internal->nb_bsfcs = ost->internal->nb_bsfcs; + ost->internal->bsfcs = NULL; + ost->internal->nb_bsfcs = 0; + } + return ret; + } + return 1; +} + #define OFFSET(x) offsetof(DASHContext, x) #define E AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { @@ -1008,10 +1045,12 @@ AVOutputFormat ff_dash_muxer = { .audio_codec = AV_CODEC_ID_AAC, .video_codec = AV_CODEC_ID_H264, .flags = AVFMT_GLOBALHEADER | AVFMT_NOFILE | AVFMT_TS_NEGATIVE, + .init = dash_init, .write_header = dash_write_header, .write_packet = dash_write_packet, .write_trailer = dash_write_trailer, .deinit = dash_free, .codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 }, + .check_bitstream = dash_check_bitstream, .priv_class = &dash_class, }; |