Newer
Older
if (parse_image_size(&frame_width, &frame_height, arg) < 0) {
fprintf(stderr, "Incorrect frame size\n");
exit(1);
}
if ((frame_width % 2) != 0 || (frame_height % 2) != 0) {
fprintf(stderr, "Frame size must be a multiple of 2\n");
exit(1);
}
}
Todd Kirby
committed
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
#define SCALEBITS 10
#define ONE_HALF (1 << (SCALEBITS - 1))
#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
#define RGB_TO_Y(r, g, b) \
((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \
FIX(0.11400) * (b) + ONE_HALF) >> SCALEBITS)
#define RGB_TO_U(r1, g1, b1, shift)\
(((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \
FIX(0.50000) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
#define RGB_TO_V(r1, g1, b1, shift)\
(((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \
FIX(0.08131) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
static void opt_pad_color(const char *arg) {
/* Input is expected to be six hex digits similar to
how colors are expressed in html tags (but without the #) */
int rgb = strtol(arg, NULL, 16);
int r,g,b;
r = (rgb >> 16);
g = ((rgb >> 8) & 255);
b = (rgb & 255);
padcolor[0] = RGB_TO_Y(r,g,b);
padcolor[1] = RGB_TO_U(r,g,b,0);
padcolor[2] = RGB_TO_V(r,g,b,0);
}
static void opt_frame_pad_top(const char *arg)
{
frame_padtop = atoi(arg);
if (frame_padtop < 0) {
fprintf(stderr, "Incorrect top pad size\n");
exit(1);
}
if ((frame_padtop % 2) != 0) {
fprintf(stderr, "Top pad size must be a multiple of 2\n");
exit(1);
}
}
static void opt_frame_pad_bottom(const char *arg)
{
frame_padbottom = atoi(arg);
if (frame_padbottom < 0) {
fprintf(stderr, "Incorrect bottom pad size\n");
exit(1);
}
if ((frame_padbottom % 2) != 0) {
fprintf(stderr, "Bottom pad size must be a multiple of 2\n");
exit(1);
}
}
static void opt_frame_pad_left(const char *arg)
{
frame_padleft = atoi(arg);
if (frame_padleft < 0) {
fprintf(stderr, "Incorrect left pad size\n");
exit(1);
}
if ((frame_padleft % 2) != 0) {
fprintf(stderr, "Left pad size must be a multiple of 2\n");
exit(1);
}
}
static void opt_frame_pad_right(const char *arg)
{
frame_padright = atoi(arg);
if (frame_padright < 0) {
fprintf(stderr, "Incorrect right pad size\n");
exit(1);
}
if ((frame_padright % 2) != 0) {
fprintf(stderr, "Right pad size must be a multiple of 2\n");
exit(1);
}
}
static void opt_frame_pix_fmt(const char *arg)
{
frame_pix_fmt = avcodec_get_pix_fmt(arg);
}
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
static void opt_frame_aspect_ratio(const char *arg)
{
int x = 0, y = 0;
double ar = 0;
const char *p;
p = strchr(arg, ':');
if (p) {
x = strtol(arg, (char **)&arg, 10);
if (arg == p)
y = strtol(arg+1, (char **)&arg, 10);
if (x > 0 && y > 0)
ar = (double)x / (double)y;
} else
ar = strtod(arg, (char **)&arg);
if (!ar) {
fprintf(stderr, "Incorrect aspect ratio specification.\n");
exit(1);
}
frame_aspect_ratio = ar;
}
static void opt_gop_size(const char *arg)
static void opt_b_frames(const char *arg)
{
b_frames = atoi(arg);
if (b_frames > FF_MAX_B_FRAMES) {
fprintf(stderr, "\nCannot have more than %d B frames, increase FF_MAX_B_FRAMES.\n", FF_MAX_B_FRAMES);
exit(1);
} else if (b_frames < 1) {
fprintf(stderr, "\nNumber of B frames must be higher than 0\n");
exit(1);
}
}
static void opt_mb_decision(const char *arg)
{
mb_decision = atoi(arg);
}
static void opt_mb_cmp(const char *arg)
{
mb_cmp = atoi(arg);
}
static void opt_ildct_cmp(const char *arg)
{
ildct_cmp = atoi(arg);
}
static void opt_sub_cmp(const char *arg)
{
sub_cmp = atoi(arg);
}
static void opt_cmp(const char *arg)
{
cmp = atoi(arg);
}
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
static void opt_pre_cmp(const char *arg)
{
pre_cmp = atoi(arg);
}
static void opt_pre_me(const char *arg)
{
pre_me = atoi(arg);
}
static void opt_lumi_mask(const char *arg)
{
lumi_mask = atof(arg);
}
static void opt_dark_mask(const char *arg)
{
dark_mask = atof(arg);
}
static void opt_scplx_mask(const char *arg)
{
scplx_mask = atof(arg);
}
static void opt_tcplx_mask(const char *arg)
{
tcplx_mask = atof(arg);
}
static void opt_p_mask(const char *arg)
{
p_mask = atof(arg);
}
static void opt_qscale(const char *arg)
Michael Niedermayer
committed
video_qscale = atof(arg);
if (video_qscale < 0.01 ||
video_qscale > 255) {
fprintf(stderr, "qscale must be >= 0.01 and <= 255\n");
static void opt_lmax(const char *arg)
{
video_lmax = atof(arg)*FF_QP2LAMBDA;
}
static void opt_lmin(const char *arg)
{
video_lmin = atof(arg)*FF_QP2LAMBDA;
}
static void opt_qmin(const char *arg)
{
video_qmin = atoi(arg);
if (video_qmin < 0 ||
video_qmin > 31) {
fprintf(stderr, "qmin must be >= 1 and <= 31\n");
exit(1);
}
}
static void opt_qmax(const char *arg)
{
video_qmax = atoi(arg);
if (video_qmax < 0 ||
video_qmax > 31) {
fprintf(stderr, "qmax must be >= 1 and <= 31\n");
exit(1);
}
}
static void opt_mb_qmin(const char *arg)
{
video_mb_qmin = atoi(arg);
if (video_mb_qmin < 0 ||
video_mb_qmin > 31) {
fprintf(stderr, "qmin must be >= 1 and <= 31\n");
exit(1);
}
}
static void opt_mb_qmax(const char *arg)
{
video_mb_qmax = atoi(arg);
if (video_mb_qmax < 0 ||
video_mb_qmax > 31) {
fprintf(stderr, "qmax must be >= 1 and <= 31\n");
exit(1);
}
}
static void opt_qdiff(const char *arg)
{
video_qdiff = atoi(arg);
if (video_qdiff < 0 ||
video_qdiff > 31) {
fprintf(stderr, "qdiff must be >= 1 and <= 31\n");
exit(1);
}
}
static void opt_qblur(const char *arg)
{
video_qblur = atof(arg);
}
static void opt_qcomp(const char *arg)
{
video_qcomp = atof(arg);
}
static void opt_rc_initial_cplx(const char *arg)
{
video_rc_initial_cplx = atof(arg);
}
static void opt_b_qfactor(const char *arg)
{
video_b_qfactor = atof(arg);
}
static void opt_i_qfactor(const char *arg)
{
video_i_qfactor = atof(arg);
}
static void opt_b_qoffset(const char *arg)
{
video_b_qoffset = atof(arg);
}
static void opt_i_qoffset(const char *arg)
{
video_i_qoffset = atof(arg);
}
static void opt_ibias(const char *arg)
{
video_intra_quant_bias = atoi(arg);
}
static void opt_pbias(const char *arg)
{
video_inter_quant_bias = atoi(arg);
}
static void opt_packet_size(const char *arg)
{
packet_size= atoi(arg);
}
static void opt_error_rate(const char *arg)
{
error_rate= atoi(arg);
}
static void opt_strict(const char *arg)
static void opt_top_field_first(const char *arg)
{
top_field_first= atoi(arg);
}
static void opt_noise_reduction(const char *arg)
{
noise_reduction= atoi(arg);
}
static void opt_qns(const char *arg)
{
qns= atoi(arg);
}
static void opt_sc_threshold(const char *arg)
{
sc_threshold= atoi(arg);
}
Timofei V. Bondarenko
committed
static void opt_me_range(const char *arg)
{
me_range = atoi(arg);
}
static void opt_thread_count(const char *arg)
{
thread_count= atoi(arg);
#if !defined(HAVE_PTHREADS) && !defined(HAVE_W32THREADS)
if (verbose >= 0)
fprintf(stderr, "Warning: not compiled with thread support, using thread emulation\n");
static void opt_audio_bitrate(const char *arg)
static void opt_audio_rate(const char *arg)
static void opt_audio_channels(const char *arg)
static void opt_video_device(const char *arg)
static void opt_video_channel(const char *arg)
Fabrice Bellard
committed
{
video_channel = strtol(arg, NULL, 0);
}
static void opt_video_standard(const char *arg)
{
video_standard = av_strdup(arg);
}
static void opt_audio_device(const char *arg)
static void opt_dv1394(const char *arg)
{
video_grab_format = "dv1394";
audio_grab_format = NULL;
static void opt_audio_codec(const char *arg)
if (!strcmp(arg, "copy")) {
audio_stream_copy = 1;
p = first_avcodec;
while (p) {
if (!strcmp(p->name, arg) && p->type == CODEC_TYPE_AUDIO)
break;
p = p->next;
}
if (p == NULL) {
fprintf(stderr, "Unknown audio codec '%s'\n", arg);
exit(1);
} else {
audio_codec_id = p->id;
}
static void add_frame_hooker(const char *arg)
{
int argc = 0;
char *argv[64];
int i;
using_vhook = 1;
argv[0] = strtok(args, " ");
while (argc < 62 && (argv[++argc] = strtok(NULL, " "))) {
}
i = frame_hook_add(argc, argv);
if (i != 0) {
fprintf(stderr, "Failed to add video hook function: %s\n", arg);
exit(1);
}
}
const char *motion_str[] = {
"zero",
"full",
"log",
"phods",
static void opt_motion_estimation(const char *arg)
{
const char **p;
p = motion_str;
for(;;) {
if (!*p) {
fprintf(stderr, "Unknown motion estimation method '%s'\n", arg);
exit(1);
}
if (!strcmp(*p, arg))
break;
p++;
}
static void opt_video_codec(const char *arg)
if (!strcmp(arg, "copy")) {
video_stream_copy = 1;
p = first_avcodec;
while (p) {
if (!strcmp(p->name, arg) && p->type == CODEC_TYPE_VIDEO)
break;
p = p->next;
}
if (p == NULL) {
fprintf(stderr, "Unknown video codec '%s'\n", arg);
exit(1);
} else {
video_codec_id = p->id;
}
static void opt_map(const char *arg)
{
AVStreamMap *m;
const char *p;
p = arg;
m = &stream_maps[nb_stream_maps++];
m->file_index = strtol(arg, (char **)&p, 0);
if (*p)
p++;
m->stream_index = strtol(p, (char **)&p, 0);
static void opt_recording_time(const char *arg)
static void opt_start_time(const char *arg)
{
start_time = parse_date(arg, 1);
}
static void opt_rec_timestamp(const char *arg)
{
rec_timestamp = parse_date(arg, 0) / 1000000;
}
static void opt_input_file(const char *filename)
{
AVFormatContext *ic;
AVFormatParameters params, *ap = ¶ms;
Michael Niedermayer
committed
int err, i, ret, rfps, rfps_base;
if (!strcmp(filename, "-"))
filename = "pipe:";
using_stdin |= !strcmp(filename, "pipe:" ) ||
!strcmp( filename, "/dev/stdin" );
memset(ap, 0, sizeof(*ap));
ap->sample_rate = audio_sample_rate;
ap->channels = audio_channels;
ap->frame_rate = frame_rate;
Michael Niedermayer
committed
ap->frame_rate_base = frame_rate_base;
Todd Kirby
committed
ap->width = frame_width + frame_padleft + frame_padright;
ap->height = frame_height + frame_padtop + frame_padbottom;
Fabrice Bellard
committed
ap->image_format = image_format;
ap->pix_fmt = frame_pix_fmt;
/* open the input file with generic libav function */
err = av_open_input_file(&ic, filename, file_iformat, 0, ap);
print_error(filename, err);
/* If not enough info to get the stream parameters, we decode the
first frames to get it. (used in mpeg case for example) */
ret = av_find_stream_info(ic);
if (ret < 0 && verbose >= 0) {
fprintf(stderr, "%s: could not find codec parameters\n", filename);
exit(1);
}
/* if seeking requested, we execute it */
if (start_time != 0) {
int64_t timestamp;
timestamp = start_time;
/* add the stream start time */
if (ic->start_time != AV_NOPTS_VALUE)
timestamp += ic->start_time;
ret = av_seek_frame(ic, -1, timestamp);
if (ret < 0) {
fprintf(stderr, "%s: could not seek to position %0.3f\n",
filename, (double)timestamp / AV_TIME_BASE);
}
/* reset seek info */
start_time = 0;
}
/* update the current parameters so that they match the one of the input stream */
for(i=0;i<ic->nb_streams;i++) {
AVCodecContext *enc = &ic->streams[i]->codec;
#if defined(HAVE_PTHREADS) || defined(HAVE_W32THREADS)
if(thread_count>1)
avcodec_thread_init(enc, thread_count);
#endif
enc->thread_count= thread_count;
//fprintf(stderr, "\nInput Audio channels: %d", enc->channels);
audio_channels = enc->channels;
audio_sample_rate = enc->sample_rate;
break;
case CODEC_TYPE_VIDEO:
frame_height = enc->height;
frame_width = enc->width;
frame_aspect_ratio = av_q2d(enc->sample_aspect_ratio) * enc->width / enc->height;
frame_pix_fmt = enc->pix_fmt;
Michael Niedermayer
committed
rfps = ic->streams[i]->r_frame_rate;
rfps_base = ic->streams[i]->r_frame_rate_base;
Michael Niedermayer
committed
enc->workaround_bugs = workaround_bugs;
enc->error_resilience = error_resilience;
enc->error_concealment = error_concealment;
Wolfgang Hesseler
committed
enc->idct_algo = idct_algo;
enc->debug = debug;
enc->debug_mv = debug_mv;
if(bitexact)
enc->flags|= CODEC_FLAG_BITEXACT;
Michael Niedermayer
committed
if(me_threshold)
enc->debug |= FF_DEBUG_MV;
Michael Niedermayer
committed
assert(enc->frame_rate_base == rfps_base); // should be true for now
if (enc->frame_rate != rfps) {
if (verbose >= 0)
fprintf(stderr,"\nSeems that stream %d comes from film source: %2.2f->%2.2f\n",
i, (float)enc->frame_rate / enc->frame_rate_base,
Michael Niedermayer
committed
(float)rfps / rfps_base);
/* update the current frame rate to match the stream frame rate */
Michael Niedermayer
committed
frame_rate = rfps;
frame_rate_base = rfps_base;
Max Krasnyansky
committed
enc->rate_emu = rate_emu;
case CODEC_TYPE_DATA:
break;
default:
av_abort();
}
}
input_files[nb_input_files] = ic;
/* dump the file content */
if (verbose >= 0)
dump_format(ic, nb_input_files, filename, 0);
file_iformat = NULL;
file_oformat = NULL;
Fabrice Bellard
committed
image_format = NULL;
Max Krasnyansky
committed
rate_emu = 0;
static void check_audio_video_inputs(int *has_video_ptr, int *has_audio_ptr)
Fabrice Bellard
committed
{
int has_video, has_audio, i, j;
AVFormatContext *ic;
has_video = 0;
has_audio = 0;
for(j=0;j<nb_input_files;j++) {
ic = input_files[j];
for(i=0;i<ic->nb_streams;i++) {
AVCodecContext *enc = &ic->streams[i]->codec;
switch(enc->codec_type) {
case CODEC_TYPE_AUDIO:
has_audio = 1;
break;
case CODEC_TYPE_VIDEO:
has_video = 1;
break;
Wolfram Gloger
committed
case CODEC_TYPE_DATA:
break;
default:
av_abort();
Fabrice Bellard
committed
}
}
}
*has_video_ptr = has_video;
*has_audio_ptr = has_audio;
}
static void opt_output_file(const char *filename)
Fabrice Bellard
committed
int use_video, use_audio, nb_streams, input_has_video, input_has_audio;
Fabrice Bellard
committed
AVFormatParameters params, *ap = ¶ms;
oc = av_alloc_format_context();
if (!file_oformat) {
file_oformat = guess_format(NULL, filename, NULL);
if (!file_oformat) {
fprintf(stderr, "Unable for find a suitable output format for '%s'\n",
filename);
exit(1);
}
oc->oformat = file_oformat;
if (!strcmp(file_oformat->name, "ffm") &&
strstart(filename, "http:", NULL)) {
/* special case for files sent to ffserver: we get the stream
parameters from ffserver */
if (read_ffserver_streams(oc, filename) < 0) {
fprintf(stderr, "Could not read stream parameters from '%s'\n", filename);
exit(1);
}
} else {
use_video = file_oformat->video_codec != CODEC_ID_NONE || video_stream_copy;
use_audio = file_oformat->audio_codec != CODEC_ID_NONE || audio_stream_copy;
Fabrice Bellard
committed
/* disable if no corresponding type found and at least one
input file */
if (nb_input_files > 0) {
check_audio_video_inputs(&input_has_video, &input_has_audio);
if (!input_has_video)
use_video = 0;
if (!input_has_audio)
use_audio = 0;
}
Fabrice Bellard
committed
/* manual disable */
if (audio_disable) {
use_audio = 0;
}
if (video_disable) {
use_video = 0;
}
nb_streams = 0;
if (use_video) {
AVCodecContext *video_enc;
st = av_new_stream(oc, nb_streams++);
if (!st) {
fprintf(stderr, "Could not alloc stream\n");
exit(1);
}
#if defined(HAVE_PTHREADS) || defined(HAVE_W32THREADS)
avcodec_thread_init(&st->codec, thread_count);
video_enc = &st->codec;
Michael Niedermayer
committed
if(!strcmp(file_oformat->name, "mp4") || !strcmp(file_oformat->name, "mov") || !strcmp(file_oformat->name, "3gp"))
video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
if (video_stream_copy) {
st->stream_copy = 1;
video_enc->codec_type = CODEC_TYPE_VIDEO;
} else {
char *p;
int i;
codec_id = file_oformat->video_codec;
if (video_codec_id != CODEC_ID_NONE)
codec_id = video_codec_id;
video_enc->codec_id = codec_id;
codec = avcodec_find_encoder(codec_id);
video_enc->bit_rate = video_bit_rate;
video_enc->bit_rate_tolerance = video_bit_rate_tolerance;
video_enc->frame_rate = frame_rate;
Michael Niedermayer
committed
video_enc->frame_rate_base = frame_rate_base;
if(codec && codec->supported_framerates){
const AVRational *p= codec->supported_framerates;
AVRational req= (AVRational){frame_rate, frame_rate_base};
const AVRational *best=NULL;
AVRational best_error= (AVRational){INT_MAX, 1};
for(; p->den!=0; p++){
AVRational error= av_sub_q(req, *p);
if(error.num <0) error.num *= -1;
if(av_cmp_q(error, best_error) < 0){
best_error= error;
best= p;
}
}
video_enc->frame_rate = best->num;
video_enc->frame_rate_base= best->den;
}
Todd Kirby
committed
video_enc->width = frame_width + frame_padright + frame_padleft;
video_enc->height = frame_height + frame_padtop + frame_padbottom;
video_enc->sample_aspect_ratio = av_d2q(frame_aspect_ratio*frame_height/frame_width, 255);
video_enc->pix_fmt = frame_pix_fmt;
if(codec && codec->pix_fmts){
const enum PixelFormat *p= codec->pix_fmts;
for(; *p!=-1; p++){
if(*p == video_enc->pix_fmt)
break;
}
if(*p == -1)
video_enc->pix_fmt = codec->pix_fmts[0];
}
if (!intra_only)
video_enc->gop_size = gop_size;
else
video_enc->gop_size = 0;
if (video_qscale || same_quality) {
video_enc->flags |= CODEC_FLAG_QSCALE;
Michael Niedermayer
committed
st->quality = FF_QP2LAMBDA * video_qscale;
}
Vidar Madsen
committed
if(intra_matrix)
video_enc->intra_matrix = intra_matrix;
if(inter_matrix)
video_enc->inter_matrix = inter_matrix;
if(bitexact)
video_enc->flags |= CODEC_FLAG_BITEXACT;
video_enc->mb_decision = mb_decision;
video_enc->mb_cmp = mb_cmp;
video_enc->ildct_cmp = ildct_cmp;
video_enc->me_sub_cmp = sub_cmp;
video_enc->me_cmp = cmp;
video_enc->me_pre_cmp = pre_cmp;
video_enc->pre_me = pre_me;
video_enc->lumi_masking = lumi_mask;
video_enc->dark_masking = dark_mask;
video_enc->spatial_cplx_masking = scplx_mask;
video_enc->temporal_cplx_masking = tcplx_mask;
video_enc->p_masking = p_mask;
Michael Niedermayer
committed
if (use_umv) {
video_enc->flags |= CODEC_FLAG_H263P_UMV;
}
if (use_ss) {
video_enc->flags |= CODEC_FLAG_H263P_SLICE_STRUCT;
}
Michael Niedermayer
committed
if (use_aic) {
video_enc->flags |= CODEC_FLAG_H263P_AIC;
}
if (use_aiv) {
video_enc->flags |= CODEC_FLAG_H263P_AIV;
}
if (use_4mv) {
video_enc->flags |= CODEC_FLAG_4MV;
}
if (use_obmc) {
video_enc->flags |= CODEC_FLAG_OBMC;
}
if (use_loop) {
video_enc->flags |= CODEC_FLAG_LOOP_FILTER;
}
video_enc->flags |= CODEC_FLAG_PART;
if (use_alt_scan) {
video_enc->flags |= CODEC_FLAG_ALT_SCAN;
}
if (use_trell) {
video_enc->flags |= CODEC_FLAG_TRELLIS_QUANT;
}
if (use_scan_offset) {
video_enc->flags |= CODEC_FLAG_SVCD_SCAN_OFFSET;
}
if (closed_gop) {
video_enc->flags |= CODEC_FLAG_CLOSED_GOP;
}
if (use_qpel) {
video_enc->flags |= CODEC_FLAG_QPEL;
}
if (use_qprd) {
video_enc->flags |= CODEC_FLAG_QP_RD;
}
if (use_cbprd) {
video_enc->flags |= CODEC_FLAG_CBP_RD;
}
if (b_frames) {
video_enc->max_b_frames = b_frames;
video_enc->b_frame_strategy = 0;
video_enc->b_quant_factor = 2.0;
video_enc->flags |= CODEC_FLAG_INTERLACED_DCT;
}
if (do_interlace_me) {
video_enc->flags |= CODEC_FLAG_INTERLACED_ME;
}
video_enc->qmin = video_qmin;
video_enc->qmax = video_qmax;
video_enc->lmin = video_lmin;
video_enc->lmax = video_lmax;
video_enc->mb_qmin = video_mb_qmin;
video_enc->mb_qmax = video_mb_qmax;
video_enc->max_qdiff = video_qdiff;
video_enc->qblur = video_qblur;
video_enc->qcompress = video_qcomp;
video_enc->rc_eq = video_rc_eq;
Wolfgang Hesseler
committed
video_enc->debug = debug;
video_enc->debug_mv = debug_mv;
video_enc->thread_count = thread_count;
p= video_rc_override_string;
for(i=0; p; i++){
int start, end, q;
int e=sscanf(p, "%d,%d,%d", &start, &end, &q);
if(e!=3){
fprintf(stderr, "error parsing rc_override\n");
exit(1);
}
video_enc->rc_override=
av_realloc(video_enc->rc_override,
sizeof(RcOverride)*(i+1));
video_enc->rc_override[i].start_frame= start;
video_enc->rc_override[i].end_frame = end;
if(q>0){
video_enc->rc_override[i].qscale= q;
video_enc->rc_override[i].quality_factor= 1.0;
}
else{
video_enc->rc_override[i].qscale= 0;
video_enc->rc_override[i].quality_factor= -q/100.0;
}
p= strchr(p, '/');
if(p) p++;
}
video_enc->rc_override_count=i;
video_enc->rc_max_rate = video_rc_max_rate;
video_enc->rc_min_rate = video_rc_min_rate;
video_enc->rc_buffer_size = video_rc_buffer_size;
video_enc->rc_buffer_aggressivity= video_rc_buffer_aggressivity;
video_enc->rc_initial_cplx= video_rc_initial_cplx;
video_enc->i_quant_factor = video_i_qfactor;
video_enc->b_quant_factor = video_b_qfactor;
video_enc->i_quant_offset = video_i_qoffset;
video_enc->b_quant_offset = video_b_qoffset;
video_enc->intra_quant_bias = video_intra_quant_bias;
video_enc->inter_quant_bias = video_inter_quant_bias;
video_enc->dct_algo = dct_algo;
video_enc->idct_algo = idct_algo;
Michael Niedermayer
committed
video_enc->me_threshold= me_threshold;
Michael Niedermayer
committed
video_enc->mb_threshold= mb_threshold;
video_enc->error_rate = error_rate;
video_enc->noise_reduction= noise_reduction;
video_enc->scenechange_threshold= sc_threshold;
Timofei V. Bondarenko
committed
video_enc->me_range = me_range;
video_enc->coder_type= coder;
video_enc->context_model= context;
video_enc->prediction_method= predictor;
Timofei V. Bondarenko
committed
if(packet_size){
video_enc->rtp_mode= 1;
video_enc->rtp_payload_size= packet_size;
}
if (do_psnr)
video_enc->flags|= CODEC_FLAG_PSNR;
video_enc->me_method = me_method;
/* two pass mode */
if (do_pass) {
if (do_pass == 1) {
video_enc->flags |= CODEC_FLAG_PASS1;
} else {
video_enc->flags |= CODEC_FLAG_PASS2;
}
}
if (use_audio) {
AVCodecContext *audio_enc;
st = av_new_stream(oc, nb_streams++);
if (!st) {
fprintf(stderr, "Could not alloc stream\n");
exit(1);
}
#if defined(HAVE_PTHREADS) || defined(HAVE_W32THREADS)
avcodec_thread_init(&st->codec, thread_count);
audio_enc = &st->codec;
audio_enc->codec_type = CODEC_TYPE_AUDIO;
Michael Niedermayer
committed
if(!strcmp(file_oformat->name, "mp4") || !strcmp(file_oformat->name, "mov") || !strcmp(file_oformat->name, "3gp"))
audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
if (audio_stream_copy) {
st->stream_copy = 1;
} else {
codec_id = file_oformat->audio_codec;
if (audio_codec_id != CODEC_ID_NONE)
codec_id = audio_codec_id;
audio_enc->codec_id = codec_id;
audio_enc->bit_rate = audio_bit_rate;
audio_enc->sample_rate = audio_sample_rate;
audio_enc->strict_std_compliance = strict;