static int video_rc_qmod_freq=0;
#endif
static char *video_rc_override_string=NULL;
-static char *video_rc_eq="tex^qComp";
static int video_disable = 0;
static int video_discard = 0;
static char *video_codec_name = NULL;
int size_out, frame_bytes, ret;
AVCodecContext *enc= ost->st->codec;
+ AVCodecContext *dec= ist->st->codec;
/* SC: dynamic allocation of buffers */
if (!audio_buf)
if (!audio_buf || !audio_out)
return; /* Should signal an error ! */
+ if (enc->channels != dec->channels)
+ ost->audio_resample = 1;
+
+ if (ost->audio_resample && !ost->resample) {
+ ost->resample = audio_resample_init(enc->channels, dec->channels,
+ enc->sample_rate, dec->sample_rate);
+ if (!ost->resample) {
+ fprintf(stderr, "Can not resample %d channels @ %d Hz to %d channels @ %d Hz\n",
+ dec->channels, dec->sample_rate,
+ enc->channels, enc->sample_rate);
+ exit(1);
+ }
+ }
+
if(audio_sync_method){
double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts
- av_fifo_size(&ost->fifo)/(ost->st->codec->channels * 2);
case CODEC_TYPE_AUDIO:
if (av_fifo_init(&ost->fifo, 2 * MAX_AUDIO_PACKET_SIZE))
goto fail;
-
- if (codec->channels == icodec->channels &&
- codec->sample_rate == icodec->sample_rate) {
- ost->audio_resample = 0;
- } else {
- if (codec->channels != icodec->channels &&
- (icodec->codec_id == CODEC_ID_AC3 ||
- icodec->codec_id == CODEC_ID_DTS)) {
- /* Special case for 5:1 AC3 and DTS input */
- /* and mono or stereo output */
- /* Request specific number of channels */
- icodec->channels = codec->channels;
- if (codec->sample_rate == icodec->sample_rate)
- ost->audio_resample = 0;
- else {
- ost->audio_resample = 1;
- }
- } else {
- ost->audio_resample = 1;
- }
- }
- if(audio_sync_method>1)
- ost->audio_resample = 1;
-
- if(ost->audio_resample){
- ost->resample = audio_resample_init(codec->channels, icodec->channels,
- codec->sample_rate, icodec->sample_rate);
- if(!ost->resample){
- printf("Can't resample. Aborting.\n");
- abort();
- }
- }
+ ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
+ icodec->request_channels = codec->channels;
ist->decoding_needed = 1;
ost->encoding_needed = 1;
break;
#endif
if(avctx_opts[0]->debug)
- av_log_level = AV_LOG_DEBUG;
+ av_log_set_level(AV_LOG_DEBUG);
return 0;
}
-static void opt_video_rc_eq(char *arg)
-{
- video_rc_eq = arg;
-}
-
static void opt_video_rc_override_string(char *arg)
{
video_rc_override_string = arg;
static void opt_verbose(const char *arg)
{
verbose = atoi(arg);
- av_log_level = atoi(arg);
+ av_log_set_level(atoi(arg));
}
static void opt_frame_rate(const char *arg)
for(i=0; i<opt_name_count; i++){
char buf[256];
const AVOption *opt;
- char *str= av_get_string(avformat_opts, opt_names[i], &opt, buf, sizeof(buf));
+ const char *str= av_get_string(avformat_opts, opt_names[i], &opt, buf, sizeof(buf));
if(str && (opt->flags & AV_OPT_FLAG_DECODING_PARAM))
av_set_string(ic, opt_names[i], str);
}
+
+ ic->video_codec_id = find_codec_or_die(video_codec_name , CODEC_TYPE_VIDEO , 0);
+ ic->audio_codec_id = find_codec_or_die(audio_codec_name , CODEC_TYPE_AUDIO , 0);
+ ic->subtitle_codec_id= find_codec_or_die(subtitle_codec_name, CODEC_TYPE_SUBTITLE, 0);
+
/* open the input file with generic libav function */
err = av_open_input_file(&ic, filename, file_iformat, 0, ap);
if (err < 0) {
for(j=0; j<opt_name_count; j++){
char buf[256];
const AVOption *opt;
- char *str= av_get_string(avctx_opts[CODEC_TYPE_AUDIO], opt_names[j], &opt, buf, sizeof(buf));
+ const char *str= av_get_string(avctx_opts[CODEC_TYPE_AUDIO], opt_names[j], &opt, buf, sizeof(buf));
if(str && (opt->flags & AV_OPT_FLAG_AUDIO_PARAM) && (opt->flags & AV_OPT_FLAG_DECODING_PARAM))
av_set_string(enc, opt_names[j], str);
}
for(j=0; j<opt_name_count; j++){
char buf[256];
const AVOption *opt;
- char *str= av_get_string(avctx_opts[CODEC_TYPE_VIDEO], opt_names[j], &opt, buf, sizeof(buf));
+ const char *str= av_get_string(avctx_opts[CODEC_TYPE_VIDEO], opt_names[j], &opt, buf, sizeof(buf));
if(str && (opt->flags & AV_OPT_FLAG_VIDEO_PARAM) && (opt->flags & AV_OPT_FLAG_DECODING_PARAM))
av_set_string(enc, opt_names[j], str);
}
for(i=0; i<opt_name_count; i++){
char buf[256];
const AVOption *opt;
- char *str= av_get_string(avctx_opts[CODEC_TYPE_VIDEO], opt_names[i], &opt, buf, sizeof(buf));
+ const char *str= av_get_string(avctx_opts[CODEC_TYPE_VIDEO], opt_names[i], &opt, buf, sizeof(buf));
if(str && (opt->flags & AV_OPT_FLAG_VIDEO_PARAM) && (opt->flags & AV_OPT_FLAG_ENCODING_PARAM))
av_set_string(video_enc, opt_names[i], str);
}
video_enc->inter_matrix = inter_matrix;
video_enc->max_qdiff = video_qdiff;
- video_enc->rc_eq = video_rc_eq;
video_enc->thread_count = thread_count;
p= video_rc_override_string;
for(i=0; p; i++){
for(i=0; i<opt_name_count; i++){
char buf[256];
const AVOption *opt;
- char *str= av_get_string(avctx_opts[CODEC_TYPE_AUDIO], opt_names[i], &opt, buf, sizeof(buf));
+ const char *str= av_get_string(avctx_opts[CODEC_TYPE_AUDIO], opt_names[i], &opt, buf, sizeof(buf));
if(str && (opt->flags & AV_OPT_FLAG_AUDIO_PARAM) && (opt->flags & AV_OPT_FLAG_ENCODING_PARAM))
av_set_string(audio_enc, opt_names[i], str);
}
for(i=0; i<opt_name_count; i++){
char buf[256];
const AVOption *opt;
- char *str= av_get_string(avctx_opts[CODEC_TYPE_SUBTITLE], opt_names[i], &opt, buf, sizeof(buf));
+ const char *str= av_get_string(avctx_opts[CODEC_TYPE_SUBTITLE], opt_names[i], &opt, buf, sizeof(buf));
if(str && (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) && (opt->flags & AV_OPT_FLAG_ENCODING_PARAM))
av_set_string(subtitle_enc, opt_names[i], str);
}
for(i=0; i<opt_name_count; i++){
char buf[256];
const AVOption *opt;
- char *str= av_get_string(avformat_opts, opt_names[i], &opt, buf, sizeof(buf));
+ const char *str= av_get_string(avformat_opts, opt_names[i], &opt, buf, sizeof(buf));
if(str && (opt->flags & AV_OPT_FLAG_ENCODING_PARAM))
av_set_string(oc, opt_names[i], str);
}
static void opt_show_formats(void)
{
- AVInputFormat *ifmt;
- AVOutputFormat *ofmt;
- URLProtocol *up;
- AVCodec *p, *p2;
+ AVInputFormat *ifmt=NULL;
+ AVOutputFormat *ofmt=NULL;
+ URLProtocol *up=NULL;
+ AVCodec *p=NULL, *p2;
+ AVBitStreamFilter *bsf=NULL;
const char *last_name;
printf("File formats:\n");
const char *name=NULL;
const char *long_name=NULL;
- for(ofmt = first_oformat; ofmt != NULL; ofmt = ofmt->next) {
+ while(ofmt= av_oformat_next(ofmt)) {
if((name == NULL || strcmp(ofmt->name, name)<0) &&
strcmp(ofmt->name, last_name)>0){
name= ofmt->name;
encode=1;
}
}
- for(ifmt = first_iformat; ifmt != NULL; ifmt = ifmt->next) {
+ while(ifmt= av_iformat_next(ifmt)) {
if((name == NULL || strcmp(ifmt->name, name)<0) &&
strcmp(ifmt->name, last_name)>0){
name= ifmt->name;
const char *type_str;
p2=NULL;
- for(p = first_avcodec; p != NULL; p = p->next) {
+ while(p= av_codec_next(p)) {
if((p2==NULL || strcmp(p->name, p2->name)<0) &&
strcmp(p->name, last_name)>0){
p2= p;
}
printf("\n");
+ printf("Bitstream filters:\n");
+ while(bsf = av_bitstream_filter_next(bsf))
+ printf(" %s", bsf->name);
+ printf("\n");
+
printf("Supported file protocols:\n");
- for(up = first_protocol; up != NULL; up = up->next)
+ while(up = av_protocol_next(up))
printf(" %s:", up->name);
printf("\n");
{ "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_discard}, "discard threshold", "n" },
{ "qscale", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qscale}, "use fixed video quantizer scale (VBR)", "q" },
{ "qdiff", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qdiff}, "max difference between the quantizer scale (VBR)", "q" },
- { "rc_eq", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_rc_eq}, "set rate control equation", "equation" },
{ "rc_override", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_rc_override_string}, "rate control override for specific intervals", "override" },
{ "vcodec", HAS_ARG | OPT_VIDEO, {(void*)opt_video_codec}, "force video codec ('copy' to copy stream)", "codec" },
{ "me_threshold", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_me_threshold}, "motion estimaton threshold", "" },