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;
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 */
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 */
if(qp_hist){
int j;
int qp= lrintf(enc->coded_frame->quality/(float)FF_QP2LAMBDA);
- if(qp>=0 && qp<sizeof(qp_histogram)/sizeof(int))
+ if(qp>=0 && qp<FF_ARRAY_ELEMS(qp_histogram))
qp_histogram[qp]++;
for(j=0; j<32; j++)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log(qp_histogram[j]+1)/log(2)));
}
/* 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,
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,
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;
}
}
}
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
if (!os->nb_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;
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;
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;
/* 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);
if (ost->encoding_needed) {
AVCodec *codec = output_codecs[i];
if (!codec)
- codec = avcodec_find_encoder(ost->st->codec->codec_id);
+ codec = avcodec_find_encoder(ost->st->codec->codec_id);
if (!codec) {
fprintf(stderr, "Unsupported codec for output stream #%d.%d\n",
ost->file_index, ost->index);
if (ist->decoding_needed) {
AVCodec *codec = input_codecs[i];
if (!codec)
- codec = avcodec_find_decoder(ist->st->codec->codec_id);
+ codec = avcodec_find_decoder(ist->st->codec->codec_id);
if (!codec) {
fprintf(stderr, "Unsupported codec (id=%d) for input stream #%d.%d\n",
ist->st->codec->codec_id, ist->file_index, ist->index);
}
// fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type);
- if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE) {
+ if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE
+ && (is->iformat->flags & AVFMT_TS_DISCONT)) {
int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta= pkt_dts - ist->next_pts;
if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){
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;
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;
video_channel = 0;
- rate_emu = 0;
av_freep(&video_codec_name);
av_freep(&audio_codec_name);
av_freep(&subtitle_codec_name);
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;
static int opt_preset(const char *opt, const char *arg)
{
FILE *f=NULL;
- char tmp[1000], tmp2[1000], line[1000];
+ char filename[1000], tmp[1000], tmp2[1000], line[1000];
int i;
const char *base[3]= { getenv("HOME"),
"/usr/local/share",
};
for(i=!base[0]; i<3 && !f; i++){
- snprintf(tmp, sizeof(tmp), "%s/%sffmpeg/%s.ffpreset", base[i], i ? "" : ".", arg);
- f= fopen(tmp, "r");
+ snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s.ffpreset", base[i], i ? "" : ".", arg);
+ f= fopen(filename, "r");
if(!f){
char *codec_name= *opt == 'v' ? video_codec_name :
*opt == 'a' ? audio_codec_name :
subtitle_codec_name;
- snprintf(tmp, sizeof(tmp), "%s/%sffmpeg/%s-%s.ffpreset", base[i], i ? "" : ".", codec_name, arg);
- f= fopen(tmp, "r");
+ snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s-%s.ffpreset", base[i], i ? "" : ".", codec_name, arg);
+ f= fopen(filename, "r");
}
}
- if(!f && ((arg[0]=='.' && arg[1]=='/') || arg[0]=='/')){
- f= fopen(arg, "r");
+ if(!f && ((arg[0]=='.' && arg[1]=='/') || arg[0]=='/' ||
+ is_dos_path(arg))){
+ snprintf(filename, sizeof(filename), arg);
+ f= fopen(filename, "r");
}
if(!f){
- fprintf(stderr, "Preset file not found\n");
+ fprintf(stderr, "File for preset '%s' not found\n", arg);
av_exit(1);
}
continue;
e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2;
if(e){
- fprintf(stderr, "Preset file invalid\n");
+ fprintf(stderr, "%s: Invalid syntax: '%s'\n", filename, line);
av_exit(1);
}
if(!strcmp(tmp, "acodec")){
opt_video_codec(tmp2);
}else if(!strcmp(tmp, "scodec")){
opt_subtitle_codec(tmp2);
- }else
- opt_default(tmp, tmp2);
+ }else if(opt_default(tmp, tmp2) < 0){
+ fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2);
+ av_exit(1);
+ }
}
fclose(f);
{ "vbsf", OPT_FUNC2 | HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
{ "sbsf", OPT_FUNC2 | HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
- { "apre", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_EXPERT, {(void*)opt_preset}, "", "preset" },
- { "vpre", OPT_FUNC2 | HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_preset}, "", "preset" },
- { "spre", OPT_FUNC2 | HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_preset}, "", "preset" },
+ { "apre", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_EXPERT, {(void*)opt_preset}, "set the audio options to the indicated preset", "preset" },
+ { "vpre", OPT_FUNC2 | HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_preset}, "set the video options to the indicated preset", "preset" },
+ { "spre", OPT_FUNC2 | HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_preset}, "set the subtitle options to the indicated preset", "preset" },
{ "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
{ NULL, },
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);
}