ffmpeg_opt.c 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891
  1. /*
  2. * ffmpeg option parsing
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "config.h"
  21. #include <stdint.h>
  22. #if HAVE_SYS_RESOURCE_H
  23. #include <sys/time.h>
  24. #include <sys/resource.h>
  25. #endif
  26. #include "ffmpeg.h"
  27. #include "ffmpeg_sched.h"
  28. #include "cmdutils.h"
  29. #include "opt_common.h"
  30. #include "libavformat/avformat.h"
  31. #include "libavcodec/avcodec.h"
  32. #include "libavcodec/bsf.h"
  33. #include "libavfilter/avfilter.h"
  34. #include "libavutil/avassert.h"
  35. #include "libavutil/avstring.h"
  36. #include "libavutil/avutil.h"
  37. #include "libavutil/mathematics.h"
  38. #include "libavutil/mem.h"
  39. #include "libavutil/opt.h"
  40. #include "libavutil/parseutils.h"
  41. HWDevice *filter_hw_device;
  42. char *vstats_filename;
  43. float audio_drift_threshold = 0.1;
  44. float dts_delta_threshold = 10;
  45. float dts_error_threshold = 3600*30;
  46. #if FFMPEG_OPT_VSYNC
  47. enum VideoSyncMethod video_sync_method = VSYNC_AUTO;
  48. #endif
  49. float frame_drop_threshold = 0;
  50. int do_benchmark = 0;
  51. int do_benchmark_all = 0;
  52. int do_hex_dump = 0;
  53. int do_pkt_dump = 0;
  54. int copy_ts = 0;
  55. int start_at_zero = 0;
  56. int copy_tb = -1;
  57. int debug_ts = 0;
  58. int exit_on_error = 0;
  59. int abort_on_flags = 0;
  60. int print_stats = -1;
  61. int stdin_interaction = 1;
  62. float max_error_rate = 2.0/3;
  63. char *filter_nbthreads;
  64. int filter_complex_nbthreads = 0;
  65. int vstats_version = 2;
  66. int auto_conversion_filters = 1;
  67. int64_t stats_period = 500000;
  68. static int file_overwrite = 0;
  69. static int no_file_overwrite = 0;
  70. int ignore_unknown_streams = 0;
  71. int copy_unknown_streams = 0;
  72. int recast_media = 0;
  73. static void uninit_options(OptionsContext *o)
  74. {
  75. int i;
  76. /* all OPT_SPEC and OPT_TYPE_STRING can be freed in generic way */
  77. for (const OptionDef *po = options; po->name; po++) {
  78. void *dst;
  79. if (!(po->flags & OPT_FLAG_OFFSET))
  80. continue;
  81. dst = (uint8_t*)o + po->u.off;
  82. if (po->flags & OPT_FLAG_SPEC) {
  83. SpecifierOptList *so = dst;
  84. for (int i = 0; i < so->nb_opt; i++) {
  85. av_freep(&so->opt[i].specifier);
  86. if (po->type == OPT_TYPE_STRING)
  87. av_freep(&so->opt[i].u.str);
  88. }
  89. av_freep(&so->opt);
  90. so->nb_opt = 0;
  91. } else if (po->type == OPT_TYPE_STRING)
  92. av_freep(dst);
  93. }
  94. for (i = 0; i < o->nb_stream_maps; i++)
  95. av_freep(&o->stream_maps[i].linklabel);
  96. av_freep(&o->stream_maps);
  97. for (i = 0; i < o->nb_attachments; i++)
  98. av_freep(&o->attachments[i]);
  99. av_freep(&o->attachments);
  100. av_dict_free(&o->streamid);
  101. }
  102. static void init_options(OptionsContext *o)
  103. {
  104. memset(o, 0, sizeof(*o));
  105. o->stop_time = INT64_MAX;
  106. o->mux_max_delay = 0.7;
  107. o->start_time = AV_NOPTS_VALUE;
  108. o->start_time_eof = AV_NOPTS_VALUE;
  109. o->recording_time = INT64_MAX;
  110. o->limit_filesize = INT64_MAX;
  111. o->chapters_input_file = INT_MAX;
  112. o->accurate_seek = 1;
  113. o->thread_queue_size = 0;
  114. o->input_sync_ref = -1;
  115. o->find_stream_info = 1;
  116. o->shortest_buf_duration = 10.f;
  117. }
  118. static int show_hwaccels(void *optctx, const char *opt, const char *arg)
  119. {
  120. enum AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE;
  121. printf("Hardware acceleration methods:\n");
  122. while ((type = av_hwdevice_iterate_types(type)) !=
  123. AV_HWDEVICE_TYPE_NONE)
  124. printf("%s\n", av_hwdevice_get_type_name(type));
  125. printf("\n");
  126. return 0;
  127. }
  128. const char *opt_match_per_type_str(const SpecifierOptList *sol,
  129. char mediatype)
  130. {
  131. av_assert0(!sol->nb_opt || sol->type == OPT_TYPE_STRING);
  132. for (int i = 0; i < sol->nb_opt; i++) {
  133. const char *spec = sol->opt[i].specifier;
  134. if (spec[0] == mediatype && !spec[1])
  135. return sol->opt[i].u.str;
  136. }
  137. return NULL;
  138. }
  139. int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global)
  140. {
  141. if (!av_strcasecmp(arg, "cfr")) *vsync_var = VSYNC_CFR;
  142. else if (!av_strcasecmp(arg, "vfr")) *vsync_var = VSYNC_VFR;
  143. else if (!av_strcasecmp(arg, "passthrough")) *vsync_var = VSYNC_PASSTHROUGH;
  144. #if FFMPEG_OPT_VSYNC_DROP
  145. else if (!av_strcasecmp(arg, "drop")) {
  146. av_log(NULL, AV_LOG_WARNING, "-vsync/fps_mode drop is deprecated\n");
  147. *vsync_var = VSYNC_DROP;
  148. }
  149. #endif
  150. else if (!is_global && !av_strcasecmp(arg, "auto")) *vsync_var = VSYNC_AUTO;
  151. else if (!is_global) {
  152. av_log(NULL, AV_LOG_FATAL, "Invalid value %s specified for fps_mode of #%d:%d.\n", arg, file_idx, st_idx);
  153. return AVERROR(EINVAL);
  154. }
  155. #if FFMPEG_OPT_VSYNC
  156. if (is_global && *vsync_var == VSYNC_AUTO) {
  157. int ret;
  158. double num;
  159. ret = parse_number("vsync", arg, OPT_TYPE_INT, VSYNC_AUTO, VSYNC_VFR, &num);
  160. if (ret < 0)
  161. return ret;
  162. video_sync_method = num;
  163. av_log(NULL, AV_LOG_WARNING, "Passing a number to -vsync is deprecated,"
  164. " use a string argument as described in the manual.\n");
  165. }
  166. #endif
  167. return 0;
  168. }
  169. /* Correct input file start times based on enabled streams */
  170. static void correct_input_start_times(void)
  171. {
  172. for (int i = 0; i < nb_input_files; i++) {
  173. InputFile *ifile = input_files[i];
  174. AVFormatContext *is = ifile->ctx;
  175. int64_t new_start_time = INT64_MAX, diff, abs_start_seek;
  176. ifile->start_time_effective = is->start_time;
  177. if (is->start_time == AV_NOPTS_VALUE ||
  178. !(is->iformat->flags & AVFMT_TS_DISCONT))
  179. continue;
  180. for (int j = 0; j < is->nb_streams; j++) {
  181. AVStream *st = is->streams[j];
  182. if(st->discard == AVDISCARD_ALL || st->start_time == AV_NOPTS_VALUE)
  183. continue;
  184. new_start_time = FFMIN(new_start_time, av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q));
  185. }
  186. diff = new_start_time - is->start_time;
  187. if (diff) {
  188. av_log(NULL, AV_LOG_VERBOSE, "Correcting start time of Input #%d by %"PRId64" us.\n", i, diff);
  189. ifile->start_time_effective = new_start_time;
  190. if (copy_ts && start_at_zero)
  191. ifile->ts_offset = -new_start_time;
  192. else if (!copy_ts) {
  193. abs_start_seek = is->start_time + (ifile->start_time != AV_NOPTS_VALUE) ? ifile->start_time : 0;
  194. ifile->ts_offset = abs_start_seek > new_start_time ? -abs_start_seek : -new_start_time;
  195. } else if (copy_ts)
  196. ifile->ts_offset = 0;
  197. ifile->ts_offset += ifile->input_ts_offset;
  198. }
  199. }
  200. }
  201. static int apply_sync_offsets(void)
  202. {
  203. for (int i = 0; i < nb_input_files; i++) {
  204. InputFile *ref, *self = input_files[i];
  205. int64_t adjustment;
  206. int64_t self_start_time, ref_start_time, self_seek_start, ref_seek_start;
  207. int start_times_set = 1;
  208. if (self->input_sync_ref == -1 || self->input_sync_ref == i) continue;
  209. if (self->input_sync_ref >= nb_input_files || self->input_sync_ref < -1) {
  210. av_log(NULL, AV_LOG_FATAL, "-isync for input %d references non-existent input %d.\n", i, self->input_sync_ref);
  211. return AVERROR(EINVAL);
  212. }
  213. if (copy_ts && !start_at_zero) {
  214. av_log(NULL, AV_LOG_FATAL, "Use of -isync requires that start_at_zero be set if copyts is set.\n");
  215. return AVERROR(EINVAL);
  216. }
  217. ref = input_files[self->input_sync_ref];
  218. if (ref->input_sync_ref != -1 && ref->input_sync_ref != self->input_sync_ref) {
  219. av_log(NULL, AV_LOG_ERROR, "-isync for input %d references a resynced input %d. Sync not set.\n", i, self->input_sync_ref);
  220. continue;
  221. }
  222. if (self->ctx->start_time_realtime != AV_NOPTS_VALUE && ref->ctx->start_time_realtime != AV_NOPTS_VALUE) {
  223. self_start_time = self->ctx->start_time_realtime;
  224. ref_start_time = ref->ctx->start_time_realtime;
  225. } else if (self->start_time_effective != AV_NOPTS_VALUE && ref->start_time_effective != AV_NOPTS_VALUE) {
  226. self_start_time = self->start_time_effective;
  227. ref_start_time = ref->start_time_effective;
  228. } else {
  229. start_times_set = 0;
  230. }
  231. if (start_times_set) {
  232. self_seek_start = self->start_time == AV_NOPTS_VALUE ? 0 : self->start_time;
  233. ref_seek_start = ref->start_time == AV_NOPTS_VALUE ? 0 : ref->start_time;
  234. adjustment = (self_start_time - ref_start_time) + !copy_ts*(self_seek_start - ref_seek_start) + ref->input_ts_offset;
  235. self->ts_offset += adjustment;
  236. av_log(NULL, AV_LOG_INFO, "Adjusted ts offset for Input #%d by %"PRId64" us to sync with Input #%d.\n", i, adjustment, self->input_sync_ref);
  237. } else {
  238. av_log(NULL, AV_LOG_INFO, "Unable to identify start times for Inputs #%d and %d both. No sync adjustment made.\n", i, self->input_sync_ref);
  239. }
  240. }
  241. return 0;
  242. }
  243. static int opt_filter_threads(void *optctx, const char *opt, const char *arg)
  244. {
  245. av_free(filter_nbthreads);
  246. filter_nbthreads = av_strdup(arg);
  247. return 0;
  248. }
  249. static int opt_abort_on(void *optctx, const char *opt, const char *arg)
  250. {
  251. static const AVOption opts[] = {
  252. { "abort_on" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, (double)INT64_MAX, .unit = "flags" },
  253. { "empty_output" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT }, .unit = "flags" },
  254. { "empty_output_stream", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM }, .unit = "flags" },
  255. { NULL },
  256. };
  257. static const AVClass class = {
  258. .class_name = "",
  259. .item_name = av_default_item_name,
  260. .option = opts,
  261. .version = LIBAVUTIL_VERSION_INT,
  262. };
  263. const AVClass *pclass = &class;
  264. return av_opt_eval_flags(&pclass, &opts[0], arg, &abort_on_flags);
  265. }
  266. static int opt_stats_period(void *optctx, const char *opt, const char *arg)
  267. {
  268. int64_t user_stats_period;
  269. int ret = av_parse_time(&user_stats_period, arg, 1);
  270. if (ret < 0)
  271. return ret;
  272. if (user_stats_period <= 0) {
  273. av_log(NULL, AV_LOG_ERROR, "stats_period %s must be positive.\n", arg);
  274. return AVERROR(EINVAL);
  275. }
  276. stats_period = user_stats_period;
  277. av_log(NULL, AV_LOG_INFO, "ffmpeg stats and -progress period set to %s.\n", arg);
  278. return 0;
  279. }
  280. static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
  281. {
  282. OptionsContext *o = optctx;
  283. return parse_option(o, "codec:a", arg, options);
  284. }
  285. static int opt_video_codec(void *optctx, const char *opt, const char *arg)
  286. {
  287. OptionsContext *o = optctx;
  288. return parse_option(o, "codec:v", arg, options);
  289. }
  290. static int opt_subtitle_codec(void *optctx, const char *opt, const char *arg)
  291. {
  292. OptionsContext *o = optctx;
  293. return parse_option(o, "codec:s", arg, options);
  294. }
  295. static int opt_data_codec(void *optctx, const char *opt, const char *arg)
  296. {
  297. OptionsContext *o = optctx;
  298. return parse_option(o, "codec:d", arg, options);
  299. }
  300. static int opt_map(void *optctx, const char *opt, const char *arg)
  301. {
  302. OptionsContext *o = optctx;
  303. StreamMap *m = NULL;
  304. int i, negative = 0, file_idx, disabled = 0;
  305. int ret;
  306. char *map, *p;
  307. char *allow_unused;
  308. if (*arg == '-') {
  309. negative = 1;
  310. arg++;
  311. }
  312. map = av_strdup(arg);
  313. if (!map)
  314. return AVERROR(ENOMEM);
  315. if (map[0] == '[') {
  316. /* this mapping refers to lavfi output */
  317. const char *c = map + 1;
  318. ret = GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
  319. if (ret < 0)
  320. goto fail;
  321. m = &o->stream_maps[o->nb_stream_maps - 1];
  322. m->linklabel = av_get_token(&c, "]");
  323. if (!m->linklabel) {
  324. av_log(NULL, AV_LOG_ERROR, "Invalid output link label: %s.\n", map);
  325. ret = AVERROR(EINVAL);
  326. goto fail;
  327. }
  328. } else {
  329. if (allow_unused = strchr(map, '?'))
  330. *allow_unused = 0;
  331. file_idx = strtol(map, &p, 0);
  332. if (file_idx >= nb_input_files || file_idx < 0) {
  333. av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx);
  334. ret = AVERROR(EINVAL);
  335. goto fail;
  336. }
  337. if (negative)
  338. /* disable some already defined maps */
  339. for (i = 0; i < o->nb_stream_maps; i++) {
  340. m = &o->stream_maps[i];
  341. if (file_idx == m->file_index &&
  342. check_stream_specifier(input_files[m->file_index]->ctx,
  343. input_files[m->file_index]->ctx->streams[m->stream_index],
  344. *p == ':' ? p + 1 : p) > 0)
  345. m->disabled = 1;
  346. }
  347. else
  348. for (i = 0; i < input_files[file_idx]->nb_streams; i++) {
  349. if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i],
  350. *p == ':' ? p + 1 : p) <= 0)
  351. continue;
  352. if (input_files[file_idx]->streams[i]->user_set_discard == AVDISCARD_ALL) {
  353. disabled = 1;
  354. continue;
  355. }
  356. ret = GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
  357. if (ret < 0)
  358. goto fail;
  359. m = &o->stream_maps[o->nb_stream_maps - 1];
  360. m->file_index = file_idx;
  361. m->stream_index = i;
  362. }
  363. }
  364. if (!m) {
  365. if (allow_unused) {
  366. av_log(NULL, AV_LOG_VERBOSE, "Stream map '%s' matches no streams; ignoring.\n", arg);
  367. } else if (disabled) {
  368. av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches disabled streams.\n"
  369. "To ignore this, add a trailing '?' to the map.\n", arg);
  370. ret = AVERROR(EINVAL);
  371. goto fail;
  372. } else {
  373. av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n"
  374. "To ignore this, add a trailing '?' to the map.\n", arg);
  375. ret = AVERROR(EINVAL);
  376. goto fail;
  377. }
  378. }
  379. ret = 0;
  380. fail:
  381. av_freep(&map);
  382. return ret;
  383. }
  384. static int opt_attach(void *optctx, const char *opt, const char *arg)
  385. {
  386. OptionsContext *o = optctx;
  387. int ret = GROW_ARRAY(o->attachments, o->nb_attachments);
  388. if (ret < 0)
  389. return ret;
  390. o->attachments[o->nb_attachments - 1] = av_strdup(arg);
  391. if (!o->attachments[o->nb_attachments - 1])
  392. return AVERROR(ENOMEM);
  393. return 0;
  394. }
  395. static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
  396. {
  397. Scheduler *sch = optctx;
  398. return sch_sdp_filename(sch, arg);
  399. }
  400. #if CONFIG_VAAPI
  401. static int opt_vaapi_device(void *optctx, const char *opt, const char *arg)
  402. {
  403. const char *prefix = "vaapi:";
  404. char *tmp;
  405. int err;
  406. tmp = av_asprintf("%s%s", prefix, arg);
  407. if (!tmp)
  408. return AVERROR(ENOMEM);
  409. err = hw_device_init_from_string(tmp, NULL);
  410. av_free(tmp);
  411. return err;
  412. }
  413. #endif
  414. #if CONFIG_QSV
  415. static int opt_qsv_device(void *optctx, const char *opt, const char *arg)
  416. {
  417. const char *prefix = "qsv=__qsv_device:hw_any,child_device=";
  418. int err;
  419. char *tmp = av_asprintf("%s%s", prefix, arg);
  420. if (!tmp)
  421. return AVERROR(ENOMEM);
  422. err = hw_device_init_from_string(tmp, NULL);
  423. av_free(tmp);
  424. return err;
  425. }
  426. #endif
  427. static int opt_init_hw_device(void *optctx, const char *opt, const char *arg)
  428. {
  429. if (!strcmp(arg, "list")) {
  430. enum AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE;
  431. printf("Supported hardware device types:\n");
  432. while ((type = av_hwdevice_iterate_types(type)) !=
  433. AV_HWDEVICE_TYPE_NONE)
  434. printf("%s\n", av_hwdevice_get_type_name(type));
  435. printf("\n");
  436. return AVERROR_EXIT;
  437. } else {
  438. return hw_device_init_from_string(arg, NULL);
  439. }
  440. }
  441. static int opt_filter_hw_device(void *optctx, const char *opt, const char *arg)
  442. {
  443. if (filter_hw_device) {
  444. av_log(NULL, AV_LOG_ERROR, "Only one filter device can be used.\n");
  445. return AVERROR(EINVAL);
  446. }
  447. filter_hw_device = hw_device_get_by_name(arg);
  448. if (!filter_hw_device) {
  449. av_log(NULL, AV_LOG_ERROR, "Invalid filter device %s.\n", arg);
  450. return AVERROR(EINVAL);
  451. }
  452. return 0;
  453. }
  454. static int opt_recording_timestamp(void *optctx, const char *opt, const char *arg)
  455. {
  456. OptionsContext *o = optctx;
  457. char buf[128];
  458. int64_t recording_timestamp;
  459. int ret;
  460. struct tm time;
  461. ret = av_parse_time(&recording_timestamp, arg, 0);
  462. if (ret < 0)
  463. return ret;
  464. recording_timestamp /= 1e6;
  465. time = *gmtime((time_t*)&recording_timestamp);
  466. if (!strftime(buf, sizeof(buf), "creation_time=%Y-%m-%dT%H:%M:%S%z", &time))
  467. return -1;
  468. parse_option(o, "metadata", buf, options);
  469. av_log(NULL, AV_LOG_WARNING, "%s is deprecated, set the 'creation_time' metadata "
  470. "tag instead.\n", opt);
  471. return 0;
  472. }
  473. int find_codec(void *logctx, const char *name,
  474. enum AVMediaType type, int encoder, const AVCodec **pcodec)
  475. {
  476. const AVCodecDescriptor *desc;
  477. const char *codec_string = encoder ? "encoder" : "decoder";
  478. const AVCodec *codec;
  479. codec = encoder ?
  480. avcodec_find_encoder_by_name(name) :
  481. avcodec_find_decoder_by_name(name);
  482. if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
  483. codec = encoder ? avcodec_find_encoder(desc->id) :
  484. avcodec_find_decoder(desc->id);
  485. if (codec)
  486. av_log(logctx, AV_LOG_VERBOSE, "Matched %s '%s' for codec '%s'.\n",
  487. codec_string, codec->name, desc->name);
  488. }
  489. if (!codec) {
  490. av_log(logctx, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
  491. return encoder ? AVERROR_ENCODER_NOT_FOUND :
  492. AVERROR_DECODER_NOT_FOUND;
  493. }
  494. if (codec->type != type && !recast_media) {
  495. av_log(logctx, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name);
  496. return AVERROR(EINVAL);
  497. }
  498. *pcodec = codec;
  499. return 0;;
  500. }
  501. int assert_file_overwrite(const char *filename)
  502. {
  503. const char *proto_name = avio_find_protocol_name(filename);
  504. if (file_overwrite && no_file_overwrite) {
  505. fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
  506. return AVERROR(EINVAL);
  507. }
  508. if (!file_overwrite) {
  509. if (proto_name && !strcmp(proto_name, "file") && avio_check(filename, 0) == 0) {
  510. if (stdin_interaction && !no_file_overwrite) {
  511. fprintf(stderr,"File '%s' already exists. Overwrite? [y/N] ", filename);
  512. fflush(stderr);
  513. term_exit();
  514. signal(SIGINT, SIG_DFL);
  515. if (!read_yesno()) {
  516. av_log(NULL, AV_LOG_FATAL, "Not overwriting - exiting\n");
  517. return AVERROR_EXIT;
  518. }
  519. term_init();
  520. }
  521. else {
  522. av_log(NULL, AV_LOG_FATAL, "File '%s' already exists. Exiting.\n", filename);
  523. return AVERROR_EXIT;
  524. }
  525. }
  526. }
  527. if (proto_name && !strcmp(proto_name, "file")) {
  528. for (int i = 0; i < nb_input_files; i++) {
  529. InputFile *file = input_files[i];
  530. if (file->ctx->iformat->flags & AVFMT_NOFILE)
  531. continue;
  532. if (!strcmp(filename, file->ctx->url)) {
  533. av_log(NULL, AV_LOG_FATAL, "Output %s same as Input #%d - exiting\n", filename, i);
  534. av_log(NULL, AV_LOG_WARNING, "FFmpeg cannot edit existing files in-place.\n");
  535. return AVERROR(EINVAL);
  536. }
  537. }
  538. }
  539. return 0;
  540. }
  541. /* arg format is "output-stream-index:streamid-value". */
  542. static int opt_streamid(void *optctx, const char *opt, const char *arg)
  543. {
  544. OptionsContext *o = optctx;
  545. char *p;
  546. char idx_str[16];
  547. av_strlcpy(idx_str, arg, sizeof(idx_str));
  548. p = strchr(idx_str, ':');
  549. if (!p) {
  550. av_log(NULL, AV_LOG_FATAL,
  551. "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
  552. arg, opt);
  553. return AVERROR(EINVAL);
  554. }
  555. *p++ = '\0';
  556. return av_dict_set(&o->streamid, idx_str, p, 0);
  557. }
  558. static int opt_target(void *optctx, const char *opt, const char *arg)
  559. {
  560. OptionsContext *o = optctx;
  561. enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN;
  562. static const char *const frame_rates[] = { "25", "30000/1001", "24000/1001" };
  563. if (!strncmp(arg, "pal-", 4)) {
  564. norm = PAL;
  565. arg += 4;
  566. } else if (!strncmp(arg, "ntsc-", 5)) {
  567. norm = NTSC;
  568. arg += 5;
  569. } else if (!strncmp(arg, "film-", 5)) {
  570. norm = FILM;
  571. arg += 5;
  572. } else {
  573. /* Try to determine PAL/NTSC by peeking in the input files */
  574. if (nb_input_files) {
  575. int i, j;
  576. for (j = 0; j < nb_input_files; j++) {
  577. for (i = 0; i < input_files[j]->nb_streams; i++) {
  578. AVStream *st = input_files[j]->ctx->streams[i];
  579. int64_t fr;
  580. if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
  581. continue;
  582. fr = st->time_base.den * 1000LL / st->time_base.num;
  583. if (fr == 25000) {
  584. norm = PAL;
  585. break;
  586. } else if ((fr == 29970) || (fr == 23976)) {
  587. norm = NTSC;
  588. break;
  589. }
  590. }
  591. if (norm != UNKNOWN)
  592. break;
  593. }
  594. }
  595. if (norm != UNKNOWN)
  596. av_log(NULL, AV_LOG_INFO, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC");
  597. }
  598. if (norm == UNKNOWN) {
  599. av_log(NULL, AV_LOG_FATAL, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
  600. av_log(NULL, AV_LOG_FATAL, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
  601. av_log(NULL, AV_LOG_FATAL, "or set a framerate with \"-r xxx\".\n");
  602. return AVERROR(EINVAL);
  603. }
  604. if (!strcmp(arg, "vcd")) {
  605. opt_video_codec(o, "c:v", "mpeg1video");
  606. opt_audio_codec(o, "c:a", "mp2");
  607. parse_option(o, "f", "vcd", options);
  608. parse_option(o, "s", norm == PAL ? "352x288" : "352x240", options);
  609. parse_option(o, "r", frame_rates[norm], options);
  610. opt_default(NULL, "g", norm == PAL ? "15" : "18");
  611. opt_default(NULL, "b:v", "1150000");
  612. opt_default(NULL, "maxrate:v", "1150000");
  613. opt_default(NULL, "minrate:v", "1150000");
  614. opt_default(NULL, "bufsize:v", "327680"); // 40*1024*8;
  615. opt_default(NULL, "b:a", "224000");
  616. parse_option(o, "ar", "44100", options);
  617. parse_option(o, "ac", "2", options);
  618. opt_default(NULL, "packetsize", "2324");
  619. opt_default(NULL, "muxrate", "1411200"); // 2352 * 75 * 8;
  620. /* We have to offset the PTS, so that it is consistent with the SCR.
  621. SCR starts at 36000, but the first two packs contain only padding
  622. and the first pack from the other stream, respectively, may also have
  623. been written before.
  624. So the real data starts at SCR 36000+3*1200. */
  625. o->mux_preload = (36000 + 3 * 1200) / 90000.0; // 0.44
  626. } else if (!strcmp(arg, "svcd")) {
  627. opt_video_codec(o, "c:v", "mpeg2video");
  628. opt_audio_codec(o, "c:a", "mp2");
  629. parse_option(o, "f", "svcd", options);
  630. parse_option(o, "s", norm == PAL ? "480x576" : "480x480", options);
  631. parse_option(o, "r", frame_rates[norm], options);
  632. parse_option(o, "pix_fmt", "yuv420p", options);
  633. opt_default(NULL, "g", norm == PAL ? "15" : "18");
  634. opt_default(NULL, "b:v", "2040000");
  635. opt_default(NULL, "maxrate:v", "2516000");
  636. opt_default(NULL, "minrate:v", "0"); // 1145000;
  637. opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
  638. opt_default(NULL, "scan_offset", "1");
  639. opt_default(NULL, "b:a", "224000");
  640. parse_option(o, "ar", "44100", options);
  641. opt_default(NULL, "packetsize", "2324");
  642. } else if (!strcmp(arg, "dvd")) {
  643. opt_video_codec(o, "c:v", "mpeg2video");
  644. opt_audio_codec(o, "c:a", "ac3");
  645. parse_option(o, "f", "dvd", options);
  646. parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
  647. parse_option(o, "r", frame_rates[norm], options);
  648. parse_option(o, "pix_fmt", "yuv420p", options);
  649. opt_default(NULL, "g", norm == PAL ? "15" : "18");
  650. opt_default(NULL, "b:v", "6000000");
  651. opt_default(NULL, "maxrate:v", "9000000");
  652. opt_default(NULL, "minrate:v", "0"); // 1500000;
  653. opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;
  654. opt_default(NULL, "packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
  655. opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
  656. opt_default(NULL, "b:a", "448000");
  657. parse_option(o, "ar", "48000", options);
  658. } else if (!strncmp(arg, "dv", 2)) {
  659. parse_option(o, "f", "dv", options);
  660. parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
  661. parse_option(o, "pix_fmt", !strncmp(arg, "dv50", 4) ? "yuv422p" :
  662. norm == PAL ? "yuv420p" : "yuv411p", options);
  663. parse_option(o, "r", frame_rates[norm], options);
  664. parse_option(o, "ar", "48000", options);
  665. parse_option(o, "ac", "2", options);
  666. } else {
  667. av_log(NULL, AV_LOG_ERROR, "Unknown target: %s\n", arg);
  668. return AVERROR(EINVAL);
  669. }
  670. av_dict_copy(&o->g->codec_opts, codec_opts, AV_DICT_DONT_OVERWRITE);
  671. av_dict_copy(&o->g->format_opts, format_opts, AV_DICT_DONT_OVERWRITE);
  672. return 0;
  673. }
  674. static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
  675. {
  676. av_free (vstats_filename);
  677. vstats_filename = av_strdup (arg);
  678. return 0;
  679. }
  680. static int opt_vstats(void *optctx, const char *opt, const char *arg)
  681. {
  682. char filename[40];
  683. time_t today2 = time(NULL);
  684. struct tm *today = localtime(&today2);
  685. if (!today) { // maybe tomorrow
  686. av_log(NULL, AV_LOG_FATAL, "Unable to get current time: %s\n", strerror(errno));
  687. return AVERROR(errno);
  688. }
  689. snprintf(filename, sizeof(filename), "vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
  690. today->tm_sec);
  691. return opt_vstats_file(NULL, opt, filename);
  692. }
  693. static int opt_video_frames(void *optctx, const char *opt, const char *arg)
  694. {
  695. OptionsContext *o = optctx;
  696. return parse_option(o, "frames:v", arg, options);
  697. }
  698. static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
  699. {
  700. OptionsContext *o = optctx;
  701. return parse_option(o, "frames:a", arg, options);
  702. }
  703. static int opt_data_frames(void *optctx, const char *opt, const char *arg)
  704. {
  705. OptionsContext *o = optctx;
  706. return parse_option(o, "frames:d", arg, options);
  707. }
  708. static int opt_default_new(OptionsContext *o, const char *opt, const char *arg)
  709. {
  710. int ret;
  711. AVDictionary *cbak = codec_opts;
  712. AVDictionary *fbak = format_opts;
  713. codec_opts = NULL;
  714. format_opts = NULL;
  715. ret = opt_default(NULL, opt, arg);
  716. av_dict_copy(&o->g->codec_opts , codec_opts, 0);
  717. av_dict_copy(&o->g->format_opts, format_opts, 0);
  718. av_dict_free(&codec_opts);
  719. av_dict_free(&format_opts);
  720. codec_opts = cbak;
  721. format_opts = fbak;
  722. return ret;
  723. }
  724. static int opt_preset(void *optctx, const char *opt, const char *arg)
  725. {
  726. OptionsContext *o = optctx;
  727. FILE *f=NULL;
  728. char filename[1000], line[1000], tmp_line[1000];
  729. const char *codec_name = NULL;
  730. int ret = 0;
  731. codec_name = opt_match_per_type_str(&o->codec_names, *opt);
  732. if (!(f = get_preset_file(filename, sizeof(filename), arg, *opt == 'f', codec_name))) {
  733. if(!strncmp(arg, "libx264-lossless", strlen("libx264-lossless"))){
  734. av_log(NULL, AV_LOG_FATAL, "Please use -preset <speed> -qp 0\n");
  735. }else
  736. av_log(NULL, AV_LOG_FATAL, "File for preset '%s' not found\n", arg);
  737. return AVERROR(ENOENT);
  738. }
  739. while (fgets(line, sizeof(line), f)) {
  740. char *key = tmp_line, *value, *endptr;
  741. if (strcspn(line, "#\n\r") == 0)
  742. continue;
  743. av_strlcpy(tmp_line, line, sizeof(tmp_line));
  744. if (!av_strtok(key, "=", &value) ||
  745. !av_strtok(value, "\r\n", &endptr)) {
  746. av_log(NULL, AV_LOG_FATAL, "%s: Invalid syntax: '%s'\n", filename, line);
  747. ret = AVERROR(EINVAL);
  748. goto fail;
  749. }
  750. av_log(NULL, AV_LOG_DEBUG, "ffpreset[%s]: set '%s' = '%s'\n", filename, key, value);
  751. if (!strcmp(key, "acodec")) opt_audio_codec (o, key, value);
  752. else if (!strcmp(key, "vcodec")) opt_video_codec (o, key, value);
  753. else if (!strcmp(key, "scodec")) opt_subtitle_codec(o, key, value);
  754. else if (!strcmp(key, "dcodec")) opt_data_codec (o, key, value);
  755. else if (opt_default_new(o, key, value) < 0) {
  756. av_log(NULL, AV_LOG_FATAL, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
  757. filename, line, key, value);
  758. ret = AVERROR(EINVAL);
  759. goto fail;
  760. }
  761. }
  762. fail:
  763. fclose(f);
  764. return ret;
  765. }
  766. static int opt_old2new(void *optctx, const char *opt, const char *arg)
  767. {
  768. OptionsContext *o = optctx;
  769. int ret;
  770. char *s = av_asprintf("%s:%c", opt + 1, *opt);
  771. if (!s)
  772. return AVERROR(ENOMEM);
  773. ret = parse_option(o, s, arg, options);
  774. av_free(s);
  775. return ret;
  776. }
  777. static int opt_bitrate(void *optctx, const char *opt, const char *arg)
  778. {
  779. OptionsContext *o = optctx;
  780. if(!strcmp(opt, "ab")){
  781. av_dict_set(&o->g->codec_opts, "b:a", arg, 0);
  782. return 0;
  783. } else if(!strcmp(opt, "b")){
  784. av_log(NULL, AV_LOG_WARNING, "Please use -b:a or -b:v, -b is ambiguous\n");
  785. av_dict_set(&o->g->codec_opts, "b:v", arg, 0);
  786. return 0;
  787. }
  788. av_dict_set(&o->g->codec_opts, opt, arg, 0);
  789. return 0;
  790. }
  791. static int opt_qscale(void *optctx, const char *opt, const char *arg)
  792. {
  793. OptionsContext *o = optctx;
  794. char *s;
  795. int ret;
  796. if(!strcmp(opt, "qscale")){
  797. av_log(NULL, AV_LOG_WARNING, "Please use -q:a or -q:v, -qscale is ambiguous\n");
  798. return parse_option(o, "q:v", arg, options);
  799. }
  800. s = av_asprintf("q%s", opt + 6);
  801. if (!s)
  802. return AVERROR(ENOMEM);
  803. ret = parse_option(o, s, arg, options);
  804. av_free(s);
  805. return ret;
  806. }
  807. static int opt_profile(void *optctx, const char *opt, const char *arg)
  808. {
  809. OptionsContext *o = optctx;
  810. if(!strcmp(opt, "profile")){
  811. av_log(NULL, AV_LOG_WARNING, "Please use -profile:a or -profile:v, -profile is ambiguous\n");
  812. av_dict_set(&o->g->codec_opts, "profile:v", arg, 0);
  813. return 0;
  814. }
  815. av_dict_set(&o->g->codec_opts, opt, arg, 0);
  816. return 0;
  817. }
  818. static int opt_video_filters(void *optctx, const char *opt, const char *arg)
  819. {
  820. OptionsContext *o = optctx;
  821. return parse_option(o, "filter:v", arg, options);
  822. }
  823. static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
  824. {
  825. OptionsContext *o = optctx;
  826. return parse_option(o, "filter:a", arg, options);
  827. }
  828. #if FFMPEG_OPT_VSYNC
  829. static int opt_vsync(void *optctx, const char *opt, const char *arg)
  830. {
  831. av_log(NULL, AV_LOG_WARNING, "-vsync is deprecated. Use -fps_mode\n");
  832. return parse_and_set_vsync(arg, &video_sync_method, -1, -1, 1);
  833. }
  834. #endif
  835. static int opt_timecode(void *optctx, const char *opt, const char *arg)
  836. {
  837. OptionsContext *o = optctx;
  838. int ret;
  839. char *tcr = av_asprintf("timecode=%s", arg);
  840. if (!tcr)
  841. return AVERROR(ENOMEM);
  842. ret = parse_option(o, "metadata:g", tcr, options);
  843. if (ret >= 0)
  844. ret = av_dict_set(&o->g->codec_opts, "gop_timecode", arg, 0);
  845. av_free(tcr);
  846. return ret;
  847. }
  848. static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
  849. {
  850. OptionsContext *o = optctx;
  851. return parse_option(o, "q:a", arg, options);
  852. }
  853. static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
  854. {
  855. Scheduler *sch = optctx;
  856. char *graph_desc = av_strdup(arg);
  857. if (!graph_desc)
  858. return AVERROR(ENOMEM);
  859. return fg_create(NULL, graph_desc, sch);
  860. }
  861. #if FFMPEG_OPT_FILTER_SCRIPT
  862. static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
  863. {
  864. Scheduler *sch = optctx;
  865. char *graph_desc = file_read(arg);
  866. if (!graph_desc)
  867. return AVERROR(EINVAL);
  868. av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -/filter_complex %s instead\n",
  869. opt, arg);
  870. return fg_create(NULL, graph_desc, sch);
  871. }
  872. #endif
  873. void show_help_default(const char *opt, const char *arg)
  874. {
  875. int show_advanced = 0, show_avoptions = 0;
  876. if (opt && *opt) {
  877. if (!strcmp(opt, "long"))
  878. show_advanced = 1;
  879. else if (!strcmp(opt, "full"))
  880. show_advanced = show_avoptions = 1;
  881. else
  882. av_log(NULL, AV_LOG_ERROR, "Unknown help option '%s'.\n", opt);
  883. }
  884. show_usage();
  885. printf("Getting help:\n"
  886. " -h -- print basic options\n"
  887. " -h long -- print more options\n"
  888. " -h full -- print all options (including all format and codec specific options, very long)\n"
  889. " -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol\n"
  890. " See man %s for detailed description of the options.\n"
  891. "\n"
  892. "Per-stream options can be followed by :<stream_spec> to apply that option to specific streams only. "
  893. "<stream_spec> can be a stream index, or v/a/s for video/audio/subtitle (see manual for full syntax).\n"
  894. "\n", program_name);
  895. show_help_options(options, "Print help / information / capabilities:",
  896. OPT_EXIT, OPT_EXPERT);
  897. if (show_advanced)
  898. show_help_options(options, "Advanced information / capabilities:",
  899. OPT_EXIT | OPT_EXPERT, 0);
  900. show_help_options(options, "Global options (affect whole program "
  901. "instead of just one file):",
  902. 0, OPT_PERFILE | OPT_EXIT | OPT_EXPERT);
  903. if (show_advanced)
  904. show_help_options(options, "Advanced global options:", OPT_EXPERT,
  905. OPT_PERFILE | OPT_EXIT);
  906. show_help_options(options, "Per-file options (input and output):",
  907. OPT_PERFILE | OPT_INPUT | OPT_OUTPUT,
  908. OPT_EXIT | OPT_FLAG_PERSTREAM | OPT_EXPERT |
  909. OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
  910. if (show_advanced)
  911. show_help_options(options, "Advanced per-file options (input and output):",
  912. OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_EXPERT,
  913. OPT_EXIT | OPT_FLAG_PERSTREAM |
  914. OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
  915. show_help_options(options, "Per-file options (input-only):",
  916. OPT_PERFILE | OPT_INPUT,
  917. OPT_EXIT | OPT_FLAG_PERSTREAM | OPT_OUTPUT | OPT_EXPERT |
  918. OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
  919. if (show_advanced)
  920. show_help_options(options, "Advanced per-file options (input-only):",
  921. OPT_PERFILE | OPT_INPUT | OPT_EXPERT,
  922. OPT_EXIT | OPT_FLAG_PERSTREAM | OPT_OUTPUT |
  923. OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
  924. show_help_options(options, "Per-file options (output-only):",
  925. OPT_PERFILE | OPT_OUTPUT,
  926. OPT_EXIT | OPT_FLAG_PERSTREAM | OPT_INPUT | OPT_EXPERT |
  927. OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
  928. if (show_advanced)
  929. show_help_options(options, "Advanced per-file options (output-only):",
  930. OPT_PERFILE | OPT_OUTPUT | OPT_EXPERT,
  931. OPT_EXIT | OPT_FLAG_PERSTREAM | OPT_INPUT |
  932. OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
  933. show_help_options(options, "Per-stream options:",
  934. OPT_FLAG_PERSTREAM,
  935. OPT_EXIT | OPT_EXPERT |
  936. OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
  937. if (show_advanced)
  938. show_help_options(options, "Advanced per-stream options:",
  939. OPT_FLAG_PERSTREAM | OPT_EXPERT,
  940. OPT_EXIT |
  941. OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
  942. show_help_options(options, "Video options:",
  943. OPT_VIDEO, OPT_EXPERT | OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
  944. if (show_advanced)
  945. show_help_options(options, "Advanced Video options:",
  946. OPT_EXPERT | OPT_VIDEO, OPT_AUDIO | OPT_SUBTITLE | OPT_DATA);
  947. show_help_options(options, "Audio options:",
  948. OPT_AUDIO, OPT_EXPERT | OPT_VIDEO | OPT_SUBTITLE | OPT_DATA);
  949. if (show_advanced)
  950. show_help_options(options, "Advanced Audio options:",
  951. OPT_EXPERT | OPT_AUDIO, OPT_VIDEO | OPT_SUBTITLE | OPT_DATA);
  952. show_help_options(options, "Subtitle options:",
  953. OPT_SUBTITLE, OPT_EXPERT | OPT_VIDEO | OPT_AUDIO | OPT_DATA);
  954. if (show_advanced)
  955. show_help_options(options, "Advanced Subtitle options:",
  956. OPT_EXPERT | OPT_SUBTITLE, OPT_VIDEO | OPT_AUDIO | OPT_DATA);
  957. if (show_advanced)
  958. show_help_options(options, "Data stream options:",
  959. OPT_DATA, OPT_VIDEO | OPT_AUDIO | OPT_SUBTITLE);
  960. printf("\n");
  961. if (show_avoptions) {
  962. int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
  963. show_help_children(avcodec_get_class(), flags);
  964. show_help_children(avformat_get_class(), flags);
  965. #if CONFIG_SWSCALE
  966. show_help_children(sws_get_class(), flags);
  967. #endif
  968. #if CONFIG_SWRESAMPLE
  969. show_help_children(swr_get_class(), AV_OPT_FLAG_AUDIO_PARAM);
  970. #endif
  971. show_help_children(avfilter_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM);
  972. show_help_children(av_bsf_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_BSF_PARAM);
  973. }
  974. }
  975. void show_usage(void)
  976. {
  977. av_log(NULL, AV_LOG_INFO, "Universal media converter\n");
  978. av_log(NULL, AV_LOG_INFO, "usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n", program_name);
  979. av_log(NULL, AV_LOG_INFO, "\n");
  980. }
  981. enum OptGroup {
  982. GROUP_OUTFILE,
  983. GROUP_INFILE,
  984. GROUP_DECODER,
  985. };
  986. static const OptionGroupDef groups[] = {
  987. [GROUP_OUTFILE] = { "output url", NULL, OPT_OUTPUT },
  988. [GROUP_INFILE] = { "input url", "i", OPT_INPUT },
  989. [GROUP_DECODER] = { "loopback decoder", "dec", OPT_DECODER },
  990. };
  991. static int open_files(OptionGroupList *l, const char *inout, Scheduler *sch,
  992. int (*open_file)(const OptionsContext*, const char*,
  993. Scheduler*))
  994. {
  995. int i, ret;
  996. for (i = 0; i < l->nb_groups; i++) {
  997. OptionGroup *g = &l->groups[i];
  998. OptionsContext o;
  999. init_options(&o);
  1000. o.g = g;
  1001. ret = parse_optgroup(&o, g, options);
  1002. if (ret < 0) {
  1003. av_log(NULL, AV_LOG_ERROR, "Error parsing options for %s file "
  1004. "%s.\n", inout, g->arg);
  1005. uninit_options(&o);
  1006. return ret;
  1007. }
  1008. av_log(NULL, AV_LOG_DEBUG, "Opening an %s file: %s.\n", inout, g->arg);
  1009. ret = open_file(&o, g->arg, sch);
  1010. uninit_options(&o);
  1011. if (ret < 0) {
  1012. av_log(NULL, AV_LOG_ERROR, "Error opening %s file %s.\n",
  1013. inout, g->arg);
  1014. return ret;
  1015. }
  1016. av_log(NULL, AV_LOG_DEBUG, "Successfully opened the file.\n");
  1017. }
  1018. return 0;
  1019. }
  1020. int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
  1021. {
  1022. OptionParseContext octx;
  1023. const char *errmsg = NULL;
  1024. int ret;
  1025. memset(&octx, 0, sizeof(octx));
  1026. /* split the commandline into an internal representation */
  1027. ret = split_commandline(&octx, argc, argv, options, groups,
  1028. FF_ARRAY_ELEMS(groups));
  1029. if (ret < 0) {
  1030. errmsg = "splitting the argument list";
  1031. goto fail;
  1032. }
  1033. /* apply global options */
  1034. ret = parse_optgroup(sch, &octx.global_opts, options);
  1035. if (ret < 0) {
  1036. errmsg = "parsing global options";
  1037. goto fail;
  1038. }
  1039. /* configure terminal and setup signal handlers */
  1040. term_init();
  1041. /* open input files */
  1042. ret = open_files(&octx.groups[GROUP_INFILE], "input", sch, ifile_open);
  1043. if (ret < 0) {
  1044. errmsg = "opening input files";
  1045. goto fail;
  1046. }
  1047. /* open output files */
  1048. ret = open_files(&octx.groups[GROUP_OUTFILE], "output", sch, of_open);
  1049. if (ret < 0) {
  1050. errmsg = "opening output files";
  1051. goto fail;
  1052. }
  1053. /* create loopback decoders */
  1054. ret = open_files(&octx.groups[GROUP_DECODER], "decoder", sch, dec_create);
  1055. if (ret < 0) {
  1056. errmsg = "creating loopback decoders";
  1057. goto fail;
  1058. }
  1059. // bind unbound filtegraph inputs/outputs and check consistency
  1060. ret = fg_finalise_bindings();
  1061. if (ret < 0) {
  1062. errmsg = "binding filtergraph inputs/outputs";
  1063. goto fail;
  1064. }
  1065. correct_input_start_times();
  1066. ret = apply_sync_offsets();
  1067. if (ret < 0)
  1068. goto fail;
  1069. fail:
  1070. uninit_parse_context(&octx);
  1071. if (ret < 0 && ret != AVERROR_EXIT) {
  1072. av_log(NULL, AV_LOG_FATAL, "Error %s: %s\n",
  1073. errmsg ? errmsg : "", av_err2str(ret));
  1074. }
  1075. return ret;
  1076. }
  1077. static int opt_progress(void *optctx, const char *opt, const char *arg)
  1078. {
  1079. AVIOContext *avio = NULL;
  1080. int ret;
  1081. if (!strcmp(arg, "-"))
  1082. arg = "pipe:";
  1083. ret = avio_open2(&avio, arg, AVIO_FLAG_WRITE, &int_cb, NULL);
  1084. if (ret < 0) {
  1085. av_log(NULL, AV_LOG_ERROR, "Failed to open progress URL \"%s\": %s\n",
  1086. arg, av_err2str(ret));
  1087. return ret;
  1088. }
  1089. progress_avio = avio;
  1090. return 0;
  1091. }
  1092. int opt_timelimit(void *optctx, const char *opt, const char *arg)
  1093. {
  1094. #if HAVE_SETRLIMIT
  1095. int ret;
  1096. double lim;
  1097. struct rlimit rl;
  1098. ret = parse_number(opt, arg, OPT_TYPE_INT64, 0, INT_MAX, &lim);
  1099. if (ret < 0)
  1100. return ret;
  1101. rl = (struct rlimit){ lim, lim + 1 };
  1102. if (setrlimit(RLIMIT_CPU, &rl))
  1103. perror("setrlimit");
  1104. #else
  1105. av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
  1106. #endif
  1107. return 0;
  1108. }
  1109. #if FFMPEG_OPT_QPHIST
  1110. static int opt_qphist(void *optctx, const char *opt, const char *arg)
  1111. {
  1112. av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
  1113. return 0;
  1114. }
  1115. #endif
  1116. #if FFMPEG_OPT_ADRIFT_THRESHOLD
  1117. static int opt_adrift_threshold(void *optctx, const char *opt, const char *arg)
  1118. {
  1119. av_log(NULL, AV_LOG_WARNING, "Option -%s is deprecated and has no effect\n", opt);
  1120. return 0;
  1121. }
  1122. #endif
  1123. static const char *const alt_bsf[] = { "absf", "vbsf", NULL };
  1124. static const char *const alt_channel_layout[] = { "ch_layout", NULL};
  1125. static const char *const alt_codec[] = { "c", "acodec", "vcodec", "scodec", "dcodec", NULL };
  1126. static const char *const alt_filter[] = { "af", "vf", NULL };
  1127. static const char *const alt_frames[] = { "aframes", "vframes", "dframes", NULL };
  1128. static const char *const alt_pre[] = { "apre", "vpre", "spre", NULL};
  1129. static const char *const alt_qscale[] = { "q", NULL};
  1130. static const char *const alt_tag[] = { "atag", "vtag", "stag", NULL };
  1131. #define OFFSET(x) offsetof(OptionsContext, x)
  1132. const OptionDef options[] = {
  1133. /* main options */
  1134. CMDUTILS_COMMON_OPTIONS
  1135. { "f", OPT_TYPE_STRING, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
  1136. { .off = OFFSET(format) },
  1137. "force container format (auto-detected otherwise)", "fmt" },
  1138. { "y", OPT_TYPE_BOOL, 0,
  1139. { &file_overwrite },
  1140. "overwrite output files" },
  1141. { "n", OPT_TYPE_BOOL, 0,
  1142. { &no_file_overwrite },
  1143. "never overwrite output files" },
  1144. { "ignore_unknown", OPT_TYPE_BOOL, OPT_EXPERT,
  1145. { &ignore_unknown_streams },
  1146. "Ignore unknown stream types" },
  1147. { "copy_unknown", OPT_TYPE_BOOL, OPT_EXPERT,
  1148. { &copy_unknown_streams },
  1149. "Copy unknown stream types" },
  1150. { "recast_media", OPT_TYPE_BOOL, OPT_EXPERT,
  1151. { &recast_media },
  1152. "allow recasting stream type in order to force a decoder of different media type" },
  1153. { "c", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT | OPT_DECODER | OPT_HAS_CANON,
  1154. { .off = OFFSET(codec_names) },
  1155. "select encoder/decoder ('copy' to copy stream without reencoding)", "codec",
  1156. .u1.name_canon = "codec", },
  1157. { "codec", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT | OPT_DECODER | OPT_EXPERT | OPT_HAS_ALT,
  1158. { .off = OFFSET(codec_names) },
  1159. "alias for -c (select encoder/decoder)", "codec",
  1160. .u1.names_alt = alt_codec, },
  1161. { "pre", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_ALT,
  1162. { .off = OFFSET(presets) },
  1163. "preset name", "preset",
  1164. .u1.names_alt = alt_pre, },
  1165. { "map", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
  1166. { .func_arg = opt_map },
  1167. "set input stream mapping",
  1168. "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
  1169. { "map_metadata", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
  1170. { .off = OFFSET(metadata_map) },
  1171. "set metadata information of outfile from infile",
  1172. "outfile[,metadata]:infile[,metadata]" },
  1173. { "map_chapters", OPT_TYPE_INT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
  1174. { .off = OFFSET(chapters_input_file) },
  1175. "set chapters mapping", "input_file_index" },
  1176. { "t", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
  1177. { .off = OFFSET(recording_time) },
  1178. "stop transcoding after specified duration",
  1179. "duration" },
  1180. { "to", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
  1181. { .off = OFFSET(stop_time) },
  1182. "stop transcoding after specified time is reached",
  1183. "time_stop" },
  1184. { "fs", OPT_TYPE_INT64, OPT_OFFSET | OPT_OUTPUT | OPT_EXPERT,
  1185. { .off = OFFSET(limit_filesize) },
  1186. "set the limit file size in bytes", "limit_size" },
  1187. { "ss", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
  1188. { .off = OFFSET(start_time) },
  1189. "start transcoding at specified time", "time_off" },
  1190. { "sseof", OPT_TYPE_TIME, OPT_OFFSET | OPT_INPUT | OPT_EXPERT,
  1191. { .off = OFFSET(start_time_eof) },
  1192. "set the start time offset relative to EOF", "time_off" },
  1193. { "seek_timestamp", OPT_TYPE_INT, OPT_OFFSET | OPT_INPUT | OPT_EXPERT,
  1194. { .off = OFFSET(seek_timestamp) },
  1195. "enable/disable seeking by timestamp with -ss" },
  1196. { "accurate_seek", OPT_TYPE_BOOL, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
  1197. { .off = OFFSET(accurate_seek) },
  1198. "enable/disable accurate seeking with -ss" },
  1199. { "isync", OPT_TYPE_INT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
  1200. { .off = OFFSET(input_sync_ref) },
  1201. "Indicate the input index for sync reference", "sync ref" },
  1202. { "itsoffset", OPT_TYPE_TIME, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
  1203. { .off = OFFSET(input_ts_offset) },
  1204. "set the input ts offset", "time_off" },
  1205. { "itsscale", OPT_TYPE_DOUBLE, OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
  1206. { .off = OFFSET(ts_scale) },
  1207. "set the input ts scale", "scale" },
  1208. { "timestamp", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
  1209. { .func_arg = opt_recording_timestamp },
  1210. "set the recording timestamp ('now' to set the current time)", "time" },
  1211. { "metadata", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT,
  1212. { .off = OFFSET(metadata) },
  1213. "add metadata", "key=value" },
  1214. { "program", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_OUTPUT,
  1215. { .off = OFFSET(program) },
  1216. "add program with specified streams", "title=string:st=number..." },
  1217. { "stream_group", OPT_TYPE_STRING, OPT_SPEC | OPT_OUTPUT | OPT_EXPERT,
  1218. { .off = OFFSET(stream_groups) },
  1219. "add stream group with specified streams and group type-specific arguments", "id=number:st=number..." },
  1220. { "dframes", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT | OPT_HAS_CANON,
  1221. { .func_arg = opt_data_frames },
  1222. "set the number of data frames to output", "number",
  1223. .u1.name_canon = "frames" },
  1224. { "benchmark", OPT_TYPE_BOOL, OPT_EXPERT,
  1225. { &do_benchmark },
  1226. "add timings for benchmarking" },
  1227. { "benchmark_all", OPT_TYPE_BOOL, OPT_EXPERT,
  1228. { &do_benchmark_all },
  1229. "add timings for each task" },
  1230. { "progress", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1231. { .func_arg = opt_progress },
  1232. "write program-readable progress information", "url" },
  1233. { "stdin", OPT_TYPE_BOOL, OPT_EXPERT,
  1234. { &stdin_interaction },
  1235. "enable or disable interaction on standard input" },
  1236. { "timelimit", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1237. { .func_arg = opt_timelimit },
  1238. "set max runtime in seconds in CPU user time", "limit" },
  1239. { "dump", OPT_TYPE_BOOL, OPT_EXPERT,
  1240. { &do_pkt_dump },
  1241. "dump each input packet" },
  1242. { "hex", OPT_TYPE_BOOL, OPT_EXPERT,
  1243. { &do_hex_dump },
  1244. "when dumping packets, also dump the payload" },
  1245. { "re", OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_INPUT,
  1246. { .off = OFFSET(rate_emu) },
  1247. "read input at native frame rate; equivalent to -readrate 1", "" },
  1248. { "readrate", OPT_TYPE_FLOAT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
  1249. { .off = OFFSET(readrate) },
  1250. "read input at specified rate", "speed" },
  1251. { "readrate_initial_burst", OPT_TYPE_DOUBLE, OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
  1252. { .off = OFFSET(readrate_initial_burst) },
  1253. "The initial amount of input to burst read before imposing any readrate", "seconds" },
  1254. { "target", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
  1255. { .func_arg = opt_target },
  1256. "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" "
  1257. "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" },
  1258. { "frame_drop_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
  1259. { &frame_drop_threshold },
  1260. "frame drop threshold", "" },
  1261. { "copyts", OPT_TYPE_BOOL, OPT_EXPERT,
  1262. { &copy_ts },
  1263. "copy timestamps" },
  1264. { "start_at_zero", OPT_TYPE_BOOL, OPT_EXPERT,
  1265. { &start_at_zero },
  1266. "shift input timestamps to start at 0 when using copyts" },
  1267. { "copytb", OPT_TYPE_INT, OPT_EXPERT,
  1268. { &copy_tb },
  1269. "copy input stream time base when stream copying", "mode" },
  1270. { "shortest", OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
  1271. { .off = OFFSET(shortest) },
  1272. "finish encoding within shortest input" },
  1273. { "shortest_buf_duration", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
  1274. { .off = OFFSET(shortest_buf_duration) },
  1275. "maximum buffering duration (in seconds) for the -shortest option" },
  1276. { "bitexact", OPT_TYPE_BOOL, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT | OPT_INPUT,
  1277. { .off = OFFSET(bitexact) },
  1278. "bitexact mode" },
  1279. { "dts_delta_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
  1280. { &dts_delta_threshold },
  1281. "timestamp discontinuity delta threshold", "threshold" },
  1282. { "dts_error_threshold", OPT_TYPE_FLOAT, OPT_EXPERT,
  1283. { &dts_error_threshold },
  1284. "timestamp error delta threshold", "threshold" },
  1285. { "xerror", OPT_TYPE_BOOL, OPT_EXPERT,
  1286. { &exit_on_error },
  1287. "exit on error", "error" },
  1288. { "abort_on", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1289. { .func_arg = opt_abort_on },
  1290. "abort on the specified condition flags", "flags" },
  1291. { "copyinkf", OPT_TYPE_BOOL, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1292. { .off = OFFSET(copy_initial_nonkeyframes) },
  1293. "copy initial non-keyframes" },
  1294. { "copypriorss", OPT_TYPE_INT, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1295. { .off = OFFSET(copy_prior_start) },
  1296. "copy or discard frames before start time" },
  1297. { "frames", OPT_TYPE_INT64, OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_ALT,
  1298. { .off = OFFSET(max_frames) },
  1299. "set the number of frames to output", "number",
  1300. .u1.names_alt = alt_frames, },
  1301. { "tag", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT | OPT_INPUT | OPT_HAS_ALT,
  1302. { .off = OFFSET(codec_tags) },
  1303. "force codec tag/fourcc", "fourcc/tag",
  1304. .u1.names_alt = alt_tag, },
  1305. { "q", OPT_TYPE_DOUBLE, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT | OPT_HAS_CANON,
  1306. { .off = OFFSET(qscale) },
  1307. "use fixed quality scale (VBR)", "q",
  1308. .u1.name_canon = "qscale", },
  1309. { "qscale", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_ALT,
  1310. { .func_arg = opt_qscale },
  1311. "use fixed quality scale (VBR)", "q",
  1312. .u1.names_alt = alt_qscale, },
  1313. { "profile", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
  1314. { .func_arg = opt_profile },
  1315. "set profile", "profile" },
  1316. { "filter", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_OUTPUT | OPT_HAS_ALT,
  1317. { .off = OFFSET(filters) },
  1318. "apply specified filters to audio/video", "filter_graph",
  1319. .u1.names_alt = alt_filter, },
  1320. { "filter_threads", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1321. { .func_arg = opt_filter_threads },
  1322. "number of non-complex filter threads" },
  1323. #if FFMPEG_OPT_FILTER_SCRIPT
  1324. { "filter_script", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
  1325. { .off = OFFSET(filter_scripts) },
  1326. "deprecated, use -/filter", "filename" },
  1327. #endif
  1328. { "reinit_filter", OPT_TYPE_INT, OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
  1329. { .off = OFFSET(reinit_filters) },
  1330. "reinit filtergraph on input parameter changes", "" },
  1331. { "filter_complex", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1332. { .func_arg = opt_filter_complex },
  1333. "create a complex filtergraph", "graph_description" },
  1334. { "filter_complex_threads", OPT_TYPE_INT, OPT_EXPERT,
  1335. { &filter_complex_nbthreads },
  1336. "number of threads for -filter_complex" },
  1337. { "lavfi", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1338. { .func_arg = opt_filter_complex },
  1339. "create a complex filtergraph", "graph_description" },
  1340. #if FFMPEG_OPT_FILTER_SCRIPT
  1341. { "filter_complex_script", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1342. { .func_arg = opt_filter_complex_script },
  1343. "deprecated, use -/filter_complex instead", "filename" },
  1344. #endif
  1345. { "auto_conversion_filters", OPT_TYPE_BOOL, OPT_EXPERT,
  1346. { &auto_conversion_filters },
  1347. "enable automatic conversion filters globally" },
  1348. { "stats", OPT_TYPE_BOOL, 0,
  1349. { &print_stats },
  1350. "print progress report during encoding", },
  1351. { "stats_period", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1352. { .func_arg = opt_stats_period },
  1353. "set the period at which ffmpeg updates stats and -progress output", "time" },
  1354. { "attach", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_PERFILE | OPT_EXPERT | OPT_OUTPUT,
  1355. { .func_arg = opt_attach },
  1356. "add an attachment to the output file", "filename" },
  1357. { "dump_attachment", OPT_TYPE_STRING, OPT_SPEC | OPT_EXPERT | OPT_INPUT,
  1358. { .off = OFFSET(dump_attachment) },
  1359. "extract an attachment into a file", "filename" },
  1360. { "stream_loop", OPT_TYPE_INT, OPT_EXPERT | OPT_INPUT | OPT_OFFSET,
  1361. { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" },
  1362. { "debug_ts", OPT_TYPE_BOOL, OPT_EXPERT,
  1363. { &debug_ts },
  1364. "print timestamp debugging info" },
  1365. { "max_error_rate", OPT_TYPE_FLOAT, OPT_EXPERT,
  1366. { &max_error_rate },
  1367. "ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.", "maximum error rate" },
  1368. { "discard", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
  1369. { .off = OFFSET(discard) },
  1370. "discard", "" },
  1371. { "disposition", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT,
  1372. { .off = OFFSET(disposition) },
  1373. "disposition", "" },
  1374. { "thread_queue_size", OPT_TYPE_INT, OPT_OFFSET | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT,
  1375. { .off = OFFSET(thread_queue_size) },
  1376. "set the maximum number of queued packets from the demuxer" },
  1377. { "find_stream_info", OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT | OPT_OFFSET,
  1378. { .off = OFFSET(find_stream_info) },
  1379. "read and decode the streams to fill missing information with heuristics" },
  1380. { "bits_per_raw_sample", OPT_TYPE_INT, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1381. { .off = OFFSET(bits_per_raw_sample) },
  1382. "set the number of bits per raw sample", "number" },
  1383. { "stats_enc_pre", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
  1384. { .off = OFFSET(enc_stats_pre) },
  1385. "write encoding stats before encoding" },
  1386. { "stats_enc_post", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
  1387. { .off = OFFSET(enc_stats_post) },
  1388. "write encoding stats after encoding" },
  1389. { "stats_mux_pre", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
  1390. { .off = OFFSET(mux_stats) },
  1391. "write packets stats before muxing" },
  1392. { "stats_enc_pre_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
  1393. { .off = OFFSET(enc_stats_pre_fmt) },
  1394. "format of the stats written with -stats_enc_pre" },
  1395. { "stats_enc_post_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
  1396. { .off = OFFSET(enc_stats_post_fmt) },
  1397. "format of the stats written with -stats_enc_post" },
  1398. { "stats_mux_pre_fmt", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
  1399. { .off = OFFSET(mux_stats_fmt) },
  1400. "format of the stats written with -stats_mux_pre" },
  1401. /* video options */
  1402. { "vframes", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_CANON,
  1403. { .func_arg = opt_video_frames },
  1404. "set the number of video frames to output", "number",
  1405. .u1.name_canon = "frames", },
  1406. { "r", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
  1407. { .off = OFFSET(frame_rates) },
  1408. "override input framerate/convert to given output framerate (Hz value, fraction or abbreviation)", "rate" },
  1409. { "fpsmax", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT,
  1410. { .off = OFFSET(max_frame_rates) },
  1411. "set max frame rate (Hz value, fraction or abbreviation)", "rate" },
  1412. { "s", OPT_TYPE_STRING, OPT_VIDEO | OPT_SUBTITLE | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
  1413. { .off = OFFSET(frame_sizes) },
  1414. "set frame size (WxH or abbreviation)", "size" },
  1415. { "aspect", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_OUTPUT,
  1416. { .off = OFFSET(frame_aspect_ratios) },
  1417. "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
  1418. { "pix_fmt", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
  1419. { .off = OFFSET(frame_pix_fmts) },
  1420. "set pixel format", "format" },
  1421. { "display_rotation", OPT_TYPE_DOUBLE, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
  1422. { .off = OFFSET(display_rotations) },
  1423. "set pure counter-clockwise rotation in degrees for stream(s)",
  1424. "angle" },
  1425. { "display_hflip", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
  1426. { .off = OFFSET(display_hflips) },
  1427. "set display horizontal flip for stream(s) "
  1428. "(overrides any display rotation if it is not set)"},
  1429. { "display_vflip", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
  1430. { .off = OFFSET(display_vflips) },
  1431. "set display vertical flip for stream(s) "
  1432. "(overrides any display rotation if it is not set)"},
  1433. { "vn", OPT_TYPE_BOOL, OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
  1434. { .off = OFFSET(video_disable) },
  1435. "disable video" },
  1436. { "rc_override", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1437. { .off = OFFSET(rc_overrides) },
  1438. "rate control override for specific intervals", "override" },
  1439. { "vcodec", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
  1440. { .func_arg = opt_video_codec },
  1441. "alias for -c:v (select encoder/decoder for video streams)", "codec",
  1442. .u1.name_canon = "codec", },
  1443. { "timecode", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_EXPERT,
  1444. { .func_arg = opt_timecode },
  1445. "set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
  1446. { "pass", OPT_TYPE_INT, OPT_VIDEO | OPT_PERSTREAM | OPT_OUTPUT | OPT_EXPERT,
  1447. { .off = OFFSET(pass) },
  1448. "select the pass number (1 to 3)", "n" },
  1449. { "passlogfile", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1450. { .off = OFFSET(passlogfiles) },
  1451. "select two pass log file name prefix", "prefix" },
  1452. { "vstats", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
  1453. { .func_arg = opt_vstats },
  1454. "dump video coding statistics to file" },
  1455. { "vstats_file", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT,
  1456. { .func_arg = opt_vstats_file },
  1457. "dump video coding statistics to file", "file" },
  1458. { "vstats_version", OPT_TYPE_INT, OPT_VIDEO | OPT_EXPERT,
  1459. { &vstats_version },
  1460. "Version of the vstats format to use."},
  1461. { "vf", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
  1462. { .func_arg = opt_video_filters },
  1463. "alias for -filter:v (apply filters to video streams)", "filter_graph",
  1464. .u1.name_canon = "filter", },
  1465. { "intra_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1466. { .off = OFFSET(intra_matrices) },
  1467. "specify intra matrix coeffs", "matrix" },
  1468. { "inter_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1469. { .off = OFFSET(inter_matrices) },
  1470. "specify inter matrix coeffs", "matrix" },
  1471. { "chroma_intra_matrix", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1472. { .off = OFFSET(chroma_intra_matrices) },
  1473. "specify intra matrix coeffs", "matrix" },
  1474. { "vtag", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
  1475. { .func_arg = opt_old2new },
  1476. "force video tag/fourcc", "fourcc/tag",
  1477. .u1.name_canon = "tag", },
  1478. { "fps_mode", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1479. { .off = OFFSET(fps_mode) },
  1480. "set framerate mode for matching video streams; overrides vsync" },
  1481. { "force_fps", OPT_TYPE_BOOL, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1482. { .off = OFFSET(force_fps) },
  1483. "force the selected framerate, disable the best supported framerate selection" },
  1484. { "streamid", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT,
  1485. { .func_arg = opt_streamid },
  1486. "set the value of an outfile streamid", "streamIndex:value" },
  1487. { "force_key_frames", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1488. { .off = OFFSET(forced_key_frames) },
  1489. "force key frames at specified timestamps", "timestamps" },
  1490. { "b", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
  1491. { .func_arg = opt_bitrate },
  1492. "video bitrate (please use -b:v)", "bitrate" },
  1493. { "hwaccel", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT,
  1494. { .off = OFFSET(hwaccels) },
  1495. "use HW accelerated decoding", "hwaccel name" },
  1496. { "hwaccel_device", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT,
  1497. { .off = OFFSET(hwaccel_devices) },
  1498. "select a device for HW acceleration", "devicename" },
  1499. { "hwaccel_output_format", OPT_TYPE_STRING, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT,
  1500. { .off = OFFSET(hwaccel_output_formats) },
  1501. "select output format used with HW accelerated decoding", "format" },
  1502. { "hwaccels", OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT,
  1503. { .func_arg = show_hwaccels },
  1504. "show available HW acceleration methods" },
  1505. { "autorotate", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
  1506. { .off = OFFSET(autorotate) },
  1507. "automatically insert correct rotate filters" },
  1508. { "autoscale", OPT_TYPE_BOOL, OPT_VIDEO | OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
  1509. { .off = OFFSET(autoscale) },
  1510. "automatically insert a scale filter at the end of the filter graph" },
  1511. { "apply_cropping", OPT_TYPE_STRING, OPT_VIDEO | OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
  1512. { .off = OFFSET(apply_cropping) },
  1513. "select the cropping to apply" },
  1514. { "fix_sub_duration_heartbeat", OPT_TYPE_BOOL, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1515. { .off = OFFSET(fix_sub_duration_heartbeat) },
  1516. "set this video output stream to be a heartbeat stream for "
  1517. "fix_sub_duration, according to which subtitles should be split at "
  1518. "random access points" },
  1519. /* audio options */
  1520. { "aframes", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_EXPERT | OPT_HAS_CANON,
  1521. { .func_arg = opt_audio_frames },
  1522. "set the number of audio frames to output", "number",
  1523. .u1.name_canon = "frames", },
  1524. { "aq", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
  1525. { .func_arg = opt_audio_qscale },
  1526. "set audio quality (codec-specific)", "quality", },
  1527. { "ar", OPT_TYPE_INT, OPT_AUDIO | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
  1528. { .off = OFFSET(audio_sample_rate) },
  1529. "set audio sampling rate (in Hz)", "rate" },
  1530. { "ac", OPT_TYPE_INT, OPT_AUDIO | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
  1531. { .off = OFFSET(audio_channels) },
  1532. "set number of audio channels", "channels" },
  1533. { "an", OPT_TYPE_BOOL, OPT_AUDIO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
  1534. { .off = OFFSET(audio_disable) },
  1535. "disable audio" },
  1536. { "acodec", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
  1537. { .func_arg = opt_audio_codec },
  1538. "alias for -c:a (select encoder/decoder for audio streams)", "codec",
  1539. .u1.name_canon = "codec", },
  1540. { "ab", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT,
  1541. { .func_arg = opt_bitrate },
  1542. "alias for -b:a (select bitrate for audio streams)", "bitrate" },
  1543. { "apad", OPT_TYPE_STRING, OPT_AUDIO | OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
  1544. { .off = OFFSET(apad) },
  1545. "audio pad", "" },
  1546. { "atag", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
  1547. { .func_arg = opt_old2new },
  1548. "force audio tag/fourcc", "fourcc/tag",
  1549. .u1.name_canon = "tag", },
  1550. { "sample_fmt", OPT_TYPE_STRING, OPT_AUDIO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
  1551. { .off = OFFSET(sample_fmts) },
  1552. "set sample format", "format" },
  1553. { "channel_layout", OPT_TYPE_STRING, OPT_AUDIO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT | OPT_HAS_ALT,
  1554. { .off = OFFSET(audio_ch_layouts) },
  1555. "set channel layout", "layout",
  1556. .u1.names_alt = alt_channel_layout, },
  1557. { "ch_layout", OPT_TYPE_STRING, OPT_AUDIO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
  1558. { .off = OFFSET(audio_ch_layouts) },
  1559. "set channel layout", "layout",
  1560. .u1.name_canon = "channel_layout", },
  1561. { "af", OPT_TYPE_FUNC, OPT_AUDIO | OPT_FUNC_ARG | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
  1562. { .func_arg = opt_audio_filters },
  1563. "alias for -filter:a (apply filters to audio streams)", "filter_graph",
  1564. .u1.name_canon = "filter", },
  1565. { "guess_layout_max", OPT_TYPE_INT, OPT_AUDIO | OPT_PERSTREAM | OPT_EXPERT | OPT_INPUT,
  1566. { .off = OFFSET(guess_layout_max) },
  1567. "set the maximum number of channels to try to guess the channel layout" },
  1568. /* subtitle options */
  1569. { "sn", OPT_TYPE_BOOL, OPT_SUBTITLE | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
  1570. { .off = OFFSET(subtitle_disable) },
  1571. "disable subtitle" },
  1572. { "scodec", OPT_TYPE_FUNC, OPT_SUBTITLE | OPT_FUNC_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
  1573. { .func_arg = opt_subtitle_codec },
  1574. "alias for -c:s (select encoder/decoder for subtitle streams)", "codec",
  1575. .u1.name_canon = "codec", },
  1576. { "stag", OPT_TYPE_FUNC, OPT_SUBTITLE | OPT_FUNC_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
  1577. { .func_arg = opt_old2new }
  1578. , "force subtitle tag/fourcc", "fourcc/tag",
  1579. .u1.name_canon = "tag" },
  1580. { "fix_sub_duration", OPT_TYPE_BOOL, OPT_EXPERT | OPT_SUBTITLE | OPT_PERSTREAM | OPT_INPUT,
  1581. { .off = OFFSET(fix_sub_duration) },
  1582. "fix subtitles duration" },
  1583. { "canvas_size", OPT_TYPE_STRING, OPT_SUBTITLE | OPT_PERSTREAM | OPT_INPUT | OPT_EXPERT,
  1584. { .off = OFFSET(canvas_sizes) },
  1585. "set canvas size (WxH or abbreviation)", "size" },
  1586. /* muxer options */
  1587. { "muxdelay", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
  1588. { .off = OFFSET(mux_max_delay) },
  1589. "set the maximum demux-decode delay", "seconds" },
  1590. { "muxpreload", OPT_TYPE_FLOAT, OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT,
  1591. { .off = OFFSET(mux_preload) },
  1592. "set the initial demux-decode delay", "seconds" },
  1593. { "sdp_file", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT | OPT_OUTPUT,
  1594. { .func_arg = opt_sdp_file },
  1595. "specify a file in which to print sdp information", "file" },
  1596. { "time_base", OPT_TYPE_STRING, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1597. { .off = OFFSET(time_bases) },
  1598. "set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)", "ratio" },
  1599. { "enc_time_base", OPT_TYPE_STRING, OPT_EXPERT | OPT_PERSTREAM | OPT_OUTPUT,
  1600. { .off = OFFSET(enc_time_bases) },
  1601. "set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). "
  1602. "two special values are defined - "
  1603. "0 = use frame rate (video) or sample rate (audio),"
  1604. "-1 = match source time base", "ratio" },
  1605. { "bsf", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT | OPT_INPUT,
  1606. { .off = OFFSET(bitstream_filters) },
  1607. "A comma-separated list of bitstream filters", "bitstream_filters", },
  1608. { "apre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
  1609. { .func_arg = opt_preset },
  1610. "set the audio options to the indicated preset", "preset",
  1611. .u1.name_canon = "pre", },
  1612. { "vpre", OPT_TYPE_FUNC, OPT_VIDEO | OPT_FUNC_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
  1613. { .func_arg = opt_preset },
  1614. "set the video options to the indicated preset", "preset",
  1615. .u1.name_canon = "pre", },
  1616. { "spre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_SUBTITLE | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
  1617. { .func_arg = opt_preset },
  1618. "set the subtitle options to the indicated preset", "preset",
  1619. .u1.name_canon = "pre", },
  1620. { "fpre", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT | OPT_HAS_CANON,
  1621. { .func_arg = opt_preset },
  1622. "set options from indicated preset file", "filename",
  1623. .u1.name_canon = "pre", },
  1624. { "max_muxing_queue_size", OPT_TYPE_INT, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
  1625. { .off = OFFSET(max_muxing_queue_size) },
  1626. "maximum number of packets that can be buffered while waiting for all streams to initialize", "packets" },
  1627. { "muxing_queue_data_threshold", OPT_TYPE_INT, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT,
  1628. { .off = OFFSET(muxing_queue_data_threshold) },
  1629. "set the threshold after which max_muxing_queue_size is taken into account", "bytes" },
  1630. /* data codec support */
  1631. { "dcodec", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT | OPT_HAS_CANON,
  1632. { .func_arg = opt_data_codec },
  1633. "alias for -c:d (select encoder/decoder for data streams)", "codec",
  1634. .u1.name_canon = "codec", },
  1635. { "dn", OPT_TYPE_BOOL, OPT_DATA | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,
  1636. { .off = OFFSET(data_disable) }, "disable data" },
  1637. #if CONFIG_VAAPI
  1638. { "vaapi_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1639. { .func_arg = opt_vaapi_device },
  1640. "set VAAPI hardware device (DirectX adapter index, DRM path or X11 display name)", "device" },
  1641. #endif
  1642. #if CONFIG_QSV
  1643. { "qsv_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1644. { .func_arg = opt_qsv_device },
  1645. "set QSV hardware device (DirectX adapter index, DRM path or X11 display name)", "device"},
  1646. #endif
  1647. { "init_hw_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1648. { .func_arg = opt_init_hw_device },
  1649. "initialise hardware device", "args" },
  1650. { "filter_hw_device", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1651. { .func_arg = opt_filter_hw_device },
  1652. "set hardware device used when filtering", "device" },
  1653. // deprecated options
  1654. #if FFMPEG_OPT_ADRIFT_THRESHOLD
  1655. { "adrift_threshold", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1656. { .func_arg = opt_adrift_threshold },
  1657. "deprecated, does nothing", "threshold" },
  1658. #endif
  1659. #if FFMPEG_OPT_TOP
  1660. { "top", OPT_TYPE_INT, OPT_VIDEO | OPT_EXPERT | OPT_PERSTREAM | OPT_INPUT | OPT_OUTPUT,
  1661. { .off = OFFSET(top_field_first) },
  1662. "deprecated, use the setfield video filter", "" },
  1663. #endif
  1664. #if FFMPEG_OPT_QPHIST
  1665. { "qphist", OPT_TYPE_FUNC, OPT_VIDEO | OPT_EXPERT,
  1666. { .func_arg = opt_qphist },
  1667. "deprecated, does nothing" },
  1668. #endif
  1669. #if FFMPEG_OPT_VSYNC
  1670. { "vsync", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT,
  1671. { .func_arg = opt_vsync },
  1672. "set video sync method globally; deprecated, use -fps_mode", "" },
  1673. #endif
  1674. { NULL, },
  1675. };