121 // some formats want stream headers to be separate |
121 // some formats want stream headers to be separate |
122 if (g_pFormat->flags & AVFMT_GLOBALHEADER) |
122 if (g_pFormat->flags & AVFMT_GLOBALHEADER) |
123 g_pAudio->flags |= CODEC_FLAG_GLOBAL_HEADER; |
123 g_pAudio->flags |= CODEC_FLAG_GLOBAL_HEADER; |
124 |
124 |
125 // open it |
125 // open it |
|
126 #if LIBAVCODEC_VERSION_MAJOR >= 53 |
126 if (avcodec_open2(g_pAudio, g_pACodec, NULL) < 0) |
127 if (avcodec_open2(g_pAudio, g_pACodec, NULL) < 0) |
|
128 #else |
|
129 if (avcodec_open(g_pAudio, g_pACodec) < 0) |
|
130 #endif |
127 { |
131 { |
128 Log("Could not open audio codec %s\n", g_pACodec->long_name); |
132 Log("Could not open audio codec %s\n", g_pACodec->long_name); |
129 return; |
133 return; |
130 } |
134 } |
131 |
135 |
230 { |
234 { |
231 g_pVideo->flags |= CODEC_FLAG_QSCALE; |
235 g_pVideo->flags |= CODEC_FLAG_QSCALE; |
232 g_pVideo->global_quality = g_VQuality*FF_QP2LAMBDA; |
236 g_pVideo->global_quality = g_VQuality*FF_QP2LAMBDA; |
233 } |
237 } |
234 |
238 |
|
239 // some formats want stream headers to be separate |
|
240 if (g_pFormat->flags & AVFMT_GLOBALHEADER) |
|
241 g_pVideo->flags |= CODEC_FLAG_GLOBAL_HEADER; |
|
242 |
|
243 // open the codec |
|
244 #if LIBAVCODEC_VERSION_MAJOR >= 53 |
235 AVDictionary* pDict = NULL; |
245 AVDictionary* pDict = NULL; |
236 if (strcmp(g_pVCodec->name, "libx264") == 0) |
246 if (strcmp(g_pVCodec->name, "libx264") == 0) |
237 av_dict_set(&pDict, "preset", g_pPreset, 0); |
247 av_dict_set(&pDict, "preset", g_pPreset, 0); |
238 |
248 |
239 // some formats want stream headers to be separate |
|
240 if (g_pFormat->flags & AVFMT_GLOBALHEADER) |
|
241 g_pVideo->flags |= CODEC_FLAG_GLOBAL_HEADER; |
|
242 |
|
243 // open the codec |
|
244 if (avcodec_open2(g_pVideo, g_pVCodec, &pDict) < 0) |
249 if (avcodec_open2(g_pVideo, g_pVCodec, &pDict) < 0) |
|
250 #else |
|
251 if (avcodec_open(g_pVideo, g_pVCodec) < 0) |
|
252 #endif |
245 FatalError("Could not open video codec %s", g_pVCodec->long_name); |
253 FatalError("Could not open video codec %s", g_pVCodec->long_name); |
246 |
254 |
247 g_pVFrame = avcodec_alloc_frame(); |
255 g_pVFrame = avcodec_alloc_frame(); |
248 if (!g_pVFrame) |
256 if (!g_pVFrame) |
249 FatalError("Could not allocate frame"); |
257 FatalError("Could not allocate frame"); |