| 572 | } |
| 573 | |
| 574 | static int new_stream_video(Muxer *mux, const OptionsContext *o, |
| 575 | OutputStream *ost, int *keep_pix_fmt, |
| 576 | enum VideoSyncMethod *vsync_method) |
| 577 | { |
| 578 | MuxStream *ms = ms_from_ost(ost); |
| 579 | AVFormatContext *oc = mux->fc; |
| 580 | AVStream *st; |
| 581 | const char *frame_rate = NULL, *max_frame_rate = NULL, *frame_aspect_ratio = NULL; |
| 582 | int ret = 0; |
| 583 | |
| 584 | st = ost->st; |
| 585 | |
| 586 | opt_match_per_stream_str(ost, &o->frame_rates, oc, st, &frame_rate); |
| 587 | if (frame_rate && av_parse_video_rate(&ms->frame_rate, frame_rate) < 0) { |
| 588 | av_log(ost, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate); |
| 589 | return AVERROR(EINVAL); |
| 590 | } |
| 591 | |
| 592 | opt_match_per_stream_str(ost, &o->max_frame_rates, oc, st, &max_frame_rate); |
| 593 | if (max_frame_rate && av_parse_video_rate(&ms->max_frame_rate, max_frame_rate) < 0) { |
| 594 | av_log(ost, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", max_frame_rate); |
| 595 | return AVERROR(EINVAL); |
| 596 | } |
| 597 | |
| 598 | if (frame_rate && max_frame_rate) { |
| 599 | av_log(ost, AV_LOG_ERROR, "Only one of -fpsmax and -r can be set for a stream.\n"); |
| 600 | return AVERROR(EINVAL); |
| 601 | } |
| 602 | |
| 603 | opt_match_per_stream_str(ost, &o->frame_aspect_ratios, oc, st, &frame_aspect_ratio); |
| 604 | if (frame_aspect_ratio) { |
| 605 | AVRational q; |
| 606 | if (av_parse_ratio(&q, frame_aspect_ratio, 255, 0, NULL) < 0 || |
| 607 | q.num <= 0 || q.den <= 0) { |
| 608 | av_log(ost, AV_LOG_FATAL, "Invalid aspect ratio: %s\n", frame_aspect_ratio); |
| 609 | return AVERROR(EINVAL); |
| 610 | } |
| 611 | ost->frame_aspect_ratio = q; |
| 612 | } |
| 613 | |
| 614 | if (ost->enc) { |
| 615 | AVCodecContext *video_enc = ost->enc->enc_ctx; |
| 616 | const char *p = NULL, *fps_mode = NULL; |
| 617 | const char *frame_size = NULL; |
| 618 | const char *frame_pix_fmt = NULL; |
| 619 | const char *intra_matrix = NULL, *inter_matrix = NULL; |
| 620 | const char *chroma_intra_matrix = NULL; |
| 621 | int do_pass = 0; |
| 622 | int i; |
| 623 | |
| 624 | opt_match_per_stream_str(ost, &o->frame_sizes, oc, st, &frame_size); |
| 625 | if (frame_size) { |
| 626 | ret = av_parse_video_size(&video_enc->width, &video_enc->height, frame_size); |
| 627 | if (ret < 0) { |
| 628 | av_log(ost, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size); |
| 629 | return AVERROR(EINVAL); |
| 630 | } |
| 631 | } |
no test coverage detected