X-Git-Url: https://rtime.felk.cvut.cz/gitweb/frescor/ffmpeg.git/blobdiff_plain/9c2ccc03e849c6dcfc4c4bb9839fd8d670e03dae..9c204df96092b369f6e4f5a8eb245ac4a6b5b2c0:/ffmpeg.c diff --git a/ffmpeg.c b/ffmpeg.c index 1a4fcfbc4..5f407c96c 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1061,7 +1061,7 @@ static void print_report(AVFormatContext **output_files, { char buf[1024]; AVOutputStream *ost; - AVFormatContext *oc, *os; + AVFormatContext *oc; int64_t total_size; AVCodecContext *enc; int frame_number, vid, i; @@ -1094,7 +1094,6 @@ static void print_report(AVFormatContext **output_files, vid = 0; for(i=0;ifile_index]; enc = ost->st->codec; if (vid && enc->codec_type == CODEC_TYPE_VIDEO) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", @@ -1465,10 +1464,13 @@ static int output_packet(AVInputStream *ist, int ist_index, ret = 0; /* encode any samples remaining in fifo */ if(fifo_bytes > 0 && enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) { + int osize = av_get_bits_per_sample_format(enc->sample_fmt) >> 3; int fs_tmp = enc->frame_size; - enc->frame_size = fifo_bytes / (2 * enc->channels); + enc->frame_size = fifo_bytes / (osize * enc->channels); av_fifo_generic_read(ost->fifo, samples, fifo_bytes, NULL); ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, samples); + pkt.duration = av_rescale((int64_t)enc->frame_size*ost->st->time_base.den, + ost->st->time_base.num, enc->sample_rate); enc->frame_size = fs_tmp; } if(ret <= 0) { @@ -1746,6 +1748,8 @@ static int av_encode(AVFormatContext **output_files, av_metadata_set(&ost->st->metadata, "language", lang->value); ost->st->disposition = ist->st->disposition; + codec->bits_per_raw_sample= icodec->bits_per_raw_sample; + codec->chroma_sample_location = icodec->chroma_sample_location; if (ost->st->stream_copy) { /* if stream_copy is selected, no need to decode or encode */ @@ -1855,6 +1859,7 @@ static int av_encode(AVFormatContext **output_files, av_exit(1); } ost->resample_height = icodec->height - (frame_topBand + frame_bottomBand); + codec->bits_per_raw_sample= 0; } ost->encoding_needed = 1; ist->decoding_needed = 1; @@ -1970,7 +1975,6 @@ static int av_encode(AVFormatContext **output_files, /* init pts */ for(i=0;ifile_index]; ist->pts = 0; ist->next_pts = AV_NOPTS_VALUE; ist->is_start = 1; @@ -2061,7 +2065,6 @@ static int av_encode(AVFormatContext **output_files, } term_init(); - key = -1; timer_start = av_gettime(); for(; received_sigterm == 0;) { @@ -2335,10 +2338,11 @@ static int opt_me_threshold(const char *opt, const char *arg) return 0; } -static void opt_loglevel(const char *opt, const char *arg) +static int opt_loglevel(const char *opt, const char *arg) { int level = parse_number_or_die(opt, arg, OPT_INT, INT_MIN, INT_MAX); av_log_set_level(level); + return 0; } static int opt_verbose(const char *opt, const char *arg) @@ -3212,6 +3216,8 @@ static void new_audio_stream(AVFormatContext *oc) audio_enc->channels = audio_channels; audio_enc->sample_fmt = audio_sample_fmt; audio_enc->channel_layout = channel_layout; + if (avcodec_channel_layout_num_channels(channel_layout) != audio_channels) + audio_enc->channel_layout = 0; if(codec && codec->sample_fmts){ const enum SampleFormat *p= codec->sample_fmts; @@ -3814,8 +3820,8 @@ static const OptionDef options[] = { { "ss", OPT_FUNC2 | HAS_ARG, {(void*)opt_start_time}, "set the start time offset", "time_off" }, { "itsoffset", OPT_FUNC2 | HAS_ARG, {(void*)opt_input_ts_offset}, "set the input ts offset", "time_off" }, { "itsscale", HAS_ARG, {(void*)opt_input_ts_scale}, "set the input ts scale", "stream:scale" }, - { "timestamp", OPT_FUNC2 | HAS_ARG, {(void*)&opt_rec_timestamp}, "set the timestamp ('now' to set the current time)", "time" }, - { "metadata", OPT_FUNC2 | HAS_ARG, {(void*)&opt_metadata}, "add metadata", "string=string" }, + { "timestamp", OPT_FUNC2 | HAS_ARG, {(void*)opt_rec_timestamp}, "set the timestamp ('now' to set the current time)", "time" }, + { "metadata", OPT_FUNC2 | HAS_ARG, {(void*)opt_metadata}, "add metadata", "string=string" }, { "dframes", OPT_INT | HAS_ARG, {(void*)&max_frames[CODEC_TYPE_DATA]}, "set the number of data frames to record", "number" }, { "benchmark", OPT_BOOL | OPT_EXPERT, {(void*)&do_benchmark}, "add timings for benchmarking" },