bitstream_filters.texi 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  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. @section hevc_metadata
  294. Modify metadata embedded in an HEVC stream.
  295. @table @option
  296. @item aud
  297. Insert or remove AUD NAL units in all access units of the stream.
  298. @table @samp
  299. @item insert
  300. @item remove
  301. @end table
  302. @item sample_aspect_ratio
  303. Set the sample aspect ratio in the stream in the VUI parameters.
  304. @item video_format
  305. @item video_full_range_flag
  306. Set the video format in the stream (see H.265 section E.3.1 and
  307. table E.2).
  308. @item colour_primaries
  309. @item transfer_characteristics
  310. @item matrix_coefficients
  311. Set the colour description in the stream (see H.265 section E.3.1
  312. and tables E.3, E.4 and E.5).
  313. @item chroma_sample_loc_type
  314. Set the chroma sample location in the stream (see H.265 section
  315. E.3.1 and figure E.1).
  316. @item tick_rate
  317. Set the tick rate in the VPS and VUI parameters (time_scale /
  318. num_units_in_tick). Combined with @option{num_ticks_poc_diff_one}, this can
  319. set a constant framerate in the stream. Note that it is likely to be
  320. overridden by container parameters when the stream is in a container.
  321. @item num_ticks_poc_diff_one
  322. Set poc_proportional_to_timing_flag in VPS and VUI and use this value
  323. to set num_ticks_poc_diff_one_minus1 (see H.265 sections 7.4.3.1 and
  324. E.3.1). Ignored if @option{tick_rate} is not also set.
  325. @item crop_left
  326. @item crop_right
  327. @item crop_top
  328. @item crop_bottom
  329. Set the conformance window cropping offsets in the SPS. These values
  330. will replace the current ones if the stream is already cropped.
  331. These fields are set in pixels. Note that some sizes may not be
  332. representable if the chroma is subsampled (H.265 section 7.4.3.2.1).
  333. @item level
  334. Set the level in the VPS and SPS. See H.265 section A.4 and tables
  335. A.6 and A.7.
  336. The argument must be the name of a level (for example, @samp{5.1}), a
  337. @emph{general_level_idc} value (for example, @samp{153} for level 5.1),
  338. or the special name @samp{auto} indicating that the filter should
  339. attempt to guess the level from the input stream properties.
  340. @end table
  341. @section hevc_mp4toannexb
  342. Convert an HEVC/H.265 bitstream from length prefixed mode to start code
  343. prefixed mode (as defined in the Annex B of the ITU-T H.265
  344. specification).
  345. This is required by some streaming formats, typically the MPEG-2
  346. transport stream format (muxer @code{mpegts}).
  347. For example to remux an MP4 file containing an HEVC stream to mpegts
  348. format with @command{ffmpeg}, you can use the command:
  349. @example
  350. ffmpeg -i INPUT.mp4 -codec copy -bsf:v hevc_mp4toannexb OUTPUT.ts
  351. @end example
  352. Please note that this filter is auto-inserted for MPEG-TS (muxer
  353. @code{mpegts}) and raw HEVC/H.265 (muxer @code{h265} or
  354. @code{hevc}) output formats.
  355. @section imxdump
  356. Modifies the bitstream to fit in MOV and to be usable by the Final Cut
  357. Pro decoder. This filter only applies to the mpeg2video codec, and is
  358. likely not needed for Final Cut Pro 7 and newer with the appropriate
  359. @option{-tag:v}.
  360. For example, to remux 30 MB/sec NTSC IMX to MOV:
  361. @example
  362. ffmpeg -i input.mxf -c copy -bsf:v imxdump -tag:v mx3n output.mov
  363. @end example
  364. @section mjpeg2jpeg
  365. Convert MJPEG/AVI1 packets to full JPEG/JFIF packets.
  366. MJPEG is a video codec wherein each video frame is essentially a
  367. JPEG image. The individual frames can be extracted without loss,
  368. e.g. by
  369. @example
  370. ffmpeg -i ../some_mjpeg.avi -c:v copy frames_%d.jpg
  371. @end example
  372. Unfortunately, these chunks are incomplete JPEG images, because
  373. they lack the DHT segment required for decoding. Quoting from
  374. @url{http://www.digitalpreservation.gov/formats/fdd/fdd000063.shtml}:
  375. Avery Lee, writing in the rec.video.desktop newsgroup in 2001,
  376. commented that "MJPEG, or at least the MJPEG in AVIs having the
  377. MJPG fourcc, is restricted JPEG with a fixed -- and *omitted* --
  378. Huffman table. The JPEG must be YCbCr colorspace, it must be 4:2:2,
  379. and it must use basic Huffman encoding, not arithmetic or
  380. progressive. . . . You can indeed extract the MJPEG frames and
  381. decode them with a regular JPEG decoder, but you have to prepend
  382. the DHT segment to them, or else the decoder won't have any idea
  383. how to decompress the data. The exact table necessary is given in
  384. the OpenDML spec."
  385. This bitstream filter patches the header of frames extracted from an MJPEG
  386. stream (carrying the AVI1 header ID and lacking a DHT segment) to
  387. produce fully qualified JPEG images.
  388. @example
  389. ffmpeg -i mjpeg-movie.avi -c:v copy -bsf:v mjpeg2jpeg frame_%d.jpg
  390. exiftran -i -9 frame*.jpg
  391. ffmpeg -i frame_%d.jpg -c:v copy rotated.avi
  392. @end example
  393. @section mjpegadump
  394. Add an MJPEG A header to the bitstream, to enable decoding by
  395. Quicktime.
  396. @anchor{mov2textsub}
  397. @section mov2textsub
  398. Extract a representable text file from MOV subtitles, stripping the
  399. metadata header from each subtitle packet.
  400. See also the @ref{text2movsub} filter.
  401. @section mp3decomp
  402. Decompress non-standard compressed MP3 audio headers.
  403. @section mpeg2_metadata
  404. Modify metadata embedded in an MPEG-2 stream.
  405. @table @option
  406. @item display_aspect_ratio
  407. Set the display aspect ratio in the stream.
  408. The following fixed values are supported:
  409. @table @option
  410. @item 4/3
  411. @item 16/9
  412. @item 221/100
  413. @end table
  414. Any other value will result in square pixels being signalled instead
  415. (see H.262 section 6.3.3 and table 6-3).
  416. @item frame_rate
  417. Set the frame rate in the stream. This is constructed from a table
  418. of known values combined with a small multiplier and divisor - if
  419. the supplied value is not exactly representable, the nearest
  420. representable value will be used instead (see H.262 section 6.3.3
  421. and table 6-4).
  422. @item video_format
  423. Set the video format in the stream (see H.262 section 6.3.6 and
  424. table 6-6).
  425. @item colour_primaries
  426. @item transfer_characteristics
  427. @item matrix_coefficients
  428. Set the colour description in the stream (see H.262 section 6.3.6
  429. and tables 6-7, 6-8 and 6-9).
  430. @end table
  431. @section mpeg4_unpack_bframes
  432. Unpack DivX-style packed B-frames.
  433. DivX-style packed B-frames are not valid MPEG-4 and were only a
  434. workaround for the broken Video for Windows subsystem.
  435. They use more space, can cause minor AV sync issues, require more
  436. CPU power to decode (unless the player has some decoded picture queue
  437. to compensate the 2,0,2,0 frame per packet style) and cause
  438. trouble if copied into a standard container like mp4 or mpeg-ps/ts,
  439. because MPEG-4 decoders may not be able to decode them, since they are
  440. not valid MPEG-4.
  441. For example to fix an AVI file containing an MPEG-4 stream with
  442. DivX-style packed B-frames using @command{ffmpeg}, you can use the command:
  443. @example
  444. ffmpeg -i INPUT.avi -codec copy -bsf:v mpeg4_unpack_bframes OUTPUT.avi
  445. @end example
  446. @section noise
  447. Damages the contents of packets or simply drops them without damaging the
  448. container. Can be used for fuzzing or testing error resilience/concealment.
  449. Parameters:
  450. @table @option
  451. @item amount
  452. Accepts an expression whose evaluation per-packet determines how often bytes in that
  453. packet will be modified. A value below 0 will result in a variable frequency.
  454. Default is 0 which results in no modification. However, if neither amount nor drop is specified,
  455. amount will be set to @var{-1}. See below for accepted variables.
  456. @item drop
  457. Accepts an expression evaluated per-packet whose value determines whether that packet is dropped.
  458. Evaluation to a positive value results in the packet being dropped. Evaluation to a negative
  459. value results in a variable chance of it being dropped, roughly inverse in proportion to the magnitude
  460. of the value. Default is 0 which results in no drops. See below for accepted variables.
  461. @item dropamount
  462. Accepts a non-negative integer, which assigns a variable chance of it being dropped, roughly inverse
  463. in proportion to the value. Default is 0 which results in no drops. This option is kept for backwards
  464. compatibility and is equivalent to setting drop to a negative value with the same magnitude
  465. i.e. @code{dropamount=4} is the same as @code{drop=-4}. Ignored if drop is also specified.
  466. @end table
  467. Both @code{amount} and @code{drop} accept expressions containing the following variables:
  468. @table @samp
  469. @item n
  470. The index of the packet, starting from zero.
  471. @item tb
  472. The timebase for packet timestamps.
  473. @item pts
  474. Packet presentation timestamp.
  475. @item dts
  476. Packet decoding timestamp.
  477. @item nopts
  478. Constant representing AV_NOPTS_VALUE.
  479. @item startpts
  480. First non-AV_NOPTS_VALUE PTS seen in the stream.
  481. @item startdts
  482. First non-AV_NOPTS_VALUE DTS seen in the stream.
  483. @item duration
  484. @itemx d
  485. Packet duration, in timebase units.
  486. @item pos
  487. Packet position in input; may be -1 when unknown or not set.
  488. @item size
  489. Packet size, in bytes.
  490. @item key
  491. Whether packet is marked as a keyframe.
  492. @item state
  493. A pseudo random integer, primarily derived from the content of packet payload.
  494. @end table
  495. @subsection Examples
  496. Apply modification to every byte but don't drop any packets.
  497. @example
  498. ffmpeg -i INPUT -c copy -bsf noise=1 output.mkv
  499. @end example
  500. Drop every video packet not marked as a keyframe after timestamp 30s but do not
  501. modify any of the remaining packets.
  502. @example
  503. ffmpeg -i INPUT -c copy -bsf:v noise=drop='gt(t\,30)*not(key)' output.mkv
  504. @end example
  505. Drop one second of audio every 10 seconds and add some random noise to the rest.
  506. @example
  507. ffmpeg -i INPUT -c copy -bsf:a noise=amount=-1:drop='between(mod(t\,10)\,9\,10)' output.mkv
  508. @end example
  509. @section null
  510. This bitstream filter passes the packets through unchanged.
  511. @section pcm_rechunk
  512. Repacketize PCM audio to a fixed number of samples per packet or a fixed packet
  513. rate per second. This is similar to the @ref{asetnsamples,,asetnsamples audio
  514. filter,ffmpeg-filters} but works on audio packets instead of audio frames.
  515. @table @option
  516. @item nb_out_samples, n
  517. Set the number of samples per each output audio packet. The number is intended
  518. as the number of samples @emph{per each channel}. Default value is 1024.
  519. @item pad, p
  520. If set to 1, the filter will pad the last audio packet with silence, so that it
  521. will contain the same number of samples (or roughly the same number of samples,
  522. see @option{frame_rate}) as the previous ones. Default value is 1.
  523. @item frame_rate, r
  524. This option makes the filter output a fixed number of packets per second instead
  525. of a fixed number of samples per packet. If the audio sample rate is not
  526. divisible by the frame rate then the number of samples will not be constant but
  527. will vary slightly so that each packet will start as close to the frame
  528. boundary as possible. Using this option has precedence over @option{nb_out_samples}.
  529. @end table
  530. You can generate the well known 1602-1601-1602-1601-1602 pattern of 48kHz audio
  531. for NTSC frame rate using the @option{frame_rate} option.
  532. @example
  533. ffmpeg -f lavfi -i sine=r=48000:d=1 -c pcm_s16le -bsf pcm_rechunk=r=30000/1001 -f framecrc -
  534. @end example
  535. @section pgs_frame_merge
  536. Merge a sequence of PGS Subtitle segments ending with an "end of display set"
  537. segment into a single packet.
  538. This is required by some containers that support PGS subtitles
  539. (muxer @code{matroska}).
  540. @section prores_metadata
  541. Modify color property metadata embedded in prores stream.
  542. @table @option
  543. @item color_primaries
  544. Set the color primaries.
  545. Available values are:
  546. @table @samp
  547. @item auto
  548. Keep the same color primaries property (default).
  549. @item unknown
  550. @item bt709
  551. @item bt470bg
  552. BT601 625
  553. @item smpte170m
  554. BT601 525
  555. @item bt2020
  556. @item smpte431
  557. DCI P3
  558. @item smpte432
  559. P3 D65
  560. @end table
  561. @item transfer_characteristics
  562. Set the color transfer.
  563. Available values are:
  564. @table @samp
  565. @item auto
  566. Keep the same transfer characteristics property (default).
  567. @item unknown
  568. @item bt709
  569. BT 601, BT 709, BT 2020
  570. @item smpte2084
  571. SMPTE ST 2084
  572. @item arib-std-b67
  573. ARIB STD-B67
  574. @end table
  575. @item matrix_coefficients
  576. Set the matrix coefficient.
  577. Available values are:
  578. @table @samp
  579. @item auto
  580. Keep the same colorspace property (default).
  581. @item unknown
  582. @item bt709
  583. @item smpte170m
  584. BT 601
  585. @item bt2020nc
  586. @end table
  587. @end table
  588. Set Rec709 colorspace for each frame of the file
  589. @example
  590. ffmpeg -i INPUT -c copy -bsf:v prores_metadata=color_primaries=bt709:color_trc=bt709:colorspace=bt709 output.mov
  591. @end example
  592. Set Hybrid Log-Gamma parameters for each frame of the file
  593. @example
  594. ffmpeg -i INPUT -c copy -bsf:v prores_metadata=color_primaries=bt2020:color_trc=arib-std-b67:colorspace=bt2020nc output.mov
  595. @end example
  596. @section remove_extra
  597. Remove extradata from packets.
  598. It accepts the following parameter:
  599. @table @option
  600. @item freq
  601. Set which frame types to remove extradata from.
  602. @table @samp
  603. @item k
  604. Remove extradata from non-keyframes only.
  605. @item keyframe
  606. Remove extradata from keyframes only.
  607. @item e, all
  608. Remove extradata from all frames.
  609. @end table
  610. @end table
  611. @section setts
  612. Set PTS and DTS in packets.
  613. It accepts the following parameters:
  614. @table @option
  615. @item ts
  616. @item pts
  617. @item dts
  618. Set expressions for PTS, DTS or both.
  619. @item duration
  620. Set expression for duration.
  621. @item time_base
  622. Set output time base.
  623. @end table
  624. The expressions are evaluated through the eval API and can contain the following
  625. constants:
  626. @table @option
  627. @item N
  628. The count of the input packet. Starting from 0.
  629. @item TS
  630. The demux timestamp in input in case of @code{ts} or @code{dts} option or presentation
  631. timestamp in case of @code{pts} option.
  632. @item POS
  633. The original position in the file of the packet, or undefined if undefined
  634. for the current packet
  635. @item DTS
  636. The demux timestamp in input.
  637. @item PTS
  638. The presentation timestamp in input.
  639. @item DURATION
  640. The duration in input.
  641. @item STARTDTS
  642. The DTS of the first packet.
  643. @item STARTPTS
  644. The PTS of the first packet.
  645. @item PREV_INDTS
  646. The previous input DTS.
  647. @item PREV_INPTS
  648. The previous input PTS.
  649. @item PREV_INDURATION
  650. The previous input duration.
  651. @item PREV_OUTDTS
  652. The previous output DTS.
  653. @item PREV_OUTPTS
  654. The previous output PTS.
  655. @item PREV_OUTDURATION
  656. The previous output duration.
  657. @item NEXT_DTS
  658. The next input DTS.
  659. @item NEXT_PTS
  660. The next input PTS.
  661. @item NEXT_DURATION
  662. The next input duration.
  663. @item TB
  664. The timebase of stream packet belongs.
  665. @item TB_OUT
  666. The output timebase.
  667. @item SR
  668. The sample rate of stream packet belongs.
  669. @item NOPTS
  670. The AV_NOPTS_VALUE constant.
  671. @end table
  672. @anchor{text2movsub}
  673. @section text2movsub
  674. Convert text subtitles to MOV subtitles (as used by the @code{mov_text}
  675. codec) with metadata headers.
  676. See also the @ref{mov2textsub} filter.
  677. @section trace_headers
  678. Log trace output containing all syntax elements in the coded stream
  679. headers (everything above the level of individual coded blocks).
  680. This can be useful for debugging low-level stream issues.
  681. Supports AV1, H.264, H.265, (M)JPEG, MPEG-2 and VP9, but depending
  682. on the build only a subset of these may be available.
  683. @section truehd_core
  684. Extract the core from a TrueHD stream, dropping ATMOS data.
  685. @section vp9_metadata
  686. Modify metadata embedded in a VP9 stream.
  687. @table @option
  688. @item color_space
  689. Set the color space value in the frame header. Note that any frame
  690. set to RGB will be implicitly set to PC range and that RGB is
  691. incompatible with profiles 0 and 2.
  692. @table @samp
  693. @item unknown
  694. @item bt601
  695. @item bt709
  696. @item smpte170
  697. @item smpte240
  698. @item bt2020
  699. @item rgb
  700. @end table
  701. @item color_range
  702. Set the color range value in the frame header. Note that any value
  703. imposed by the color space will take precedence over this value.
  704. @table @samp
  705. @item tv
  706. @item pc
  707. @end table
  708. @end table
  709. @section vp9_superframe
  710. Merge VP9 invisible (alt-ref) frames back into VP9 superframes. This
  711. fixes merging of split/segmented VP9 streams where the alt-ref frame
  712. was split from its visible counterpart.
  713. @section vp9_superframe_split
  714. Split VP9 superframes into single frames.
  715. @section vp9_raw_reorder
  716. Given a VP9 stream with correct timestamps but possibly out of order,
  717. insert additional show-existing-frame packets to correct the ordering.
  718. @c man end BITSTREAM FILTERS