MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / opt_target

Function opt_target

fftools/ffmpeg_opt.c:904–1045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

902}
903
904static int opt_target(void *optctx, const char *opt, const char *arg)
905{
906 OptionsContext *o = optctx;
907 enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN;
908 static const char *const frame_rates[] = { "25", "30000/1001", "24000/1001" };
909
910 if (!strncmp(arg, "pal-", 4)) {
911 norm = PAL;
912 arg += 4;
913 } else if (!strncmp(arg, "ntsc-", 5)) {
914 norm = NTSC;
915 arg += 5;
916 } else if (!strncmp(arg, "film-", 5)) {
917 norm = FILM;
918 arg += 5;
919 } else {
920 /* Try to determine PAL/NTSC by peeking in the input files */
921 if (nb_input_files) {
922 int i, j;
923 for (j = 0; j < nb_input_files; j++) {
924 for (i = 0; i < input_files[j]->nb_streams; i++) {
925 AVStream *st = input_files[j]->ctx->streams[i];
926 int64_t fr;
927 if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
928 continue;
929 fr = st->time_base.den * 1000LL / st->time_base.num;
930 if (fr == 25000) {
931 norm = PAL;
932 break;
933 } else if ((fr == 29970) || (fr == 23976)) {
934 norm = NTSC;
935 break;
936 }
937 }
938 if (norm != UNKNOWN)
939 break;
940 }
941 }
942 if (norm != UNKNOWN)
943 av_log(NULL, AV_LOG_INFO, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC");
944 }
945
946 if (norm == UNKNOWN) {
947 av_log(NULL, AV_LOG_FATAL, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
948 av_log(NULL, AV_LOG_FATAL, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
949 av_log(NULL, AV_LOG_FATAL, "or set a framerate with \"-r xxx\".\n");
950 return AVERROR(EINVAL);
951 }
952
953 if (!strcmp(arg, "vcd")) {
954 opt_video_codec(o, "c:v", "mpeg1video");
955 opt_audio_codec(o, "c:a", "mp2");
956 parse_option(o, "f", "vcd", options);
957
958 parse_option(o, "s", norm == PAL ? "352x288" : "352x240", options);
959 parse_option(o, "r", frame_rates[norm], options);
960 opt_default(NULL, "g", norm == PAL ? "15" : "18");
961

Callers

nothing calls this directly

Calls 6

av_logFunction · 0.85
opt_video_codecFunction · 0.85
opt_audio_codecFunction · 0.85
parse_optionFunction · 0.85
opt_defaultFunction · 0.85
av_dict_copyFunction · 0.85

Tested by

no test coverage detected