X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg_opt.c;h=048c3df944aa6f6b7759bbd55dc7a202f9d741d4;hb=57848ef3c6a135caeb1f8034cadc157a38947009;hp=1c5794ce092b8be221150fb065e53f44da7f7a12;hpb=dac7b278026401a67795181c22f6eaaf72095074;p=ffmpeg diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 1c5794ce092..048c3df944a 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -40,6 +40,7 @@ #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "libavutil/pixfmt.h" +#include "libavutil/time_internal.h" #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\ {\ @@ -1203,6 +1204,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e uint32_t tag = strtol(codec_tag, &next, 0); if (*next) tag = AV_RL32(codec_tag); + ost->st->codec->codec_tag = ost->enc_ctx->codec_tag = tag; } @@ -1917,7 +1919,7 @@ static int open_output_file(OptionsContext *o, const char *filename) for (i = 0; i < nb_input_streams; i++) { int new_area; ist = input_streams[i]; - new_area = ist->st->codec->width * ist->st->codec->height; + new_area = ist->st->codec->width * ist->st->codec->height + 100000000*!!ist->st->codec_info_nb_frames; if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) new_area = 1; if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && @@ -2026,6 +2028,7 @@ loop_end: if(o-> data_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_DATA) continue; + ost = NULL; switch (ist->st->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break; case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (o, oc, src_idx); break; @@ -2049,6 +2052,9 @@ loop_end: exit_program(1); } } + if (ost) + ost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index + + map->sync_stream_index]; } } } @@ -2237,6 +2243,7 @@ loop_end: char type, *val; const char *stream_spec; int index = 0, j, ret = 0; + char now_time[256]; val = strchr(o->metadata[i].u.str, '='); if (!val) { @@ -2246,6 +2253,17 @@ loop_end: } *val++ = 0; + if (!strcmp(o->metadata[i].u.str, "creation_time") && + !strcmp(val, "now")) { + time_t now = time(0); + struct tm *ptm, tmbuf; + ptm = localtime_r(&now, &tmbuf); + if (ptm) { + if (strftime(now_time, sizeof(now_time), "%Y-%m-%d %H:%M:%S", ptm)) + val = now_time; + } + } + parse_meta_type(o->metadata[i].specifier, &type, &index, &stream_spec); if (type == 's') { for (j = 0; j < oc->nb_streams; j++) { @@ -2438,6 +2456,11 @@ static int opt_vstats(void *optctx, const char *opt, const char *arg) time_t today2 = time(NULL); struct tm *today = localtime(&today2); + if (!today) { // maybe tomorrow + av_log(NULL, AV_LOG_FATAL, "Unable to get current time: %s\n", strerror(errno)); + exit_program(1); + } + snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min, today->tm_sec); return opt_vstats_file(NULL, opt, filename);