---
ffmpeg.c | 58 +++++++++++++++++++++-----------------------
tests/codec-regression.sh | 2 +-
tests/fate2.mak | 4 +-
tests/lavf-regression.sh | 18 +++++++-------
tests/regression-funcs.sh | 2 +-
5 files changed, 41 insertions(+), 43 deletions(-)
diff --git a/ffmpeg.c b/ffmpeg.c
index cbcdba8..8fd9ca0 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -113,6 +113,7 @@ static int nb_input_codecs = 0;
static int nb_input_files_ts_scale[MAX_FILES] = {0};
static AVFormatContext *output_files[MAX_FILES];
+static AVDictionary *output_opts[MAX_FILES];
static AVCodec **output_codecs = NULL;
static int nb_output_files = 0;
static int nb_output_codecs = 0;
@@ -464,6 +465,7 @@ static int ffmpeg_exit(int ret)
avio_close(s->pb);
avformat_free_context(s);
av_free(output_streams_for_file[i]);
+ av_dict_free(&output_opts[i]);
}
for(i=0;i<nb_input_files;i++) {
av_close_input_file(input_files[i].ctx);
@@ -514,6 +516,15 @@ static int ffmpeg_exit(int ret)
return ret;
}
+static void assert_avoptions(AVDictionary *m)
+{
+ AVDictionaryEntry *t;
+ if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+ av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
+ ffmpeg_exit(1);
+ }
+}
+
/* similar to ff_dynarray_add() and av_fast_realloc() */
static void *grow_array(void *array, int elem_size, int *size, int new_size)
{
@@ -666,10 +677,10 @@ static AVOutputStream *new_output_stream(AVFormatContext
*oc, int file_idx)
static int read_ffserver_streams(AVFormatContext *s, const char *filename)
{
int i, err;
- AVFormatContext *ic;
+ AVFormatContext *ic = NULL;
int nopts = 0;
- err = av_open_input_file(&ic, filename, NULL, FFM_PACKET_SIZE, NULL);
+ err = avformat_open_input(&ic, filename, NULL, NULL);
if (err < 0)
return err;
/* copy stream format */
@@ -2442,11 +2453,12 @@ static int transcode(AVFormatContext **output_files,
/* open files and write file headers */
for(i=0;i<nb_output_files;i++) {
os = output_files[i];
- if (av_write_header(os) < 0) {
+ if (avformat_open_output(os, &output_opts[i]) < 0) {
snprintf(error, sizeof(error), "Could not write header for output
file #%d (incorrect codec parameters ?)", i);
ret = AVERROR(EINVAL);
goto dump_format;
}
+ assert_avoptions(output_opts[i]);
if (strcmp(output_files[i]->oformat->name, "rtp")) {
want_sdp = 0;
}
@@ -3120,7 +3132,6 @@ static enum CodecID find_codec_or_die(const char *name,
int type, int encoder, i
static int opt_input_file(const char *opt, const char *filename)
{
AVFormatContext *ic;
- AVFormatParameters params, *ap = ¶ms;
AVInputFormat *file_iformat = NULL;
int err, i, ret, rfps, rfps_base;
int64_t timestamp;
@@ -3146,21 +3157,6 @@ static int opt_input_file(const char *opt, const char
*filename)
ffmpeg_exit(1);
}
- memset(ap, 0, sizeof(*ap));
- ap->prealloced_context = 1;
- ap->sample_rate = audio_sample_rate;
- ap->channels = audio_channels;
- ap->time_base.den = frame_rate.num;
- ap->time_base.num = frame_rate.den;
- ap->width = frame_width;
- ap->height = frame_height;
- ap->pix_fmt = frame_pix_fmt;
- // ap->sample_fmt = audio_sample_fmt; //FIXME:not implemented in libavformat
- ap->channel = video_channel;
- ap->standard = video_standard;
-
- set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM, NULL);
-
ic->video_codec_id =
find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0,
avcodec_opts[AVMEDIA_TYPE_VIDEO
]->strict_std_compliance);
@@ -3173,11 +3169,13 @@ static int opt_input_file(const char *opt, const char
*filename)
ic->flags |= AVFMT_FLAG_NONBLOCK;
/* open the input file with generic libav function */
- err = av_open_input_file(&ic, filename, file_iformat, 0, ap);
+ err = avformat_open_input(&ic, filename, file_iformat, &format_opts);
if (err < 0) {
print_error(filename, err);
ffmpeg_exit(1);
}
+ assert_avoptions(format_opts);
+
if(opt_programid) {
int i, j;
int found=0;
@@ -3754,7 +3752,6 @@ static void opt_output_file(const char *filename)
AVFormatContext *oc;
int err, use_video, use_audio, use_subtitle, use_data;
int input_has_video, input_has_audio, input_has_subtitle, input_has_data;
- AVFormatParameters params, *ap = ¶ms;
AVOutputFormat *file_oformat;
if (!strcmp(filename, "-"))
@@ -3835,6 +3832,7 @@ static void opt_output_file(const char *filename)
av_dict_free(&metadata);
}
+ av_dict_copy(&output_opts[nb_output_files], format_opts, 0);
output_files[nb_output_files++] = oc;
/* check filename in case of an image number is expected */
@@ -3874,20 +3872,11 @@ static void opt_output_file(const char *filename)
}
}
- memset(ap, 0, sizeof(*ap));
- if (av_set_parameters(oc, ap) < 0) {
- fprintf(stderr, "%s: Invalid encoding parameters\n",
- oc->filename);
- ffmpeg_exit(1);
- }
-
oc->preload= (int)(mux_preload*AV_TIME_BASE);
oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);
oc->loop_output = loop_output;
oc->flags |= AVFMT_FLAG_NONBLOCK;
- set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL);
-
av_freep(&forced_key_frames);
uninit_opts();
init_opts();
@@ -3976,6 +3965,7 @@ static void show_help(void)
{
AVCodec *c;
AVOutputFormat *oformat = NULL;
+ AVInputFormat *iformat = NULL;
av_log_set_callback(log_callback_help);
show_usage();
@@ -4026,6 +4016,14 @@ static void show_help(void)
}
}
+ /* individual demuxer options */
+ while ((iformat = av_iformat_next(iformat))) {
+ if (iformat->priv_class) {
+ av_opt_show2(&iformat->priv_class, NULL,
AV_OPT_FLAG_DECODING_PARAM, 0);
+ printf("\n");
+ }
+ }
+
av_opt_show2(sws_opts, NULL,
AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0);
}
diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh
index 335e1f7..d15eb67 100755
--- a/tests/codec-regression.sh
+++ b/tests/codec-regression.sh
@@ -18,7 +18,7 @@ if [ -n "$do_vref" ]; then
do_ffmpeg $raw_ref -f image2 -vcodec pgmyuv -i $raw_src -an -f rawvideo
fi
if [ -n "$do_aref" ]; then
-do_ffmpeg $pcm_ref -ab 128k -ac 2 -ar 44100 -f s16le -i $pcm_src -f wav
+do_ffmpeg $pcm_ref -ab 128k -channels 2 -sample_rate 44100 -f s16le -i
$pcm_src -f wav
fi
if [ -n "$do_mpeg" ] ; then
diff --git a/tests/fate2.mak b/tests/fate2.mak
index 6a9448f..2ee1fdf 100644
--- a/tests/fate2.mak
+++ b/tests/fate2.mak
@@ -131,7 +131,7 @@ FATE_TESTS += fate-gsm-ms
fate-gsm-ms: CMD = framecrc -i $(SAMPLES)/gsm/ciao.wav
FATE_TESTS += fate-g722dec-1
-fate-g722dec-1: CMD = framecrc -ar 16000 -i
$(SAMPLES)/g722/conf-adminmenu-162.g722
+fate-g722dec-1: CMD = framecrc -channels 1 -sample_rate 16000 -i
$(SAMPLES)/g722/conf-adminmenu-162.g722
FATE_TESTS += fate-msmpeg4v1
fate-msmpeg4v1: CMD = framecrc -flags +bitexact -dct fastint -idct simple -i
$(SAMPLES)/msmpeg4v1/mpg4.avi -an
@@ -165,7 +165,7 @@ fate-wmapro-2ch: CMP = oneoff
fate-wmapro-2ch: REF = $(SAMPLES)/wmapro/Beethovens_9th-1_small.pcm
FATE_TESTS += fate-ansi
-fate-ansi: CMD = framecrc -i $(SAMPLES)/ansi/TRE-IOM5.ANS -pix_fmt rgb24
+fate-ansi: CMD = framecrc -chars_per_frame 44100 -i
$(SAMPLES)/ansi/TRE-IOM5.ANS -pix_fmt rgb24
FATE_TESTS += fate-wmv8-drm
# discard last packet to avoid fails due to overread of VC-1 decoder
diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh
index 94d2583..503eb0a 100755
--- a/tests/lavf-regression.sh
+++ b/tests/lavf-regression.sh
@@ -14,7 +14,7 @@ eval do_$test=y
do_lavf()
{
file=${outfile}lavf.$1
- do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS
-f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $2
+ do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS
-channels 1 -sample_rate 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $2
do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file $3
}
@@ -39,8 +39,8 @@ do_image_formats()
do_audio_only()
{
file=${outfile}lavf.$1
- do_ffmpeg $file $DEC_OPTS $2 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale
10 $3
- do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file
+ do_ffmpeg $file $DEC_OPTS -channels 1 -sample_rate 44100 $2 -f s16le -i
$pcm_src $ENC_OPTS -t 1 -qscale 10 $3
+ do_ffmpeg_crc $file $DEC_OPTS $4 -i $target_path/$file
}
rm -f "$logfile"
@@ -55,7 +55,7 @@ fi
if [ -n "$do_rm" ] ; then
file=${outfile}lavf.rm
-do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -f
s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed
+do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS
-channels 1 -sample_rate 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10
-acodec ac3_fixed
# broken
#do_ffmpeg_crc $file -i $target_path/$file
fi
@@ -181,11 +181,11 @@ do_audio_only wav
fi
if [ -n "$do_alaw" ] ; then
-do_audio_only al
+do_audio_only al "" "" "-channels 1 -sample_rate 44100"
fi
if [ -n "$do_mulaw" ] ; then
-do_audio_only ul
+do_audio_only ul "" "" "-channels 1 -sample_rate 44100"
fi
if [ -n "$do_au" ] ; then
@@ -205,7 +205,7 @@ do_audio_only voc
fi
if [ -n "$do_voc_s16" ] ; then
-do_audio_only s16.voc "-ac 2" "-acodec pcm_s16le"
+do_audio_only s16.voc "-channels 2" "-acodec pcm_s16le"
fi
if [ -n "$do_ogg" ] ; then
@@ -226,9 +226,9 @@ conversions="yuv420p yuv422p yuv444p yuyv422 yuv410p
yuv411p yuvj420p \
monob yuv440p yuvj440p"
for pix_fmt in $conversions ; do
file=${outfile}${pix_fmt}.yuv
- run_ffmpeg $DEC_OPTS -r 1 -t 1 -f image2 -vcodec pgmyuv -i $raw_src \
+ run_ffmpeg $DEC_OPTS -framerate 1 -t 1 -f image2 -vcodec pgmyuv -i
$raw_src \
$ENC_OPTS -f rawvideo -s 352x288 -pix_fmt $pix_fmt
$target_path/$raw_dst
- do_ffmpeg $file $DEC_OPTS -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i
$target_path/$raw_dst \
+ do_ffmpeg $file $DEC_OPTS -f rawvideo -video_size 352x288 -pixel_format
$pix_fmt -i $target_path/$raw_dst \
$ENC_OPTS -f rawvideo -s 352x288 -pix_fmt yuv444p
done
fi
diff --git a/tests/regression-funcs.sh b/tests/regression-funcs.sh
index 4cf2e20..8ec6688 100755
--- a/tests/regression-funcs.sh
+++ b/tests/regression-funcs.sh
@@ -114,7 +114,7 @@ do_video_encoding()
do_audio_encoding()
{
file=${outfile}$1
- do_ffmpeg $file $DEC_OPTS -ac 2 -f s16le -i $pcm_src -ab 128k $ENC_OPTS $2
+ do_ffmpeg $file $DEC_OPTS -channels 2 -sample_rate 44100 -f s16le -i
$pcm_src -ab 128k $ENC_OPTS $2
}
do_audio_decoding()
--
1.7.5.3
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel