Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: source/patched-ffmpeg-mt/ffmpeg.c

Issue 4533003: patched ffmpeg nov 2 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * FFmpeg main 2 * FFmpeg main
3 * Copyright (c) 2000-2003 Fabrice Bellard 3 * Copyright (c) 2000-2003 Fabrice Bellard
4 * 4 *
5 * This file is part of FFmpeg. 5 * This file is part of FFmpeg.
6 * 6 *
7 * FFmpeg is free software; you can redistribute it and/or 7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 /* indexed by output file stream index */ 130 /* indexed by output file stream index */
131 static int *streamid_map = NULL; 131 static int *streamid_map = NULL;
132 static int nb_streamid_map = 0; 132 static int nb_streamid_map = 0;
133 133
134 static int frame_width = 0; 134 static int frame_width = 0;
135 static int frame_height = 0; 135 static int frame_height = 0;
136 static float frame_aspect_ratio = 0; 136 static float frame_aspect_ratio = 0;
137 static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE; 137 static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;
138 static enum SampleFormat audio_sample_fmt = SAMPLE_FMT_NONE; 138 static enum SampleFormat audio_sample_fmt = SAMPLE_FMT_NONE;
139 static int frame_topBand = 0;
140 static int frame_bottomBand = 0;
141 static int frame_leftBand = 0;
142 static int frame_rightBand = 0;
143 static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX}; 139 static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX};
144 static AVRational frame_rate; 140 static AVRational frame_rate;
145 static float video_qscale = 0; 141 static float video_qscale = 0;
146 static uint16_t *intra_matrix = NULL; 142 static uint16_t *intra_matrix = NULL;
147 static uint16_t *inter_matrix = NULL; 143 static uint16_t *inter_matrix = NULL;
148 static const char *video_rc_override_string=NULL; 144 static const char *video_rc_override_string=NULL;
149 static int video_disable = 0; 145 static int video_disable = 0;
150 static int video_discard = 0; 146 static int video_discard = 0;
151 static char *video_codec_name = NULL; 147 static char *video_codec_name = NULL;
152 static unsigned int video_codec_tag = 0; 148 static unsigned int video_codec_tag = 0;
(...skipping 28 matching lines...) Expand all
181 static unsigned int subtitle_codec_tag = 0; 177 static unsigned int subtitle_codec_tag = 0;
182 178
183 static float mux_preload= 0.5; 179 static float mux_preload= 0.5;
184 static float mux_max_delay= 0.7; 180 static float mux_max_delay= 0.7;
185 181
186 static int64_t recording_time = INT64_MAX; 182 static int64_t recording_time = INT64_MAX;
187 static int64_t start_time = 0; 183 static int64_t start_time = 0;
188 static int64_t recording_timestamp = 0; 184 static int64_t recording_timestamp = 0;
189 static int64_t input_ts_offset = 0; 185 static int64_t input_ts_offset = 0;
190 static int file_overwrite = 0; 186 static int file_overwrite = 0;
191 static int metadata_count; 187 static AVMetadata *metadata;
192 static AVMetadataTag *metadata;
193 static int do_benchmark = 0; 188 static int do_benchmark = 0;
194 static int do_hex_dump = 0; 189 static int do_hex_dump = 0;
195 static int do_pkt_dump = 0; 190 static int do_pkt_dump = 0;
196 static int do_psnr = 0; 191 static int do_psnr = 0;
197 static int do_pass = 0; 192 static int do_pass = 0;
198 static char *pass_logfilename_prefix = NULL; 193 static char *pass_logfilename_prefix = NULL;
199 static int audio_stream_copy = 0; 194 static int audio_stream_copy = 0;
200 static int video_stream_copy = 0; 195 static int video_stream_copy = 0;
201 static int subtitle_stream_copy = 0; 196 static int subtitle_stream_copy = 0;
202 static int video_sync_method= -1; 197 static int video_sync_method= -1;
(...skipping 20 matching lines...) Expand all
223 static int thread_count= 1; 218 static int thread_count= 1;
224 static int q_pressed = 0; 219 static int q_pressed = 0;
225 static int64_t video_size = 0; 220 static int64_t video_size = 0;
226 static int64_t audio_size = 0; 221 static int64_t audio_size = 0;
227 static int64_t extra_size = 0; 222 static int64_t extra_size = 0;
228 static int nb_frames_dup = 0; 223 static int nb_frames_dup = 0;
229 static int nb_frames_drop = 0; 224 static int nb_frames_drop = 0;
230 static int input_sync; 225 static int input_sync;
231 static uint64_t limit_filesize = 0; 226 static uint64_t limit_filesize = 0;
232 static int force_fps = 0; 227 static int force_fps = 0;
228 static char *forced_key_frames = NULL;
233 229
234 static int pgmyuv_compatibility_hack=0; 230 static int pgmyuv_compatibility_hack=0;
235 static float dts_delta_threshold = 10; 231 static float dts_delta_threshold = 10;
236 232
237 static unsigned int sws_flags = SWS_BICUBIC; 233 static unsigned int sws_flags = SWS_BICUBIC;
238 234
239 static int64_t timer_start; 235 static int64_t timer_start;
240 236
241 static uint8_t *audio_buf; 237 static uint8_t *audio_buf;
242 static uint8_t *audio_out; 238 static uint8_t *audio_out;
243 unsigned int allocated_audio_out_size, allocated_audio_buf_size; 239 unsigned int allocated_audio_out_size, allocated_audio_buf_size;
244 240
245 static short *samples; 241 static short *samples;
246 242
247 static AVBitStreamFilterContext *video_bitstream_filters=NULL; 243 static AVBitStreamFilterContext *video_bitstream_filters=NULL;
248 static AVBitStreamFilterContext *audio_bitstream_filters=NULL; 244 static AVBitStreamFilterContext *audio_bitstream_filters=NULL;
249 static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL; 245 static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL;
250 static AVBitStreamFilterContext **bitstream_filters[MAX_FILES] = {NULL};
251 static int nb_bitstream_filters[MAX_FILES] = {0};
252 246
253 #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass" 247 #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
254 248
255 struct AVInputStream; 249 struct AVInputStream;
256 250
257 typedef struct AVOutputStream { 251 typedef struct AVOutputStream {
258 int file_index; /* file index */ 252 int file_index; /* file index */
259 int index; /* stream index in the output file */ 253 int index; /* stream index in the output file */
260 int source_index; /* AVInputStream index */ 254 int source_index; /* AVInputStream index */
261 AVStream *st; /* stream in the output file */ 255 AVStream *st; /* stream in the output file */
262 int encoding_needed; /* true if encoding needed for this stream */ 256 int encoding_needed; /* true if encoding needed for this stream */
263 int frame_number; 257 int frame_number;
264 /* input pts and corresponding output pts 258 /* input pts and corresponding output pts
265 for A/V sync */ 259 for A/V sync */
266 //double sync_ipts; /* dts from the AVPacket of the demuxer in second units */ 260 //double sync_ipts; /* dts from the AVPacket of the demuxer in second units */
267 struct AVInputStream *sync_ist; /* input stream to sync against */ 261 struct AVInputStream *sync_ist; /* input stream to sync against */
268 int64_t sync_opts; /* output frame counter, could be changed to some t rue timestamp */ //FIXME look at frame_number 262 int64_t sync_opts; /* output frame counter, could be changed to some t rue timestamp */ //FIXME look at frame_number
263 AVBitStreamFilterContext *bitstream_filters;
269 /* video only */ 264 /* video only */
270 int video_resample; 265 int video_resample;
271 AVFrame pict_tmp; /* temporary image for resampling */ 266 AVFrame pict_tmp; /* temporary image for resampling */
272 struct SwsContext *img_resample_ctx; /* for image resampling */ 267 struct SwsContext *img_resample_ctx; /* for image resampling */
273 int resample_height; 268 int resample_height;
274 int resample_width; 269 int resample_width;
275 int resample_pix_fmt; 270 int resample_pix_fmt;
276 271
277 /* full frame size of first frame */ 272 /* full frame size of first frame */
278 int original_height; 273 int original_height;
279 int original_width; 274 int original_width;
280 275
281 /* cropping area sizes */ 276 /* forced key frames */
282 int video_crop; 277 int64_t *forced_kf_pts;
283 int topBand; 278 int forced_kf_count;
284 int bottomBand; 279 int forced_kf_index;
285 int leftBand;
286 int rightBand;
287
288 /* cropping area of first frame */
289 int original_topBand;
290 int original_bottomBand;
291 int original_leftBand;
292 int original_rightBand;
293 280
294 /* audio only */ 281 /* audio only */
295 int audio_resample; 282 int audio_resample;
296 ReSampleContext *resample; /* for audio resampling */ 283 ReSampleContext *resample; /* for audio resampling */
297 int reformat_pair; 284 int reformat_pair;
298 AVAudioConvert *reformat_ctx; 285 AVAudioConvert *reformat_ctx;
299 AVFifoBuffer *fifo; /* for compression: one audio fifo per codec */ 286 AVFifoBuffer *fifo; /* for compression: one audio fifo per codec */
300 FILE *logfile; 287 FILE *logfile;
301 } AVOutputStream; 288 } AVOutputStream;
302 289
290 static AVOutputStream **output_streams_for_file[MAX_FILES] = { NULL };
291 static int nb_output_streams_for_file[MAX_FILES] = { 0 };
292
303 typedef struct AVInputStream { 293 typedef struct AVInputStream {
304 int file_index; 294 int file_index;
305 int index; 295 int index;
306 AVStream *st; 296 AVStream *st;
307 int discard; /* true if stream data should be discarded */ 297 int discard; /* true if stream data should be discarded */
308 int decoding_needed; /* true if the packets must be decoded in 'raw_fifo ' */ 298 int decoding_needed; /* true if the packets must be decoded in 'raw_fifo ' */
309 int64_t sample_index; /* current sample */ 299 int64_t sample_index; /* current sample */
310 300
311 int64_t start; /* time when read started */ 301 int64_t start; /* time when read started */
312 int64_t next_pts; /* synthetic pts for cases where pkt.pts 302 int64_t next_pts; /* synthetic pts for cases where pkt.pts
(...skipping 19 matching lines...) Expand all
332 int nb_streams; /* nb streams we are aware of */ 322 int nb_streams; /* nb streams we are aware of */
333 } AVInputFile; 323 } AVInputFile;
334 324
335 #if HAVE_TERMIOS_H 325 #if HAVE_TERMIOS_H
336 326
337 /* init terminal so that we can grab keys */ 327 /* init terminal so that we can grab keys */
338 static struct termios oldtty; 328 static struct termios oldtty;
339 #endif 329 #endif
340 330
341 #if CONFIG_AVFILTER 331 #if CONFIG_AVFILTER
342 typedef struct {
343 int pix_fmt;
344 } FilterOutPriv;
345
346
347 static int output_init(AVFilterContext *ctx, const char *args, void *opaque)
348 {
349 FilterOutPriv *priv = ctx->priv;
350
351 if(!opaque) return -1;
352
353 priv->pix_fmt = *((int *)opaque);
354
355 return 0;
356 }
357
358 static void output_end_frame(AVFilterLink *link)
359 {
360 }
361
362 static int output_query_formats(AVFilterContext *ctx)
363 {
364 FilterOutPriv *priv = ctx->priv;
365 enum PixelFormat pix_fmts[] = { priv->pix_fmt, PIX_FMT_NONE };
366
367 avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
368 return 0;
369 }
370
371 static int get_filtered_video_pic(AVFilterContext *ctx,
372 AVFilterBufferRef **picref, AVFrame *pic2,
373 uint64_t *pts)
374 {
375 AVFilterBufferRef *pic;
376
377 if(avfilter_request_frame(ctx->inputs[0]))
378 return -1;
379 if(!(pic = ctx->inputs[0]->cur_buf))
380 return -1;
381 *picref = pic;
382 ctx->inputs[0]->cur_buf = NULL;
383
384 *pts = pic->pts;
385
386 memcpy(pic2->data, pic->data, sizeof(pic->data));
387 memcpy(pic2->linesize, pic->linesize, sizeof(pic->linesize));
388 pic2->interlaced_frame = pic->video->interlaced;
389 pic2->top_field_first = pic->video->top_field_first;
390
391 return 1;
392 }
393
394 static AVFilter output_filter =
395 {
396 .name = "ffmpeg_output",
397
398 .priv_size = sizeof(FilterOutPriv),
399 .init = output_init,
400
401 .query_formats = output_query_formats,
402
403 .inputs = (AVFilterPad[]) {{ .name = "default",
404 .type = AVMEDIA_TYPE_VIDEO,
405 .end_frame = output_end_frame,
406 .min_perms = AV_PERM_READ, },
407 { .name = NULL }},
408 .outputs = (AVFilterPad[]) {{ .name = NULL }},
409 };
410 332
411 static int configure_filters(AVInputStream *ist, AVOutputStream *ost) 333 static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
412 { 334 {
413 AVFilterContext *last_filter, *filter; 335 AVFilterContext *last_filter, *filter;
414 /** filter graph containing all filters including input & output */ 336 /** filter graph containing all filters including input & output */
415 AVCodecContext *codec = ost->st->codec; 337 AVCodecContext *codec = ost->st->codec;
416 AVCodecContext *icodec = ist->st->codec; 338 AVCodecContext *icodec = ist->st->codec;
339 FFSinkContext ffsink_ctx = { .pix_fmt = codec->pix_fmt };
417 char args[255]; 340 char args[255];
418 int ret; 341 int ret;
419 342
420 graph = av_mallocz(sizeof(AVFilterGraph)); 343 graph = av_mallocz(sizeof(AVFilterGraph));
421 344
422 if ((ret = avfilter_open(&ist->input_video_filter, avfilter_get_by_name("buf fer"), "src")) < 0) 345 if ((ret = avfilter_open(&ist->input_video_filter, avfilter_get_by_name("buf fer"), "src")) < 0)
423 return ret; 346 return ret;
424 if ((ret = avfilter_open(&ist->output_video_filter, &output_filter, "out")) < 0) 347 if ((ret = avfilter_open(&ist->output_video_filter, &ffsink, "out")) < 0)
425 return ret; 348 return ret;
426 349
427 snprintf(args, 255, "%d:%d:%d", ist->st->codec->width, 350 snprintf(args, 255, "%d:%d:%d:%d:%d", ist->st->codec->width,
428 ist->st->codec->height, ist->st->codec->pix_fmt); 351 ist->st->codec->height, ist->st->codec->pix_fmt,
352 ist->st->time_base.num, ist->st->time_base.den);
429 if ((ret = avfilter_init_filter(ist->input_video_filter, args, NULL)) < 0) 353 if ((ret = avfilter_init_filter(ist->input_video_filter, args, NULL)) < 0)
430 return ret; 354 return ret;
431 if ((ret = avfilter_init_filter(ist->output_video_filter, NULL, &codec->pix_ fmt)) < 0) 355 if ((ret = avfilter_init_filter(ist->output_video_filter, NULL, &ffsink_ctx) ) < 0)
432 return ret; 356 return ret;
433 357
434 /* add input and output filters to the overall graph */ 358 /* add input and output filters to the overall graph */
435 avfilter_graph_add_filter(graph, ist->input_video_filter); 359 avfilter_graph_add_filter(graph, ist->input_video_filter);
436 avfilter_graph_add_filter(graph, ist->output_video_filter); 360 avfilter_graph_add_filter(graph, ist->output_video_filter);
437 361
438 last_filter = ist->input_video_filter; 362 last_filter = ist->input_video_filter;
439 363
440 if (ost->video_crop) { 364 if (codec->width != icodec->width || codec->height != icodec->height) {
441 snprintf(args, 255, "%d:%d:%d:%d",
442 codec->width, codec->height,
443 ost->leftBand, ost->topBand);
444 if ((ret = avfilter_open(&filter, avfilter_get_by_name("crop"), NULL)) < 0)
445 return ret;
446 if ((ret = avfilter_init_filter(filter, args, NULL)) < 0)
447 return ret;
448 if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
449 return ret;
450 last_filter = filter;
451 avfilter_graph_add_filter(graph, last_filter);
452 }
453
454 if((codec->width !=
455 icodec->width - (frame_leftBand + frame_rightBand)) ||
456 (codec->height != icodec->height - (frame_topBand + frame_bottomBand))) {
457 snprintf(args, 255, "%d:%d:flags=0x%X", 365 snprintf(args, 255, "%d:%d:flags=0x%X",
458 codec->width, 366 codec->width,
459 codec->height, 367 codec->height,
460 (int)av_get_int(sws_opts, "sws_flags", NULL)); 368 (int)av_get_int(sws_opts, "sws_flags", NULL));
461 if ((ret = avfilter_open(&filter, avfilter_get_by_name("scale"), NULL)) < 0) 369 if ((ret = avfilter_open(&filter, avfilter_get_by_name("scale"), NULL)) < 0)
462 return ret; 370 return ret;
463 if ((ret = avfilter_init_filter(filter, args, NULL)) < 0) 371 if ((ret = avfilter_init_filter(filter, args, NULL)) < 0)
464 return ret; 372 return ret;
465 if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0) 373 if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
466 return ret; 374 return ret;
(...skipping 19 matching lines...) Expand all
486 inputs->next = NULL; 394 inputs->next = NULL;
487 395
488 if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0) 396 if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
489 return ret; 397 return ret;
490 av_freep(&vfilters); 398 av_freep(&vfilters);
491 } else { 399 } else {
492 if ((ret = avfilter_link(last_filter, 0, ist->output_video_filter, 0)) < 0) 400 if ((ret = avfilter_link(last_filter, 0, ist->output_video_filter, 0)) < 0)
493 return ret; 401 return ret;
494 } 402 }
495 403
496 /* configure all the filter links */ 404 if ((ret = avfilter_graph_config(graph, NULL)) < 0)
497 if ((ret = avfilter_graph_check_validity(graph, NULL)) < 0)
498 return ret;
499 if ((ret = avfilter_graph_config_formats(graph, NULL)) < 0)
500 return ret;
501 if ((ret = avfilter_graph_config_links(graph, NULL)) < 0)
502 return ret; 405 return ret;
503 406
504 codec->width = ist->output_video_filter->inputs[0]->w; 407 codec->width = ist->output_video_filter->inputs[0]->w;
505 codec->height = ist->output_video_filter->inputs[0]->h; 408 codec->height = ist->output_video_filter->inputs[0]->h;
506 409
507 return 0; 410 return 0;
508 } 411 }
509 #endif /* CONFIG_AVFILTER */ 412 #endif /* CONFIG_AVFILTER */
510 413
511 static void term_exit(void) 414 static void term_exit(void)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 av_free(s->streams[j]); 508 av_free(s->streams[j]);
606 } 509 }
607 for(j=0;j<s->nb_programs;j++) { 510 for(j=0;j<s->nb_programs;j++) {
608 av_metadata_free(&s->programs[j]->metadata); 511 av_metadata_free(&s->programs[j]->metadata);
609 } 512 }
610 for(j=0;j<s->nb_chapters;j++) { 513 for(j=0;j<s->nb_chapters;j++) {
611 av_metadata_free(&s->chapters[j]->metadata); 514 av_metadata_free(&s->chapters[j]->metadata);
612 } 515 }
613 av_metadata_free(&s->metadata); 516 av_metadata_free(&s->metadata);
614 av_free(s); 517 av_free(s);
615 av_free(bitstream_filters[i]); 518 av_free(output_streams_for_file[i]);
616 } 519 }
617 for(i=0;i<nb_input_files;i++) { 520 for(i=0;i<nb_input_files;i++) {
618 av_close_input_file(input_files[i]); 521 av_close_input_file(input_files[i]);
619 av_free(input_files_ts_scale[i]); 522 av_free(input_files_ts_scale[i]);
620 } 523 }
621 524
622 av_free(intra_matrix); 525 av_free(intra_matrix);
623 av_free(inter_matrix); 526 av_free(inter_matrix);
624 527
625 if (vstats_file) 528 if (vstats_file)
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 fprintf(stderr, "Audio encoding failed\n"); 897 fprintf(stderr, "Audio encoding failed\n");
995 ffmpeg_exit(1); 898 ffmpeg_exit(1);
996 } 899 }
997 audio_size += ret; 900 audio_size += ret;
998 pkt.stream_index= ost->index; 901 pkt.stream_index= ost->index;
999 pkt.data= audio_out; 902 pkt.data= audio_out;
1000 pkt.size= ret; 903 pkt.size= ret;
1001 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) 904 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
1002 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost ->st->time_base); 905 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost ->st->time_base);
1003 pkt.flags |= AV_PKT_FLAG_KEY; 906 pkt.flags |= AV_PKT_FLAG_KEY;
1004 write_frame(s, &pkt, enc, bitstream_filters[ost->file_index][pkt.str eam_index]); 907 write_frame(s, &pkt, enc, ost->bitstream_filters);
1005 908
1006 ost->sync_opts += enc->frame_size; 909 ost->sync_opts += enc->frame_size;
1007 } 910 }
1008 } else { 911 } else {
1009 AVPacket pkt; 912 AVPacket pkt;
1010 av_init_packet(&pkt); 913 av_init_packet(&pkt);
1011 914
1012 ost->sync_opts += size_out / (osize * enc->channels); 915 ost->sync_opts += size_out / (osize * enc->channels);
1013 916
1014 /* output a pcm frame */ 917 /* output a pcm frame */
(...skipping 14 matching lines...) Expand all
1029 fprintf(stderr, "Audio encoding failed\n"); 932 fprintf(stderr, "Audio encoding failed\n");
1030 ffmpeg_exit(1); 933 ffmpeg_exit(1);
1031 } 934 }
1032 audio_size += ret; 935 audio_size += ret;
1033 pkt.stream_index= ost->index; 936 pkt.stream_index= ost->index;
1034 pkt.data= audio_out; 937 pkt.data= audio_out;
1035 pkt.size= ret; 938 pkt.size= ret;
1036 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE) 939 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS_VALUE)
1037 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st ->time_base); 940 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st ->time_base);
1038 pkt.flags |= AV_PKT_FLAG_KEY; 941 pkt.flags |= AV_PKT_FLAG_KEY;
1039 write_frame(s, &pkt, enc, bitstream_filters[ost->file_index][pkt.stream_ index]); 942 write_frame(s, &pkt, enc, ost->bitstream_filters);
1040 } 943 }
1041 } 944 }
1042 945
1043 static void pre_process_video_frame(AVInputStream *ist, AVPicture *picture, void **bufp) 946 static void pre_process_video_frame(AVInputStream *ist, AVPicture *picture, void **bufp)
1044 { 947 {
1045 AVCodecContext *dec; 948 AVCodecContext *dec;
1046 AVPicture *picture2; 949 AVPicture *picture2;
1047 AVPicture picture_tmp; 950 AVPicture picture_tmp;
1048 uint8_t *buf = 0; 951 uint8_t *buf = 0;
1049 952
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 pkt.size = subtitle_out_size; 1037 pkt.size = subtitle_out_size;
1135 pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->st->time_base); 1038 pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->st->time_base);
1136 if (enc->codec_id == CODEC_ID_DVB_SUBTITLE) { 1039 if (enc->codec_id == CODEC_ID_DVB_SUBTITLE) {
1137 /* XXX: the pts correction is handled here. Maybe handling 1040 /* XXX: the pts correction is handled here. Maybe handling
1138 it in the codec would be better */ 1041 it in the codec would be better */
1139 if (i == 0) 1042 if (i == 0)
1140 pkt.pts += 90 * sub->start_display_time; 1043 pkt.pts += 90 * sub->start_display_time;
1141 else 1044 else
1142 pkt.pts += 90 * sub->end_display_time; 1045 pkt.pts += 90 * sub->end_display_time;
1143 } 1046 }
1144 write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][ pkt.stream_index]); 1047 write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters);
1145 } 1048 }
1146 } 1049 }
1147 1050
1148 static int bit_buffer_size= 1024*256; 1051 static int bit_buffer_size= 1024*256;
1149 static uint8_t *bit_buffer= NULL; 1052 static uint8_t *bit_buffer= NULL;
1150 1053
1151 static void do_video_out(AVFormatContext *s, 1054 static void do_video_out(AVFormatContext *s,
1152 AVOutputStream *ost, 1055 AVOutputStream *ost,
1153 AVInputStream *ist, 1056 AVInputStream *ist,
1154 AVFrame *in_picture, 1057 AVFrame *in_picture,
1155 int *frame_size) 1058 int *frame_size)
1156 { 1059 {
1157 int nb_frames, i, ret; 1060 int nb_frames, i, ret;
1158 #if !CONFIG_AVFILTER
1159 int64_t topBand, bottomBand, leftBand, rightBand;
1160 #endif
1161 AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src; 1061 AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
1162 AVFrame picture_crop_temp, picture_pad_temp;
1163 AVCodecContext *enc, *dec; 1062 AVCodecContext *enc, *dec;
1164 double sync_ipts; 1063 double sync_ipts;
1165 1064
1166 avcodec_get_frame_defaults(&picture_crop_temp);
1167 avcodec_get_frame_defaults(&picture_pad_temp);
1168
1169 enc = ost->st->codec; 1065 enc = ost->st->codec;
1170 dec = ist->st->codec; 1066 dec = ist->st->codec;
1171 1067
1172 sync_ipts = get_sync_ipts(ost) / av_q2d(enc->time_base); 1068 sync_ipts = get_sync_ipts(ost) / av_q2d(enc->time_base);
1173 1069
1174 /* by default, we output a single frame */ 1070 /* by default, we output a single frame */
1175 nb_frames = 1; 1071 nb_frames = 1;
1176 1072
1177 *frame_size = 0; 1073 *frame_size = 0;
1178 1074
(...skipping 19 matching lines...) Expand all
1198 if (verbose>2) 1094 if (verbose>2)
1199 fprintf(stderr, "*** %d dup!\n", nb_frames-1); 1095 fprintf(stderr, "*** %d dup!\n", nb_frames-1);
1200 } 1096 }
1201 }else 1097 }else
1202 ost->sync_opts= lrintf(sync_ipts); 1098 ost->sync_opts= lrintf(sync_ipts);
1203 1099
1204 nb_frames= FFMIN(nb_frames, max_frames[AVMEDIA_TYPE_VIDEO] - ost->frame_numb er); 1100 nb_frames= FFMIN(nb_frames, max_frames[AVMEDIA_TYPE_VIDEO] - ost->frame_numb er);
1205 if (nb_frames <= 0) 1101 if (nb_frames <= 0)
1206 return; 1102 return;
1207 1103
1208 #if CONFIG_AVFILTER
1209 formatted_picture = in_picture; 1104 formatted_picture = in_picture;
1210 #else
1211 if (ost->video_crop) {
1212 if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_pic ture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
1213 fprintf(stderr, "error cropping picture\n");
1214 if (exit_on_error)
1215 ffmpeg_exit(1);
1216 return;
1217 }
1218 formatted_picture = &picture_crop_temp;
1219 } else {
1220 formatted_picture = in_picture;
1221 }
1222 #endif
1223
1224 final_picture = formatted_picture; 1105 final_picture = formatted_picture;
1225 padding_src = formatted_picture; 1106 padding_src = formatted_picture;
1226 resampling_dst = &ost->pict_tmp; 1107 resampling_dst = &ost->pict_tmp;
1227 1108
1228 if( (ost->resample_height != (ist->st->codec->height - (ost->topBand + o st->bottomBand))) 1109 if ( ost->resample_height != ist->st->codec->height
1229 || (ost->resample_width != (ist->st->codec->width - (ost->leftBand + o st->rightBand))) 1110 || ost->resample_width != ist->st->codec->width
1230 || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) { 1111 || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
1231 1112
1232 fprintf(stderr,"Input Stream #%d.%d frame size changed to %dx%d, %s\n", ist->file_index, ist->index, ist->st->codec->width, ist->st->codec->height,a vcodec_get_pix_fmt_name(ist->st->codec->pix_fmt)); 1113 fprintf(stderr,"Input Stream #%d.%d frame size changed to %dx%d, %s\n", ist->file_index, ist->index, ist->st->codec->width, ist->st->codec->height,a vcodec_get_pix_fmt_name(ist->st->codec->pix_fmt));
1233 if(!ost->video_resample) 1114 if(!ost->video_resample)
1234 ffmpeg_exit(1); 1115 ffmpeg_exit(1);
1235 } 1116 }
1236 1117
1237 #if !CONFIG_AVFILTER 1118 #if !CONFIG_AVFILTER
1238 if (ost->video_resample) { 1119 if (ost->video_resample) {
1239 padding_src = NULL; 1120 padding_src = NULL;
1240 final_picture = &ost->pict_tmp; 1121 final_picture = &ost->pict_tmp;
1241 if( (ost->resample_height != (ist->st->codec->height - (ost->topBand + ost->bottomBand))) 1122 if( ost->resample_height != ist->st->codec->height
1242 || (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand))) 1123 || ost->resample_width != ist->st->codec->width
1243 || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) { 1124 || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
1244 1125
1245 /* keep bands proportional to the frame size */
1246 topBand = ((int64_t)ist->st->codec->height * ost->original_topBan d / ost->original_height) & ~1;
1247 bottomBand = ((int64_t)ist->st->codec->height * ost->original_bottom Band / ost->original_height) & ~1;
1248 leftBand = ((int64_t)ist->st->codec->width * ost->original_leftBa nd / ost->original_width) & ~1;
1249 rightBand = ((int64_t)ist->st->codec->width * ost->original_rightB and / ost->original_width) & ~1;
1250
1251 /* sanity check to ensure no bad band sizes sneak in */
1252 av_assert0(topBand <= INT_MAX && topBand >= 0);
1253 av_assert0(bottomBand <= INT_MAX && bottomBand >= 0);
1254 av_assert0(leftBand <= INT_MAX && leftBand >= 0);
1255 av_assert0(rightBand <= INT_MAX && rightBand >= 0);
1256
1257 ost->topBand = topBand;
1258 ost->bottomBand = bottomBand;
1259 ost->leftBand = leftBand;
1260 ost->rightBand = rightBand;
1261
1262 ost->resample_height = ist->st->codec->height - (ost->topBand + ost ->bottomBand);
1263 ost->resample_width = ist->st->codec->width - (ost->leftBand + ost ->rightBand);
1264 ost->resample_pix_fmt= ist->st->codec->pix_fmt;
1265
1266 /* initialize a new scaler context */ 1126 /* initialize a new scaler context */
1267 sws_freeContext(ost->img_resample_ctx); 1127 sws_freeContext(ost->img_resample_ctx);
1268 sws_flags = av_get_int(sws_opts, "sws_flags", NULL); 1128 sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
1269 ost->img_resample_ctx = sws_getContext( 1129 ost->img_resample_ctx = sws_getContext(
1270 ist->st->codec->width - (ost->leftBand + ost->rightBand), 1130 ist->st->codec->width,
1271 ist->st->codec->height - (ost->topBand + ost->bottomBand), 1131 ist->st->codec->height,
1272 ist->st->codec->pix_fmt, 1132 ist->st->codec->pix_fmt,
1273 ost->st->codec->width, 1133 ost->st->codec->width,
1274 ost->st->codec->height, 1134 ost->st->codec->height,
1275 ost->st->codec->pix_fmt, 1135 ost->st->codec->pix_fmt,
1276 sws_flags, NULL, NULL, NULL); 1136 sws_flags, NULL, NULL, NULL);
1277 if (ost->img_resample_ctx == NULL) { 1137 if (ost->img_resample_ctx == NULL) {
1278 fprintf(stderr, "Cannot get resampling context\n"); 1138 fprintf(stderr, "Cannot get resampling context\n");
1279 ffmpeg_exit(1); 1139 ffmpeg_exit(1);
1280 } 1140 }
1281 } 1141 }
(...skipping 12 matching lines...) Expand all
1294 /* raw pictures are written as AVPicture structure to 1154 /* raw pictures are written as AVPicture structure to
1295 avoid any copies. We support temorarily the older 1155 avoid any copies. We support temorarily the older
1296 method. */ 1156 method. */
1297 AVFrame* old_frame = enc->coded_frame; 1157 AVFrame* old_frame = enc->coded_frame;
1298 enc->coded_frame = dec->coded_frame; //FIXME/XXX remove this hack 1158 enc->coded_frame = dec->coded_frame; //FIXME/XXX remove this hack
1299 pkt.data= (uint8_t *)final_picture; 1159 pkt.data= (uint8_t *)final_picture;
1300 pkt.size= sizeof(AVPicture); 1160 pkt.size= sizeof(AVPicture);
1301 pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_ base); 1161 pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_ base);
1302 pkt.flags |= AV_PKT_FLAG_KEY; 1162 pkt.flags |= AV_PKT_FLAG_KEY;
1303 1163
1304 write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_ind ex][pkt.stream_index]); 1164 write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters);
1305 enc->coded_frame = old_frame; 1165 enc->coded_frame = old_frame;
1306 } else { 1166 } else {
1307 AVFrame big_picture; 1167 AVFrame big_picture;
1308 1168
1309 big_picture= *final_picture; 1169 big_picture= *final_picture;
1310 /* better than nothing: use input picture interlaced 1170 /* better than nothing: use input picture interlaced
1311 settings */ 1171 settings */
1312 big_picture.interlaced_frame = in_picture->interlaced_frame; 1172 big_picture.interlaced_frame = in_picture->interlaced_frame;
1313 if(avcodec_opts[AVMEDIA_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_ DCT|CODEC_FLAG_INTERLACED_ME)){ 1173 if(avcodec_opts[AVMEDIA_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_ DCT|CODEC_FLAG_INTERLACED_ME)){
1314 if(top_field_first == -1) 1174 if(top_field_first == -1)
1315 big_picture.top_field_first = in_picture->top_field_first; 1175 big_picture.top_field_first = in_picture->top_field_first;
1316 else 1176 else
1317 big_picture.top_field_first = top_field_first; 1177 big_picture.top_field_first = top_field_first;
1318 } 1178 }
1319 1179
1320 /* handles sameq here. This is not correct because it may 1180 /* handles sameq here. This is not correct because it may
1321 not be a global option */ 1181 not be a global option */
1322 big_picture.quality = same_quality ? ist->st->quality : ost->st->qua lity; 1182 big_picture.quality = same_quality ? ist->st->quality : ost->st->qua lity;
1323 if(!me_threshold) 1183 if(!me_threshold)
1324 big_picture.pict_type = 0; 1184 big_picture.pict_type = 0;
1325 // big_picture.pts = AV_NOPTS_VALUE; 1185 // big_picture.pts = AV_NOPTS_VALUE;
1326 big_picture.pts= ost->sync_opts; 1186 big_picture.pts= ost->sync_opts;
1327 // big_picture.pts= av_rescale(ost->sync_opts, AV_TIME_BASE*(int64_t) enc->time_base.num, enc->time_base.den); 1187 // big_picture.pts= av_rescale(ost->sync_opts, AV_TIME_BASE*(int64_t) enc->time_base.num, enc->time_base.den);
1328 //av_log(NULL, AV_LOG_DEBUG, "%"PRId64" -> encoder\n", ost->sync_opts); 1188 //av_log(NULL, AV_LOG_DEBUG, "%"PRId64" -> encoder\n", ost->sync_opts);
1189 if (ost->forced_kf_index < ost->forced_kf_count &&
1190 big_picture.pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
1191 big_picture.pict_type = FF_I_TYPE;
1192 ost->forced_kf_index++;
1193 }
1329 ret = avcodec_encode_video(enc, 1194 ret = avcodec_encode_video(enc,
1330 bit_buffer, bit_buffer_size, 1195 bit_buffer, bit_buffer_size,
1331 &big_picture); 1196 &big_picture);
1332 if (ret < 0) { 1197 if (ret < 0) {
1333 fprintf(stderr, "Video encoding failed\n"); 1198 fprintf(stderr, "Video encoding failed\n");
1334 ffmpeg_exit(1); 1199 ffmpeg_exit(1);
1335 } 1200 }
1336 1201
1337 if(ret>0){ 1202 if(ret>0){
1338 pkt.data= bit_buffer; 1203 pkt.data= bit_buffer;
1339 pkt.size= ret; 1204 pkt.size= ret;
1340 if(enc->coded_frame->pts != AV_NOPTS_VALUE) 1205 if(enc->coded_frame->pts != AV_NOPTS_VALUE)
1341 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base); 1206 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
1342 /*av_log(NULL, AV_LOG_DEBUG, "encoder -> %"PRId64"/%"PRId64"\n", 1207 /*av_log(NULL, AV_LOG_DEBUG, "encoder -> %"PRId64"/%"PRId64"\n",
1343 pkt.pts != AV_NOPTS_VALUE ? av_rescale(pkt.pts, enc->time_base.den, AV_TIME_B ASE*(int64_t)enc->time_base.num) : -1, 1208 pkt.pts != AV_NOPTS_VALUE ? av_rescale(pkt.pts, enc->time_base.den, AV_TIME_B ASE*(int64_t)enc->time_base.num) : -1,
1344 pkt.dts != AV_NOPTS_VALUE ? av_rescale(pkt.dts, enc->time_base.den, AV_TIME_B ASE*(int64_t)enc->time_base.num) : -1);*/ 1209 pkt.dts != AV_NOPTS_VALUE ? av_rescale(pkt.dts, enc->time_base.den, AV_TIME_B ASE*(int64_t)enc->time_base.num) : -1);*/
1345 1210
1346 if(enc->coded_frame->key_frame) 1211 if(enc->coded_frame->key_frame)
1347 pkt.flags |= AV_PKT_FLAG_KEY; 1212 pkt.flags |= AV_PKT_FLAG_KEY;
1348 write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file _index][pkt.stream_index]); 1213 write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters);
1349 *frame_size = ret; 1214 *frame_size = ret;
1350 video_size += ret; 1215 video_size += ret;
1351 //fprintf(stderr,"\nFrame: %3d size: %5d type: %d", 1216 //fprintf(stderr,"\nFrame: %3d size: %5d type: %d",
1352 // enc->frame_number-1, ret, enc->pict_type); 1217 // enc->frame_number-1, ret, enc->pict_type);
1353 /* if two pass, output log */ 1218 /* if two pass, output log */
1354 if (ost->logfile && enc->stats_out) { 1219 if (ost->logfile && enc->stats_out) {
1355 fprintf(ost->logfile, "%s", enc->stats_out); 1220 fprintf(ost->logfile, "%s", enc->stats_out);
1356 } 1221 }
1357 } 1222 }
1358 } 1223 }
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 } 1572 }
1708 #if CONFIG_AVFILTER 1573 #if CONFIG_AVFILTER
1709 frame_available = ist->st->codec->codec_type != AVMEDIA_TYPE_VIDEO || 1574 frame_available = ist->st->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
1710 !ist->output_video_filter || avfilter_poll_frame(ist->output_video_f ilter->inputs[0]); 1575 !ist->output_video_filter || avfilter_poll_frame(ist->output_video_f ilter->inputs[0]);
1711 #endif 1576 #endif
1712 /* if output time reached then transcode raw format, 1577 /* if output time reached then transcode raw format,
1713 encode packets and output them */ 1578 encode packets and output them */
1714 if (start_time == 0 || ist->pts >= start_time) 1579 if (start_time == 0 || ist->pts >= start_time)
1715 #if CONFIG_AVFILTER 1580 #if CONFIG_AVFILTER
1716 while (frame_available) { 1581 while (frame_available) {
1582 AVRational ist_pts_tb;
1717 if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ist->output_ video_filter) 1583 if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ist->output_ video_filter)
1718 get_filtered_video_pic(ist->output_video_filter, &ist->picref, & picture, &ist->pts); 1584 get_filtered_video_frame(ist->output_video_filter, &picture, &is t->picref, &ist_pts_tb);
1585 if (ist->picref)
1586 ist->pts = ist->picref->pts;
1719 #endif 1587 #endif
1720 for(i=0;i<nb_ostreams;i++) { 1588 for(i=0;i<nb_ostreams;i++) {
1721 int frame_size; 1589 int frame_size;
1722 1590
1723 ost = ost_table[i]; 1591 ost = ost_table[i];
1724 if (ost->source_index == ist_index) { 1592 if (ost->source_index == ist_index) {
1725 os = output_files[ost->file_index]; 1593 os = output_files[ost->file_index];
1726 1594
1727 /* set the input output pts pairs */ 1595 /* set the input output pts pairs */
1728 //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset [ist->file_index] - start_time)/ AV_TIME_BASE; 1596 //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset [ist->file_index] - start_time)/ AV_TIME_BASE;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 && ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO 1661 && ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO
1794 && ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO 1662 && ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO
1795 ) { 1663 ) {
1796 if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & AV_PKT_FLAG_KEY)) 1664 if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & AV_PKT_FLAG_KEY))
1797 opkt.destruct= av_destruct_packet; 1665 opkt.destruct= av_destruct_packet;
1798 } else { 1666 } else {
1799 opkt.data = data_buf; 1667 opkt.data = data_buf;
1800 opkt.size = data_size; 1668 opkt.size = data_size;
1801 } 1669 }
1802 1670
1803 write_frame(os, &opkt, ost->st->codec, bitstream_filters [ost->file_index][opkt.stream_index]); 1671 write_frame(os, &opkt, ost->st->codec, ost->bitstream_fi lters);
1804 ost->st->codec->frame_number++; 1672 ost->st->codec->frame_number++;
1805 ost->frame_number++; 1673 ost->frame_number++;
1806 av_free_packet(&opkt); 1674 av_free_packet(&opkt);
1807 } 1675 }
1808 } 1676 }
1809 } 1677 }
1810 1678
1811 #if CONFIG_AVFILTER 1679 #if CONFIG_AVFILTER
1812 frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) && 1680 frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
1813 ist->output_video_filter && avfilter_poll_frame(is t->output_video_filter->inputs[0]); 1681 ist->output_video_filter && avfilter_poll_frame(is t->output_video_filter->inputs[0]);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 default: 1770 default:
1903 ret=-1; 1771 ret=-1;
1904 } 1772 }
1905 1773
1906 if(ret<=0) 1774 if(ret<=0)
1907 break; 1775 break;
1908 pkt.data= bit_buffer; 1776 pkt.data= bit_buffer;
1909 pkt.size= ret; 1777 pkt.size= ret;
1910 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS _VALUE) 1778 if(enc->coded_frame && enc->coded_frame->pts != AV_NOPTS _VALUE)
1911 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->ti me_base, ost->st->time_base); 1779 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->ti me_base, ost->st->time_base);
1912 write_frame(os, &pkt, ost->st->codec, bitstream_filters[ ost->file_index][pkt.stream_index]); 1780 write_frame(os, &pkt, ost->st->codec, ost->bitstream_fil ters);
1913 } 1781 }
1914 } 1782 }
1915 } 1783 }
1916 } 1784 }
1917 } 1785 }
1918 1786
1919 return 0; 1787 return 0;
1920 fail_decode: 1788 fail_decode:
1921 return -1; 1789 return -1;
1922 } 1790 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 1832
1965 os->nb_chapters++; 1833 os->nb_chapters++;
1966 os->chapters = av_realloc(os->chapters, sizeof(AVChapter)*os->nb_chapter s); 1834 os->chapters = av_realloc(os->chapters, sizeof(AVChapter)*os->nb_chapter s);
1967 if (!os->chapters) 1835 if (!os->chapters)
1968 return AVERROR(ENOMEM); 1836 return AVERROR(ENOMEM);
1969 os->chapters[os->nb_chapters - 1] = out_ch; 1837 os->chapters[os->nb_chapters - 1] = out_ch;
1970 } 1838 }
1971 return 0; 1839 return 0;
1972 } 1840 }
1973 1841
1842 static void parse_forced_key_frames(char *kf, AVOutputStream *ost,
1843 AVCodecContext *avctx)
1844 {
1845 char *p;
1846 int n = 1, i;
1847 int64_t t;
1848
1849 for (p = kf; *p; p++)
1850 if (*p == ',')
1851 n++;
1852 ost->forced_kf_count = n;
1853 ost->forced_kf_pts = av_malloc(sizeof(*ost->forced_kf_pts) * n);
1854 if (!ost->forced_kf_pts) {
1855 av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\ n");
1856 ffmpeg_exit(1);
1857 }
1858 for (i = 0; i < n; i++) {
1859 p = i ? strchr(p, ',') + 1 : kf;
1860 t = parse_time_or_die("force_key_frames", p, 1);
1861 ost->forced_kf_pts[i] = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base );
1862 }
1863 }
1864
1974 /* 1865 /*
1975 * The following code is the main loop of the file converter 1866 * The following code is the main loop of the file converter
1976 */ 1867 */
1977 static int transcode(AVFormatContext **output_files, 1868 static int transcode(AVFormatContext **output_files,
1978 int nb_output_files, 1869 int nb_output_files,
1979 AVFormatContext **input_files, 1870 AVFormatContext **input_files,
1980 int nb_input_files, 1871 int nb_input_files,
1981 AVStreamMap *stream_maps, int nb_stream_maps) 1872 AVStreamMap *stream_maps, int nb_stream_maps)
1982 { 1873 {
1983 int ret = 0, i, j, k, n, nb_istreams = 0, nb_ostreams = 0; 1874 int ret = 0, i, j, k, n, nb_istreams = 0, nb_ostreams = 0;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 si < 0 || si > file_table[fi].nb_streams - 1) { 1959 si < 0 || si > file_table[fi].nb_streams - 1) {
2069 fprintf(stderr,"Could not find sync stream #%d.%d\n", fi, si); 1960 fprintf(stderr,"Could not find sync stream #%d.%d\n", fi, si);
2070 ret = AVERROR(EINVAL); 1961 ret = AVERROR(EINVAL);
2071 goto fail; 1962 goto fail;
2072 } 1963 }
2073 } 1964 }
2074 1965
2075 ost_table = av_mallocz(sizeof(AVOutputStream *) * nb_ostreams); 1966 ost_table = av_mallocz(sizeof(AVOutputStream *) * nb_ostreams);
2076 if (!ost_table) 1967 if (!ost_table)
2077 goto fail; 1968 goto fail;
2078 for(i=0;i<nb_ostreams;i++) {
2079 ost = av_mallocz(sizeof(AVOutputStream));
2080 if (!ost)
2081 goto fail;
2082 ost_table[i] = ost;
2083 }
2084
2085 n = 0; 1969 n = 0;
2086 for(k=0;k<nb_output_files;k++) { 1970 for(k=0;k<nb_output_files;k++) {
2087 os = output_files[k]; 1971 os = output_files[k];
2088 for(i=0;i<os->nb_streams;i++,n++) { 1972 for(i=0;i<os->nb_streams;i++,n++) {
2089 int found; 1973 int found;
2090 ost = ost_table[n]; 1974 ost = ost_table[n] = output_streams_for_file[k][i];
2091 ost->file_index = k;
2092 ost->index = i;
2093 ost->st = os->streams[i]; 1975 ost->st = os->streams[i];
2094 if (nb_stream_maps > 0) { 1976 if (nb_stream_maps > 0) {
2095 ost->source_index = file_table[stream_maps[n].file_index].ist_in dex + 1977 ost->source_index = file_table[stream_maps[n].file_index].ist_in dex +
2096 stream_maps[n].stream_index; 1978 stream_maps[n].stream_index;
2097 1979
2098 /* Sanity check that the stream types match */ 1980 /* Sanity check that the stream types match */
2099 if (ist_table[ost->source_index]->st->codec->codec_type != ost-> st->codec->codec_type) { 1981 if (ist_table[ost->source_index]->st->codec->codec_type != ost-> st->codec->codec_type) {
2100 int i= ost->file_index; 1982 int i= ost->file_index;
2101 dump_format(output_files[i], i, output_files[i]->filename, 1 ); 1983 dump_format(output_files[i], i, output_files[i]->filename, 1 );
2102 fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> # %d.%d\n", 1984 fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> # %d.%d\n",
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; 2135 ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
2254 icodec->request_channels = codec->channels; 2136 icodec->request_channels = codec->channels;
2255 ist->decoding_needed = 1; 2137 ist->decoding_needed = 1;
2256 ost->encoding_needed = 1; 2138 ost->encoding_needed = 1;
2257 break; 2139 break;
2258 case AVMEDIA_TYPE_VIDEO: 2140 case AVMEDIA_TYPE_VIDEO:
2259 if (ost->st->codec->pix_fmt == PIX_FMT_NONE) { 2141 if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
2260 fprintf(stderr, "Video pixel format is unknown, stream canno t be encoded\n"); 2142 fprintf(stderr, "Video pixel format is unknown, stream canno t be encoded\n");
2261 ffmpeg_exit(1); 2143 ffmpeg_exit(1);
2262 } 2144 }
2263 ost->video_crop = ((frame_leftBand + frame_rightBand + frame_top Band + frame_bottomBand) != 0); 2145 ost->video_resample = (codec->width != icodec->width ||
2264 ost->video_resample = ((codec->width != icodec->width - 2146 codec->height != icodec->height ||
2265 (frame_leftBand + frame_rightBand)) ||
2266 (codec->height != icodec->height -
2267 (frame_topBand + frame_bottomBand)) ||
2268 (codec->pix_fmt != icodec->pix_fmt)); 2147 (codec->pix_fmt != icodec->pix_fmt));
2269 if (ost->video_crop) {
2270 ost->topBand = ost->original_topBand = frame_topBand;
2271 ost->bottomBand = ost->original_bottomBand = frame_bottomBan d;
2272 ost->leftBand = ost->original_leftBand = frame_leftBand;
2273 ost->rightBand = ost->original_rightBand = frame_rightBand ;
2274 }
2275 if (ost->video_resample) { 2148 if (ost->video_resample) {
2276 avcodec_get_frame_defaults(&ost->pict_tmp); 2149 avcodec_get_frame_defaults(&ost->pict_tmp);
2277 if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fm t, 2150 if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fm t,
2278 codec->width, codec->height)) { 2151 codec->width, codec->height)) {
2279 fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n"); 2152 fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n");
2280 ffmpeg_exit(1); 2153 ffmpeg_exit(1);
2281 } 2154 }
2282 sws_flags = av_get_int(sws_opts, "sws_flags", NULL); 2155 sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
2283 ost->img_resample_ctx = sws_getContext( 2156 ost->img_resample_ctx = sws_getContext(
2284 icodec->width - (frame_leftBand + frame_rightBand), 2157 icodec->width,
2285 icodec->height - (frame_topBand + frame_bottomBand), 2158 icodec->height,
2286 icodec->pix_fmt, 2159 icodec->pix_fmt,
2287 codec->width, 2160 codec->width,
2288 codec->height, 2161 codec->height,
2289 codec->pix_fmt, 2162 codec->pix_fmt,
2290 sws_flags, NULL, NULL, NULL); 2163 sws_flags, NULL, NULL, NULL);
2291 if (ost->img_resample_ctx == NULL) { 2164 if (ost->img_resample_ctx == NULL) {
2292 fprintf(stderr, "Cannot get resampling context\n"); 2165 fprintf(stderr, "Cannot get resampling context\n");
2293 ffmpeg_exit(1); 2166 ffmpeg_exit(1);
2294 } 2167 }
2295 2168
2296 #if !CONFIG_AVFILTER 2169 #if !CONFIG_AVFILTER
2297 ost->original_height = icodec->height; 2170 ost->original_height = icodec->height;
2298 ost->original_width = icodec->width; 2171 ost->original_width = icodec->width;
2299 #endif 2172 #endif
2300 codec->bits_per_raw_sample= 0; 2173 codec->bits_per_raw_sample= 0;
2301 } 2174 }
2302 ost->resample_height = icodec->height - (frame_topBand + frame_ bottomBand); 2175 ost->resample_height = icodec->height;
2303 ost->resample_width = icodec->width - (frame_leftBand + frame_ rightBand); 2176 ost->resample_width = icodec->width;
2304 ost->resample_pix_fmt= icodec->pix_fmt; 2177 ost->resample_pix_fmt= icodec->pix_fmt;
2305 ost->encoding_needed = 1; 2178 ost->encoding_needed = 1;
2306 ist->decoding_needed = 1; 2179 ist->decoding_needed = 1;
2307 2180
2308 #if CONFIG_AVFILTER 2181 #if CONFIG_AVFILTER
2309 if (configure_filters(ist, ost)) { 2182 if (configure_filters(ist, ost)) {
2310 fprintf(stderr, "Error opening filters!\n"); 2183 fprintf(stderr, "Error opening filters!\n");
2311 exit(1); 2184 exit(1);
2312 } 2185 }
2313 #endif 2186 #endif
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 goto dump_format; 2314 goto dump_format;
2442 } 2315 }
2443 2316
2444 out_file = output_files[out_file_index]; 2317 out_file = output_files[out_file_index];
2445 in_file = input_files[in_file_index]; 2318 in_file = input_files[in_file_index];
2446 2319
2447 2320
2448 mtag=NULL; 2321 mtag=NULL;
2449 while((mtag=av_metadata_get(in_file->metadata, "", mtag, AV_METADATA_IGN ORE_SUFFIX))) 2322 while((mtag=av_metadata_get(in_file->metadata, "", mtag, AV_METADATA_IGN ORE_SUFFIX)))
2450 av_metadata_set2(&out_file->metadata, mtag->key, mtag->value, AV_MET ADATA_DONT_OVERWRITE); 2323 av_metadata_set2(&out_file->metadata, mtag->key, mtag->value, AV_MET ADATA_DONT_OVERWRITE);
2451 av_metadata_conv(out_file, out_file->oformat->metadata_conv,
2452 in_file->iformat->metadata_conv);
2453 } 2324 }
2454 2325
2455 /* copy chapters from the first input file that has them*/ 2326 /* copy chapters from the first input file that has them*/
2456 for (i = 0; i < nb_input_files; i++) { 2327 for (i = 0; i < nb_input_files; i++) {
2457 if (!input_files[i]->nb_chapters) 2328 if (!input_files[i]->nb_chapters)
2458 continue; 2329 continue;
2459 2330
2460 for (j = 0; j < nb_output_files; j++) 2331 for (j = 0; j < nb_output_files; j++)
2461 if ((ret = copy_chapters(i, j)) < 0) 2332 if ((ret = copy_chapters(i, j)) < 0)
2462 goto dump_format; 2333 goto dump_format;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
2725 if (ost) { 2596 if (ost) {
2726 if (ost->st->stream_copy) 2597 if (ost->st->stream_copy)
2727 av_freep(&ost->st->codec->extradata); 2598 av_freep(&ost->st->codec->extradata);
2728 if (ost->logfile) { 2599 if (ost->logfile) {
2729 fclose(ost->logfile); 2600 fclose(ost->logfile);
2730 ost->logfile = NULL; 2601 ost->logfile = NULL;
2731 } 2602 }
2732 av_fifo_free(ost->fifo); /* works even if fifo is not 2603 av_fifo_free(ost->fifo); /* works even if fifo is not
2733 initialized but set to zero */ 2604 initialized but set to zero */
2734 av_free(ost->pict_tmp.data[0]); 2605 av_free(ost->pict_tmp.data[0]);
2606 av_free(ost->forced_kf_pts);
2735 if (ost->video_resample) 2607 if (ost->video_resample)
2736 sws_freeContext(ost->img_resample_ctx); 2608 sws_freeContext(ost->img_resample_ctx);
2737 if (ost->resample) 2609 if (ost->resample)
2738 audio_resample_close(ost->resample); 2610 audio_resample_close(ost->resample);
2739 if (ost->reformat_ctx) 2611 if (ost->reformat_ctx)
2740 av_audio_convert_free(ost->reformat_ctx); 2612 av_audio_convert_free(ost->reformat_ctx);
2741 av_free(ost); 2613 av_free(ost);
2742 } 2614 }
2743 } 2615 }
2744 av_free(ost_table); 2616 av_free(ost_table);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 int codec_type = opt[0]=='a' ? AVMEDIA_TYPE_AUDIO : AVMEDIA_TYPE_VIDEO; 2662 int codec_type = opt[0]=='a' ? AVMEDIA_TYPE_AUDIO : AVMEDIA_TYPE_VIDEO;
2791 2663
2792 opt_default(opt, arg); 2664 opt_default(opt, arg);
2793 2665
2794 if (av_get_int(avcodec_opts[codec_type], "b", NULL) < 1000) 2666 if (av_get_int(avcodec_opts[codec_type], "b", NULL) < 1000)
2795 fprintf(stderr, "WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s\n"); 2667 fprintf(stderr, "WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s\n");
2796 2668
2797 return 0; 2669 return 0;
2798 } 2670 }
2799 2671
2800 static void opt_frame_crop_top(const char *arg) 2672 static int opt_frame_crop(const char *opt, const char *arg)
2801 { 2673 {
2802 frame_topBand = atoi(arg); 2674 fprintf(stderr, "Option '%s' has been removed, use the crop filter instead\n ", opt);
2803 if (frame_topBand < 0) { 2675 return AVERROR(EINVAL);
2804 fprintf(stderr, "Incorrect top crop size\n");
2805 ffmpeg_exit(1);
2806 }
2807 if ((frame_topBand) >= frame_height){
2808 fprintf(stderr, "Vertical crop dimensions are outside the range of the o riginal image.\nRemember to crop first and scale second.\n");
2809 ffmpeg_exit(1);
2810 }
2811 fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
2812 frame_height -= frame_topBand;
2813 }
2814
2815 static void opt_frame_crop_bottom(const char *arg)
2816 {
2817 frame_bottomBand = atoi(arg);
2818 if (frame_bottomBand < 0) {
2819 fprintf(stderr, "Incorrect bottom crop size\n");
2820 ffmpeg_exit(1);
2821 }
2822 if ((frame_bottomBand) >= frame_height){
2823 fprintf(stderr, "Vertical crop dimensions are outside the range of the o riginal image.\nRemember to crop first and scale second.\n");
2824 ffmpeg_exit(1);
2825 }
2826 fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
2827 frame_height -= frame_bottomBand;
2828 }
2829
2830 static void opt_frame_crop_left(const char *arg)
2831 {
2832 frame_leftBand = atoi(arg);
2833 if (frame_leftBand < 0) {
2834 fprintf(stderr, "Incorrect left crop size\n");
2835 ffmpeg_exit(1);
2836 }
2837 if ((frame_leftBand) >= frame_width){
2838 fprintf(stderr, "Horizontal crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n");
2839 ffmpeg_exit(1);
2840 }
2841 fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
2842 frame_width -= frame_leftBand;
2843 }
2844
2845 static void opt_frame_crop_right(const char *arg)
2846 {
2847 frame_rightBand = atoi(arg);
2848 if (frame_rightBand < 0) {
2849 fprintf(stderr, "Incorrect right crop size\n");
2850 ffmpeg_exit(1);
2851 }
2852 if ((frame_rightBand) >= frame_width){
2853 fprintf(stderr, "Horizontal crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n");
2854 ffmpeg_exit(1);
2855 }
2856 fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
2857 frame_width -= frame_rightBand;
2858 } 2676 }
2859 2677
2860 static void opt_frame_size(const char *arg) 2678 static void opt_frame_size(const char *arg)
2861 { 2679 {
2862 if (av_parse_video_size(&frame_width, &frame_height, arg) < 0) { 2680 if (av_parse_video_size(&frame_width, &frame_height, arg) < 0) {
2863 fprintf(stderr, "Incorrect frame size\n"); 2681 fprintf(stderr, "Incorrect frame size\n");
2864 ffmpeg_exit(1); 2682 ffmpeg_exit(1);
2865 } 2683 }
2866 } 2684 }
2867 2685
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 static int opt_metadata(const char *opt, const char *arg) 2729 static int opt_metadata(const char *opt, const char *arg)
2912 { 2730 {
2913 char *mid= strchr(arg, '='); 2731 char *mid= strchr(arg, '=');
2914 2732
2915 if(!mid){ 2733 if(!mid){
2916 fprintf(stderr, "Missing =\n"); 2734 fprintf(stderr, "Missing =\n");
2917 ffmpeg_exit(1); 2735 ffmpeg_exit(1);
2918 } 2736 }
2919 *mid++= 0; 2737 *mid++= 0;
2920 2738
2921 metadata_count++; 2739 av_metadata_set2(&metadata, arg, mid, 0);
2922 metadata= av_realloc(metadata, sizeof(*metadata)*metadata_count);
2923 metadata[metadata_count-1].key = av_strdup(arg);
2924 metadata[metadata_count-1].value= av_strdup(mid);
2925 2740
2926 return 0; 2741 return 0;
2927 } 2742 }
2928 2743
2929 static void opt_qscale(const char *arg) 2744 static void opt_qscale(const char *arg)
2930 { 2745 {
2931 video_qscale = atof(arg); 2746 video_qscale = atof(arg);
2932 if (video_qscale <= 0 || 2747 if (video_qscale <= 0 ||
2933 video_qscale > 255) { 2748 video_qscale > 255) {
2934 fprintf(stderr, "qscale must be > 0.0 and <= 255\n"); 2749 fprintf(stderr, "qscale must be > 0.0 and <= 255\n");
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
3387 default: 3202 default:
3388 abort(); 3203 abort();
3389 } 3204 }
3390 } 3205 }
3391 } 3206 }
3392 *has_video_ptr = has_video; 3207 *has_video_ptr = has_video;
3393 *has_audio_ptr = has_audio; 3208 *has_audio_ptr = has_audio;
3394 *has_subtitle_ptr = has_subtitle; 3209 *has_subtitle_ptr = has_subtitle;
3395 } 3210 }
3396 3211
3212 static AVOutputStream *new_output_stream(AVFormatContext *oc, int file_idx)
3213 {
3214 int idx = oc->nb_streams - 1;
3215 AVOutputStream *ost;
3216
3217 output_streams_for_file[file_idx] =
3218 grow_array(output_streams_for_file[file_idx],
3219 sizeof(*output_streams_for_file[file_idx]),
3220 &nb_output_streams_for_file[file_idx],
3221 oc->nb_streams);
3222 ost = output_streams_for_file[file_idx][idx] =
3223 av_mallocz(sizeof(AVOutputStream));
3224 if (!ost) {
3225 fprintf(stderr, "Could not alloc output stream\n");
3226 ffmpeg_exit(1);
3227 }
3228 ost->file_index = file_idx;
3229 ost->index = idx;
3230 return ost;
3231 }
3232
3397 static void new_video_stream(AVFormatContext *oc, int file_idx) 3233 static void new_video_stream(AVFormatContext *oc, int file_idx)
3398 { 3234 {
3399 AVStream *st; 3235 AVStream *st;
3236 AVOutputStream *ost;
3400 AVCodecContext *video_enc; 3237 AVCodecContext *video_enc;
3401 enum CodecID codec_id; 3238 enum CodecID codec_id;
3402 AVCodec *codec= NULL; 3239 AVCodec *codec= NULL;
3403 3240
3404 st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->n b_streams] : 0); 3241 st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->n b_streams] : 0);
3405 if (!st) { 3242 if (!st) {
3406 fprintf(stderr, "Could not alloc stream\n"); 3243 fprintf(stderr, "Could not alloc stream\n");
3407 ffmpeg_exit(1); 3244 ffmpeg_exit(1);
3408 } 3245 }
3246 ost = new_output_stream(oc, file_idx);
3409 3247
3410 output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output _codecs, nb_output_codecs + 1); 3248 output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output _codecs, nb_output_codecs + 1);
3411 if(!video_stream_copy){ 3249 if(!video_stream_copy){
3412 if (video_codec_name) { 3250 if (video_codec_name) {
3413 codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1 , 3251 codec_id = find_codec_or_die(video_codec_name, AVMEDIA_TYPE_VIDEO, 1 ,
3414 avcodec_opts[AVMEDIA_TYPE_VIDEO]->stric t_std_compliance); 3252 avcodec_opts[AVMEDIA_TYPE_VIDEO]->stric t_std_compliance);
3415 codec = avcodec_find_encoder_by_name(video_codec_name); 3253 codec = avcodec_find_encoder_by_name(video_codec_name);
3416 output_codecs[nb_output_codecs-1] = codec; 3254 output_codecs[nb_output_codecs-1] = codec;
3417 } else { 3255 } else {
3418 codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVM EDIA_TYPE_VIDEO); 3256 codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVM EDIA_TYPE_VIDEO);
3419 codec = avcodec_find_encoder(codec_id); 3257 codec = avcodec_find_encoder(codec_id);
3420 } 3258 }
3421 } 3259 }
3422 3260
3423 avcodec_get_context_defaults3(st->codec, codec); 3261 avcodec_get_context_defaults3(st->codec, codec);
3424 bitstream_filters[file_idx] = 3262 ost->bitstream_filters = video_bitstream_filters;
3425 grow_array(bitstream_filters[file_idx],
3426 sizeof(*bitstream_filters[file_idx]),
3427 &nb_bitstream_filters[file_idx], oc->nb_streams);
3428 bitstream_filters[file_idx][oc->nb_streams - 1]= video_bitstream_filters;
3429 video_bitstream_filters= NULL; 3263 video_bitstream_filters= NULL;
3430 3264
3431 st->codec->thread_count= thread_count; 3265 st->codec->thread_count= thread_count;
3432 3266
3433 video_enc = st->codec; 3267 video_enc = st->codec;
3434 3268
3435 if(video_codec_tag) 3269 if(video_codec_tag)
3436 video_enc->codec_tag= video_codec_tag; 3270 video_enc->codec_tag= video_codec_tag;
3437 3271
3438 if( (video_global_header&1) 3272 if( (video_global_header&1)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3518 video_enc->flags|= CODEC_FLAG_PSNR; 3352 video_enc->flags|= CODEC_FLAG_PSNR;
3519 3353
3520 /* two pass mode */ 3354 /* two pass mode */
3521 if (do_pass) { 3355 if (do_pass) {
3522 if (do_pass == 1) { 3356 if (do_pass == 1) {
3523 video_enc->flags |= CODEC_FLAG_PASS1; 3357 video_enc->flags |= CODEC_FLAG_PASS1;
3524 } else { 3358 } else {
3525 video_enc->flags |= CODEC_FLAG_PASS2; 3359 video_enc->flags |= CODEC_FLAG_PASS2;
3526 } 3360 }
3527 } 3361 }
3362
3363 if (forced_key_frames)
3364 parse_forced_key_frames(forced_key_frames, ost, video_enc);
3528 } 3365 }
3529 if (video_language) { 3366 if (video_language) {
3530 av_metadata_set2(&st->metadata, "language", video_language, 0); 3367 av_metadata_set2(&st->metadata, "language", video_language, 0);
3531 av_freep(&video_language); 3368 av_freep(&video_language);
3532 } 3369 }
3533 3370
3534 /* reset some key parameters */ 3371 /* reset some key parameters */
3535 video_disable = 0; 3372 video_disable = 0;
3536 av_freep(&video_codec_name); 3373 av_freep(&video_codec_name);
3374 av_freep(&forced_key_frames);
3537 video_stream_copy = 0; 3375 video_stream_copy = 0;
3538 frame_pix_fmt = PIX_FMT_NONE; 3376 frame_pix_fmt = PIX_FMT_NONE;
3539 } 3377 }
3540 3378
3541 static void new_audio_stream(AVFormatContext *oc, int file_idx) 3379 static void new_audio_stream(AVFormatContext *oc, int file_idx)
3542 { 3380 {
3543 AVStream *st; 3381 AVStream *st;
3382 AVOutputStream *ost;
3544 AVCodec *codec= NULL; 3383 AVCodec *codec= NULL;
3545 AVCodecContext *audio_enc; 3384 AVCodecContext *audio_enc;
3546 enum CodecID codec_id; 3385 enum CodecID codec_id;
3547 3386
3548 st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->n b_streams] : 0); 3387 st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->n b_streams] : 0);
3549 if (!st) { 3388 if (!st) {
3550 fprintf(stderr, "Could not alloc stream\n"); 3389 fprintf(stderr, "Could not alloc stream\n");
3551 ffmpeg_exit(1); 3390 ffmpeg_exit(1);
3552 } 3391 }
3392 ost = new_output_stream(oc, file_idx);
3553 3393
3554 output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output _codecs, nb_output_codecs + 1); 3394 output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output _codecs, nb_output_codecs + 1);
3555 if(!audio_stream_copy){ 3395 if(!audio_stream_copy){
3556 if (audio_codec_name) { 3396 if (audio_codec_name) {
3557 codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1 , 3397 codec_id = find_codec_or_die(audio_codec_name, AVMEDIA_TYPE_AUDIO, 1 ,
3558 avcodec_opts[AVMEDIA_TYPE_AUDIO]->stric t_std_compliance); 3398 avcodec_opts[AVMEDIA_TYPE_AUDIO]->stric t_std_compliance);
3559 codec = avcodec_find_encoder_by_name(audio_codec_name); 3399 codec = avcodec_find_encoder_by_name(audio_codec_name);
3560 output_codecs[nb_output_codecs-1] = codec; 3400 output_codecs[nb_output_codecs-1] = codec;
3561 } else { 3401 } else {
3562 codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVM EDIA_TYPE_AUDIO); 3402 codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVM EDIA_TYPE_AUDIO);
3563 codec = avcodec_find_encoder(codec_id); 3403 codec = avcodec_find_encoder(codec_id);
3564 } 3404 }
3565 } 3405 }
3566 3406
3567 avcodec_get_context_defaults3(st->codec, codec); 3407 avcodec_get_context_defaults3(st->codec, codec);
3568 3408
3569 bitstream_filters[file_idx] = 3409 ost->bitstream_filters = audio_bitstream_filters;
3570 grow_array(bitstream_filters[file_idx],
3571 sizeof(*bitstream_filters[file_idx]),
3572 &nb_bitstream_filters[file_idx], oc->nb_streams);
3573 bitstream_filters[file_idx][oc->nb_streams - 1]= audio_bitstream_filters;
3574 audio_bitstream_filters= NULL; 3410 audio_bitstream_filters= NULL;
3575 3411
3576 st->codec->thread_count= thread_count; 3412 st->codec->thread_count= thread_count;
3577 3413
3578 audio_enc = st->codec; 3414 audio_enc = st->codec;
3579 audio_enc->codec_type = AVMEDIA_TYPE_AUDIO; 3415 audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
3580 3416
3581 if(audio_codec_tag) 3417 if(audio_codec_tag)
3582 audio_enc->codec_tag= audio_codec_tag; 3418 audio_enc->codec_tag= audio_codec_tag;
3583 3419
(...skipping 30 matching lines...) Expand all
3614 3450
3615 /* reset some key parameters */ 3451 /* reset some key parameters */
3616 audio_disable = 0; 3452 audio_disable = 0;
3617 av_freep(&audio_codec_name); 3453 av_freep(&audio_codec_name);
3618 audio_stream_copy = 0; 3454 audio_stream_copy = 0;
3619 } 3455 }
3620 3456
3621 static void new_subtitle_stream(AVFormatContext *oc, int file_idx) 3457 static void new_subtitle_stream(AVFormatContext *oc, int file_idx)
3622 { 3458 {
3623 AVStream *st; 3459 AVStream *st;
3460 AVOutputStream *ost;
3624 AVCodec *codec=NULL; 3461 AVCodec *codec=NULL;
3625 AVCodecContext *subtitle_enc; 3462 AVCodecContext *subtitle_enc;
3626 3463
3627 st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->n b_streams] : 0); 3464 st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->n b_streams] : 0);
3628 if (!st) { 3465 if (!st) {
3629 fprintf(stderr, "Could not alloc stream\n"); 3466 fprintf(stderr, "Could not alloc stream\n");
3630 ffmpeg_exit(1); 3467 ffmpeg_exit(1);
3631 } 3468 }
3469 ost = new_output_stream(oc, file_idx);
3632 subtitle_enc = st->codec; 3470 subtitle_enc = st->codec;
3633 output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output _codecs, nb_output_codecs + 1); 3471 output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output _codecs, nb_output_codecs + 1);
3634 if(!subtitle_stream_copy){ 3472 if(!subtitle_stream_copy){
3635 subtitle_enc->codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_ TYPE_SUBTITLE, 1, 3473 subtitle_enc->codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_ TYPE_SUBTITLE, 1,
3636 avcodec_opts[AVMEDIA_TYPE_SUB TITLE]->strict_std_compliance); 3474 avcodec_opts[AVMEDIA_TYPE_SUB TITLE]->strict_std_compliance);
3637 codec= output_codecs[nb_output_codecs-1] = avcodec_find_encoder_by_name( subtitle_codec_name); 3475 codec= output_codecs[nb_output_codecs-1] = avcodec_find_encoder_by_name( subtitle_codec_name);
3638 } 3476 }
3639 avcodec_get_context_defaults3(st->codec, codec); 3477 avcodec_get_context_defaults3(st->codec, codec);
3640 3478
3641 bitstream_filters[file_idx] = 3479 ost->bitstream_filters = subtitle_bitstream_filters;
3642 grow_array(bitstream_filters[file_idx],
3643 sizeof(*bitstream_filters[file_idx]),
3644 &nb_bitstream_filters[file_idx], oc->nb_streams);
3645 bitstream_filters[file_idx][oc->nb_streams - 1]= subtitle_bitstream_filters;
3646 subtitle_bitstream_filters= NULL; 3480 subtitle_bitstream_filters= NULL;
3647 3481
3648 subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE; 3482 subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
3649 3483
3650 if(subtitle_codec_tag) 3484 if(subtitle_codec_tag)
3651 subtitle_enc->codec_tag= subtitle_codec_tag; 3485 subtitle_enc->codec_tag= subtitle_codec_tag;
3652 3486
3653 if (subtitle_stream_copy) { 3487 if (subtitle_stream_copy) {
3654 st->stream_copy = 1; 3488 st->stream_copy = 1;
3655 } else { 3489 } else {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3706 return 0; 3540 return 0;
3707 } 3541 }
3708 3542
3709 static void opt_output_file(const char *filename) 3543 static void opt_output_file(const char *filename)
3710 { 3544 {
3711 AVFormatContext *oc; 3545 AVFormatContext *oc;
3712 int err, use_video, use_audio, use_subtitle; 3546 int err, use_video, use_audio, use_subtitle;
3713 int input_has_video, input_has_audio, input_has_subtitle; 3547 int input_has_video, input_has_audio, input_has_subtitle;
3714 AVFormatParameters params, *ap = &params; 3548 AVFormatParameters params, *ap = &params;
3715 AVOutputFormat *file_oformat; 3549 AVOutputFormat *file_oformat;
3550 AVMetadataTag *tag = NULL;
3716 3551
3717 if (!strcmp(filename, "-")) 3552 if (!strcmp(filename, "-"))
3718 filename = "pipe:"; 3553 filename = "pipe:";
3719 3554
3720 oc = avformat_alloc_context(); 3555 oc = avformat_alloc_context();
3721 if (!oc) { 3556 if (!oc) {
3722 print_error(filename, AVERROR(ENOMEM)); 3557 print_error(filename, AVERROR(ENOMEM));
3723 ffmpeg_exit(1); 3558 ffmpeg_exit(1);
3724 } 3559 }
3725 3560
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3763 &input_has_subtitle); 3598 &input_has_subtitle);
3764 if (!input_has_video) 3599 if (!input_has_video)
3765 use_video = 0; 3600 use_video = 0;
3766 if (!input_has_audio) 3601 if (!input_has_audio)
3767 use_audio = 0; 3602 use_audio = 0;
3768 if (!input_has_subtitle) 3603 if (!input_has_subtitle)
3769 use_subtitle = 0; 3604 use_subtitle = 0;
3770 } 3605 }
3771 3606
3772 /* manual disable */ 3607 /* manual disable */
3773 if (audio_disable) { 3608 if (audio_disable) use_audio = 0;
3774 use_audio = 0; 3609 if (video_disable) use_video = 0;
3775 } 3610 if (subtitle_disable) use_subtitle = 0;
3776 if (video_disable) {
3777 use_video = 0;
3778 }
3779 if (subtitle_disable) {
3780 use_subtitle = 0;
3781 }
3782 3611
3783 if (use_video) { 3612 if (use_video) new_video_stream(oc, nb_output_files);
3784 new_video_stream(oc, nb_output_files); 3613 if (use_audio) new_audio_stream(oc, nb_output_files);
3785 } 3614 if (use_subtitle) new_subtitle_stream(oc, nb_output_files);
3786
3787 if (use_audio) {
3788 new_audio_stream(oc, nb_output_files);
3789 }
3790
3791 if (use_subtitle) {
3792 new_subtitle_stream(oc, nb_output_files);
3793 }
3794 3615
3795 oc->timestamp = recording_timestamp; 3616 oc->timestamp = recording_timestamp;
3796 3617
3797 for(; metadata_count>0; metadata_count--){ 3618 while ((tag = av_metadata_get(metadata, "", tag, AV_METADATA_IGNORE_SUFF IX)))
3798 av_metadata_set2(&oc->metadata, metadata[metadata_count-1].key, 3619 av_metadata_set2(&oc->metadata, tag->key, tag->value, 0);
3799 metadata[metadata_count-1].value, 0) ; 3620 av_metadata_free(&metadata);
3800 }
3801 av_metadata_conv(oc, oc->oformat->metadata_conv, NULL);
3802 } 3621 }
3803 3622
3804 output_files[nb_output_files++] = oc; 3623 output_files[nb_output_files++] = oc;
3805 3624
3806 /* check filename in case of an image number is expected */ 3625 /* check filename in case of an image number is expected */
3807 if (oc->oformat->flags & AVFMT_NEEDNUMBER) { 3626 if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
3808 if (!av_filename_number_test(oc->filename)) { 3627 if (!av_filename_number_test(oc->filename)) {
3809 print_error(oc->filename, AVERROR_NUMEXPECTED); 3628 print_error(oc->filename, AVERROR_NUMEXPECTED);
3810 ffmpeg_exit(1); 3629 ffmpeg_exit(1);
3811 } 3630 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3848 } 3667 }
3849 3668
3850 oc->preload= (int)(mux_preload*AV_TIME_BASE); 3669 oc->preload= (int)(mux_preload*AV_TIME_BASE);
3851 oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE); 3670 oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);
3852 oc->loop_output = loop_output; 3671 oc->loop_output = loop_output;
3853 oc->flags |= AVFMT_FLAG_NONBLOCK; 3672 oc->flags |= AVFMT_FLAG_NONBLOCK;
3854 3673
3855 set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL); 3674 set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL);
3856 3675
3857 nb_streamid_map = 0; 3676 nb_streamid_map = 0;
3677 av_freep(&forced_key_frames);
3858 } 3678 }
3859 3679
3860 /* same option as mencoder */ 3680 /* same option as mencoder */
3861 static void opt_pass(const char *pass_str) 3681 static void opt_pass(const char *pass_str)
3862 { 3682 {
3863 int pass; 3683 int pass;
3864 pass = atoi(pass_str); 3684 pass = atoi(pass_str);
3865 if (pass != 1 && pass != 2) { 3685 if (pass != 1 && pass != 2) {
3866 fprintf(stderr, "pass number can be only 1 or 2\n"); 3686 fprintf(stderr, "pass number can be only 1 or 2\n");
3867 ffmpeg_exit(1); 3687 ffmpeg_exit(1);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
4260 { "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)&copy_initial_nonkeyframes}, "c opy initial non-keyframes" }, 4080 { "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)&copy_initial_nonkeyframes}, "c opy initial non-keyframes" },
4261 4081
4262 /* video options */ 4082 /* video options */
4263 { "b", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate ( in bits/s)", "bitrate" }, 4083 { "b", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate ( in bits/s)", "bitrate" },
4264 { "vb", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" }, 4084 { "vb", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },
4265 { "vframes", OPT_INT | HAS_ARG | OPT_VIDEO, {(void*)&max_frames[AVMEDIA_TYPE _VIDEO]}, "set the number of video frames to record", "number" }, 4085 { "vframes", OPT_INT | HAS_ARG | OPT_VIDEO, {(void*)&max_frames[AVMEDIA_TYPE _VIDEO]}, "set the number of video frames to record", "number" },
4266 { "r", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_rate}, "set frame rate (Hz value, fraction or abbreviation)", "rate" }, 4086 { "r", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_rate}, "set frame rate (Hz value, fraction or abbreviation)", "rate" },
4267 { "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" }, 4087 { "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
4268 { "aspect", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_aspect_ratio}, "set aspec t ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" }, 4088 { "aspect", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_aspect_ratio}, "set aspec t ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
4269 { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, " set pixel format, 'list' as argument shows all the pixel formats supported", "fo rmat" }, 4089 { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, " set pixel format, 'list' as argument shows all the pixel formats supported", "fo rmat" },
4270 { "croptop", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_top}, "Deprecated, please use the crop avfilter", "size" }, 4090 { "croptop", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Remo ved, use the crop filter instead", "size" },
4271 { "cropbottom", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_bottom}, "Deprec ated, please use the crop avfilter", "size" }, 4091 { "cropbottom", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "R emoved, use the crop filter instead", "size" },
4272 { "cropleft", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_left}, "Deprecated , please use the crop avfilter", "size" }, 4092 { "cropleft", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Rem oved, use the crop filter instead", "size" },
4273 { "cropright", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_right}, "Deprecat ed, please use the crop avfilter", "size" }, 4093 { "cropright", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Re moved, use the crop filter instead", "size" },
4274 { "padtop", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" }, 4094 { "padtop", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
4275 { "padbottom", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" }, 4095 { "padbottom", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
4276 { "padleft", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, us e the pad filter instead", "size" }, 4096 { "padleft", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, us e the pad filter instead", "size" },
4277 { "padright", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, u se the pad filter instead", "size" }, 4097 { "padright", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, u se the pad filter instead", "size" },
4278 { "padcolor", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, u se the pad filter instead", "color" }, 4098 { "padcolor", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, u se the pad filter instead", "color" },
4279 { "intra", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_only}, "use onl y intra frames"}, 4099 { "intra", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_only}, "use onl y intra frames"},
4280 { "vn", OPT_BOOL | OPT_VIDEO, {(void*)&video_disable}, "disable video" }, 4100 { "vn", OPT_BOOL | OPT_VIDEO, {(void*)&video_disable}, "disable video" },
4281 { "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_discard} , "discard threshold", "n" }, 4101 { "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_discard} , "discard threshold", "n" },
4282 { "qscale", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qscale}, "use fixe d video quantizer scale (VBR)", "q" }, 4102 { "qscale", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qscale}, "use fixe d video quantizer scale (VBR)", "q" },
4283 { "rc_override", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_rc_over ride_string}, "rate control override for specific intervals", "override" }, 4103 { "rc_override", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_rc_over ride_string}, "rate control override for specific intervals", "override" },
(...skipping 14 matching lines...) Expand all
4298 { "intra_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_intra_matrix }, "specify intra matrix coeffs", "matrix" }, 4118 { "intra_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_intra_matrix }, "specify intra matrix coeffs", "matrix" },
4299 { "inter_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_inter_matrix }, "specify inter matrix coeffs", "matrix" }, 4119 { "inter_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_inter_matrix }, "specify inter matrix coeffs", "matrix" },
4300 { "top", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_top_field_first}, "to p=1/bottom=0/auto=-1 field first", "" }, 4120 { "top", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_top_field_first}, "to p=1/bottom=0/auto=-1 field first", "" },
4301 { "dc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_dc_precis ion}, "intra_dc_precision", "precision" }, 4121 { "dc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_dc_precis ion}, "intra_dc_precision", "precision" },
4302 { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_tag}, "force v ideo tag/fourcc", "fourcc/tag" }, 4122 { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_tag}, "force v ideo tag/fourcc", "fourcc/tag" },
4303 { "newvideo", OPT_VIDEO | OPT_FUNC2, {(void*)opt_new_stream}, "add a new vid eo stream to the current output stream" }, 4123 { "newvideo", OPT_VIDEO | OPT_FUNC2, {(void*)opt_new_stream}, "add a new vid eo stream to the current output stream" },
4304 { "vlang", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void *)&video_language}, "set the ISO 639 language code (3 letters) of the current video stream" , "code" }, 4124 { "vlang", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void *)&video_language}, "set the ISO 639 language code (3 letters) of the current video stream" , "code" },
4305 { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show Q P histogram" }, 4125 { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show Q P histogram" },
4306 { "force_fps", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&force_fps}, "forc e the selected framerate, disable the best supported framerate selection" }, 4126 { "force_fps", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&force_fps}, "forc e the selected framerate, disable the best supported framerate selection" },
4307 { "streamid", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" }, 4127 { "streamid", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" },
4128 { "force_key_frames", OPT_STRING | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void *)&forced_key_frames}, "force key frames at specified timestamps", "timestamps" },
4308 4129
4309 /* audio options */ 4130 /* audio options */
4310 { "ab", OPT_FUNC2 | HAS_ARG | OPT_AUDIO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" }, 4131 { "ab", OPT_FUNC2 | HAS_ARG | OPT_AUDIO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" },
4311 { "aframes", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&max_frames[AVMEDIA_TYPE _AUDIO]}, "set the number of audio frames to record", "number" }, 4132 { "aframes", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&max_frames[AVMEDIA_TYPE _AUDIO]}, "set the number of audio frames to record", "number" },
4312 { "aq", OPT_FLOAT | HAS_ARG | OPT_AUDIO, {(void*)&audio_qscale}, "set audio quality (codec-specific)", "quality", }, 4133 { "aq", OPT_FLOAT | HAS_ARG | OPT_AUDIO, {(void*)&audio_qscale}, "set audio quality (codec-specific)", "quality", },
4313 { "ar", HAS_ARG | OPT_FUNC2 | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" }, 4134 { "ar", HAS_ARG | OPT_FUNC2 | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" },
4314 { "ac", HAS_ARG | OPT_FUNC2 | OPT_AUDIO, {(void*)opt_audio_channels}, "set n umber of audio channels", "channels" }, 4135 { "ac", HAS_ARG | OPT_FUNC2 | OPT_AUDIO, {(void*)opt_audio_channels}, "set n umber of audio channels", "channels" },
4315 { "an", OPT_BOOL | OPT_AUDIO, {(void*)&audio_disable}, "disable audio" }, 4136 { "an", OPT_BOOL | OPT_AUDIO, {(void*)&audio_disable}, "disable audio" },
4316 { "acodec", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_codec}, "force audio code c ('copy' to copy stream)", "codec" }, 4137 { "acodec", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_codec}, "force audio code c ('copy' to copy stream)", "codec" },
4317 { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_audio_tag}, "force a udio tag/fourcc", "fourcc/tag" }, 4138 { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_audio_tag}, "force a udio tag/fourcc", "fourcc/tag" },
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
4398 stream_maps, nb_stream_maps) < 0) 4219 stream_maps, nb_stream_maps) < 0)
4399 ffmpeg_exit(1); 4220 ffmpeg_exit(1);
4400 ti = getutime() - ti; 4221 ti = getutime() - ti;
4401 if (do_benchmark) { 4222 if (do_benchmark) {
4402 int maxrss = getmaxrss() / 1024; 4223 int maxrss = getmaxrss() / 1024;
4403 printf("bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss); 4224 printf("bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss);
4404 } 4225 }
4405 4226
4406 return ffmpeg_exit(0); 4227 return ffmpeg_exit(0);
4407 } 4228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698