bitstream_filters.texi 27 KB

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