Merge "simple_encoder: Add a frame limit argument."
This commit is contained in:
@@ -109,8 +109,8 @@ static const char *exec_name;
|
|||||||
void usage_exit(void) {
|
void usage_exit(void) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Usage: %s <codec> <width> <height> <infile> <outfile> "
|
"Usage: %s <codec> <width> <height> <infile> <outfile> "
|
||||||
"<keyframe-interval> [<error-resilient>]\nSee comments in "
|
"<keyframe-interval> <error-resilient> <frames to encode>\n"
|
||||||
"simple_encoder.c for more information.\n",
|
"See comments in simple_encoder.c for more information.\n",
|
||||||
exec_name);
|
exec_name);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -147,6 +147,7 @@ static int encode_frame(vpx_codec_ctx_t *codec,
|
|||||||
return got_pkts;
|
return got_pkts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(tomfinegan): Improve command line parsing and add args for bitrate/fps.
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
FILE *infile = NULL;
|
FILE *infile = NULL;
|
||||||
vpx_codec_ctx_t codec;
|
vpx_codec_ctx_t codec;
|
||||||
@@ -157,12 +158,11 @@ int main(int argc, char **argv) {
|
|||||||
VpxVideoInfo info = {0};
|
VpxVideoInfo info = {0};
|
||||||
VpxVideoWriter *writer = NULL;
|
VpxVideoWriter *writer = NULL;
|
||||||
const VpxInterface *encoder = NULL;
|
const VpxInterface *encoder = NULL;
|
||||||
const int fps = 30; // TODO(dkovalev) add command line argument
|
const int fps = 30;
|
||||||
const int bitrate = 200; // kbit/s TODO(dkovalev) add command line argument
|
const int bitrate = 200;
|
||||||
int keyframe_interval = 0;
|
int keyframe_interval = 0;
|
||||||
|
int max_frames = 0;
|
||||||
// TODO(dkovalev): Add some simple command line parsing code to make the
|
int frames_encoded = 0;
|
||||||
// command line more flexible.
|
|
||||||
const char *codec_arg = NULL;
|
const char *codec_arg = NULL;
|
||||||
const char *width_arg = NULL;
|
const char *width_arg = NULL;
|
||||||
const char *height_arg = NULL;
|
const char *height_arg = NULL;
|
||||||
@@ -172,7 +172,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
exec_name = argv[0];
|
exec_name = argv[0];
|
||||||
|
|
||||||
if (argc < 7)
|
if (argc != 9)
|
||||||
die("Invalid number of arguments");
|
die("Invalid number of arguments");
|
||||||
|
|
||||||
codec_arg = argv[1];
|
codec_arg = argv[1];
|
||||||
@@ -181,6 +181,7 @@ int main(int argc, char **argv) {
|
|||||||
infile_arg = argv[4];
|
infile_arg = argv[4];
|
||||||
outfile_arg = argv[5];
|
outfile_arg = argv[5];
|
||||||
keyframe_interval_arg = argv[6];
|
keyframe_interval_arg = argv[6];
|
||||||
|
max_frames = strtol(argv[8], NULL, 0);
|
||||||
|
|
||||||
encoder = get_vpx_encoder_by_name(codec_arg);
|
encoder = get_vpx_encoder_by_name(codec_arg);
|
||||||
if (!encoder)
|
if (!encoder)
|
||||||
@@ -219,7 +220,7 @@ int main(int argc, char **argv) {
|
|||||||
cfg.g_timebase.num = info.time_base.numerator;
|
cfg.g_timebase.num = info.time_base.numerator;
|
||||||
cfg.g_timebase.den = info.time_base.denominator;
|
cfg.g_timebase.den = info.time_base.denominator;
|
||||||
cfg.rc_target_bitrate = bitrate;
|
cfg.rc_target_bitrate = bitrate;
|
||||||
cfg.g_error_resilient = argc > 7 ? strtol(argv[7], NULL, 0) : 0;
|
cfg.g_error_resilient = strtol(argv[7], NULL, 0);
|
||||||
|
|
||||||
writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info);
|
writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info);
|
||||||
if (!writer)
|
if (!writer)
|
||||||
@@ -237,6 +238,9 @@ int main(int argc, char **argv) {
|
|||||||
if (keyframe_interval > 0 && frame_count % keyframe_interval == 0)
|
if (keyframe_interval > 0 && frame_count % keyframe_interval == 0)
|
||||||
flags |= VPX_EFLAG_FORCE_KF;
|
flags |= VPX_EFLAG_FORCE_KF;
|
||||||
encode_frame(&codec, &raw, frame_count++, flags, writer);
|
encode_frame(&codec, &raw, frame_count++, flags, writer);
|
||||||
|
frames_encoded++;
|
||||||
|
if (max_frames > 0 && frames_encoded >= max_frames)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush encoder.
|
// Flush encoder.
|
||||||
|
@@ -23,7 +23,7 @@ simple_encoder_verify_environment() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Runs simple_encoder using the codec specified by $1.
|
# Runs simple_encoder using the codec specified by $1 with a frame limit of 100.
|
||||||
simple_encoder() {
|
simple_encoder() {
|
||||||
local encoder="${LIBVPX_BIN_PATH}/simple_encoder${VPX_TEST_EXE_SUFFIX}"
|
local encoder="${LIBVPX_BIN_PATH}/simple_encoder${VPX_TEST_EXE_SUFFIX}"
|
||||||
local codec="$1"
|
local codec="$1"
|
||||||
@@ -35,7 +35,7 @@ simple_encoder() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
eval "${VPX_TEST_PREFIX}" "${encoder}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \
|
eval "${VPX_TEST_PREFIX}" "${encoder}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \
|
||||||
"${YUV_RAW_INPUT_HEIGHT}" "${YUV_RAW_INPUT}" "${output_file}" 9999 \
|
"${YUV_RAW_INPUT_HEIGHT}" "${YUV_RAW_INPUT}" "${output_file}" 9999 0 100 \
|
||||||
${devnull}
|
${devnull}
|
||||||
|
|
||||||
[ -e "${output_file}" ] || return 1
|
[ -e "${output_file}" ] || return 1
|
||||||
@@ -47,16 +47,13 @@ simple_encoder_vp8() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO(tomfinegan): Add a frame limit param to simple_encoder and enable this
|
simple_encoder_vp9() {
|
||||||
# test. VP9 is just too slow right now: This test takes 4m30s+ on a fast
|
|
||||||
# machine.
|
|
||||||
DISABLED_simple_encoder_vp9() {
|
|
||||||
if [ "$(vp9_encode_available)" = "yes" ]; then
|
if [ "$(vp9_encode_available)" = "yes" ]; then
|
||||||
simple_encoder vp9 || return 1
|
simple_encoder vp9 || return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
simple_encoder_tests="simple_encoder_vp8
|
simple_encoder_tests="simple_encoder_vp8
|
||||||
DISABLED_simple_encoder_vp9"
|
simple_encoder_vp9"
|
||||||
|
|
||||||
run_tests simple_encoder_verify_environment "${simple_encoder_tests}"
|
run_tests simple_encoder_verify_environment "${simple_encoder_tests}"
|
||||||
|
Reference in New Issue
Block a user