X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg.c;h=d601dc5d6af4a30a69ef911d9b3c026bd2ef94c7;hb=fe5c7e588db7c2bd37f095e2276c6a296a5a9d2a;hp=9d744914d7a7b7e92cf0f4919294961d07f7fcae;hpb=37d3e0667abd01124d783f3ca10a4aef05746a2a;p=ffmpeg diff --git a/ffmpeg.c b/ffmpeg.c index 9d744914d7a..d601dc5d6af 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -151,6 +151,7 @@ static int qp_hist = 0; static int intra_only = 0; static int audio_sample_rate = 44100; +static int64_t channel_layout = 0; #define QSCALE_NONE -99999 static float audio_qscale = QSCALE_NONE; static int audio_disable = 0; @@ -280,7 +281,6 @@ typedef struct AVInputStream { int64_t sample_index; /* current sample */ int64_t start; /* time when read started */ - unsigned long frame; /* current frame */ int64_t next_pts; /* synthetic pts for cases where pkt.pts is not defined */ int64_t pts; /* current pts */ @@ -419,7 +419,7 @@ static int av_exit(int ret) av_free(video_standard); #ifdef CONFIG_POWERPC_PERF - extern void powerpc_display_perf_report(void); + void powerpc_display_perf_report(void); powerpc_display_perf_report(); #endif /* CONFIG_POWERPC_PERF */ @@ -1305,13 +1305,11 @@ static int output_packet(AVInputStream *ist, int ist_index, } /* frame rate emulation */ - if (ist->st->codec->rate_emu) { - int64_t pts = av_rescale((int64_t) ist->frame * ist->st->codec->time_base.num, 1000000, ist->st->codec->time_base.den); + if (rate_emu) { + int64_t pts = av_rescale(ist->pts, 1000000, AV_TIME_BASE); int64_t now = av_gettime() - ist->start; if (pts > now) usleep(pts - now); - - ist->frame++; } /* if output time reached then transcode raw format, @@ -1488,6 +1486,7 @@ static void print_sdp(AVFormatContext **avc, int n) avf_sdp_create(avc, n, sdp, sizeof(sdp)); printf("SDP:\n%s\n", sdp); + fflush(stdout); } static int stream_index_from_inputs(AVFormatContext **input_files, @@ -1569,9 +1568,8 @@ static int av_encode(AVFormatContext **output_files, ist->discard = 1; /* the stream is discarded by default (changed later) */ - if (ist->st->codec->rate_emu) { + if (rate_emu) { ist->start = av_gettime(); - ist->frame = 0; } } } @@ -1581,7 +1579,8 @@ static int av_encode(AVFormatContext **output_files, for(i=0;inb_streams) { - fprintf(stderr, "Output file does not contain any stream\n"); + dump_format(output_files[i], i, output_files[i]->filename, 1); + fprintf(stderr, "Output file #%d does not contain any stream\n", i); av_exit(1); } nb_ostreams += os->nb_streams; @@ -1733,6 +1732,7 @@ static int av_encode(AVFormatContext **output_files, fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n"); av_exit(1); } + codec->channel_layout = icodec->channel_layout; codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; codec->frame_size = icodec->frame_size; @@ -1841,7 +1841,7 @@ static int av_encode(AVFormatContext **output_files, if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(logfilename, "w"); if (!f) { - perror(logfilename); + fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); av_exit(1); } ost->logfile = f; @@ -1849,7 +1849,7 @@ static int av_encode(AVFormatContext **output_files, /* read the log file */ f = fopen(logfilename, "r"); if (!f) { - perror(logfilename); + fprintf(stderr, "Cannot read log file '%s' for pass-2 encoding: %s\n", logfilename, strerror(errno)); av_exit(1); } fseek(f, 0, SEEK_END); @@ -2821,6 +2821,7 @@ static void opt_input_file(const char *filename) case CODEC_TYPE_AUDIO: set_context_opts(enc, avctx_opts[CODEC_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM); //fprintf(stderr, "\nInput Audio channels: %d", enc->channels); + channel_layout = enc->channel_layout; audio_channels = enc->channels; audio_sample_rate = enc->sample_rate; audio_sample_fmt = enc->sample_fmt; @@ -2856,7 +2857,6 @@ static void opt_input_file(const char *filename) frame_rate.num = rfps; frame_rate.den = rfps_base; - enc->rate_emu = rate_emu; input_codecs[nb_icodecs++] = avcodec_find_decoder_by_name(video_codec_name); if(video_disable) ic->streams[i]->discard= AVDISCARD_ALL; @@ -2891,7 +2891,6 @@ static void opt_input_file(const char *filename) video_channel = 0; - rate_emu = 0; av_freep(&video_codec_name); av_freep(&audio_codec_name); av_freep(&subtitle_codec_name); @@ -3130,6 +3129,7 @@ static void new_audio_stream(AVFormatContext *oc) audio_enc->thread_count = thread_count; audio_enc->channels = audio_channels; audio_enc->sample_fmt = audio_sample_fmt; + audio_enc->channel_layout = channel_layout; if(codec && codec->sample_fmts){ const enum SampleFormat *p= codec->sample_fmts; @@ -3702,7 +3702,7 @@ static int opt_preset(const char *opt, const char *arg) continue; e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2; if(e){ - fprintf(stderr, "%s: Preset file invalid\n", filename); + fprintf(stderr, "%s: Invalid syntax: '%s'\n", filename, line); av_exit(1); } if(!strcmp(tmp, "acodec")){ @@ -3712,7 +3712,7 @@ static int opt_preset(const char *opt, const char *arg) }else if(!strcmp(tmp, "scodec")){ opt_subtitle_codec(tmp2); }else if(opt_default(tmp, tmp2) < 0){ - fprintf(stderr, "%s: Invalid option or argument: %s=%s\n", filename, tmp, tmp2); + fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2); av_exit(1); } } @@ -3873,22 +3873,18 @@ int main(int argc, char **argv) sws_opts = sws_getContext(16,16,0, 16,16,0, sws_flags, NULL,NULL,NULL); show_banner(); - if (argc <= 1) { - show_help(); - av_exit(1); - } /* parse options */ parse_options(argc, argv, options, opt_output_file); /* file converter / grab */ if (nb_output_files <= 0) { - fprintf(stderr, "Must supply at least one output file\n"); + fprintf(stderr, "At least one output file must be specified\n"); av_exit(1); } if (nb_input_files == 0) { - fprintf(stderr, "Must supply at least one input file\n"); + fprintf(stderr, "At least one input file must be specified\n"); av_exit(1); }