225 |
225 |
static int input_sync;
|
226 |
226 |
static uint64_t limit_filesize = 0;
|
227 |
227 |
static int force_fps = 0;
|
|
228 |
static char *forced_key_frames = NULL;
|
228 |
229 |
|
229 |
230 |
static int pgmyuv_compatibility_hack=0;
|
230 |
231 |
static float dts_delta_threshold = 10;
|
... | ... | |
272 |
273 |
int original_height;
|
273 |
274 |
int original_width;
|
274 |
275 |
|
|
276 |
/* forced key frames */
|
|
277 |
int64_t *forced_kf_pts;
|
|
278 |
int forced_kf_count;
|
|
279 |
int forced_kf_index;
|
|
280 |
|
275 |
281 |
/* audio only */
|
276 |
282 |
int audio_resample;
|
277 |
283 |
ReSampleContext *resample; /* for audio resampling */
|
... | ... | |
1189 |
1195 |
big_picture.pts= ost->sync_opts;
|
1190 |
1196 |
// big_picture.pts= av_rescale(ost->sync_opts, AV_TIME_BASE*(int64_t)enc->time_base.num, enc->time_base.den);
|
1191 |
1197 |
//av_log(NULL, AV_LOG_DEBUG, "%"PRId64" -> encoder\n", ost->sync_opts);
|
|
1198 |
if (ost->forced_kf_index < ost->forced_kf_count &&
|
|
1199 |
big_picture.pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
|
|
1200 |
big_picture.pict_type = FF_I_TYPE;
|
|
1201 |
ost->forced_kf_index++;
|
|
1202 |
}
|
1192 |
1203 |
ret = avcodec_encode_video(enc,
|
1193 |
1204 |
bit_buffer, bit_buffer_size,
|
1194 |
1205 |
&big_picture);
|
... | ... | |
1837 |
1848 |
return 0;
|
1838 |
1849 |
}
|
1839 |
1850 |
|
|
1851 |
static void parse_forced_key_frames(char *kf, AVOutputStream *ost,
|
|
1852 |
AVCodecContext *avctx)
|
|
1853 |
{
|
|
1854 |
char *p;
|
|
1855 |
int n = 1, i;
|
|
1856 |
int64_t t;
|
|
1857 |
|
|
1858 |
for (p = kf; *p; p++)
|
|
1859 |
if (*p == ',')
|
|
1860 |
n++;
|
|
1861 |
ost->forced_kf_count = n;
|
|
1862 |
ost->forced_kf_pts = av_malloc(sizeof(*ost->forced_kf_pts) * n);
|
|
1863 |
if (!ost->forced_kf_pts) {
|
|
1864 |
av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\n");
|
|
1865 |
ffmpeg_exit(1);
|
|
1866 |
}
|
|
1867 |
for (i = 0; i < n; i++) {
|
|
1868 |
p = i ? strchr(p, ',') + 1 : kf;
|
|
1869 |
t = parse_time_or_die("force_key_frames", p, 1);
|
|
1870 |
ost->forced_kf_pts[i] = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base);
|
|
1871 |
}
|
|
1872 |
}
|
|
1873 |
|
1840 |
1874 |
/*
|
1841 |
1875 |
* The following code is the main loop of the file converter
|
1842 |
1876 |
*/
|
... | ... | |
2578 |
2612 |
av_fifo_free(ost->fifo); /* works even if fifo is not
|
2579 |
2613 |
initialized but set to zero */
|
2580 |
2614 |
av_free(ost->pict_tmp.data[0]);
|
|
2615 |
av_free(ost->forced_kf_pts);
|
2581 |
2616 |
if (ost->video_resample)
|
2582 |
2617 |
sws_freeContext(ost->img_resample_ctx);
|
2583 |
2618 |
if (ost->resample)
|
... | ... | |
3333 |
3368 |
video_enc->flags |= CODEC_FLAG_PASS2;
|
3334 |
3369 |
}
|
3335 |
3370 |
}
|
|
3371 |
|
|
3372 |
if (forced_key_frames)
|
|
3373 |
parse_forced_key_frames(forced_key_frames, ost, video_enc);
|
3336 |
3374 |
}
|
3337 |
3375 |
if (video_language) {
|
3338 |
3376 |
av_metadata_set2(&st->metadata, "language", video_language, 0);
|
... | ... | |
3342 |
3380 |
/* reset some key parameters */
|
3343 |
3381 |
video_disable = 0;
|
3344 |
3382 |
av_freep(&video_codec_name);
|
|
3383 |
av_freep(&forced_key_frames);
|
3345 |
3384 |
video_stream_copy = 0;
|
3346 |
3385 |
frame_pix_fmt = PIX_FMT_NONE;
|
3347 |
3386 |
}
|
... | ... | |
3644 |
3683 |
set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL);
|
3645 |
3684 |
|
3646 |
3685 |
nb_streamid_map = 0;
|
|
3686 |
av_freep(&forced_key_frames);
|
3647 |
3687 |
}
|
3648 |
3688 |
|
3649 |
3689 |
/* same option as mencoder */
|
... | ... | |
4094 |
4134 |
{ "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show QP histogram" },
|
4095 |
4135 |
{ "force_fps", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&force_fps}, "force the selected framerate, disable the best supported framerate selection" },
|
4096 |
4136 |
{ "streamid", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" },
|
|
4137 |
{ "force_key_frames", OPT_STRING | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void *)&forced_key_frames}, "force key frames at specified timestamps", "timestamps" },
|
4097 |
4138 |
|
4098 |
4139 |
/* audio options */
|
4099 |
4140 |
{ "ab", OPT_FUNC2 | HAS_ARG | OPT_AUDIO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },
|