Remove -[va]frames options, add instead a -frames option that uses
generic stream specifiers.
---
avconv.c | 22 ++++++++++++++--------
doc/avconv.texi | 12 ++++--------
tests/codec-regression.sh | 10 +++++-----
tests/fate/h264.mak | 2 +-
tests/fate2.mak | 2 +-
5 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/avconv.c b/avconv.c
index 3930eb6..6c6818f 100644
--- a/avconv.c
+++ b/avconv.c
@@ -106,7 +106,6 @@ static int frame_height = 0;
static float frame_aspect_ratio = 0;
static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;
static enum AVSampleFormat audio_sample_fmt = AV_SAMPLE_FMT_NONE;
-static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX};
static AVRational frame_rate;
static float video_qscale = 0;
static uint16_t *intra_matrix = NULL;
@@ -234,6 +233,7 @@ typedef struct OutputStream {
int64_t sync_opts; /* output frame counter, could be changed to some
true timestamp */ //FIXME look at frame_number
AVBitStreamFilterContext *bitstream_filters;
AVCodec *enc;
+ int64_t max_frames;
/* video only */
int video_resample;
@@ -326,6 +326,8 @@ typedef struct OptionsContext {
SpecifierOpt *metadata;
int nb_metadata;
+ SpecifierOpt *max_frames;
+ int nb_max_frames;
} OptionsContext;
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
@@ -1174,7 +1176,7 @@ static void do_video_out(AVFormatContext *s,
}else
ost->sync_opts= lrintf(sync_ipts);
- nb_frames= FFMIN(nb_frames, max_frames[AVMEDIA_TYPE_VIDEO] -
ost->frame_number);
+ nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number);
if (nb_frames <= 0)
return;
@@ -2310,9 +2312,11 @@ static int transcode(OutputFile *output_files,
if(!input_sync) file_index = ist->file_index;
}
}
- if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
- file_index= -1;
- break;
+ if (ost->frame_number >= ost->max_frames) {
+ int j;
+ for (j = of->ost_index; j < of->ctx->nb_streams; j++)
+ output_streams[j].is_past_recording_time = 1;
+ continue;
}
}
/* if none, if is finished */
@@ -3055,6 +3059,7 @@ static OutputStream *new_output_stream(OptionsContext *o,
AVFormatContext *oc, e
OutputStream *ost;
AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ?
streamid_map[oc->nb_streams] : 0);
int idx = oc->nb_streams - 1;
+ int64_t max_frames = INT64_MAX;
if (!st) {
av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n");
@@ -3076,6 +3081,9 @@ static OutputStream *new_output_stream(OptionsContext *o,
AVFormatContext *oc, e
avcodec_get_context_defaults3(st->codec, ost->enc);
st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2()
sets type to unknown for stream copy
+ MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st);
+ ost->max_frames = max_frames;
+
ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
return ost;
}
@@ -4036,7 +4044,6 @@ static const OptionDef options[] = {
{ "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET, {.off =
OFFSET(input_ts_offset)}, "set the input ts offset", "time_off" },
{ "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC, {.off = OFFSET(ts_scale)},
"set the input ts scale", "scale" },
{ "metadata", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(metadata)},
"add metadata", "string=string" },
- { "dframes", OPT_INT | HAS_ARG, {(void*)&max_frames[AVMEDIA_TYPE_DATA]},
"set the number of data frames to record", "number" },
{ "benchmark", OPT_BOOL | OPT_EXPERT, {(void*)&do_benchmark},
"add timings for benchmarking" },
{ "timelimit", HAS_ARG, {(void*)opt_timelimit}, "set max runtime in
seconds", "limit" },
@@ -4057,9 +4064,9 @@ static const OptionDef options[] = {
{ "programid", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&opt_programid},
"desired program number", "" },
{ "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" },
{ "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)©_initial_nonkeyframes},
"copy initial non-keyframes" },
+ { "frames", OPT_INT64 | HAS_ARG | OPT_SPEC, {.off = OFFSET(max_frames)},
"set the number of frames to record", "number" },
/* video options */
- { "vframes", OPT_INT | HAS_ARG | OPT_VIDEO,
{(void*)&max_frames[AVMEDIA_TYPE_VIDEO]}, "set the number of video frames to
record", "number" },
{ "r", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_rate}, "set frame rate (Hz
value, fraction or abbreviation)", "rate" },
{ "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH
or abbreviation)", "size" },
{ "aspect", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_aspect_ratio}, "set
aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
@@ -4094,7 +4101,6 @@ static const OptionDef options[] = {
{ "force_key_frames", OPT_STRING | HAS_ARG | OPT_EXPERT | OPT_VIDEO,
{(void *)&forced_key_frames}, "force key frames at specified timestamps",
"timestamps" },
/* audio options */
- { "aframes", OPT_INT | HAS_ARG | OPT_AUDIO,
{(void*)&max_frames[AVMEDIA_TYPE_AUDIO]}, "set the number of audio frames to
record", "number" },
{ "aq", OPT_FLOAT | HAS_ARG | OPT_AUDIO, {(void*)&audio_qscale}, "set
audio quality (codec-specific)", "quality", },
{ "ar", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling
rate (in Hz)", "rate" },
{ "ac", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_channels}, "set number of
audio channels", "channels" },
diff --git a/doc/avconv.texi b/doc/avconv.texi
index 0b56044..a05a443 100644
--- a/doc/avconv.texi
+++ b/doc/avconv.texi
@@ -199,19 +199,17 @@ they do not conflict with the standard, as in:
avconv -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
@end example
-@item -dframes @var{number}
-Set the number of data frames to record.
-
@item -slang @var{code}
Set the ISO 639 language code (3 letters) of the current subtitle stream.
+@item -frames[:stream_specifier] @var{framecount}
+Stop writing to the stream after @var{framecount} frames.
+
@end table
@section Video Options
@table @option
-@item -vframes @var{number}
-Set the number of video frames to record.
@item -r @var{fps}
Set frame rate (Hz value, fraction or abbreviation), (default = 25).
@item -s @var{size}
@@ -580,8 +578,6 @@ The timestamps must be specified in ascending order.
@section Audio Options
@table @option
-@item -aframes @var{number}
-Set the number of audio frames to record.
@item -ar @var{freq}
Set the audio sampling frequency. For output streams it is set by
default to the frequency of the corresponding input stream. For input
@@ -993,7 +989,7 @@ output them in files named @file{foo-001.jpeg},
@file{foo-002.jpeg},
etc. Images will be rescaled to fit the new WxH values.
If you want to extract just a limited number of frames, you can use the
-above command in combination with the -vframes or -t option, or in
+above command in combination with the -frames or -t option, or in
combination with -ss to start extracting from a certain point in time.
For creating a video from many images:
diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh
index 164550b..c9479da 100755
--- a/tests/codec-regression.sh
+++ b/tests/codec-regression.sh
@@ -216,22 +216,22 @@ fi
if [ -n "$do_dnxhd_1080i" ] ; then
# FIXME: interlaced raw DNxHD decoding is broken
-do_video_encoding dnxhd-1080i.mov "-vcodec dnxhd -flags +ildct -s hd1080 -b
120M -pix_fmt yuv422p -vframes 5 -an"
+do_video_encoding dnxhd-1080i.mov "-vcodec dnxhd -flags +ildct -s hd1080 -b
120M -pix_fmt yuv422p -frames:v 5 -an"
do_video_decoding "" "-s cif -pix_fmt yuv420p"
fi
if [ -n "$do_dnxhd_720p" ] ; then
-do_video_encoding dnxhd-720p.dnxhd "-s hd720 -b 90M -pix_fmt yuv422p -vframes
5 -an"
+do_video_encoding dnxhd-720p.dnxhd "-s hd720 -b 90M -pix_fmt yuv422p -frames:v
5 -an"
do_video_decoding "" "-s cif -pix_fmt yuv420p"
fi
if [ -n "$do_dnxhd_720p_rd" ] ; then
-do_video_encoding dnxhd-720p-rd.dnxhd "-threads 4 -mbd rd -s hd720 -b 90M
-pix_fmt yuv422p -vframes 5 -an"
+do_video_encoding dnxhd-720p-rd.dnxhd "-threads 4 -mbd rd -s hd720 -b 90M
-pix_fmt yuv422p -frames:v 5 -an"
do_video_decoding "" "-s cif -pix_fmt yuv420p"
fi
if [ -n "$do_dnxhd_720p_10bit" ] ; then
-do_video_encoding dnxhd-720p-10bit.dnxhd "-s hd720 -b 90M -pix_fmt yuv422p10
-vframes 5 -an"
+do_video_encoding dnxhd-720p-10bit.dnxhd "-s hd720 -b 90M -pix_fmt yuv422p10
-frames:v 5 -an"
do_video_decoding "" "-s cif -pix_fmt yuv420p"
fi
@@ -246,7 +246,7 @@ do_video_decoding "" "-pix_fmt yuv420p -sws_flags
area+accurate_rnd+bitexact"
fi
if [ -n "$do_roq" ] ; then
-do_video_encoding roqav.roq "-vframes 5"
+do_video_encoding roqav.roq "-frames:v 5"
do_video_decoding "" "-pix_fmt yuv420p"
fi
diff --git a/tests/fate/h264.mak b/tests/fate/h264.mak
index 969bf41..e87e808 100644
--- a/tests/fate/h264.mak
+++ b/tests/fate/h264.mak
@@ -352,6 +352,6 @@ fate-h264-conformance-sva_fm1_e: CMD = framecrc -vsync 0 -i
$(SAMPLES)/h264-conf
fate-h264-conformance-sva_nl1_b: CMD = framecrc -vsync 0 -i
$(SAMPLES)/h264-conformance/SVA_NL1_B.264
fate-h264-conformance-sva_nl2_e: CMD = framecrc -vsync 0 -i
$(SAMPLES)/h264-conformance/SVA_NL2_E.264
-fate-h264-interlace-crop: CMD = framecrc -vsync 0 -vframes 3 -i
$(SAMPLES)/h264/interlaced_crop.mp4
+fate-h264-interlace-crop: CMD = framecrc -vsync 0 -i
$(SAMPLES)/h264/interlaced_crop.mp4 -frames:v 3
fate-h264-lossless: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264/lossless.h264
fate-h264-extreme-plane-pred: CMD = framemd5 -strict 1 -vsync 0 -i
$(SAMPLES)/h264/extreme-plane-pred.h264
diff --git a/tests/fate2.mak b/tests/fate2.mak
index 6a01412..3fce9fc 100644
--- a/tests/fate2.mak
+++ b/tests/fate2.mak
@@ -169,7 +169,7 @@ fate-ansi: CMD = framecrc -chars_per_frame 44100 -i
$(SAMPLES)/ansi/TRE-IOM5.ANS
FATE_TESTS += fate-wmv8-drm
# discard last packet to avoid fails due to overread of VC-1 decoder
-fate-wmv8-drm: CMD = framecrc -cryptokey
137381538c84c068111902a59c5cf6c340247c39 -i $(SAMPLES)/wmv8/wmv_drm.wmv -an
-vframes 162
+fate-wmv8-drm: CMD = framecrc -cryptokey
137381538c84c068111902a59c5cf6c340247c39 -i $(SAMPLES)/wmv8/wmv_drm.wmv -an
-frames:v 162
FATE_TESTS += fate-wmv8-drm-nodec
fate-wmv8-drm-nodec: CMD = framecrc -cryptokey
137381538c84c068111902a59c5cf6c340247c39 -i $(SAMPLES)/wmv8/wmv_drm.wmv -acodec
copy -vcodec copy
--
1.7.5.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel