胡斌

set the encode parameter ultrafast

@@ -216,7 +216,7 @@ int CAVTranscoder::open_output_file(const char *filename) @@ -216,7 +216,7 @@ int CAVTranscoder::open_output_file(const char *filename)
216 enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; 216 enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
217 217
218 if (0 == i) { 218 if (0 == i) {
219 - encoder = avcodec_find_encoder(AV_CODEC_ID_H264);; 219 + encoder = avcodec_find_encoder(AV_CODEC_ID_H264);
220 if (!encoder) { 220 if (!encoder) {
221 av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n"); 221 av_log(NULL, AV_LOG_FATAL, "Necessary encoder not found\n");
222 return AVERROR_INVALIDDATA; 222 return AVERROR_INVALIDDATA;
@@ -241,15 +241,15 @@ int CAVTranscoder::open_output_file(const char *filename) @@ -241,15 +241,15 @@ int CAVTranscoder::open_output_file(const char *filename)
241 enc_ctx->qmin = 10; 241 enc_ctx->qmin = 10;
242 enc_ctx->qmax = 30; 242 enc_ctx->qmax = 30;
243 enc_ctx->qcompress = 0.6f; 243 enc_ctx->qcompress = 0.6f;
  244 +
244 enc_ctx->framerate.den = 20; 245 enc_ctx->framerate.den = 20;
245 enc_ctx->framerate.num = 1; 246 enc_ctx->framerate.num = 1;
  247 + enc_ctx->max_b_frames = 0;
246 248
247 AVDictionary * d = NULL; 249 AVDictionary * d = NULL;
248 - char *k = av_strdup("preset"); // if your strings are already allocated,  
249 - char *v = av_strdup("ultrafast"); // you can avoid copying them like this  
250 - av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); 250 + av_dict_set(&d, "preset", "ultrafast", 0);
251 /* Third parameter can be used to pass settings to encoder */ 251 /* Third parameter can be used to pass settings to encoder */
252 - ret = avcodec_open2(enc_ctx, encoder, NULL); 252 + ret = avcodec_open2(enc_ctx, encoder, &d);
253 if (ret < 0) { 253 if (ret < 0) {
254 av_log(NULL, AV_LOG_ERROR, "Cannot open video encoder for stream #%u\n", i); 254 av_log(NULL, AV_LOG_ERROR, "Cannot open video encoder for stream #%u\n", i);
255 return ret; 255 return ret;