summaryrefslogtreecommitdiff
path: root/rotord/src/libavwrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src/libavwrapper.cpp')
-rw-r--r--rotord/src/libavwrapper.cpp47
1 files changed, 27 insertions, 20 deletions
diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp
index 65bbeb5..406adb1 100644
--- a/rotord/src/libavwrapper.cpp
+++ b/rotord/src/libavwrapper.cpp
@@ -168,9 +168,22 @@ bool libav::exporter::record(std::string filename){
video_st->time_base = video_st->codec->time_base;
//audioStream->time_base = codecCtx->time_base; //???has the capability of crashing
- video_st->codec->gop_size = 10; /* emit one intra frame every ten frames */
+ video_st->codec->gop_size = 75; /* emit one intra frame every ten frames */
video_st->codec->pix_fmt = PIX_FMT_YUV420P;
+
+ //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;
+
+ //how to set profile????? 190913
+ //this causes a crash
+ //av_opt_set(video_st->codec->priv_data,"profile",FF_PROFILE_H264_CONSTRAINED_BASELINE, 0);
+ //
+ // http://libav-users.943685.n4.nabble.com/Libav-user-encoding-bitrate-wrong-td4433740.html
+ // 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. //
if (video_st)
@@ -195,27 +208,13 @@ bool libav::exporter::record(std::string filename){
}
}
-<<<<<<< HEAD
AVDictionary *opts = NULL; // "create" an empty dictionary
+ av_dict_set(opts, "movflags", "empty_moov", 0);
- // Write the stream header, if any. //
- int ret = avformat_write_header(oc, &opts);
-=======
- ///
- /// trying to change the moov atom 170913
-
- //MOVMuxContext *mov = oc->priv_data;
- //mov->flags |= FF_MOV_FLAG_FRAGMENT;
- //AVDictionary* options;
- //av_dict_set(&options, "vprofile", "baseline", 0);
-
- ///
- ///
// Write the stream header, if any. //
- int ret = avformat_write_header(oc, NULL); //&options); //
->>>>>>> e8bfadcde7063ebaac5c8121747109dd574abf61
+ int ret = avformat_write_header(oc, &opts);
if (ret < 0) {
std::cerr <<"Error occurred when opening output file:" <<endl; // av_err2str(ret) << std::endl;
return false;
@@ -355,10 +354,18 @@ AVStream* libav::exporter::add_stream(AVFormatContext *oc, AVCodec **codec,enum
case AVMEDIA_TYPE_VIDEO:
c->codec_id = codec_id;
- c->bit_rate = 400000; //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_buffer_size = Profile()->m_videoMaxVopSize; //??
+
+
// Resolution must be a multiple of two. //
- c->width = 352;
- c->height = 288;
+ //c->width = 352;
+ //c->height = 288;
+
+
// timebase: This is the fundamental unit of time (in seconds) in terms
// * of which frame timestamps are represented. For fixed-fps content,
// * timebase should be 1/framerate and timestamp increments should be