胡斌

set the encode parameter ultrafast

... ... @@ -216,7 +216,7 @@ int CAVTranscoder::open_output_file(const char *filename)
enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
if (0 == i) {
encoder = avcodec_find_encoder(AV_CODEC_ID_H264);;
encoder = avcodec_find_encoder(AV_CODEC_ID_H264);
if (!encoder) {
av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n");
return AVERROR_INVALIDDATA;
... ... @@ -235,21 +235,21 @@ int CAVTranscoder::open_output_file(const char *filename)
enc_ctx->time_base.num = 1;
enc_ctx->time_base.den = 20;
enc_ctx->gop_size = 20;
enc_ctx->me_range = 16;
enc_ctx->max_qdiff = 4;
enc_ctx->qmin = 10;
enc_ctx->qmax = 30;
enc_ctx->qcompress = 0.6f;
enc_ctx->framerate.den = 20;
enc_ctx->framerate.num = 1;
enc_ctx->max_b_frames = 0;
AVDictionary * d = NULL;
char *k = av_strdup("preset"); // if your strings are already allocated,
char *v = av_strdup("ultrafast"); // you can avoid copying them like this
av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
/* Third parameter can be used to pass settings to encoder */
ret = avcodec_open2(enc_ctx, encoder, NULL);
AVDictionary * d = NULL;
av_dict_set(&d, "preset", "ultrafast", 0);
/* Third parameter can be used to pass settings to encoder */
ret = avcodec_open2(enc_ctx, encoder, &d);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot open video encoder for stream #%u\n", i);
return ret;
... ...