ffmpeg_opt.c 76 KB

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