| 2683 | } |
| 2684 | |
| 2685 | static int opt_target(void *optctx, const char *opt, const char *arg) |
| 2686 | { |
| 2687 | OptionsContext *o = optctx; |
| 2688 | enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN; |
| 2689 | static const char *const frame_rates[] = { "25", "30000/1001", "24000/1001" }; |
| 2690 | |
| 2691 | if (!strncmp(arg, "pal-", 4)) { |
| 2692 | norm = PAL; |
| 2693 | arg += 4; |
| 2694 | } else if (!strncmp(arg, "ntsc-", 5)) { |
| 2695 | norm = NTSC; |
| 2696 | arg += 5; |
| 2697 | } else if (!strncmp(arg, "film-", 5)) { |
| 2698 | norm = FILM; |
| 2699 | arg += 5; |
| 2700 | } else { |
| 2701 | /* Try to determine PAL/NTSC by peeking in the input files */ |
| 2702 | if (nb_input_files) { |
| 2703 | int i, j, fr; |
| 2704 | for (j = 0; j < nb_input_files; j++) { |
| 2705 | for (i = 0; i < input_files[j]->nb_streams; i++) { |
| 2706 | AVStream *st = input_files[j]->ctx->streams[i]; |
| 2707 | if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) |
| 2708 | continue; |
| 2709 | fr = st->time_base.den * 1000 / st->time_base.num; |
| 2710 | if (fr == 25000) { |
| 2711 | norm = PAL; |
| 2712 | break; |
| 2713 | } else if ((fr == 29970) || (fr == 23976)) { |
| 2714 | norm = NTSC; |
| 2715 | break; |
| 2716 | } |
| 2717 | } |
| 2718 | if (norm != UNKNOWN) |
| 2719 | break; |
| 2720 | } |
| 2721 | } |
| 2722 | if (norm != UNKNOWN) |
| 2723 | av_log(NULL, AV_LOG_INFO, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC"); |
| 2724 | } |
| 2725 | |
| 2726 | if (norm == UNKNOWN) { |
| 2727 | av_log(NULL, AV_LOG_FATAL, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n"); |
| 2728 | av_log(NULL, AV_LOG_FATAL, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n"); |
| 2729 | av_log(NULL, AV_LOG_FATAL, "or set a framerate with \"-r xxx\".\n"); |
| 2730 | exit_program(1); |
| 2731 | } |
| 2732 | |
| 2733 | if (!strcmp(arg, "vcd")) { |
| 2734 | opt_video_codec(o, "c:v", "mpeg1video"); |
| 2735 | opt_audio_codec(o, "c:a", "mp2"); |
| 2736 | parse_option(o, "f", "vcd", options); |
| 2737 | |
| 2738 | parse_option(o, "s", norm == PAL ? "352x288" : "352x240", options); |
| 2739 | parse_option(o, "r", frame_rates[norm], options); |
| 2740 | opt_default(NULL, "g", norm == PAL ? "15" : "18"); |
| 2741 | |
| 2742 | opt_default(NULL, "b:v", "1150000"); |
nothing calls this directly
no test coverage detected