| @@ -71,13 +71,10 @@ static int choose_encoder(const OptionsContext *o, AVFormatContext *s, · 70 unmodified lines |
| 71 | { | 71 | { |
| 72 | enum AVMediaType type = ost->type; | 72 | enum AVMediaType type = ost->type; |
| 73 | const char *codec_name = NULL; | 73 | const char *codec_name = NULL; |
| 74 | int ret; | | |
| 75 | | 74 | |
| 76 | *enc = NULL; | 75 | *enc = NULL; |
| 77 | | 76 | |
| 78 | ret = opt_match_per_stream_str(ost, &o->codec_names, s, ost->st, &codec_name); | 77 | opt_match_per_stream_str(ost, &o->codec_names, s, ost->st, &codec_name); |
| 79 | if (ret < 0) | | |
| 80 | return ret; | | |
| 81 | | 78 | |
| 82 | if (type != AVMEDIA_TYPE_VIDEO && | 79 | if (type != AVMEDIA_TYPE_VIDEO && |
| 83 | type != AVMEDIA_TYPE_AUDIO && | 80 | type != AVMEDIA_TYPE_AUDIO && |
| @@ -419,17 +416,12 @@ static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc, · 335 unmodified lines |
| 419 | OutputStream *ost, char **dst) | 416 | OutputStream *ost, char **dst) |
| 420 | { | 417 | { |
| 421 | const char *filters = NULL; | 418 | const char *filters = NULL; |
| 422 | int ret; | | |
| 423 | #if FFMPEG_OPT_FILTER_SCRIPT | 419 | #if FFMPEG_OPT_FILTER_SCRIPT |
| 424 | const char *filters_script = NULL; | 420 | const char *filters_script = NULL; |
| 425 | | 421 | |
| 426 | ret = opt_match_per_stream_str(ost, &o->filter_scripts, oc, ost->st, &filters_script); | 422 | opt_match_per_stream_str(ost, &o->filter_scripts, oc, ost->st, &filters_script); |
| 427 | if (ret < 0) | | |
| 428 | return ret; | | |
| 429 | #endif | 423 | #endif |
| 430 | ret = opt_match_per_stream_str(ost, &o->filters, oc, ost->st, &filters); | 424 | opt_match_per_stream_str(ost, &o->filters, oc, ost->st, &filters); |
| 431 | if (ret < 0) | | |
| 432 | return ret; | | |
| 433 | | 425 | |
| 434 | if (!ost->enc) { | 426 | if (!ost->enc) { |
| 435 | if ( | 427 | if ( |
| @@ -599,17 +591,13 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 163 unmodified lines |
| 599 | | 591 | |
| 600 | st = ost->st; | 592 | st = ost->st; |
| 601 | | 593 | |
| 602 | ret = opt_match_per_stream_str(ost, &o->frame_rates, oc, st, &frame_rate); | 594 | opt_match_per_stream_str(ost, &o->frame_rates, oc, st, &frame_rate); |
| 603 | if (ret < 0) | | |
| 604 | return ret; | | |
| 605 | if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) { | 595 | if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) { |
| 606 | av_log(ost, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate); | 596 | av_log(ost, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate); |
| 607 | return AVERROR(EINVAL); | 597 | return AVERROR(EINVAL); |
| 608 | } | 598 | } |
| 609 | | 599 | |
| 610 | ret = opt_match_per_stream_str(ost, &o->max_frame_rates, oc, st, &max_frame_rate); | 600 | opt_match_per_stream_str(ost, &o->max_frame_rates, oc, st, &max_frame_rate); |
| 611 | if (ret < 0) | | |
| 612 | return ret; | | |
| 613 | if (max_frame_rate && av_parse_video_rate(&ost->max_frame_rate, max_frame_rate) < 0) { | 601 | if (max_frame_rate && av_parse_video_rate(&ost->max_frame_rate, max_frame_rate) < 0) { |
| 614 | av_log(ost, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", max_frame_rate); | 602 | av_log(ost, AV_LOG_FATAL, "Invalid maximum framerate value: %s\n", max_frame_rate); |
| 615 | return AVERROR(EINVAL); | 603 | return AVERROR(EINVAL); |
| @@ -620,9 +608,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 4 unmodified lines |
| 620 | return AVERROR(EINVAL); | 608 | return AVERROR(EINVAL); |
| 621 | } | 609 | } |
| 622 | | 610 | |
| 623 | ret = opt_match_per_stream_str(ost, &o->frame_aspect_ratios, oc, st, &frame_aspect_ratio); | 611 | opt_match_per_stream_str(ost, &o->frame_aspect_ratios, oc, st, &frame_aspect_ratio); |
| 624 | if (ret < 0) | | |
| 625 | return ret; | | |
| 626 | if (frame_aspect_ratio) { | 612 | if (frame_aspect_ratio) { |
| 627 | AVRational q; | 613 | AVRational q; |
| 628 | if (av_parse_ratio(&q, frame_aspect_ratio, 255, 0, NULL) < 0 || | 614 | if (av_parse_ratio(&q, frame_aspect_ratio, 255, 0, NULL) < 0 || |
| @@ -643,9 +629,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 14 unmodified lines |
| 643 | int do_pass = 0; | 629 | int do_pass = 0; |
| 644 | int i; | 630 | int i; |
| 645 | | 631 | |
| 646 | ret = opt_match_per_stream_str(ost, &o->frame_sizes, oc, st, &frame_size); | 632 | opt_match_per_stream_str(ost, &o->frame_sizes, oc, st, &frame_size); |
| 647 | if (ret < 0) | | |
| 648 | return ret; | | |
| 649 | if (frame_size) { | 633 | if (frame_size) { |
| 650 | ret = av_parse_video_size(&video_enc->width, &video_enc->height, frame_size); | 634 | ret = av_parse_video_size(&video_enc->width, &video_enc->height, frame_size); |
| 651 | if (ret < 0) { | 635 | if (ret < 0) { |
| @@ -654,9 +638,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 2 unmodified lines |
| 654 | } | 638 | } |
| 655 | } | 639 | } |
| 656 | | 640 | |
| 657 | ret = opt_match_per_stream_str(ost, &o->frame_pix_fmts, oc, st, &frame_pix_fmt); | 641 | opt_match_per_stream_str(ost, &o->frame_pix_fmts, oc, st, &frame_pix_fmt); |
| 658 | if (ret < 0) | | |
| 659 | return ret; | | |
| 660 | if (frame_pix_fmt && *frame_pix_fmt == '+') { | 642 | if (frame_pix_fmt && *frame_pix_fmt == '+') { |
| 661 | *keep_pix_fmt = 1; | 643 | *keep_pix_fmt = 1; |
| 662 | if (!*++frame_pix_fmt) | 644 | if (!*++frame_pix_fmt) |
| @@ -668,9 +650,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 5 unmodified lines |
| 668 | return AVERROR(EINVAL); | 650 | return AVERROR(EINVAL); |
| 669 | } | 651 | } |
| 670 | | 652 | |
| 671 | ret = opt_match_per_stream_str(ost, &o->intra_matrices, oc, st, &intra_matrix); | 653 | opt_match_per_stream_str(ost, &o->intra_matrices, oc, st, &intra_matrix); |
| 672 | if (ret < 0) | | |
| 673 | return ret; | | |
| 674 | if (intra_matrix) { | 654 | if (intra_matrix) { |
| 675 | if (!(video_enc->intra_matrix = av_mallocz(sizeof(*video_enc->intra_matrix) * 64))) | 655 | if (!(video_enc->intra_matrix = av_mallocz(sizeof(*video_enc->intra_matrix) * 64))) |
| 676 | return AVERROR(ENOMEM); | 656 | return AVERROR(ENOMEM); |
| @@ -679,9 +659,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 2 unmodified lines |
| 679 | if (ret < 0) | 659 | if (ret < 0) |
| 680 | return ret; | 660 | return ret; |
| 681 | } | 661 | } |
| 682 | ret = opt_match_per_stream_str(ost, &o->chroma_intra_matrices, oc, st, &chroma_intra_matrix); | 662 | opt_match_per_stream_str(ost, &o->chroma_intra_matrices, oc, st, &chroma_intra_matrix); |
| 683 | if (ret < 0) | | |
| 684 | return ret; | | |
| 685 | if (chroma_intra_matrix) { | 663 | if (chroma_intra_matrix) { |
| 686 | uint16_t *p = av_mallocz(sizeof(*video_enc->chroma_intra_matrix) * 64); | 664 | uint16_t *p = av_mallocz(sizeof(*video_enc->chroma_intra_matrix) * 64); |
| 687 | if (!p) | 665 | if (!p) |
| @@ -691,9 +669,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 3 unmodified lines |
| 691 | if (ret < 0) | 669 | if (ret < 0) |
| 692 | return ret; | 670 | return ret; |
| 693 | } | 671 | } |
| 694 | ret = opt_match_per_stream_str(ost, &o->inter_matrices, oc, st, &inter_matrix); | 672 | opt_match_per_stream_str(ost, &o->inter_matrices, oc, st, &inter_matrix); |
| 695 | if (ret < 0) | | |
| 696 | return ret; | | |
| 697 | if (inter_matrix) { | 673 | if (inter_matrix) { |
| 698 | if (!(video_enc->inter_matrix = av_mallocz(sizeof(*video_enc->inter_matrix) * 64))) | 674 | if (!(video_enc->inter_matrix = av_mallocz(sizeof(*video_enc->inter_matrix) * 64))) |
| 699 | return AVERROR(ENOMEM); | 675 | return AVERROR(ENOMEM); |
| @@ -702,9 +678,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 2 unmodified lines |
| 702 | return ret; | 678 | return ret; |
| 703 | } | 679 | } |
| 704 | | 680 | |
| 705 | ret = opt_match_per_stream_str(ost, &o->rc_overrides, oc, st, &p); | 681 | opt_match_per_stream_str(ost, &o->rc_overrides, oc, st, &p); |
| 706 | if (ret < 0) | | |
| 707 | return ret; | | |
| 708 | for (i = 0; p; i++) { | 682 | for (i = 0; p; i++) { |
| 709 | int start, end, q; | 683 | int start, end, q; |
| 710 | int e = sscanf(p, "%d,%d,%d", &start, &end, &q); | 684 | int e = sscanf(p, "%d,%d,%d", &start, &end, &q); |
| @@ -735,9 +709,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 24 unmodified lines |
| 735 | video_enc->rc_override_count = i; | 709 | video_enc->rc_override_count = i; |
| 736 | | 710 | |
| 737 | /* two pass mode */ | 711 | /* two pass mode */ |
| 738 | ret = opt_match_per_stream_int(ost, &o->pass, oc, st, &do_pass); | 712 | opt_match_per_stream_int(ost, &o->pass, oc, st, &do_pass); |
| 739 | if (ret < 0) | | |
| 740 | return ret; | | |
| 741 | if (do_pass) { | 713 | if (do_pass) { |
| 742 | if (do_pass & 1) | 714 | if (do_pass & 1) |
| 743 | video_enc->flags |= AV_CODEC_FLAG_PASS1; | 715 | video_enc->flags |= AV_CODEC_FLAG_PASS1; |
| @@ -745,9 +717,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 1 unmodified line |
| 745 | video_enc->flags |= AV_CODEC_FLAG_PASS2; | 717 | video_enc->flags |= AV_CODEC_FLAG_PASS2; |
| 746 | } | 718 | } |
| 747 | | 719 | |
| 748 | ret = opt_match_per_stream_str(ost, &o->passlogfiles, oc, st, &ost->logfile_prefix); | 720 | opt_match_per_stream_str(ost, &o->passlogfiles, oc, st, &ost->logfile_prefix); |
| 749 | if (ret < 0) | | |
| 750 | return ret; | | |
| 751 | if (ost->logfile_prefix && | 721 | if (ost->logfile_prefix && |
| 752 | !(ost->logfile_prefix = av_strdup(ost->logfile_prefix))) | 722 | !(ost->logfile_prefix = av_strdup(ost->logfile_prefix))) |
| 753 | return AVERROR(ENOMEM); | 723 | return AVERROR(ENOMEM); |
| @@ -794,15 +764,11 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 40 unmodified lines |
| 794 | } | 764 | } |
| 795 | } | 765 | } |
| 796 | | 766 | |
| 797 | ret = opt_match_per_stream_int(ost, &o->force_fps, oc, st, &ost->force_fps); | 767 | opt_match_per_stream_int(ost, &o->force_fps, oc, st, &ost->force_fps); |
| 798 | if (ret < 0) | | |
| 799 | return ret; | | |
| 800 | | 768 | |
| 801 | #if FFMPEG_OPT_TOP | 769 | #if FFMPEG_OPT_TOP |
| 802 | ost->top_field_first = -1; | 770 | ost->top_field_first = -1; |
| 803 | ret = opt_match_per_stream_int(ost, &o->top_field_first, oc, st, &ost->top_field_first); | 771 | opt_match_per_stream_int(ost, &o->top_field_first, oc, st, &ost->top_field_first); |
| 804 | if (ret < 0) | | |
| 805 | return ret; | | |
| 806 | if (ost->top_field_first >= 0) | 772 | if (ost->top_field_first >= 0) |
| 807 | av_log(ost, AV_LOG_WARNING, "-top is deprecated, use the setfield filter instead\n"); | 773 | av_log(ost, AV_LOG_WARNING, "-top is deprecated, use the setfield filter instead\n"); |
| 808 | #endif | 774 | #endif |
| @@ -812,9 +778,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, · 3 unmodified lines |
| 812 | #else | 778 | #else |
| 813 | *vsync_method = VSYNC_AUTO; | 779 | *vsync_method = VSYNC_AUTO; |
| 814 | #endif | 780 | #endif |
| 815 | ret = opt_match_per_stream_str(ost, &o->fps_mode, oc, st, &fps_mode); | 781 | opt_match_per_stream_str(ost, &o->fps_mode, oc, st, &fps_mode); |
| 816 | if (ret < 0) | | |
| 817 | return ret; | | |
| 818 | if (fps_mode) { | 782 | if (fps_mode) { |
| 819 | ret = parse_and_set_vsync(fps_mode, vsync_method, ost->file->index, ost->index, 0); | 783 | ret = parse_and_set_vsync(fps_mode, vsync_method, ost->file->index, ost->index, 0); |
| 820 | if (ret < 0) | 784 | if (ret < 0) |
| @@ -872,40 +836,28 @@ static int new_stream_audio(Muxer *mux, const OptionsContext *o, · 51 unmodified lines |
| 872 | int channels = 0; | 836 | int channels = 0; |
| 873 | const char *layout = NULL; | 837 | const char *layout = NULL; |
| 874 | const char *sample_fmt = NULL; | 838 | const char *sample_fmt = NULL; |
| 875 | int ret; | | |
| 876 | | 839 | |
| 877 | ret = opt_match_per_stream_int(ost, &o->audio_channels, oc, st, &channels); | 840 | opt_match_per_stream_int(ost, &o->audio_channels, oc, st, &channels); |
| 878 | if (ret < 0) | | |
| 879 | return ret; | | |
| 880 | if (channels) { | 841 | if (channels) { |
| 881 | audio_enc->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; | 842 | audio_enc->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; |
| 882 | audio_enc->ch_layout.nb_channels = channels; | 843 | audio_enc->ch_layout.nb_channels = channels; |
| 883 | } | 844 | } |
| 884 | | 845 | |
| 885 | ret = opt_match_per_stream_str(ost, &o->audio_ch_layouts, oc, st, &layout); | 846 | opt_match_per_stream_str(ost, &o->audio_ch_layouts, oc, st, &layout); |
| 886 | if (ret < 0) | | |
| 887 | return ret; | | |
| 888 | if (layout && av_channel_layout_from_string(&audio_enc->ch_layout, layout) < 0) { | 847 | if (layout && av_channel_layout_from_string(&audio_enc->ch_layout, layout) < 0) { |
| 889 | av_log(ost, AV_LOG_FATAL, "Unknown channel layout: %s\n", layout); | 848 | av_log(ost, AV_LOG_FATAL, "Unknown channel layout: %s\n", layout); |
| 890 | return AVERROR(EINVAL); | 849 | return AVERROR(EINVAL); |
| 891 | } | 850 | } |
| 892 | | 851 | |
| 893 | ret = opt_match_per_stream_str(ost, &o->sample_fmts, oc, st, &sample_fmt); | 852 | opt_match_per_stream_str(ost, &o->sample_fmts, oc, st, &sample_fmt); |
| 894 | if (ret < 0) | | |
| 895 | return ret; | | |
| 896 | if (sample_fmt && | 853 | if (sample_fmt && |
| 897 | (audio_enc->sample_fmt = av_get_sample_fmt(sample_fmt)) == AV_SAMPLE_FMT_NONE) { | 854 | (audio_enc->sample_fmt = av_get_sample_fmt(sample_fmt)) == AV_SAMPLE_FMT_NONE) { |
| 898 | av_log(ost, AV_LOG_FATAL, "Invalid sample format '%s'\n", sample_fmt); | 855 | av_log(ost, AV_LOG_FATAL, "Invalid sample format '%s'\n", sample_fmt); |
| 899 | return AVERROR(EINVAL); | 856 | return AVERROR(EINVAL); |
| 900 | } | 857 | } |
| 901 | | 858 | |
| 902 | ret = opt_match_per_stream_int(ost, &o->audio_sample_rate, oc, st, &audio_enc->sample_rate); | 859 | opt_match_per_stream_int(ost, &o->audio_sample_rate, oc, st, &audio_enc->sample_rate); |
| 903 | if (ret < 0) | 860 | opt_match_per_stream_str(ost, &o->apad, oc, st, &ms->apad); |
| 904 | return ret; | | |
| 905 | | | |
| 906 | ret = opt_match_per_stream_str(ost, &o->apad, oc, st, &ms->apad); | | |
| 907 | if (ret < 0) | | |
| 908 | return ret; | | |
| 909 | } | 861 | } |
| 910 | | 862 | |
| 911 | return 0; | 863 | return 0; |
| @@ -928,11 +880,8 @@ static int new_stream_subtitle(Muxer *mux, const OptionsContext *o, · 16 unmodified lines |
| 928 | int input_props = 0, output_props = 0; | 880 | int input_props = 0, output_props = 0; |
| 929 | | 881 | |
| 930 | const char *frame_size = NULL; | 882 | const char *frame_size = NULL; |
| 931 | int ret; | | |
| 932 | | 883 | |
| 933 | ret = opt_match_per_stream_str(ost, &o->frame_sizes, mux->fc, st, &frame_size); | 884 | opt_match_per_stream_str(ost, &o->frame_sizes, mux->fc, st, &frame_size); |
| 934 | if (ret < 0) | | |
| 935 | return ret; | | |
| 936 | if (frame_size) { | 885 | if (frame_size) { |
| 937 | int ret = av_parse_video_size(&subtitle_enc->width, &subtitle_enc->height, frame_size); | 886 | int ret = av_parse_video_size(&subtitle_enc->width, &subtitle_enc->height, frame_size); |
| 938 | if (ret < 0) { | 887 | if (ret < 0) { |
| @@ -1211,13 +1160,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 272 unmodified lines |
| 1211 | if (ret < 0) | 1160 | if (ret < 0) |
| 1212 | goto fail; | 1161 | goto fail; |
| 1213 | | 1162 | |
| 1214 | ret = opt_match_per_stream_str(ost, &o->presets, oc, st, &preset); | 1163 | opt_match_per_stream_str(ost, &o->presets, oc, st, &preset); |
| 1215 | if (ret < 0) | 1164 | opt_match_per_stream_int(ost, &o->autoscale, oc, st, &autoscale); |
| 1216 | goto fail; | | |
| 1217 | | | |
| 1218 | ret = opt_match_per_stream_int(ost, &o->autoscale, oc, st, &autoscale); | | |
| 1219 | if (ret < 0) | | |
| 1220 | goto fail; | | |
| 1221 | if (preset && (!(ret = get_preset_file_2(preset, enc->codec->name, &s)))) { | 1165 | if (preset && (!(ret = get_preset_file_2(preset, enc->codec->name, &s)))) { |
| 1222 | AVBPrint bprint; | 1166 | AVBPrint bprint; |
| 1223 | av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); | 1167 | av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); |
| @@ -1248,14 +1192,12 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 24 unmodified lines |
| 1248 | goto fail; | 1192 | goto fail; |
| 1249 | } | 1193 | } |
| 1250 | | 1194 | |
| 1251 | ret = opt_match_per_stream_str(ost, &o->enc_stats_pre, oc, st, &enc_stats_pre); | 1195 | opt_match_per_stream_str(ost, &o->enc_stats_pre, oc, st, &enc_stats_pre); |
| 1252 | if (ret < 0) | | |
| 1253 | goto fail; | | |
| 1254 | if (enc_stats_pre && | 1196 | if (enc_stats_pre && |
| 1255 | (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { | 1197 | (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { |
| 1256 | const char *format = "{fidx} {sidx} {n} {t}"; | 1198 | const char *format = "{fidx} {sidx} {n} {t}"; |
| 1257 | | 1199 | |
| 1258 | ret = opt_match_per_stream_str(ost, &o->enc_stats_pre_fmt, oc, st, &format); | 1200 | opt_match_per_stream_str(ost, &o->enc_stats_pre_fmt, oc, st, &format); |
| 1259 | if (ret < 0) | 1201 | if (ret < 0) |
| 1260 | goto fail; | 1202 | goto fail; |
| 1261 | | 1203 | |
| @@ -1264,41 +1206,31 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 2 unmodified lines |
| 1264 | goto fail; | 1206 | goto fail; |
| 1265 | } | 1207 | } |
| 1266 | | 1208 | |
| 1267 | ret = opt_match_per_stream_str(ost, &o->enc_stats_post, oc, st, &enc_stats_post); | 1209 | opt_match_per_stream_str(ost, &o->enc_stats_post, oc, st, &enc_stats_post); |
| 1268 | if (ret < 0) | | |
| 1269 | goto fail; | | |
| 1270 | if (enc_stats_post && | 1210 | if (enc_stats_post && |
| 1271 | (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { | 1211 | (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { |
| 1272 | const char *format = "{fidx} {sidx} {n} {t}"; | 1212 | const char *format = "{fidx} {sidx} {n} {t}"; |
| 1273 | | 1213 | |
| 1274 | ret = opt_match_per_stream_str(ost, &o->enc_stats_post_fmt, oc, st, &format); | 1214 | opt_match_per_stream_str(ost, &o->enc_stats_post_fmt, oc, st, &format); |
| 1275 | if (ret < 0) | | |
| 1276 | goto fail; | | |
| 1277 | | 1215 | |
| 1278 | ret = enc_stats_init(ost, &ost->enc_stats_post, 0, enc_stats_post, format); | 1216 | ret = enc_stats_init(ost, &ost->enc_stats_post, 0, enc_stats_post, format); |
| 1279 | if (ret < 0) | 1217 | if (ret < 0) |
| 1280 | goto fail; | 1218 | goto fail; |
| 1281 | } | 1219 | } |
| 1282 | | 1220 | |
| 1283 | ret = opt_match_per_stream_str(ost, &o->mux_stats, oc, st, &mux_stats); | 1221 | opt_match_per_stream_str(ost, &o->mux_stats, oc, st, &mux_stats); |
| 1284 | if (ret < 0) | | |
| 1285 | goto fail; | | |
| 1286 | if (mux_stats && | 1222 | if (mux_stats && |
| 1287 | (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { | 1223 | (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { |
| 1288 | const char *format = "{fidx} {sidx} {n} {t}"; | 1224 | const char *format = "{fidx} {sidx} {n} {t}"; |
| 1289 | | 1225 | |
| 1290 | ret = opt_match_per_stream_str(ost, &o->mux_stats_fmt, oc, st, &format); | 1226 | opt_match_per_stream_str(ost, &o->mux_stats_fmt, oc, st, &format); |
| 1291 | if (ret < 0) | | |
| 1292 | goto fail; | | |
| 1293 | | 1227 | |
| 1294 | ret = enc_stats_init(ost, &ms->stats, 0, mux_stats, format); | 1228 | ret = enc_stats_init(ost, &ms->stats, 0, mux_stats, format); |
| 1295 | if (ret < 0) | 1229 | if (ret < 0) |
| 1296 | goto fail; | 1230 | goto fail; |
| 1297 | } | 1231 | } |
| 1298 | | 1232 | |
| 1299 | ret = opt_match_per_stream_str(ost, &o->enc_time_bases, oc, st, &enc_time_base); | 1233 | opt_match_per_stream_str(ost, &o->enc_time_bases, oc, st, &enc_time_base); |
| 1300 | if (ret < 0) | | |
| 1301 | goto fail; | | |
| 1302 | if (enc_time_base && type == AVMEDIA_TYPE_SUBTITLE) | 1234 | if (enc_time_base && type == AVMEDIA_TYPE_SUBTITLE) |
| 1303 | av_log(ost, AV_LOG_WARNING, | 1235 | av_log(ost, AV_LOG_WARNING, |
| 1304 | "-enc_time_base not supported for subtitles, ignoring\n"); | 1236 | "-enc_time_base not supported for subtitles, ignoring\n"); |
| @@ -1361,9 +1293,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 56 unmodified lines |
| 1361 | ost->bitexact = !!(ost->enc_ctx->flags & AV_CODEC_FLAG_BITEXACT); | 1293 | ost->bitexact = !!(ost->enc_ctx->flags & AV_CODEC_FLAG_BITEXACT); |
| 1362 | } | 1294 | } |
| 1363 | | 1295 | |
| 1364 | ret = opt_match_per_stream_str(ost, &o->time_bases, oc, st, &time_base); | 1296 | opt_match_per_stream_str(ost, &o->time_bases, oc, st, &time_base); |
| 1365 | if (ret < 0) | | |
| 1366 | goto fail; | | |
| 1367 | if (time_base) { | 1297 | if (time_base) { |
| 1368 | AVRational q; | 1298 | AVRational q; |
| 1369 | if (av_parse_ratio(&q, time_base, INT_MAX, 0, NULL) < 0 || | 1299 | if (av_parse_ratio(&q, time_base, INT_MAX, 0, NULL) < 0 || |
| @@ -1376,9 +1306,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 6 unmodified lines |
| 1376 | } | 1306 | } |
| 1377 | | 1307 | |
| 1378 | ms->max_frames = INT64_MAX; | 1308 | ms->max_frames = INT64_MAX; |
| 1379 | ret = opt_match_per_stream_int64(ost, &o->max_frames, oc, st, &ms->max_frames); | 1309 | opt_match_per_stream_int64(ost, &o->max_frames, oc, st, &ms->max_frames); |
| 1380 | if (ret < 0) | | |
| 1381 | return ret; | | |
| 1382 | for (int i = 0; i < o->max_frames.nb_opt; i++) { | 1310 | for (int i = 0; i < o->max_frames.nb_opt; i++) { |
| 1383 | char *p = o->max_frames.opt[i].specifier; | 1311 | char *p = o->max_frames.opt[i].specifier; |
| 1384 | if (!*p && type != AVMEDIA_TYPE_VIDEO) { | 1312 | if (!*p && type != AVMEDIA_TYPE_VIDEO) { |
| @@ -1388,13 +1316,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 3 unmodified lines |
| 1388 | } | 1316 | } |
| 1389 | | 1317 | |
| 1390 | ms->copy_prior_start = -1; | 1318 | ms->copy_prior_start = -1; |
| 1391 | ret = opt_match_per_stream_int(ost, &o->copy_prior_start, oc, st, &ms->copy_prior_start); | 1319 | opt_match_per_stream_int(ost, &o->copy_prior_start, oc, st, &ms->copy_prior_start); |
| 1392 | if (ret < 0) | 1320 | opt_match_per_stream_str(ost, &o->bitstream_filters, oc, st, &bsfs); |
| 1393 | goto fail; | | |
| 1394 | | | |
| 1395 | ret = opt_match_per_stream_str(ost, &o->bitstream_filters, oc, st, &bsfs); | | |
| 1396 | if (ret < 0) | | |
| 1397 | goto fail; | | |
| 1398 | if (bsfs && *bsfs) { | 1321 | if (bsfs && *bsfs) { |
| 1399 | ret = av_bsf_list_parse_str(bsfs, &ms->bsf_ctx); | 1322 | ret = av_bsf_list_parse_str(bsfs, &ms->bsf_ctx); |
| 1400 | if (ret < 0) { | 1323 | if (ret < 0) { |
| @@ -1403,9 +1326,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 2 unmodified lines |
| 1403 | } | 1326 | } |
| 1404 | } | 1327 | } |
| 1405 | | 1328 | |
| 1406 | ret = opt_match_per_stream_str(ost, &o->codec_tags, oc, st, &codec_tag); | 1329 | opt_match_per_stream_str(ost, &o->codec_tags, oc, st, &codec_tag); |
| 1407 | if (ret < 0) | | |
| 1408 | goto fail; | | |
| 1409 | if (codec_tag) { | 1330 | if (codec_tag) { |
| 1410 | uint32_t tag = strtol(codec_tag, &next, 0); | 1331 | uint32_t tag = strtol(codec_tag, &next, 0); |
| 1411 | if (*next) { | 1332 | if (*next) { |
| @@ -1419,9 +1340,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 7 unmodified lines |
| 1419 | ost->enc_ctx->codec_tag = tag; | 1340 | ost->enc_ctx->codec_tag = tag; |
| 1420 | } | 1341 | } |
| 1421 | | 1342 | |
| 1422 | ret = opt_match_per_stream_dbl(ost, &o->qscale, oc, st, &qscale); | 1343 | opt_match_per_stream_dbl(ost, &o->qscale, oc, st, &qscale); |
| 1423 | if (ret < 0) | | |
| 1424 | return ret; | | |
| 1425 | if (ost->enc_ctx && qscale >= 0) { | 1344 | if (ost->enc_ctx && qscale >= 0) { |
| 1426 | ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE; | 1345 | ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE; |
| 1427 | ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; | 1346 | ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; |
| @@ -1431,38 +1350,26 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, · 3 unmodified lines |
| 1431 | int max_muxing_queue_size = 128; | 1350 | int max_muxing_queue_size = 128; |
| 1432 | int muxing_queue_data_threshold = 50 * 1024 * 1024; | 1351 | int muxing_queue_data_threshold = 50 * 1024 * 1024; |
| 1433 | | 1352 | |
| 1434 | ret = opt_match_per_stream_int(ost, &o->max_muxing_queue_size, oc, st, | 1353 | opt_match_per_stream_int(ost, &o->max_muxing_queue_size, oc, st, |
| 1435 | &max_muxing_queue_size); | 1354 | &max_muxing_queue_size); |
| 1436 | if (ret < 0) | 1355 | opt_match_per_stream_int(ost, &o->muxing_queue_data_threshold, |
| 1437 | goto fail; | 1356 | oc, st, &muxing_queue_data_threshold); |
| 1438 | | | |
| 1439 | ret = opt_match_per_stream_int(ost, &o->muxing_queue_data_threshold, | | |
| 1440 | oc, st, &muxing_queue_data_threshold); | | |
| 1441 | if (ret < 0) | | |
| 1442 | goto fail; | | |
| 1443 | | 1357 | |
| 1444 | sch_mux_stream_buffering(mux->sch, mux->sch_idx, ms->sch_idx, | 1358 | sch_mux_stream_buffering(mux->sch, mux->sch_idx, ms->sch_idx, |
| 1445 | max_muxing_queue_size, muxing_queue_data_threshold); | 1359 | max_muxing_queue_size, muxing_queue_data_threshold); |
| 1446 | } | 1360 | } |
| 1447 | | 1361 | |
| 1448 | ret = opt_match_per_stream_int(ost, &o->bits_per_raw_sample, oc, st, | 1362 | opt_match_per_stream_int(ost, &o->bits_per_raw_sample, oc, st, |
| 1449 | &ost->bits_per_raw_sample); | 1363 | &ost->bits_per_raw_sample); |
| 1450 | if (ret < 0) | | |
| 1451 | goto fail; | | |
| 1452 | | 1364 | |
| 1453 | ret = opt_match_per_stream_int(ost, &o->fix_sub_duration_heartbeat, | 1365 | opt_match_per_stream_int(ost, &o->fix_sub_duration_heartbeat, |
| 1454 | oc, st, &ost->fix_sub_duration_heartbeat); | 1366 | oc, st, &ost->fix_sub_duration_heartbeat); |
| 1455 | if (ret < 0) | | |
| 1456 | goto fail; | | |
| 1457 | | 1367 | |
| 1458 | if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc_ctx) | 1368 | if (oc->oformat->flags & AVFMT_GLOBALHEADER && ost->enc_ctx) |
| 1459 | ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; | 1369 | ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; |
| 1460 | | 1370 | |
| 1461 | ret = opt_match_per_stream_int(ost, &o->copy_initial_nonkeyframes, | 1371 | opt_match_per_stream_int(ost, &o->copy_initial_nonkeyframes, |
| 1462 | oc, st, &ms->copy_initial_nonkeyframes); | 1372 | oc, st, &ms->copy_initial_nonkeyframes); |
| 1463 | if (ret < 0) | | |
| 1464 | goto fail; | | |
| 1465 | | | |
| 1466 | switch (type) { | 1373 | switch (type) { |
| 1467 | case AVMEDIA_TYPE_VIDEO: ret = new_stream_video (mux, o, ost, &keep_pix_fmt, &vsync_method); break; | 1374 | case AVMEDIA_TYPE_VIDEO: ret = new_stream_video (mux, o, ost, &keep_pix_fmt, &vsync_method); break; |
| 1468 | case AVMEDIA_TYPE_AUDIO: ret = new_stream_audio (mux, o, ost); break; | 1375 | case AVMEDIA_TYPE_AUDIO: ret = new_stream_audio (mux, o, ost); break; |
| @@ -3036,9 +2943,7 @@ static int set_dispositions(Muxer *mux, const OptionsContext *o) · 1567 unmodified lines |
| 3036 | | 2943 | |
| 3037 | nb_streams[ost->type + 1]++; | 2944 | nb_streams[ost->type + 1]++; |
| 3038 | | 2945 | |
| 3039 | ret = opt_match_per_stream_str(ost, &o->disposition, ctx, ost->st, &dispositions[i]); | 2946 | opt_match_per_stream_str(ost, &o->disposition, ctx, ost->st, &dispositions[i]); |
| 3040 | if (ret < 0) | | |
| 3041 | goto finish; | | |
| 3042 | | 2947 | |
| 3043 | have_manual |= !!dispositions[i]; | 2948 | have_manual |= !!dispositions[i]; |
| 3044 | | 2949 | |
| @@ -3183,12 +3088,9 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o) · 138 unmodified lines |
| 3183 | for (int i = 0; i < mux->of.nb_streams; i++) { | 3088 | for (int i = 0; i < mux->of.nb_streams; i++) { |
| 3184 | OutputStream *ost = mux->of.streams[i]; | 3089 | OutputStream *ost = mux->of.streams[i]; |
| 3185 | const char *forced_keyframes = NULL; | 3090 | const char *forced_keyframes = NULL; |
| 3186 | int ret; | | |
| 3187 | | 3091 | |
| 3188 | ret = opt_match_per_stream_str(ost, &o->forced_key_frames, | 3092 | opt_match_per_stream_str(ost, &o->forced_key_frames, |
| 3189 | mux->fc, ost->st, &forced_keyframes); | 3093 | mux->fc, ost->st, &forced_keyframes); |
| 3190 | if (ret < 0) | | |
| 3191 | return ret; | | |
| 3192 | | 3094 | |
| 3193 | if (!(ost->type == AVMEDIA_TYPE_VIDEO && | 3095 | if (!(ost->type == AVMEDIA_TYPE_VIDEO && |
| 3194 | ost->enc_ctx && forced_keyframes)) | 3096 | ost->enc_ctx && forced_keyframes)) |