X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg.c;h=2b7408692ad3f5e5849f85d27696c785e9d22c3e;hb=3fff63826bf4576923016f94a9e4c61e87536b8b;hp=ee6b01784a51ec372b370879319fbd7daf9a1aa7;hpb=6c7c44ee7ae3be5dcef5bba685fa375493c0b1f2;p=ffmpeg diff --git a/ffmpeg.c b/ffmpeg.c index ee6b01784a5..2b7408692ad 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -555,12 +555,12 @@ static void do_audio_out(AVFormatContext *s, ost->audio_resample = 1; if (ost->audio_resample && !ost->resample) { - if (dec->sample_fmt != SAMPLE_FMT_S16) { - fprintf(stderr, "Audio resampler only works with 16 bits per sample, patch welcome.\n"); - av_exit(1); - } - ost->resample = audio_resample_init(enc->channels, dec->channels, - enc->sample_rate, dec->sample_rate); + if (dec->sample_fmt != SAMPLE_FMT_S16) + fprintf(stderr, "Warning, using s16 intermediate sample format for resampling\n"); + ost->resample = av_audio_resample_init(enc->channels, dec->channels, + enc->sample_rate, dec->sample_rate, + enc->sample_fmt, dec->sample_fmt, + 16, 10, 0, 0.8); if (!ost->resample) { fprintf(stderr, "Can not resample %d channels @ %d Hz to %d channels @ %d Hz\n", dec->channels, dec->sample_rate, @@ -570,7 +570,7 @@ static void do_audio_out(AVFormatContext *s, } #define MAKE_SFMT_PAIR(a,b) ((a)+SAMPLE_FMT_NB*(b)) - if (dec->sample_fmt!=enc->sample_fmt && + if (!ost->audio_resample && dec->sample_fmt!=enc->sample_fmt && MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt)!=ost->reformat_pair) { if (!audio_out2) audio_out2 = av_malloc(audio_out_size); @@ -647,7 +647,7 @@ static void do_audio_out(AVFormatContext *s, size_out = size; } - if (dec->sample_fmt!=enc->sample_fmt) { + if (!ost->audio_resample && dec->sample_fmt!=enc->sample_fmt) { const void *ibuf[6]= {buftmp}; void *obuf[6]= {audio_out2}; int istride[6]= {isize}; @@ -888,7 +888,7 @@ static void do_video_out(AVFormatContext *s, if (ost->video_crop) { if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) { - av_log(NULL, AV_LOG_ERROR, "error cropping picture\n"); + fprintf(stderr, "error cropping picture\n"); if (exit_on_error) av_exit(1); return; @@ -905,7 +905,7 @@ static void do_video_out(AVFormatContext *s, final_picture = &ost->pict_tmp; if (ost->video_resample) { if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) { - av_log(NULL, AV_LOG_ERROR, "error padding picture\n"); + fprintf(stderr, "error padding picture\n"); if (exit_on_error) av_exit(1); return; @@ -2100,7 +2100,10 @@ static int av_encode(AVFormatContext **output_files, /* read a frame from it and output it in the fifo */ is = input_files[file_index]; - if (av_read_frame(is, &pkt) < 0) { + ret= av_read_frame(is, &pkt); + if(ret == AVERROR(EAGAIN) && strcmp(is->iformat->name, "ffm")) + continue; + if (ret < 0) { file_table[file_index].eof_reached = 1; if (opt_shortest) break; @@ -2751,11 +2754,11 @@ static enum CodecID find_codec_or_die(const char *name, int type, int encoder) avcodec_find_encoder_by_name(name) : avcodec_find_decoder_by_name(name); if(!codec) { - av_log(NULL, AV_LOG_ERROR, "Unknown %s '%s'\n", codec_string, name); + fprintf(stderr, "Unknown %s '%s'\n", codec_string, name); av_exit(1); } if(codec->type != type) { - av_log(NULL, AV_LOG_ERROR, "Invalid %s type '%s'\n", codec_string, name); + fprintf(stderr, "Invalid %s type '%s'\n", codec_string, name); av_exit(1); } return codec->id; @@ -2775,7 +2778,7 @@ static void opt_input_file(const char *filename) !strcmp(filename, "/dev/stdin"); /* get default parameters from command line */ - ic = av_alloc_format_context(); + ic = avformat_alloc_context(); memset(ap, 0, sizeof(*ap)); ap->prealloced_context = 1; @@ -3264,7 +3267,7 @@ static void opt_output_file(const char *filename) if (!strcmp(filename, "-")) filename = "pipe:"; - oc = av_alloc_format_context(); + oc = avformat_alloc_context(); if (!file_oformat) { file_oformat = guess_format(NULL, filename, NULL); @@ -3697,25 +3700,24 @@ static int opt_preset(const char *opt, const char *arg) FILE *f=NULL; char filename[1000], tmp[1000], tmp2[1000], line[1000]; int i; - const char *base[3]= { getenv("HOME"), - "/usr/local/share", - "/usr/share", + const char *base[2]= { getenv("HOME"), + FFMPEG_DATADIR, }; - for(i=!base[0]; i<3 && !f; i++){ - snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s.ffpreset", base[i], i ? "" : ".", arg); + for(i=!base[0]; i<2 && !f; i++){ + snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i ? "" : "/.ffmpeg", arg); f= fopen(filename, "r"); if(!f){ char *codec_name= *opt == 'v' ? video_codec_name : *opt == 'a' ? audio_codec_name : subtitle_codec_name; - snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s-%s.ffpreset", base[i], i ? "" : ".", codec_name, arg); + snprintf(filename, sizeof(filename), "%s%s/%s-%s.ffpreset", base[i], i ? "" : "/.ffmpeg", codec_name, arg); f= fopen(filename, "r"); } } if(!f && ((arg[0]=='.' && arg[1]=='/') || arg[0]=='/' || is_dos_path(arg))){ - snprintf(filename, sizeof(filename), arg); + av_strlcpy(filename, arg, sizeof(filename)); f= fopen(filename, "r"); } @@ -3767,7 +3769,7 @@ static const OptionDef options[] = { { "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" }, { "title", HAS_ARG | OPT_STRING, {(void*)&str_title}, "set the title", "string" }, - { "timestamp", OPT_FUNC2 | HAS_ARG, {(void*)&opt_rec_timestamp}, "set the timestamp", "time" }, + { "timestamp", OPT_FUNC2 | HAS_ARG, {(void*)&opt_rec_timestamp}, "set the timestamp ('now' to set the current time)", "time" }, { "author", HAS_ARG | OPT_STRING, {(void*)&str_author}, "set the author", "string" }, { "copyright", HAS_ARG | OPT_STRING, {(void*)&str_copyright}, "set the copyright", "string" }, { "comment", HAS_ARG | OPT_STRING, {(void*)&str_comment}, "set the comment", "string" }, @@ -3898,7 +3900,7 @@ int main(int argc, char **argv) for(i=0; i