bitstream_filters.texi 26 KB

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