diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-11-14 11:49:57 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-11-14 11:49:57 +0000 |
| commit | 17993784daaa38098b9430824333a2ff72757930 (patch) | |
| tree | b313cd0ce09cc7a6000dd21e96985c93252e543b /rotord/src/libavwrapper.cpp | |
| parent | c95f125f3296d75789685fe1ababe48abe161973 (diff) | |
lower default data rate
Diffstat (limited to 'rotord/src/libavwrapper.cpp')
| -rw-r--r-- | rotord/src/libavwrapper.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp index c4d267a..c3fa235 100644 --- a/rotord/src/libavwrapper.cpp +++ b/rotord/src/libavwrapper.cpp @@ -174,6 +174,8 @@ bool libav::exporter::record(std::string filename){ } fmt = oc->oformat; + av_opt_set(oc->priv_data, "profile", "baseline", AV_OPT_SEARCH_CHILDREN); + // Add the audio and video streams using the default format codecs // * and initialize the codecs. // @@ -181,7 +183,7 @@ bool libav::exporter::record(std::string filename){ audio_st = NULL; fmt->video_codec=AV_CODEC_ID_H264; //AV_CODEC_ID_MPEG4 - //fmt->audio_codec=AV_CODEC_MP3; //guessing, 011013 + fmt->audio_codec=AV_CODEC_ID_AAC; //guessing, 011013 if (fmt->video_codec != AV_CODEC_ID_NONE) { @@ -205,11 +207,22 @@ bool libav::exporter::record(std::string filename){ video_st->codec->gop_size = 75; /* emit one intra frame every 75 frames */ video_st->codec->pix_fmt = PIX_FMT_YUV420P; + cerr<<"Libav::exporter setting bitrate to "<<bitRate<<endl; + + + video_st->codec->bit_rate = bitRate; //need to deal with resolution etc + video_st->codec->rc_max_rate = bitRate; + video_st->codec->rc_min_rate = 0; - //video_st->codec->bit_rate = bitRate; //need to deal with resolution etc - //video_st->codec->rc_max_rate = bitRate; - //video_st->codec->rc_min_rate = 0; + //added 131113 + video_st->codec->rc_buffer_size = bitRate * 2; + //av_dict_set(&options, "profile", "baseline", 0); + //video_st->codec->flags2 = CODEC_FLAG2_FASTPSKIP; + video_st->codec->profile = FF_PROFILE_H264_BASELINE; + video_st->codec->level = 13; + + //how to set profile????? 190913 //this causes a crash //av_opt_set(video_st->codec->priv_data,"profile",FF_PROFILE_H264_CONSTRAINED_BASELINE, 0); @@ -218,6 +231,8 @@ bool libav::exporter::record(std::string filename){ // http://libav-users.943685.n4.nabble.com/Libav-user-H264-encoding-set-target-average-bitrate-td3912529.html // http://trac.ffmpeg.org/wiki/x264EncodingGuide + + // Now that all the parameters are set, we can open the audio and // * video codecs and allocate the necessary encode buffers. // @@ -363,6 +378,7 @@ void libav::exporter::finishRecord(){ AVStream* libav::exporter::add_stream(AVFormatContext *oc, AVCodec **codec,enum AVCodecID codec_id) { + //removed some of the repeats from record() 141113 AVCodecContext *c; AVStream *st; @@ -394,13 +410,11 @@ AVStream* libav::exporter::add_stream(AVFormatContext *oc, AVCodec **codec,enum case AVMEDIA_TYPE_VIDEO: c->codec_id = codec_id; + + //c->bit_rate = bitRate; //need to deal with resolution etc - - - c->bit_rate = bitRate; //need to deal with resolution etc - - c->rc_max_rate = bitRate; - c->rc_min_rate = 0; + // c->rc_max_rate = bitRate; + //c->rc_min_rate = 0; //c->rc_buffer_size = Profile()->m_videoMaxVopSize; //?? /* @@ -419,7 +433,7 @@ AVStream* libav::exporter::add_stream(AVFormatContext *oc, AVCodec **codec,enum // * identical to 1. // c->time_base.den = frameRate; c->time_base.num = 1; - c->gop_size = 12; // emit one intra frame every twelve frames at most // + // c->gop_size = 12; // emit one intra frame every twelve frames at most // c->pix_fmt = AV_PIX_FMT_YUV420P; //ADDED HARDCODED TJR 280513 if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) { // just for testing, we also add B frames // |
