bitstream_filters.texi 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. @chapter Bitstream Filters
  2. @c man begin BITSTREAM FILTERS
  3. When you configure your FFmpeg build, all the supported bitstream
  4. filters are enabled by default. You can list all available ones using
  5. the configure option @code{--list-bsfs}.
  6. You can disable all the bitstream filters using the configure option
  7. @code{--disable-bsfs}, and selectively enable any bitstream filter using
  8. the option @code{--enable-bsf=BSF}, or you can disable a particular
  9. bitstream filter using the option @code{--disable-bsf=BSF}.
  10. The option @code{-bsfs} of the ff* tools will display the list of
  11. all the supported bitstream filters included in your build.
  12. The ff* tools have a -bsf option applied per stream, taking a
  13. comma-separated list of filters, whose parameters follow the filter
  14. name after a '='.
  15. @example
  16. ffmpeg -i INPUT -c:v copy -bsf:v filter1[=opt1=str1:opt2=str2][,filter2] OUTPUT
  17. @end example
  18. Below is a description of the currently available bitstream filters,
  19. with their parameters, if any.
  20. @section aac_adtstoasc
  21. Convert MPEG-2/4 AAC ADTS to an MPEG-4 Audio Specific Configuration
  22. bitstream.
  23. This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
  24. ADTS header and removes the ADTS header.
  25. This filter is required for example when copying an AAC stream from a
  26. raw ADTS AAC or an MPEG-TS container to MP4A-LATM, to an FLV file, or
  27. to MOV/MP4 files and related formats such as 3GP or M4A. Please note
  28. that it is auto-inserted for MP4A-LATM and MOV/MP4 and related formats.
  29. @section av1_metadata
  30. Modify metadata embedded in an AV1 stream.
  31. @table @option
  32. @item td
  33. Insert or remove temporal delimiter OBUs in all temporal units of the
  34. stream.
  35. @table @samp
  36. @item insert
  37. Insert a TD at the beginning of every TU which does not already have one.
  38. @item remove
  39. Remove the TD from the beginning of every TU which has one.
  40. @end table
  41. @item color_primaries
  42. @item transfer_characteristics
  43. @item matrix_coefficients
  44. Set the color description fields in the stream (see AV1 section 6.4.2).
  45. @item color_range
  46. Set the color range in the stream (see AV1 section 6.4.2; note that
  47. this cannot be set for streams using BT.709 primaries, sRGB transfer
  48. characteristic and identity (RGB) matrix coefficients).
  49. @table @samp
  50. @item tv
  51. Limited range.
  52. @item pc
  53. Full range.
  54. @end table
  55. @item chroma_sample_position
  56. Set the chroma sample location in the stream (see AV1 section 6.4.2).
  57. This can only be set for 4:2:0 streams.
  58. @table @samp
  59. @item vertical
  60. Left position (matching the default in MPEG-2 and H.264).
  61. @item colocated
  62. Top-left position.
  63. @end table
  64. @item tick_rate
  65. Set the tick rate (@emph{time_scale / num_units_in_display_tick}) in
  66. the timing info in the sequence header.
  67. @item num_ticks_per_picture
  68. Set the number of ticks in each picture, to indicate that the stream
  69. has a fixed framerate. Ignored if @option{tick_rate} is not also set.
  70. @item delete_padding
  71. Deletes Padding OBUs.
  72. @end table
  73. @section chomp
  74. Remove zero padding at the end of a packet.
  75. @section dca_core
  76. Extract the core from a DCA/DTS stream, dropping extensions such as
  77. DTS-HD.
  78. @section dovi_rpu
  79. Manipulate Dolby Vision metadata in a HEVC/AV1 bitstream, optionally enabling
  80. metadata compression.
  81. @table @option
  82. @item strip
  83. If enabled, strip all Dolby Vision metadata (configuration record + RPU data
  84. blocks) from the stream.
  85. @item compression
  86. Which compression level to enable.
  87. @table @samp
  88. @item none
  89. No metadata compression.
  90. @item limited
  91. Limited metadata compression scheme. Should be compatible with most devices.
  92. This is the default.
  93. @item extended
  94. Extended metadata compression. Devices are not required to support this. Note
  95. that this level currently behaves the same as @samp{limited} in libavcodec.
  96. @end table
  97. @end table
  98. @section dump_extra
  99. Add extradata to the beginning of the filtered packets except when
  100. said packets already exactly begin with the extradata that is intended
  101. to be added.
  102. @table @option
  103. @item freq
  104. The additional argument specifies which packets should be filtered.
  105. It accepts the values:
  106. @table @samp
  107. @item k
  108. @item keyframe
  109. add extradata to all key packets
  110. @item e
  111. @item all
  112. add extradata to all packets
  113. @end table
  114. @end table
  115. If not specified it is assumed @samp{k}.
  116. For example the following @command{ffmpeg} command forces a global
  117. header (thus disabling individual packet headers) in the H.264 packets
  118. generated by the @code{libx264} encoder, but corrects them by adding
  119. the header stored in extradata to the key packets:
  120. @example
  121. ffmpeg -i INPUT -map 0 -flags:v +global_header -c:v libx264 -bsf:v dump_extra out.ts
  122. @end example
  123. @section dv_error_marker
  124. Blocks in DV which are marked as damaged are replaced by blocks of the specified color.
  125. @table @option
  126. @item color
  127. The color to replace damaged blocks by
  128. @item sta
  129. A 16 bit mask which specifies which of the 16 possible error status values are
  130. to be replaced by colored blocks. 0xFFFE is the default which replaces all non 0
  131. error status values.
  132. @table @samp
  133. @item ok
  134. No error, no concealment
  135. @item err
  136. Error, No concealment
  137. @item res
  138. Reserved
  139. @item notok
  140. Error or concealment
  141. @item notres
  142. Not reserved
  143. @item Aa, Ba, Ca, Ab, Bb, Cb, A, B, C, a, b, erri, erru
  144. The specific error status code
  145. @end table
  146. see page 44-46 or section 5.5 of
  147. @url{http://web.archive.org/web/20060927044735/http://www.smpte.org/smpte_store/standards/pdf/s314m.pdf}
  148. @end table
  149. @section eac3_core
  150. Extract the core from a E-AC-3 stream, dropping extra channels.
  151. @section extract_extradata
  152. Extract the in-band extradata.
  153. Certain codecs allow the long-term headers (e.g. MPEG-2 sequence headers,
  154. or H.264/HEVC (VPS/)SPS/PPS) to be transmitted either "in-band" (i.e. as a part
  155. of the bitstream containing the coded frames) or "out of band" (e.g. on the
  156. container level). This latter form is called "extradata" in FFmpeg terminology.
  157. This bitstream filter detects the in-band headers and makes them available as
  158. extradata.
  159. @table @option
  160. @item remove
  161. When this option is enabled, the long-term headers are removed from the
  162. bitstream after extraction.
  163. @end table
  164. @section filter_units
  165. Remove units with types in or not in a given set from the stream.
  166. @table @option
  167. @item pass_types
  168. List of unit types or ranges of unit types to pass through while removing
  169. all others. This is specified as a '|'-separated list of unit type values
  170. or ranges of values with '-'.
  171. @item remove_types
  172. Identical to @option{pass_types}, except the units in the given set
  173. removed and all others passed through.
  174. @end table
  175. The types used by pass_types and remove_types correspond to NAL unit types
  176. (nal_unit_type) in H.264, HEVC and H.266 (see Table 7-1 in the H.264
  177. and HEVC specifications or Table 5 in the H.266 specification), to
  178. marker values for JPEG (without 0xFF prefix) and to start codes without
  179. start code prefix (i.e. the byte following the 0x000001) for MPEG-2.
  180. For VP8 and VP9, every unit has type zero.
  181. Extradata is unchanged by this transformation, but note that if the stream
  182. contains inline parameter sets then the output may be unusable if they are
  183. removed.
  184. For example, to remove all non-VCL NAL units from an H.264 stream:
  185. @example
  186. ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=pass_types=1-5' OUTPUT
  187. @end example
  188. To remove all AUDs, SEI and filler from an H.265 stream:
  189. @example
  190. ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=35|38-40' OUTPUT
  191. @end example
  192. To remove all user data from a MPEG-2 stream, including Closed Captions:
  193. @example
  194. ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=178' OUTPUT
  195. @end example
  196. To remove all SEI from a H264 stream, including Closed Captions:
  197. @example
  198. ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=6' OUTPUT
  199. @end example
  200. To remove all prefix and suffix SEI from a HEVC stream, including Closed Captions and dynamic HDR:
  201. @example
  202. ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=39|40' OUTPUT
  203. @end example
  204. @section hapqa_extract
  205. Extract Rgb or Alpha part of an HAPQA file, without recompression, in order to create an HAPQ or an HAPAlphaOnly file.
  206. @table @option
  207. @item texture
  208. Specifies the texture to keep.
  209. @table @option
  210. @item color
  211. @item alpha
  212. @end table
  213. @end table
  214. Convert HAPQA to HAPQ
  215. @example
  216. ffmpeg -i hapqa_inputfile.mov -c copy -bsf:v hapqa_extract=texture=color -tag:v HapY -metadata:s:v:0 encoder="HAPQ" hapq_file.mov
  217. @end example
  218. Convert HAPQA to HAPAlphaOnly
  219. @example
  220. ffmpeg -i hapqa_inputfile.mov -c copy -bsf:v hapqa_extract=texture=alpha -tag:v HapA -metadata:s:v:0 encoder="HAPAlpha Only" hapalphaonly_file.mov
  221. @end example
  222. @section h264_metadata
  223. Modify metadata embedded in an H.264 stream.
  224. @table @option
  225. @item aud
  226. Insert or remove AUD NAL units in all access units of the stream.
  227. @table @samp
  228. @item pass
  229. @item insert
  230. @item remove
  231. @end table
  232. Default is pass.
  233. @item sample_aspect_ratio
  234. Set the sample aspect ratio of the stream in the VUI parameters.
  235. See H.264 table E-1.
  236. @item overscan_appropriate_flag
  237. Set whether the stream is suitable for display using overscan
  238. or not (see H.264 section E.2.1).
  239. @item video_format
  240. @item video_full_range_flag
  241. Set the video format in the stream (see H.264 section E.2.1 and
  242. table E-2).
  243. @item colour_primaries
  244. @item transfer_characteristics
  245. @item matrix_coefficients
  246. Set the colour description in the stream (see H.264 section E.2.1
  247. and tables E-3, E-4 and E-5).
  248. @item chroma_sample_loc_type
  249. Set the chroma sample location in the stream (see H.264 section
  250. E.2.1 and figure E-1).
  251. @item tick_rate
  252. Set the tick rate (time_scale / num_units_in_tick) in the VUI
  253. parameters. This is the smallest time unit representable in the
  254. stream, and in many cases represents the field rate of the stream
  255. (double the frame rate).
  256. @item fixed_frame_rate_flag
  257. Set whether the stream has fixed framerate - typically this indicates
  258. that the framerate is exactly half the tick rate, but the exact
  259. meaning is dependent on interlacing and the picture structure (see
  260. H.264 section E.2.1 and table E-6).
  261. @item zero_new_constraint_set_flags
  262. Zero constraint_set4_flag and constraint_set5_flag in the SPS. These
  263. bits were reserved in a previous version of the H.264 spec, and thus
  264. some hardware decoders require these to be zero. The result of zeroing
  265. this is still a valid bitstream.
  266. @item crop_left
  267. @item crop_right
  268. @item crop_top
  269. @item crop_bottom
  270. Set the frame cropping offsets in the SPS. These values will replace
  271. the current ones if the stream is already cropped.
  272. These fields are set in pixels. Note that some sizes may not be
  273. representable if the chroma is subsampled or the stream is interlaced
  274. (see H.264 section 7.4.2.1.1).
  275. @item sei_user_data
  276. Insert a string as SEI unregistered user data. The argument must
  277. be of the form @emph{UUID+string}, where the UUID is as hex digits
  278. possibly separated by hyphens, and the string can be anything.
  279. For example, @samp{086f3693-b7b3-4f2c-9653-21492feee5b8+hello} will
  280. insert the string ``hello'' associated with the given UUID.
  281. @item delete_filler
  282. Deletes both filler NAL units and filler SEI messages.
  283. @item display_orientation
  284. Insert, extract or remove Display orientation SEI messages.
  285. See H.264 section D.1.27 and D.2.27 for syntax and semantics.
  286. @table @samp
  287. @item pass
  288. @item insert
  289. @item remove
  290. @item extract
  291. @end table
  292. Default is pass.
  293. Insert mode works in conjunction with @code{rotate} and @code{flip} options.
  294. Any pre-existing Display orientation messages will be removed in insert or remove mode.
  295. Extract mode attaches the display matrix to the packet as side data.
  296. @item rotate
  297. Set rotation in display orientation SEI (anticlockwise angle in degrees).
  298. Range is -360 to +360. Default is NaN.
  299. @item flip
  300. Set flip in display orientation SEI.
  301. @table @samp
  302. @item horizontal
  303. @item vertical
  304. @end table
  305. Default is unset.
  306. @item level
  307. Set the level in the SPS. Refer to H.264 section A.3 and tables A-1
  308. to A-5.
  309. The argument must be the name of a level (for example, @samp{4.2}), a
  310. level_idc value (for example, @samp{42}), or the special name @samp{auto}
  311. indicating that the filter should attempt to guess the level from the
  312. input stream properties.
  313. @end table
  314. @section h264_mp4toannexb
  315. Convert an H.264 bitstream from length prefixed mode to start code
  316. prefixed mode (as defined in the Annex B of the ITU-T H.264
  317. specification).
  318. This is required by some streaming formats, typically the MPEG-2
  319. transport stream format (muxer @code{mpegts}).
  320. For example to remux an MP4 file containing an H.264 stream to mpegts
  321. format with @command{ffmpeg}, you can use the command:
  322. @example
  323. ffmpeg -i INPUT.mp4 -codec copy -bsf:v h264_mp4toannexb OUTPUT.ts
  324. @end example
  325. Please note that this filter is auto-inserted for MPEG-TS (muxer
  326. @code{mpegts}) and raw H.264 (muxer @code{h264}) output formats.
  327. @section h264_redundant_pps
  328. This applies a specific fixup to some Blu-ray streams which contain
  329. redundant PPSs modifying irrelevant parameters of the stream which
  330. confuse other transformations which require correct extradata.
  331. @section hevc_metadata
  332. Modify metadata embedded in an HEVC stream.
  333. @table @option
  334. @item aud
  335. Insert or remove AUD NAL units in all access units of the stream.
  336. @table @samp
  337. @item insert
  338. @item remove
  339. @end table
  340. @item sample_aspect_ratio
  341. Set the sample aspect ratio in the stream in the VUI parameters.
  342. @item video_format
  343. @item video_full_range_flag
  344. Set the video format in the stream (see H.265 section E.3.1 and
  345. table E.2).
  346. @item colour_primaries
  347. @item transfer_characteristics
  348. @item matrix_coefficients
  349. Set the colour description in the stream (see H.265 section E.3.1
  350. and tables E.3, E.4 and E.5).
  351. @item chroma_sample_loc_type
  352. Set the chroma sample location in the stream (see H.265 section
  353. E.3.1 and figure E.1).
  354. @item tick_rate
  355. Set the tick rate in the VPS and VUI parameters (time_scale /
  356. num_units_in_tick). Combined with @option{num_ticks_poc_diff_one}, this can
  357. set a constant framerate in the stream. Note that it is likely to be
  358. overridden by container parameters when the stream is in a container.
  359. @item num_ticks_poc_diff_one
  360. Set poc_proportional_to_timing_flag in VPS and VUI and use this value
  361. to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
  362. E.3.1). Ignored if @option{tick_rate} is not also set.
  363. @item crop_left
  364. @item crop_right
  365. @item crop_top
  366. @item crop_bottom
  367. Set the conformance window cropping offsets in the SPS. These values
  368. will replace the current ones if the stream is already cropped.
  369. These fields are set in pixels. Note that some sizes may not be
  370. representable if the chroma is subsampled (H.265 section 7.4.3.2.1).
  371. @item width
  372. @item height
  373. Set width and height after crop.
  374. @item level
  375. Set the level in the VPS and SPS. See H.265 section A.4 and tables
  376. A.6 and A.7.
  377. The argument must be the name of a level (for example, @samp{5.1}), a
  378. @emph{general_level_idc} value (for example, @samp{153} for level 5.1),
  379. or the special name @samp{auto} indicating that the filter should
  380. attempt to guess the level from the input stream properties.
  381. @end table
  382. @section hevc_mp4toannexb
  383. Convert an HEVC/H.265 bitstream from length prefixed mode to start code
  384. prefixed mode (as defined in the Annex B of the ITU-T H.265
  385. specification).
  386. This is required by some streaming formats, typically the MPEG-2
  387. transport stream format (muxer @code{mpegts}).
  388. For example to remux an MP4 file containing an HEVC stream to mpegts
  389. format with @command{ffmpeg}, you can use the command:
  390. @example
  391. ffmpeg -i INPUT.mp4 -codec copy -bsf:v hevc_mp4toannexb OUTPUT.ts
  392. @end example
  393. Please note that this filter is auto-inserted for MPEG-TS (muxer
  394. @code{mpegts}) and raw HEVC/H.265 (muxer @code{h265} or
  395. @code{hevc}) output formats.
  396. @section imxdump
  397. Modifies the bitstream to fit in MOV and to be usable by the Final Cut
  398. Pro decoder. This filter only applies to the mpeg2video codec, and is
  399. likely not needed for Final Cut Pro 7 and newer with the appropriate
  400. @option{-tag:v}.
  401. For example, to remux 30 MB/sec NTSC IMX to MOV:
  402. @example
  403. ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
  404. @end example
  405. @section mjpeg2jpeg
  406. Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
  407. MJPEG is a video codec wherein each video frame is essentially a
  408. JPEG image. The individual frames can be extracted without loss,
  409. e.g. by
  410. @example
  411. ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
  412. @end example
  413. Unfortunately, these chunks are incomplete JPEG images, because
  414. they lack the DHT segment required for decoding. Quoting from
  415. @url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
  416. Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
  417. commented that "MJPEG, or at least the MJPEG in AVIs having the
  418. MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
  419. Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
  420. and it must use basic Huffman encoding, not arithmetic or
  421. progressive. . . . You can indeed extract the MJPEG frames and
  422. decode them with a regular JPEG decoder, but you have to prepend
  423. the DHT segment to them, or else the decoder won't have any idea
  424. how to decompress the data. The exact table necessary is given in
  425. the OpenDML spec."
  426. This bitstream filter patches the header of frames extracted from an MJPEG
  427. stream (carrying the AVI1 header ID and lacking a DHT segment) to
  428. produce fully qualified JPEG images.
  429. @example
  430. ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
  431. exiftran -i -9 frame*.jpg
  432. ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
  433. @end example
  434. @section mjpegadump
  435. Add an MJPEG A header to the bitstream, to enable decoding by
  436. Quicktime.
  437. @anchor{mov2textsub}
  438. @section mov2textsub
  439. Extract a representable text file from MOV subtitles, stripping the
  440. metadata header from each subtitle packet.
  441. See also the @ref{text2movsub} filter.
  442. @section mpeg2_metadata
  443. Modify metadata embedded in an MPEG-2 stream.
  444. @table @option
  445. @item display_aspect_ratio
  446. Set the display aspect ratio in the stream.
  447. The following fixed values are supported:
  448. @table @option
  449. @item 4/3
  450. @item 16/9
  451. @item 221/100
  452. @end table
  453. Any other value will result in square pixels being signalled instead
  454. (see H.262 section 6.3.3 and table 6-3).
  455. @item frame_rate
  456. Set the frame rate in the stream. This is constructed from a table
  457. of known values combined with a small multiplier and divisor - if
  458. the supplied value is not exactly representable, the nearest
  459. representable value will be used instead (see H.262 section 6.3.3
  460. and table 6-4).
  461. @item video_format
  462. Set the video format in the stream (see H.262 section 6.3.6 and
  463. table 6-6).
  464. @item colour_primaries
  465. @item transfer_characteristics
  466. @item matrix_coefficients
  467. Set the colour description in the stream (see H.262 section 6.3.6
  468. and tables 6-7, 6-8 and 6-9).
  469. @end table
  470. @section mpeg4_unpack_bframes
  471. Unpack DivX-style packed B-frames.
  472. DivX-style packed B-frames are not valid MPEG-4 and were only a
  473. workaround for the broken Video for Windows subsystem.
  474. They use more space, can cause minor AV sync issues, require more
  475. CPU power to decode (unless the player has some decoded picture queue
  476. to compensate the 2,0,2,0 frame per packet style) and cause
  477. trouble if copied into a standard container like mp4 or mpeg-ps/ts,
  478. because MPEG-4 decoders may not be able to decode them, since they are
  479. not valid MPEG-4.
  480. For example to fix an AVI file containing an MPEG-4 stream with
  481. DivX-style packed B-frames using @command{ffmpeg}, you can use the command:
  482. @example
  483. ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
  484. @end example
  485. @section noise
  486. Damages the contents of packets or simply drops them without damaging the
  487. container. Can be used for fuzzing or testing error resilience/concealment.
  488. Parameters:
  489. @table @option
  490. @item amount
  491. Accepts an expression whose evaluation per-packet determines how often bytes in that
  492. packet will be modified. A value below 0 will result in a variable frequency.
  493. Default is 0 which results in no modification. However, if neither amount nor drop is specified,
  494. amount will be set to @var{-1}. See below for accepted variables.
  495. @item drop
  496. Accepts an expression evaluated per-packet whose value determines whether that packet is dropped.
  497. Evaluation to a positive value results in the packet being dropped. Evaluation to a negative
  498. value results in a variable chance of it being dropped, roughly inverse in proportion to the magnitude
  499. of the value. Default is 0 which results in no drops. See below for accepted variables.
  500. @item dropamount
  501. Accepts a non-negative integer, which assigns a variable chance of it being dropped, roughly inverse
  502. in proportion to the value. Default is 0 which results in no drops. This option is kept for backwards
  503. compatibility and is equivalent to setting drop to a negative value with the same magnitude
  504. i.e. @code{dropamount=4} is the same as @code{drop=-4}. Ignored if drop is also specified.
  505. @end table
  506. Both @code{amount} and @code{drop} accept expressions containing the following variables:
  507. @table @samp
  508. @item n
  509. The index of the packet, starting from zero.
  510. @item tb
  511. The timebase for packet timestamps.
  512. @item pts
  513. Packet presentation timestamp.
  514. @item dts
  515. Packet decoding timestamp.
  516. @item nopts
  517. Constant representing AV_NOPTS_VALUE.
  518. @item startpts
  519. First non-AV_NOPTS_VALUE PTS seen in the stream.
  520. @item startdts
  521. First non-AV_NOPTS_VALUE DTS seen in the stream.
  522. @item duration
  523. @itemx d
  524. Packet duration, in timebase units.
  525. @item pos
  526. Packet position in input; may be -1 when unknown or not set.
  527. @item size
  528. Packet size, in bytes.
  529. @item key
  530. Whether packet is marked as a keyframe.
  531. @item state
  532. A pseudo random integer, primarily derived from the content of packet payload.
  533. @end table
  534. @subsection Examples
  535. Apply modification to every byte but don't drop any packets.
  536. @example
  537. ffmpeg -i INPUT -c copy -bsf noise=1 output.mkv
  538. @end example
  539. Drop every video packet not marked as a keyframe after timestamp 30s but do not
  540. modify any of the remaining packets.
  541. @example
  542. ffmpeg -i INPUT -c copy -bsf:v noise=drop='gt(t\,30)*not(key)' output.mkv
  543. @end example
  544. Drop one second of audio every 10 seconds and add some random noise to the rest.
  545. @example
  546. ffmpeg -i INPUT -c copy -bsf:a noise=amount=-1:drop='between(mod(t\,10)\,9\,10)' output.mkv
  547. @end example
  548. @section null
  549. This bitstream filter passes the packets through unchanged.
  550. @section pcm_rechunk
  551. Repacketize PCM audio to a fixed number of samples per packet or a fixed packet
  552. rate per second. This is similar to the @ref{asetnsamples,,asetnsamples audio
  553. filter,ffmpeg-filters} but works on audio packets instead of audio frames.
  554. @table @option
  555. @item nb_out_samples, n
  556. Set the number of samples per each output audio packet. The number is intended
  557. as the number of samples @emph{per each channel}. Default value is 1024.
  558. @item pad, p
  559. If set to 1, the filter will pad the last audio packet with silence, so that it
  560. will contain the same number of samples (or roughly the same number of samples,
  561. see @option{frame_rate}) as the previous ones. Default value is 1.
  562. @item frame_rate, r
  563. This option makes the filter output a fixed number of packets per second instead
  564. of a fixed number of samples per packet. If the audio sample rate is not
  565. divisible by the frame rate then the number of samples will not be constant but
  566. will vary slightly so that each packet will start as close to the frame
  567. boundary as possible. Using this option has precedence over @option{nb_out_samples}.
  568. @end table
  569. You can generate the well known 1602-1601-1602-1601-1602 pattern of 48kHz audio
  570. for NTSC frame rate using the @option{frame_rate} option.
  571. @example
  572. ffmpeg -f lavfi -i sine=r=48000:d=1 -c pcm_s16le -bsf pcm_rechunk=r=30000/1001 -f framecrc -
  573. @end example
  574. @section pgs_frame_merge
  575. Merge a sequence of PGS Subtitle segments ending with an "end of display set"
  576. segment into a single packet.
  577. This is required by some containers that support PGS subtitles
  578. (muxer @code{matroska}).
  579. @section prores_metadata
  580. Modify color property metadata embedded in prores stream.
  581. @table @option
  582. @item color_primaries
  583. Set the color primaries.
  584. Available values are:
  585. @table @samp
  586. @item auto
  587. Keep the same color primaries property (default).
  588. @item unknown
  589. @item bt709
  590. @item bt470bg
  591. BT601 625
  592. @item smpte170m
  593. BT601 525
  594. @item bt2020
  595. @item smpte431
  596. DCI P3
  597. @item smpte432
  598. P3 D65
  599. @end table
  600. @item transfer_characteristics
  601. Set the color transfer.
  602. Available values are:
  603. @table @samp
  604. @item auto
  605. Keep the same transfer characteristics property (default).
  606. @item unknown
  607. @item bt709
  608. BT 601, BT 709, BT 2020
  609. @item smpte2084
  610. SMPTE ST 2084
  611. @item arib-std-b67
  612. ARIB STD-B67
  613. @end table
  614. @item matrix_coefficients
  615. Set the matrix coefficient.
  616. Available values are:
  617. @table @samp
  618. @item auto
  619. Keep the same colorspace property (default).
  620. @item unknown
  621. @item bt709
  622. @item smpte170m
  623. BT 601
  624. @item bt2020nc
  625. @end table
  626. @end table
  627. Set Rec709 colorspace for each frame of the file
  628. @example
  629. ffmpeg -i INPUT -c copy -bsf:v prores_metadata=color_primaries=bt709:color_trc=bt709:colorspace=bt709 output.mov
  630. @end example
  631. Set Hybrid Log-Gamma parameters for each frame of the file
  632. @example
  633. ffmpeg -i INPUT -c copy -bsf:v prores_metadata=color_primaries=bt2020:color_trc=arib-std-b67:colorspace=bt2020nc output.mov
  634. @end example
  635. @section remove_extra
  636. Remove extradata from packets.
  637. It accepts the following parameter:
  638. @table @option
  639. @item freq
  640. Set which frame types to remove extradata from.
  641. @table @samp
  642. @item k
  643. Remove extradata from non-keyframes only.
  644. @item keyframe
  645. Remove extradata from keyframes only.
  646. @item e, all
  647. Remove extradata from all frames.
  648. @end table
  649. @end table
  650. @section setts
  651. Set PTS and DTS in packets.
  652. It accepts the following parameters:
  653. @table @option
  654. @item ts
  655. @item pts
  656. @item dts
  657. Set expressions for PTS, DTS or both.
  658. @item duration
  659. Set expression for duration.
  660. @item time_base
  661. Set output time base.
  662. @end table
  663. The expressions are evaluated through the eval API and can contain the following
  664. constants:
  665. @table @option
  666. @item N
  667. The count of the input packet. Starting from 0.
  668. @item TS
  669. The demux timestamp in input in case of @code{ts} or @code{dts} option or presentation
  670. timestamp in case of @code{pts} option.
  671. @item POS
  672. The original position in the file of the packet, or undefined if undefined
  673. for the current packet
  674. @item DTS
  675. The demux timestamp in input.
  676. @item PTS
  677. The presentation timestamp in input.
  678. @item DURATION
  679. The duration in input.
  680. @item STARTDTS
  681. The DTS of the first packet.
  682. @item STARTPTS
  683. The PTS of the first packet.
  684. @item PREV_INDTS
  685. The previous input DTS.
  686. @item PREV_INPTS
  687. The previous input PTS.
  688. @item PREV_INDURATION
  689. The previous input duration.
  690. @item PREV_OUTDTS
  691. The previous output DTS.
  692. @item PREV_OUTPTS
  693. The previous output PTS.
  694. @item PREV_OUTDURATION
  695. The previous output duration.
  696. @item NEXT_DTS
  697. The next input DTS.
  698. @item NEXT_PTS
  699. The next input PTS.
  700. @item NEXT_DURATION
  701. The next input duration.
  702. @item TB
  703. The timebase of stream packet belongs.
  704. @item TB_OUT
  705. The output timebase.
  706. @item SR
  707. The sample rate of stream packet belongs.
  708. @item NOPTS
  709. The AV_NOPTS_VALUE constant.
  710. @end table
  711. For example, to set PTS equal to DTS (not recommended if B-frames are involved):
  712. @example
  713. ffmpeg -i INPUT -c:a copy -bsf:a setts=pts=DTS out.mkv
  714. @end example
  715. @section showinfo
  716. Log basic packet information. Mainly useful for testing, debugging,
  717. and development.
  718. @anchor{text2movsub}
  719. @section text2movsub
  720. Convert text subtitles to MOV subtitles (as used by the @code{mov_text}
  721. codec) with metadata headers.
  722. See also the @ref{mov2textsub} filter.
  723. @section trace_headers
  724. Log trace output containing all syntax elements in the coded stream
  725. headers (everything above the level of individual coded blocks).
  726. This can be useful for debugging low-level stream issues.
  727. Supports AV1, H.264, H.265, (M)JPEG, MPEG-2 and VP9, but depending
  728. on the build only a subset of these may be available.
  729. @section truehd_core
  730. Extract the core from a TrueHD stream, dropping ATMOS data.
  731. @section vp9_metadata
  732. Modify metadata embedded in a VP9 stream.
  733. @table @option
  734. @item color_space
  735. Set the color space value in the frame header. Note that any frame
  736. set to RGB will be implicitly set to PC range and that RGB is
  737. incompatible with profiles 0 and 2.
  738. @table @samp
  739. @item unknown
  740. @item bt601
  741. @item bt709
  742. @item smpte170
  743. @item smpte240
  744. @item bt2020
  745. @item rgb
  746. @end table
  747. @item color_range
  748. Set the color range value in the frame header. Note that any value
  749. imposed by the color space will take precedence over this value.
  750. @table @samp
  751. @item tv
  752. @item pc
  753. @end table
  754. @end table
  755. @section vp9_superframe
  756. Merge VP9 invisible (alt-ref) frames back into VP9 superframes. This
  757. fixes merging of split/segmented VP9 streams where the alt-ref frame
  758. was split from its visible counterpart.
  759. @section vp9_superframe_split
  760. Split VP9 superframes into single frames.
  761. @section vp9_raw_reorder
  762. Given a VP9 stream with correct timestamps but possibly out of order,
  763. insert additional show-existing-frame packets to correct the ordering.
  764. @c man end BITSTREAM FILTERS