diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..a900528e --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.pnm -diff -text diff --git a/.gitignore b/.gitignore index b1e99046..f38884a2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ android/armv6/share android/armv7/share lib*/*.a *.o +*.o.* *.d *.def *.dll @@ -19,6 +20,8 @@ lib*/*.a *-example *-test *_g +\#* +.\#* *_converted.c *_preprocessed.c build.log @@ -29,15 +32,19 @@ build.log /ffprobe /ffserver /config.* -/version.h +/coverage.info +/avversion.h conflog.txt /doc/*.1 /doc/*.3 /doc/*.html /doc/*.pod -/doc/*.texi +/doc/config.texi /doc/avoptions_codec.texi /doc/avoptions_format.texi +/doc/doxy/html/ +/doc/examples/avio_dir_cmd +/doc/examples/avio_reading /doc/examples/decoding_encoding /doc/examples/demuxing /doc/examples/filtering_audio @@ -48,14 +55,16 @@ conflog.txt /doc/examples/resampling_audio /doc/examples/scaling_video /doc/fate.txt -/doc/doxy/html/ /doc/print_options /libavcodec/*_tablegen /libavcodec/*_tables.c /libavcodec/*_tables.h /libavutil/avconfig.h +/libavutil/ffversion.h +/src /tests/audiogen /tests/base64 +/tests/checkasm/checkasm /tests/data/ /tests/rotozoom /tests/tiny_psnr @@ -75,4 +84,3 @@ conflog.txt /tools/qt-faststart /tools/trasher /tools/seek_print -libavutil/ffversion.h diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..e541ee16 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +language: c +sudo: false +os: + - linux + - osx +addons: + apt: + packages: + - yasm + - diffutils +compiler: + - clang + - gcc +cache: + directories: + - ffmpeg-samples +before_install: + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update --all; fi +install: + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install yasm; fi +script: + - mkdir -p ffmpeg-samples + - ./configure --samples=ffmpeg-samples --cc=$CC + - make -j 8 + - make fate-rsync + - make check -j 8 diff --git a/Changelog b/Changelog index 68ce3f7a..248f8b50 100644 --- a/Changelog +++ b/Changelog @@ -1,94 +1,179 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. -version : - -version 2.7.2: -- imc: use correct position for flcoeffs2 calculation -- hevc: check slice address length -- snow: remove an obsolete av_assert2 -- webp: fix infinite loop in webp_decode_frame -- wavpack: limit extra_bits to 32 and use get_bits_long -- ffmpeg: only count got_output/errors in decode_error_stat -- ffmpeg: exit_on_error if decoding a packet failed -- pthread_frame: forward error codes when flushing -- huffyuvdec: validate image size -- wavpack: use get_bits_long to read up to 32 bits -- nutdec: check maxpos in read_sm_data before returning success -- s302m: fix arithmetic exception -- vc1dec: use get_bits_long and limit the read bits to 32 -- mpegaudiodec: copy AVFloatDSPContext from first context to all contexts -- avcodec/vp8: Check buffer size in vp8_decode_frame_header() -- avcodec/vp8: Fix null pointer dereference in ff_vp8_decode_free() -- avcodec/diracdec: Check for hpel_base allocation failure -- avcodec/rv34: Clear pointers in ff_rv34_decode_init_thread_copy() -- avfilter/af_aresample: Check ff_all_* for allocation failures -- avcodec/pthread_frame: clear priv_data, avoid stale pointer in error case -- swscale/utils: Clear pix buffers -- avutil/fifo: Fix the case where func() returns less bytes than requested in av_fifo_generic_write() -- ffmpeg: Fix cleanup after failed allocation of output_files -- avformat/mov: Fix deallocation when MOVStreamContext failed to allocate -- ffmpeg: Fix crash with ost->last_frame allocation failure -- ffmpeg: Fix cleanup with ost = NULL -- avcodec/pthread_frame: check avctx on deallocation -- avcodec/sanm: Reset sizes in destroy_buffers() -- avcodec/alac: Clear pointers in allocate_buffers() -- bytestream2: set the reader to the end when reading more than available -- avcodec/utils: use a minimum 32pixel width in avcodec_align_dimensions2() for H.264 -- avcodec/mpegvideo: Clear pointers in ff_mpv_common_init() -- oggparsedirac: check return value of init_get_bits -- wmalosslessdec: reset frame->nb_samples on packet loss -- wmalosslessdec: avoid reading 0 bits with get_bits -- Put a space between string literals and macros. -- avcodec/rawenc: Use ff_alloc_packet() instead of ff_alloc_packet2() -- avcodec/aacsbr: check that the element type matches before applying SBR -- avcodec/h264_slice: Use w/h from the AVFrame instead of mb_w/h -- vp9/update_prob: prevent out of bounds table read -- avfilter/vf_transpose: Fix rounding error -- avcodec/h264_refs: discard mismatching references -- avcodec/mjpegdec: Fix small picture upscale -- avcodec/pngdec: Check values before updating context in decode_fctl_chunk() -- avcodec/pngdec: Copy IHDR & plte state from last thread -- avcodec/pngdec: Require a IHDR chunk before fctl -- avcodec/pngdec: Only allow one IHDR chunk -- wmavoice: limit wmavoice_decode_packet return value to packet size -- swscale/swscale_unscaled: Fix rounding difference with RGBA output between little and big endian -- ffmpeg: Do not use the data/size of a bitstream filter after failure -- swscale/x86/rgb2rgb_template: fix signedness of v in shuffle_bytes_2103_{mmx,mmxext} -- vda: unlock the pixel buffer base address. -- swscale/rgb2rgb_template: Fix signedness of v in shuffle_bytes_2103_c() -- swscale/rgb2rgb_template: Implement shuffle_bytes_0321_c and fix shuffle_bytes_2103_c on BE -- swscale/rgb2rgb_template: Disable shuffle_bytes_2103_c on big endian -- swr: Remember previously set int_sample_format from user -- swresample: soxr implementation for swr_get_out_samples() -- avformat/swfdec: Do not error out on pixel format changes -- ffmpeg_opt: Fix forcing fourccs -- configure: Check for x265_api_get -- swscale/x86/rgb2rgb_template: don't call emms on sse2/avx functions -- swscale/x86/rgb2rgb_template: add missing xmm clobbers -- library.mak: Workaround SDL redefining main and breaking fate tests on mingw -- vaapi_h264: fix RefPicList[] field flags. - -version 2.7.1: + +version 3.0.2: +- avcodec/ttaenc: Reallocate packet if its too small +- configure: build fix for P5600 with mips code restructuring +- mips: add support for R6 +- pgssubdec: fix subpicture output colorspace and range +- avcodec/ac3dec: Reset SPX when switching from EAC3 to AC3 +- avfilter/vf_drawtext: Check return code of load_glyph() +- avformat/mux: Check that deinit is set before calling it +- avcodec/takdec: add code that got somehow lost in process of REing +- avcodec/apedec: fix decoding of stereo files with one channel full of silence +- avcodec/avpacket: Fix off by 5 error +- avcodec/h264: Fix for H.264 configuration parsing +- avcodec/bmp_parser: Ensure remaining_size is not too small in startcode packet crossing corner case +- avcodec/pngdec: Fix alpha detection with skip_frame +- Changelog: Make formating consistent +- avfilter/src_movie: fix how we check for overflows with seek_point +- avcodec/j2kenc: Add attribution to OpenJPEG project: + + +version 3.0.1: +- avcodec/libutvideodec: copy frame so it has reference counters when refcounted_frames is set +- avformat/rtpdec_jpeg: fix low contrast image on low quality setting +- avformat/mpegtsenc: Fix used service +- avformat/mpegtsenc: Keep track of the program for each service +- avformat/file: Add crypto to default whitelist +- avcodec/mjpegenc_common: Store approximate aspect if exact cannot be stored +- lavc/hevc: Allow arbitrary garbage in bytestream as long as at least one NAL unit is found. +- avcodec/resample: Remove disabled and faulty code +- indeo2: Fix banding artefacts +- indeo2data: K&R formatting cosmetics +- avformat/hlsenc: Fix passing options, regression since bc9a5965c815cf7fd998d8ce14a18b8e861dd9ce +- avutil/random_seed: Add the runtime in cycles of the main loop to the entropy pool +- avutil/channel_layout: AV_CH_LAYOUT_6POINT1_BACK not reachable in parsing +- avformat/concatdec: set safe mode to enabled instead of auto +- avformat/utils: fix dts from pts code in compute_pkt_fields() during ascending delay +- avformat/rtpenc: Fix integer overflow in NTP_TO_RTP_FORMAT +- avcodec/dca: clear X96 channels if nothing was decoded +- fate/aac: Increase fuzz from of fate-aac-pns-encode from 72 to 74 for Loongson +- avformat/cache: Fix memleak of tree entries +- lavf/mov: downgrade sidx errors to non-fatal warnings; fixes trac #5216 +- lavf/mov: fix sidx with edit lists +- avcodec/mjpegdec: Fix decoding slightly odd progressive jpeg +- swscale/utils: Fix chrSrcHSubSample for GBRAP16 +- swscale/input: Fix GBRAP16 input +- avutil/pixdesc: Make get_color_type() aware of CIE XYZ formats +- avcodec/h264: Execute error concealment before marking the frame as done. +- swscale/x86/output: Fix yuv2planeX_16* with unaligned destination +- swscale/x86/output: Move code into yuv2planeX_mainloop +- MAINTAINERS: add myself as an OS/2 maintainer +- libwebpenc_animencoder: print library messages in verbose log levels +- libwebpenc_animencoder: zero initialize the WebPAnimEncoderOptions struct +- configure: check for SEC_I_CONTEXT_EXPIRED before enabling SChannel +- lavf/http: Add httpproxy to the default protocol whitelist. +- doc/utils: fix typo for min() description +- ffserver&ffm: Fixed issues preventing ffserver write_index and files_size from being set correctly which was breaking ffserver streaming. - postproc: fix unaligned access -- avformat: clarify what package needs to be compiled with SSL support -- avcodec/libx264: Avoid reconfig on equivalent aspect ratios -- avcodec/flacenc: Fix Invalid Rice order -- tls_gnutls: fix hang on disconnection -- avcodec/hevc_ps: Only discard overread VPS if a previous is available -- ffmpeg: Free last_frame instead of just unref -- avcodec/ffv1enc: fix bps for >8bit yuv when not explicitly set -- avio: fix potential crashes when combining ffio_ensure_seekback + crc -- examples/demuxing_decoding: use properties from frame instead of video_dec_ctx -- h264: er: Copy from the previous reference only if compatible -- doc: fix spelling errors -- configure: only disable VSX for !ppc64el -- ffmpeg_opt: Check for localtime() failure -- avformat/singlejpeg: fix standalone compilation -- configure: Disable VSX on unspecified / generic CPUs -- avformat: Fix bug in parse_rps for HEVC. -- takdec: ensure chan2 is a valid channel index -- avcodec/h264_slice: Use AVFrame dimensions for grayscale handling +- vc2enc: fix use of uninitialized variables in the rate control system, correctly zero out coefficient array padding +- aacenc: optimize encoding speed +- avcodec/diracdec: check bitstream size related fields for overflows +- avcodec/h264_slice: Check PPS more extensively when its not copied + + +version 3.0: +- Common Encryption (CENC) MP4 encoding and decoding support +- DXV decoding +- extrastereo filter +- ocr filter +- alimiter filter +- stereowiden filter +- stereotools filter +- rubberband filter +- tremolo filter +- agate filter +- chromakey filter +- maskedmerge filter +- Screenpresso SPV1 decoding +- chromaprint fingerprinting muxer +- ffplay dynamic volume control +- displace filter +- selectivecolor filter +- extensive native AAC encoder improvements and removal of experimental flag +- ADPCM PSX decoder +- 3dostr, dcstr, fsb, genh, vag, xvag, ads, msf, svag & vpk demuxer +- zscale filter +- wve demuxer +- zero-copy Intel QSV transcoding in ffmpeg +- shuffleframes filter +- SDX2 DPCM decoder +- vibrato filter +- innoHeim/Rsupport Screen Capture Codec decoder +- ADPCM AICA decoder +- Interplay ACM demuxer and audio decoder +- XMA1 & XMA2 decoder +- realtime filter +- anoisesrc audio filter source +- IVR demuxer +- compensationdelay filter +- acompressor filter +- support encoding 16-bit RLE SGI images +- apulsator filter +- sidechaingate audio filter +- mipsdspr1 option has been renamed to mipsdsp +- aemphasis filter +- mips32r5 option has been removed +- mips64r6 option has been removed +- DXVA2-accelerated VP9 decoding +- SOFAlizer: virtual binaural acoustics filter +- VAAPI VP9 hwaccel +- audio high-order multiband parametric equalizer +- automatic bitstream filtering +- showspectrumpic filter +- libstagefright support removed +- spectrumsynth filter +- ahistogram filter +- only seek with the right mouse button in ffplay +- toggle full screen when double-clicking with the left mouse button in ffplay +- afftfilt filter +- convolution filter +- libquvi support removed +- support for dvaudio in wav and avi +- libaacplus and libvo-aacenc support removed +- Cineform HD decoder +- new DCA decoder with full support for DTS-HD extensions +- significant performance improvements in Windows Television (WTV) demuxer +- nnedi deinterlacer +- streamselect video and astreamselect audio filter +- swaprect filter +- metadata video and ametadata audio filter +- SMPTE VC-2 HQ profile support for the Dirac decoder +- SMPTE VC-2 native encoder supporting the HQ profile + + +version 2.8: +- colorkey video filter +- BFSTM/BCSTM demuxer +- little-endian ADPCM_THP decoder +- Hap decoder and encoder +- DirectDraw Surface image/texture decoder +- ssim filter +- optional new ASF demuxer +- showvolume filter +- Many improvements to the JPEG 2000 decoder +- Go2Meeting decoding support +- adrawgraph audio and drawgraph video filter +- removegrain video filter +- Intel QSV-accelerated MPEG-2 video and HEVC encoding +- Intel QSV-accelerated MPEG-2 video and HEVC decoding +- Intel QSV-accelerated VC-1 video decoding +- libkvazaar HEVC encoder +- erosion, dilation, deflate and inflate video filters +- Dynamic Audio Normalizer as dynaudnorm filter +- Reverse video and areverse audio filter +- Random filter +- deband filter +- AAC fixed-point decoding +- sidechaincompress audio filter +- bitstream filter for converting HEVC from MP4 to Annex B +- acrossfade audio filter +- allyuv and allrgb video sources +- atadenoise video filter +- OS X VideoToolbox support +- aphasemeter filter +- showfreqs filter +- vectorscope filter +- waveform filter +- hstack and vstack filter +- Support DNx100 (1440x1080@8) +- VAAPI hevc hwaccel +- VDPAU hevc hwaccel +- framerate filter +- Switched default encoders for webm to VP9 and Opus +- Removed experimental flag from the JPEG 2000 encoder version 2.7: diff --git a/LICENSE.md b/LICENSE.md index 545d3668..0c53d0f5 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -16,6 +16,7 @@ Specifically, the GPL parts of FFmpeg are: - optional x86 optimizations in the files - `libavcodec/x86/flac_dsp_gpl.asm` - `libavcodec/x86/idct_mmx.c` + - `libavfilter/x86/vf_removegrain.asm` - libutvideo encoding/decoding wrappers in `libavcodec/libutvideo*.cpp` - the X11 grabber in `libavdevice/x11grab.c` @@ -84,6 +85,7 @@ compatible libraries The following libraries are under GPL: - frei0r - libcdio +- librubberband - libutvideo - libvidstab - libx264 @@ -102,7 +104,7 @@ license version needs to be upgraded by passing `--enable-version3` to configure incompatible libraries ---------------------- -The Fraunhofer AAC library, FAAC and aacplus are under licenses which +The Fraunhofer AAC library and FAAC are under licenses which are incompatible with the GPLv2 and v3. We do not know for certain if their licenses are compatible with the LGPL. If you wish to enable these libraries, pass `--enable-nonfree` to configure. diff --git a/MAINTAINERS b/MAINTAINERS index 795e9047..0705a699 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14,7 +14,6 @@ patches and related discussions. Project Leader ============== -Michael Niedermayer final design decisions @@ -43,7 +42,7 @@ QuickTime faststart: Miscellaneous Areas =================== -documentation Stefano Sabatini, Mike Melanson, Timothy Gu +documentation Stefano Sabatini, Mike Melanson, Timothy Gu, Lou Logan build system (configure, makefiles) Diego Biurrun, Mans Rullgard project server Árpád Gereöffy, Michael Niedermayer, Reimar Doeffinger, Alexander Strasser, Lou Logan presets Robert Swain @@ -72,6 +71,7 @@ Internal Interfaces: libavutil/common.h Michael Niedermayer Other: + aes_ctr.c, aes_ctr.h Eran Kornblau bprint Nicolas George bswap.h des Reimar Doeffinger @@ -138,6 +138,7 @@ Codecs: 4xm.c Michael Niedermayer 8bps.c Roberto Togni 8svx.c Jaikrishnan Menon + aacenc*, aaccoder.c Rostislav Pehlivanov aasc.c Kostya Shishkov ac3* Justin Ruggles alacenc.c Jaikrishnan Menon @@ -164,6 +165,7 @@ Codecs: crystalhd.c Philip Langdale cscd.c Reimar Doeffinger dca.c Kostya Shishkov, Benjamin Larsson + dirac* Rostislav Pehlivanov dnxhd* Baptiste Coudurier dpcm.c Mike Melanson dss_sp.c Oleksij Rempel, Michael Niedermayer @@ -171,6 +173,7 @@ Codecs: dvbsubdec.c Anshul Maheshwari dxa.c Kostya Shishkov eacmv*, eaidct*, eat* Peter Ross + evrc* Paul B Mahol exif.c, exif.h Thilo Borgmann ffv1* Michael Niedermayer ffwavesynth.c Nicolas George @@ -184,6 +187,7 @@ Codecs: h261* Michael Niedermayer h263* Michael Niedermayer h264* Loren Merritt, Michael Niedermayer + hap* Tom Butterworth huffyuv* Michael Niedermayer, Christophe Gisquet idcinvideo.c Mike Melanson imc* Benjamin Larsson @@ -200,12 +204,13 @@ Codecs: libcelt_dec.c Nicolas George libdirac* David Conrad libgsm.c Michel Bardiaux + libkvazaar.c Arttu Ylä-Outinen libopenjpeg.c Jaikrishnan Menon libopenjpegenc.c Michael Bradshaw libschroedinger* David Conrad libspeexdec.c Justin Ruggles libtheoraenc.c David Conrad - libutvideo* Derek Buitenhuis + libutvideo* Carl Eugen Hoyos libvorbis.c David Conrad libvpx* James Zern libx264.c Mans Rullgard, Jason Garrett-Glaser @@ -237,6 +242,7 @@ Codecs: qdm2.c, qdm2data.h Roberto Togni, Benjamin Larsson qdrw.c Kostya Shishkov qpeg.c Kostya Shishkov + qsv* Ivan Uskov qtrle.c Mike Melanson ra144.c, ra144.h, ra288.c, ra288.h Roberto Togni resample2.c Michael Niedermayer @@ -270,6 +276,7 @@ Codecs: vb.c Kostya Shishkov vble.c Derek Buitenhuis vc1* Kostya Shishkov, Christophe Gisquet + vc2* Rostislav Pehlivanov vcr1.c Michael Niedermayer vda_h264_dec.c Xidorn Quan vima.c Paul B Mahol @@ -298,11 +305,11 @@ Codecs: Hardware acceleration: crystalhd.c Philip Langdale - dxva2* Laurent Aimar - libstagefright.cpp Mohamed Naufal + dxva2* Hendrik Leppkes, Laurent Aimar vaapi* Gwenole Beauchesne vda* Sebastien Zwickert - vdpau* Carl Eugen Hoyos + vdpau* Philip Langdale, Carl Eugen Hoyos + videotoolbox* Sebastien Zwickert libavdevice @@ -334,6 +341,7 @@ Generic parts: graphdump.c Nicolas George Filters: + f_drawgraph.c Paul B Mahol af_adelay.c Paul B Mahol af_aecho.c Paul B Mahol af_afade.c Paul B Mahol @@ -341,19 +349,26 @@ Filters: af_aphaser.c Paul B Mahol af_aresample.c Michael Niedermayer af_astats.c Paul B Mahol - af_astreamsync.c Nicolas George af_atempo.c Pavel Koshevoy af_biquads.c Paul B Mahol + af_chorus.c Paul B Mahol af_compand.c Paul B Mahol af_ladspa.c Paul B Mahol af_pan.c Nicolas George + af_sidechaincompress.c Paul B Mahol af_silenceremove.c Paul B Mahol + avf_aphasemeter.c Paul B Mahol avf_avectorscope.c Paul B Mahol avf_showcqt.c Muhammad Faiz vf_blend.c Paul B Mahol + vf_chromakey.c Timo Rothenpieler + vf_colorchannelmixer.c Paul B Mahol vf_colorbalance.c Paul B Mahol + vf_colorkey.c Timo Rothenpieler + vf_colorlevels.c Paul B Mahol + vf_deband.c Paul B Mahol vf_dejudder.c Nicholas Robbins - vf_delogo.c Jean Delvare (CC ) + vf_delogo.c Jean Delvare (CC ) vf_drawbox.c/drawgrid Andrey Utkin vf_extractplanes.c Paul B Mahol vf_histogram.c Paul B Mahol @@ -362,12 +377,16 @@ Filters: vf_il.c Paul B Mahol vf_lenscorrection.c Daniel Oberhoff vf_mergeplanes.c Paul B Mahol + vf_neighbor.c Paul B Mahol vf_psnr.c Paul B Mahol + vf_random.c Paul B Mahol vf_scale.c Michael Niedermayer vf_separatefields.c Paul B Mahol + vf_ssim.c Paul B Mahol vf_stereo3d.c Paul B Mahol vf_telecine.c Paul B Mahol vf_yadif.c Michael Niedermayer + vf_zoompan.c Paul B Mahol Sources: vsrc_mandelbrot.c Michael Niedermayer @@ -384,6 +403,7 @@ Generic parts: Muxers/Demuxers: 4xm.c Mike Melanson + aadec.c Vesselin Bontchev (vesselin.bontchev at yandex dot com) adtsenc.c Robert Swain afc.c Paul B Mahol aiffdec.c Baptiste Coudurier, Matthieu Bouron @@ -415,6 +435,7 @@ Muxers/Demuxers: gxf.c Reimar Doeffinger gxfenc.c Baptiste Coudurier hls.c Anssi Hannula + hls encryption (hlsenc.c) Christian Suloway idcin.c Mike Melanson idroqdec.c Mike Melanson iff.c Jaikrishnan Menon @@ -439,6 +460,7 @@ Muxers/Demuxers: mm.c Peter Ross mov.c Michael Niedermayer, Baptiste Coudurier movenc.c Baptiste Coudurier, Matthieu Bouron + movenccenc.c Eran Kornblau mpc.c Kostya Shishkov mpeg.c Michael Niedermayer mpegenc.c Michael Niedermayer @@ -455,6 +477,7 @@ Muxers/Demuxers: oggdec.c, oggdec.h David Conrad oggenc.c Baptiste Coudurier oggparse*.c David Conrad + oggparsedaala* Rostislav Pehlivanov oma.c Maxim Poliakovski paf.c Paul B Mahol psxstr.c Mike Melanson @@ -500,6 +523,7 @@ Muxers/Demuxers: wvenc.c Paul B Mahol Protocols: + async.c Zhang Rui bluray.c Petri Hintukainen ftp.c Lukasz Marek http.c Ronald S. Bultje @@ -535,21 +559,22 @@ Amiga / PowerPC Colin Ward Linux / PowerPC Luca Barbato Windows MinGW Alex Beregszaszi, Ramiro Polla Windows Cygwin Victor Paesa -Windows MSVC Matthew Oliver +Windows MSVC Matthew Oliver, Hendrik Leppkes Windows ICL Matthew Oliver ADI/Blackfin DSP Marc Hoffman Sparc Roman Shaposhnik x86 Michael Niedermayer +OS/2 KO Myung-Hun Releases ======== +2.8 Michael Niedermayer 2.7 Michael Niedermayer 2.6 Michael Niedermayer 2.5 Michael Niedermayer 2.4 Michael Niedermayer -2.2 Michael Niedermayer If you want to maintain an older release, please contact us @@ -569,6 +594,7 @@ Clément Bœsch 52D0 3A82 D445 F194 DB8B 2B16 87EE 2CB8 F4B8 FCF Daniel Verkamp 78A6 07ED 782C 653E C628 B8B9 F0EB 8DD8 2F0E 21C7 Diego Biurrun 8227 1E31 B6D9 4994 7427 E220 9CAE D6CC 4757 FCC5 FFmpeg release signing key FCF9 86EA 15E6 E293 A564 4F10 B432 2F04 D676 58D8 +Ganesh Ajjanagadde C96A 848E 97C3 CEA2 AB72 5CE4 45F9 6A2D 3C36 FB1B Gwenole Beauchesne 2E63 B3A6 3E44 37E2 017D 2704 53C7 6266 B153 99C4 Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368 Jean Delvare 7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A @@ -580,6 +606,7 @@ Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB Nicolas George 24CE 01CE 9ACC 5CEB 74D8 8D9D B063 D997 36E5 4C93 Panagiotis Issaris 6571 13A3 33D9 3726 F728 AA98 F643 B12E ECF3 E029 Peter Ross A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B +Philip Langdale 5DC5 8D66 5FBA 3A43 18EC 045E F8D6 B194 6A75 682E Reimar Doeffinger C61D 16E5 9E2C D10C 8958 38A4 0899 A2B9 06D4 D9C7 Reinhard Tartler 9300 5DC2 7E87 6C37 ED7B CA9A 9808 3544 9453 48A4 Reynaldo H. Verdejo Pinochet 6E27 CD34 170C C78E 4D4F 5F40 C18E 077F 3114 452A diff --git a/Makefile b/Makefile index fd59628a..87a98696 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ include config.mak vpath %.c $(SRC_PATH) vpath %.cpp $(SRC_PATH) vpath %.h $(SRC_PATH) +vpath %.inc $(SRC_PATH) vpath %.m $(SRC_PATH) vpath %.S $(SRC_PATH) vpath %.asm $(SRC_PATH) @@ -31,7 +32,11 @@ $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog)-$(CONFIG_OPENCL) += cmdutils_o OBJS-ffmpeg += ffmpeg_opt.o ffmpeg_filter.o OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o -OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_vda.o +ifndef CONFIG_VIDEOTOOLBOX +OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o +endif +OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o +OBJS-ffmpeg-$(CONFIG_LIBMFX) += ffmpeg_qsv.o OBJS-ffserver += ffserver_config.o TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 @@ -60,6 +65,7 @@ include $(SRC_PATH)/common.mak FF_EXTRALIBS := $(FFEXTRALIBS) FF_DEP_LIBS := $(DEP_LIBS) +FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS) all: $(AVPROGS) @@ -80,8 +86,8 @@ SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \ HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \ ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS \ ALTIVEC-OBJS MMX-OBJS YASM-OBJS \ - MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSPR1-OBJS MSA-OBJS \ - LOONGSON3-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS + MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS \ + MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS define RESET $(1) := @@ -171,11 +177,15 @@ clean:: $(RM) $(CLEANSUFFIXES) $(RM) $(CLEANSUFFIXES:%=tools/%) $(RM) -r coverage-html - $(RM) -rf coverage.info lcov + $(RM) -rf coverage.info coverage.info.in lcov distclean:: $(RM) $(DISTCLEANSUFFIXES) - $(RM) config.* .config libavutil/avconfig.h .version version.h libavutil/ffversion.h libavcodec/codec_names.h + $(RM) config.* .config libavutil/avconfig.h .version avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h +ifeq ($(SRC_LINK),src) + $(RM) src +endif + $(RM) -rf doc/examples/pc-uninstalled config: $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION) diff --git a/README.md b/README.md index 58e1eff0..24191919 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,12 @@ such as audio, video, subtitles and related metadata. ## Tools -* [ffmpeg](http://ffmpeg.org/ffmpeg.html) is a command line toolbox to +* [ffmpeg](https://ffmpeg.org/ffmpeg.html) is a command line toolbox to manipulate, convert and stream multimedia content. -* [ffplay](http://ffmpeg.org/ffplay.html) is a minimalistic multimedia player. -* [ffprobe](http://ffmpeg.org/ffprobe.html) is a simple analysis tool to inspect +* [ffplay](https://ffmpeg.org/ffplay.html) is a minimalistic multimedia player. +* [ffprobe](https://ffmpeg.org/ffprobe.html) is a simple analysis tool to inspect multimedia content. -* [ffserver](http://ffmpeg.org/ffserver.html) is a multimedia streaming server +* [ffserver](https://ffmpeg.org/ffserver.html) is a multimedia streaming server for live broadcasts. * Additional small tools such as `aviocat`, `ismindex` and `qt-faststart`. @@ -29,8 +29,8 @@ such as audio, video, subtitles and related metadata. The offline documentation is available in the **doc/** directory. -The online documentation is available in the main [website](http://ffmpeg.org) -and in the [wiki](http://trac.ffmpeg.org). +The online documentation is available in the main [website](https://ffmpeg.org) +and in the [wiki](https://trac.ffmpeg.org). ### Examples @@ -40,3 +40,10 @@ Coding examples are available in the **doc/examples** directory. FFmpeg codebase is mainly LGPL-licensed with optional components licensed under GPL. Please refer to the LICENSE file for detailed information. + +## Contributing + +Patches should be submitted to the ffmpeg-devel mailing list using +`git format-patch` or `git send-email`. Github pull requests should be +avoided because they are not part of our review process. Few developers +follow pull requests so they will likely be ignored. diff --git a/RELEASE b/RELEASE index 37c2961c..b5021469 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -2.7.2 +3.0.2 diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 1451d33f..861dc04a 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,10 +1,10 @@ - ┌─────────────────────────────────────┐ - │ RELEASE NOTES for FFmpeg 2.7 "Nash" │ - └─────────────────────────────────────┘ + ┌─────────────────────────────────────────┐ + │ RELEASE NOTES for FFmpeg 3.0 "Einstein" │ + └─────────────────────────────────────────┘ - The FFmpeg Project proudly presents FFmpeg 2.7 "Nash", about 3 - months after the release of FFmpeg 2.6. + The FFmpeg Project proudly presents FFmpeg 3.0 "Einstein", about 5 + months after the release of FFmpeg 2.8. A complete Changelog is available at the root of the project, and the complete Git history on http://source.ffmpeg.org. diff --git a/android/x86/include/libavcodec/d3d11va.h b/android/x86/include/libavcodec/d3d11va.h new file mode 100644 index 00000000..d51e2ff8 --- /dev/null +++ b/android/x86/include/libavcodec/d3d11va.h @@ -0,0 +1,98 @@ +/* + * Direct3D11 HW acceleration + * + * copyright (c) 2009 Laurent Aimar + * copyright (c) 2015 Steve Lhomme + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_D3D11VA_H +#define AVCODEC_D3D11VA_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_d3d11va + * Public libavcodec D3D11VA header. + */ + +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif + +#include +#include + +/** + * @defgroup lavc_codec_hwaccel_d3d11va Direct3D11 + * @ingroup lavc_codec_hwaccel + * + * @{ + */ + +#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for Direct3D11 and old UVD/UVD+ ATI video cards +#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2 ///< Work around for Direct3D11 and old Intel GPUs with ClearVideo interface + +/** + * This structure is used to provides the necessary configurations and data + * to the Direct3D11 FFmpeg HWAccel implementation. + * + * The application must make it available as AVCodecContext.hwaccel_context. + */ +struct AVD3D11VAContext { + /** + * D3D11 decoder object + */ + ID3D11VideoDecoder *decoder; + + /** + * D3D11 VideoContext + */ + ID3D11VideoContext *video_context; + + /** + * D3D11 configuration used to create the decoder + */ + D3D11_VIDEO_DECODER_CONFIG *cfg; + + /** + * The number of surface in the surface array + */ + unsigned surface_count; + + /** + * The array of Direct3D surfaces used to create the decoder + */ + ID3D11VideoDecoderOutputView **surface; + + /** + * A bit field configuring the workarounds needed for using the decoder + */ + uint64_t workaround; + + /** + * Private to the FFmpeg AVHWAccel implementation + */ + unsigned report_id; +}; + +/** + * @} + */ + +#endif /* AVCODEC_D3D11VA_H */ diff --git a/libavcodec/x86/dirac_dwt.h b/android/x86/include/libavcodec/qsv.h similarity index 64% rename from libavcodec/x86/dirac_dwt.h rename to android/x86/include/libavcodec/qsv.h index 126b2902..e7487c88 100644 --- a/libavcodec/x86/dirac_dwt.h +++ b/android/x86/include/libavcodec/qsv.h @@ -1,4 +1,6 @@ /* + * Intel MediaSDK QSV public API + * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or @@ -16,15 +18,24 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVCODEC_X86_DIRAC_DWT_H -#define AVCODEC_X86_DIRAC_DWT_H +#ifndef AVCODEC_QSV_H +#define AVCODEC_QSV_H + +#include -#include "libavcodec/dirac_dwt.h" +typedef struct AVQSVContext { + mfxSession session; + int iopattern; -void ff_horizontal_compose_dd97i_end_c(IDWTELEM *b, IDWTELEM *tmp, int w2, int x); -void ff_horizontal_compose_haar1i_end_c(IDWTELEM *b, IDWTELEM *tmp, int w2, int x); -void ff_horizontal_compose_haar0i_end_c(IDWTELEM *b, IDWTELEM *tmp, int w2, int x); + mfxExtBuffer **ext_buffers; + int nb_ext_buffers; +} AVQSVContext; -void ff_spatial_idwt_init_mmx(DWTContext *d, enum dwt_type type); +/** + * Allocate a new context. + * + * It must be freed by the caller with av_free(). + */ +AVQSVContext *av_qsv_alloc_context(void); -#endif +#endif /* AVCODEC_QSV_H */ diff --git a/android/x86/include/libavutil/twofish.h b/android/x86/include/libavutil/twofish.h new file mode 100644 index 00000000..813cfecd --- /dev/null +++ b/android/x86/include/libavutil/twofish.h @@ -0,0 +1,70 @@ +/* + * An implementation of the TwoFish algorithm + * Copyright (c) 2015 Supraja Meedinti + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_TWOFISH_H +#define AVUTIL_TWOFISH_H + +#include + + +/** + * @file + * @brief Public header for libavutil TWOFISH algorithm + * @defgroup lavu_twofish TWOFISH + * @ingroup lavu_crypto + * @{ + */ + +extern const int av_twofish_size; + +struct AVTWOFISH; + +/** + * Allocate an AVTWOFISH context + * To free the struct: av_free(ptr) + */ +struct AVTWOFISH *av_twofish_alloc(void); + +/** + * Initialize an AVTWOFISH context. + * + * @param ctx an AVTWOFISH context + * @param key a key of size ranging from 1 to 32 bytes used for encryption/decryption + * @param key_bits number of keybits: 128, 192, 256 If less than the required, padded with zeroes to nearest valid value; return value is 0 if key_bits is 128/192/256, -1 if less than 0, 1 otherwise + */ +int av_twofish_init(struct AVTWOFISH *ctx, const uint8_t *key, int key_bits); + +/** + * Encrypt or decrypt a buffer using a previously initialized context + * + * @param ctx an AVTWOFISH context + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param count number of 16 byte blocks + * @paran iv initialization vector for CBC mode, NULL for ECB mode + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_twofish_crypt(struct AVTWOFISH *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt); + +/** + * @} + */ +#endif /* AVUTIL_TWOFISH_H */ diff --git a/arch.mak b/arch.mak index 4508c2a2..08f78b4e 100644 --- a/arch.mak +++ b/arch.mak @@ -5,10 +5,10 @@ OBJS-$(HAVE_VFP) += $(VFP-OBJS) $(VFP-OBJS-yes) OBJS-$(HAVE_NEON) += $(NEON-OBJS) $(NEON-OBJS-yes) OBJS-$(HAVE_MIPSFPU) += $(MIPSFPU-OBJS) $(MIPSFPU-OBJS-yes) -OBJS-$(HAVE_MIPSDSPR1) += $(MIPSDSPR1-OBJS) $(MIPSDSPR1-OBJS-yes) +OBJS-$(HAVE_MIPSDSP) += $(MIPSDSP-OBJS) $(MIPSDSP-OBJS-yes) OBJS-$(HAVE_MIPSDSPR2) += $(MIPSDSPR2-OBJS) $(MIPSDSPR2-OBJS-yes) OBJS-$(HAVE_MSA) += $(MSA-OBJS) $(MSA-OBJS-yes) -OBJS-$(HAVE_LOONGSON3) += $(LOONGSON3-OBJS) $(LOONGSON3-OBJS-yes) +OBJS-$(HAVE_MMI) += $(MMI-OBJS) $(MMI-OBJS-yes) OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes) OBJS-$(HAVE_VSX) += $(VSX-OBJS) $(VSX-OBJS-yes) diff --git a/cmdutils.c b/cmdutils.c index 6e7a0bb0..03a48362 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -52,6 +52,7 @@ #include "libavutil/opt.h" #include "libavutil/cpu.h" #include "libavutil/ffversion.h" +#include "libavutil/version.h" #include "cmdutils.h" #if CONFIG_NETWORK #include "libavformat/network.h" @@ -63,7 +64,7 @@ static int init_report(const char *env); -struct SwsContext *sws_opts; +AVDictionary *sws_dict; AVDictionary *swr_opts; AVDictionary *format_opts, *codec_opts, *resample_opts; @@ -73,20 +74,13 @@ int hide_banner = 0; void init_opts(void) { - - if(CONFIG_SWSCALE) - sws_opts = sws_getContext(16, 16, 0, 16, 16, 0, SWS_BICUBIC, - NULL, NULL, NULL); + av_dict_set(&sws_dict, "flags", "bicubic", 0); } void uninit_opts(void) { -#if CONFIG_SWSCALE - sws_freeContext(sws_opts); - sws_opts = NULL; -#endif - av_dict_free(&swr_opts); + av_dict_free(&sws_dict); av_dict_free(&format_opts); av_dict_free(&codec_opts); av_dict_free(&resample_opts); @@ -529,7 +523,7 @@ static const AVOption *opt_find(void *obj, const char *name, const char *unit, return o; } -#define FLAGS (o->type == AV_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0 +#define FLAGS (o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0 int opt_default(void *optctx, const char *opt, const char *arg) { const AVOption *o; @@ -540,7 +534,12 @@ int opt_default(void *optctx, const char *opt, const char *arg) #if CONFIG_AVRESAMPLE const AVClass *rc = avresample_get_class(); #endif - const AVClass *sc, *swr_class; +#if CONFIG_SWSCALE + const AVClass *sc = sws_get_class(); +#endif +#if CONFIG_SWRESAMPLE + const AVClass *swr_class = swr_get_class(); +#endif if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug")) av_log_set_level(AV_LOG_DEBUG); @@ -564,15 +563,24 @@ int opt_default(void *optctx, const char *opt, const char *arg) consumed = 1; } #if CONFIG_SWSCALE - sc = sws_get_class(); - if (!consumed && opt_find(&sc, opt, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { - // XXX we only support sws_flags, not arbitrary sws options - int ret = av_opt_set(sws_opts, opt, arg, 0); + if (!consumed && (o = opt_find(&sc, opt, NULL, 0, + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { + struct SwsContext *sws = sws_alloc_context(); + int ret = av_opt_set(sws, opt, arg, 0); + sws_freeContext(sws); + if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") || + !strcmp(opt, "dstw") || !strcmp(opt, "dsth") || + !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) { + av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n"); + return AVERROR(EINVAL); + } if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); return ret; } + + av_dict_set(&sws_dict, opt, arg, FLAGS); + consumed = 1; } #else @@ -582,7 +590,6 @@ int opt_default(void *optctx, const char *opt, const char *arg) } #endif #if CONFIG_SWRESAMPLE - swr_class = swr_get_class(); if (!consumed && (o=opt_find(&swr_class, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { struct SwrContext *swr = swr_alloc(); @@ -646,9 +653,7 @@ static void finish_group(OptionParseContext *octx, int group_idx, *g = octx->cur_group; g->arg = arg; g->group_def = l->group_def; -#if CONFIG_SWSCALE - g->sws_opts = sws_opts; -#endif + g->sws_dict = sws_dict; g->swr_opts = swr_opts; g->codec_opts = codec_opts; g->format_opts = format_opts; @@ -657,9 +662,7 @@ static void finish_group(OptionParseContext *octx, int group_idx, codec_opts = NULL; format_opts = NULL; resample_opts = NULL; -#if CONFIG_SWSCALE - sws_opts = NULL; -#endif + sws_dict = NULL; swr_opts = NULL; init_opts(); @@ -715,9 +718,8 @@ void uninit_parse_context(OptionParseContext *octx) av_dict_free(&l->groups[j].codec_opts); av_dict_free(&l->groups[j].format_opts); av_dict_free(&l->groups[j].resample_opts); -#if CONFIG_SWSCALE - sws_freeContext(l->groups[j].sws_opts); -#endif + + av_dict_free(&l->groups[j].sws_dict); av_dict_free(&l->groups[j].swr_opts); } av_freep(&l->groups); @@ -1057,7 +1059,8 @@ static int warned_cfg = 0; LIB##LIBNAME##_VERSION_MAJOR, \ LIB##LIBNAME##_VERSION_MINOR, \ LIB##LIBNAME##_VERSION_MICRO, \ - version >> 16, version >> 8 & 0xff, version & 0xff); \ + AV_VERSION_MAJOR(version), AV_VERSION_MINOR(version),\ + AV_VERSION_MICRO(version)); \ } \ if (flags & SHOW_CONFIG) { \ const char *cfg = libname##_configuration(); \ @@ -1076,15 +1079,15 @@ static int warned_cfg = 0; static void print_all_libs_info(int flags, int level) { - PRINT_LIB_INFO(avutil, AVUTIL, flags, level); - PRINT_LIB_INFO(avcodec, AVCODEC, flags, level); - PRINT_LIB_INFO(avformat, AVFORMAT, flags, level); - PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level); - PRINT_LIB_INFO(avfilter, AVFILTER, flags, level); + PRINT_LIB_INFO(avutil, AVUTIL, flags, level); + PRINT_LIB_INFO(avcodec, AVCODEC, flags, level); + PRINT_LIB_INFO(avformat, AVFORMAT, flags, level); + PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level); + PRINT_LIB_INFO(avfilter, AVFILTER, flags, level); PRINT_LIB_INFO(avresample, AVRESAMPLE, flags, level); - PRINT_LIB_INFO(swscale, SWSCALE, flags, level); - PRINT_LIB_INFO(swresample,SWRESAMPLE, flags, level); - PRINT_LIB_INFO(postproc, POSTPROC, flags, level); + PRINT_LIB_INFO(swscale, SWSCALE, flags, level); + PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level); + PRINT_LIB_INFO(postproc, POSTPROC, flags, level); } static void print_program_info(int flags, int level) @@ -1321,16 +1324,47 @@ static void print_codec(const AVCodec *c) printf("%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name, c->long_name ? c->long_name : ""); + printf(" General capabilities: "); + if (c->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND) + printf("horizband "); + if (c->capabilities & AV_CODEC_CAP_DR1) + printf("dr1 "); + if (c->capabilities & AV_CODEC_CAP_TRUNCATED) + printf("trunc "); + if (c->capabilities & AV_CODEC_CAP_DELAY) + printf("delay "); + if (c->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) + printf("small "); + if (c->capabilities & AV_CODEC_CAP_SUBFRAMES) + printf("subframes "); + if (c->capabilities & AV_CODEC_CAP_EXPERIMENTAL) + printf("exp "); + if (c->capabilities & AV_CODEC_CAP_CHANNEL_CONF) + printf("chconf "); + if (c->capabilities & AV_CODEC_CAP_PARAM_CHANGE) + printf("paramchange "); + if (c->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) + printf("variable "); + if (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_AUTO_THREADS)) + printf("threads "); + if (!c->capabilities) + printf("none"); + printf("\n"); + if (c->type == AVMEDIA_TYPE_VIDEO || c->type == AVMEDIA_TYPE_AUDIO) { printf(" Threading capabilities: "); - switch (c->capabilities & (CODEC_CAP_FRAME_THREADS | - CODEC_CAP_SLICE_THREADS)) { - case CODEC_CAP_FRAME_THREADS | - CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break; - case CODEC_CAP_FRAME_THREADS: printf("frame"); break; - case CODEC_CAP_SLICE_THREADS: printf("slice"); break; - default: printf("no"); break; + switch (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_AUTO_THREADS)) { + case AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break; + case AV_CODEC_CAP_FRAME_THREADS: printf("frame"); break; + case AV_CODEC_CAP_SLICE_THREADS: printf("slice"); break; + case AV_CODEC_CAP_AUTO_THREADS : printf("auto"); break; + default: printf("none"); break; } printf("\n"); } @@ -1389,7 +1423,7 @@ static int compare_codec_desc(const void *a, const void *b) const AVCodecDescriptor * const *da = a; const AVCodecDescriptor * const *db = b; - return (*da)->type != (*db)->type ? (*da)->type - (*db)->type : + return (*da)->type != (*db)->type ? FFDIFFSIGN((*da)->type, (*db)->type) : strcmp((*da)->name, (*db)->name); } @@ -1503,11 +1537,11 @@ static void print_codecs(int encoder) while ((codec = next_codec_for_id(desc->id, codec, encoder))) { printf(" %c", get_media_type_char(desc->type)); - printf((codec->capabilities & CODEC_CAP_FRAME_THREADS) ? "F" : "."); - printf((codec->capabilities & CODEC_CAP_SLICE_THREADS) ? "S" : "."); - printf((codec->capabilities & CODEC_CAP_EXPERIMENTAL) ? "X" : "."); - printf((codec->capabilities & CODEC_CAP_DRAW_HORIZ_BAND)?"B" : "."); - printf((codec->capabilities & CODEC_CAP_DR1) ? "D" : "."); + printf((codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : "."); + printf((codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : "."); + printf((codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ? "X" : "."); + printf((codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)?"B" : "."); + printf((codec->capabilities & AV_CODEC_CAP_DR1) ? "D" : "."); printf(" %-20s %s", codec->name, codec->long_name ? codec->long_name : ""); if (strcmp(codec->name, desc->name)) @@ -1581,17 +1615,17 @@ int show_filters(void *optctx, const char *opt, const char *arg) *(descr_cur++) = '>'; } pad = i ? filter->outputs : filter->inputs; - for (j = 0; pad && pad[j].name; j++) { + for (j = 0; pad && avfilter_pad_get_name(pad, j); j++) { if (descr_cur >= descr + sizeof(descr) - 4) break; - *(descr_cur++) = get_media_type_char(pad[j].type); + *(descr_cur++) = get_media_type_char(avfilter_pad_get_type(pad, j)); } if (!j) *(descr_cur++) = ((!i && (filter->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)) || ( i && (filter->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS))) ? 'N' : '|'; } *descr_cur = 0; - printf(" %c%c%c %-16s %-10s %s\n", + printf(" %c%c%c %-17s %-10s %s\n", filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE ? 'T' : '.', filter->flags & AVFILTER_FLAG_SLICE_THREADS ? 'S' : '.', filter->process_command ? 'C' : '.', @@ -1875,64 +1909,6 @@ int read_yesno(void) return yesno; } -int cmdutils_read_file(const char *filename, char **bufptr, size_t *size) -{ - int64_t ret; - FILE *f = av_fopen_utf8(filename, "rb"); - - if (!f) { - ret = AVERROR(errno); - av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, - strerror(errno)); - return ret; - } - - ret = fseek(f, 0, SEEK_END); - if (ret == -1) { - ret = AVERROR(errno); - goto out; - } - - ret = ftell(f); - if (ret < 0) { - ret = AVERROR(errno); - goto out; - } - *size = ret; - - ret = fseek(f, 0, SEEK_SET); - if (ret == -1) { - ret = AVERROR(errno); - goto out; - } - - *bufptr = av_malloc(*size + 1); - if (!*bufptr) { - av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n"); - ret = AVERROR(ENOMEM); - goto out; - } - ret = fread(*bufptr, 1, *size, f); - if (ret < *size) { - av_free(*bufptr); - if (ferror(f)) { - ret = AVERROR(errno); - av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n", - filename, strerror(errno)); - } else - ret = AVERROR_EOF; - } else { - ret = 0; - (*bufptr)[(*size)++] = '\0'; - } - -out: - if (ret < 0) - av_log(NULL, AV_LOG_ERROR, "IO error: %s\n", av_err2str(ret)); - fclose(f); - return ret; -} - FILE *get_preset_file(char *filename, size_t filename_size, const char *preset_name, int is_path, const char *codec_name) @@ -2106,7 +2082,10 @@ double get_rotation(AVStream *st) theta -= 360*floor(theta/360 + 0.9/360); if (fabs(theta - 90*round(theta/90)) > 2) - av_log_ask_for_sample(NULL, "Odd rotation angle\n"); + av_log(NULL, AV_LOG_WARNING, "Odd rotation angle.\n" + "If you want to help, upload a sample " + "of this file to ftp://upload.ffmpeg.org/incoming/ " + "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)"); return theta; } diff --git a/cmdutils.h b/cmdutils.h index a21ce35f..83ea4ad3 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef FFMPEG_CMDUTILS_H -#define FFMPEG_CMDUTILS_H +#ifndef CMDUTILS_H +#define CMDUTILS_H #include @@ -46,7 +46,7 @@ extern const int program_birth_year; extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; extern AVFormatContext *avformat_opts; -extern struct SwsContext *sws_opts; +extern AVDictionary *sws_dict; extern AVDictionary *swr_opts; extern AVDictionary *format_opts, *codec_opts, *resample_opts; extern int hide_banner; @@ -277,7 +277,7 @@ typedef struct OptionGroup { AVDictionary *codec_opts; AVDictionary *format_opts; AVDictionary *resample_opts; - struct SwsContext *sws_opts; + AVDictionary *sws_dict; AVDictionary *swr_opts; } OptionGroup; @@ -529,18 +529,6 @@ int show_colors(void *optctx, const char *opt, const char *arg); */ int read_yesno(void); -/** - * Read the file with name filename, and put its content in a newly - * allocated 0-terminated buffer. - * - * @param filename file to read from - * @param bufptr location where pointer to buffer is returned - * @param size location where size of buffer is returned - * @return >= 0 in case of success, a negative value corresponding to an - * AVERROR error code in case of failure. - */ -int cmdutils_read_file(const char *filename, char **bufptr, size_t *size); - /** * Get a file corresponding to a preset file. * diff --git a/cmdutils_opencl.c b/cmdutils_opencl.c index 61478e27..dd21344a 100644 --- a/cmdutils_opencl.c +++ b/cmdutils_opencl.c @@ -206,7 +206,9 @@ static int64_t run_opencl_bench(AVOpenCLExternalEnv *ext_opencl_env) static int compare_ocl_device_desc(const void *a, const void *b) { - return ((OpenCLDeviceBenchmark*)a)->runtime - ((OpenCLDeviceBenchmark*)b)->runtime; + const OpenCLDeviceBenchmark* va = (const OpenCLDeviceBenchmark*)a; + const OpenCLDeviceBenchmark* vb = (const OpenCLDeviceBenchmark*)b; + return FFDIFFSIGN(va->runtime , vb->runtime); } int opt_opencl_bench(void *optctx, const char *opt, const char *arg) diff --git a/common.mak b/common.mak index eac8bd99..03b51c59 100644 --- a/common.mak +++ b/common.mak @@ -18,7 +18,7 @@ ifndef SUBDIR ifndef V Q = @ ECHO = printf "$(1)\t%s\n" $(2) -BRIEF = CC CXX HOSTCC HOSTLD AS YASM AR LD STRIP CP WINDRES +BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS YASM AR LD STRIP CP WINDRES SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM MSG = $@ @@ -32,10 +32,12 @@ endif ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample # NASM requires -I path terminated with / -IFLAGS := -I. -I$(SRC_PATH)/ +IFLAGS := -I. -I$(SRC_LINK)/ CPPFLAGS := $(IFLAGS) $(CPPFLAGS) CFLAGS += $(ECFLAGS) CCFLAGS = $(CPPFLAGS) $(CFLAGS) +OBJCFLAGS += $(EOBJCFLAGS) +OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS) ASFLAGS := $(CPPFLAGS) $(ASFLAGS) CXXFLAGS += $(CPPFLAGS) $(CFLAGS) YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm @@ -45,12 +47,13 @@ LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS) define COMPILE $(call $(1)DEP,$(1)) - $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $< + $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) endef COMPILE_C = $(call COMPILE,CC) COMPILE_CXX = $(call COMPILE,CXX) COMPILE_S = $(call COMPILE,AS) +COMPILE_M = $(call COMPILE,OBJCC) COMPILE_HOSTC = $(call COMPILE,HOSTCC) %.o: %.c @@ -60,10 +63,10 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC) $(COMPILE_CXX) %.o: %.m - $(COMPILE_C) + $(COMPILE_M) %.s: %.c - $(CC) $(CPPFLAGS) $(CFLAGS) -S -o $@ $< + $(CC) $(CCFLAGS) -S -o $@ $< %.o: %.S $(COMPILE_S) @@ -81,7 +84,9 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC) $(Q)echo '#include "$*.h"' >$@ %.ver: %.v - $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@ + $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ | sed -e 's/:/:\ +/' -e 's/; /;\ +/g' > $@ %.c %.h: TAG = GEN @@ -118,8 +123,9 @@ TOOLOBJS := $(TOOLS:%=tools/%.o) TOOLS := $(TOOLS:%=tools/%$(EXESUF)) HEADERS += $(HEADERS-yes) -PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(CONFIG_SHARED:yes=S)LIBNAME)) -DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib))) +PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(2)LIBNAME)) +DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib),$(CONFIG_SHARED:yes=S))) +STATIC_DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib))) SRC_DIR := $(SRC_PATH)/lib$(NAME) ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h)) @@ -146,7 +152,7 @@ $(TOOLOBJS): | tools OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS)) -CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ho *.gcno *.gcda *$(DEFAULT_YASMD).asm +CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ver-sol2 *.ho *.gcno *.gcda *$(DEFAULT_YASMD).asm DISTCLEANSUFFIXES = *.pc LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a diff --git a/compat/aix/math.h b/compat/aix/math.h index 65a89c45..dee13c8d 100644 --- a/compat/aix/math.h +++ b/compat/aix/math.h @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef FFMPEG_COMPAT_AIX_MATH_H -#define FFMPEG_COMPAT_AIX_MATH_H +#ifndef COMPAT_AIX_MATH_H +#define COMPAT_AIX_MATH_H #define class class_in_math_h_causes_problems @@ -28,4 +28,4 @@ #undef class -#endif /* FFMPEG_COMPAT_AIX_MATH_H */ +#endif /* COMPAT_AIX_MATH_H */ diff --git a/compat/msvcrt/snprintf.h b/compat/msvcrt/snprintf.h index f02113c5..cd47953e 100644 --- a/compat/msvcrt/snprintf.h +++ b/compat/msvcrt/snprintf.h @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef COMPAT_SNPRINTF_H -#define COMPAT_SNPRINTF_H +#ifndef COMPAT_MSVCRT_SNPRINTF_H +#define COMPAT_MSVCRT_SNPRINTF_H #include #include @@ -35,4 +35,4 @@ int avpriv_vsnprintf(char *s, size_t n, const char *fmt, va_list ap); #define _snprintf avpriv_snprintf #define vsnprintf avpriv_vsnprintf -#endif /* COMPAT_SNPRINTF_H */ +#endif /* COMPAT_MSVCRT_SNPRINTF_H */ diff --git a/compat/os2threads.h b/compat/os2threads.h index 5b6ca557..40a119ff 100644 --- a/compat/os2threads.h +++ b/compat/os2threads.h @@ -23,8 +23,8 @@ * os2threads to pthreads wrapper */ -#ifndef AVCODEC_OS2PTHREADS_H -#define AVCODEC_OS2PTHREADS_H +#ifndef COMPAT_OS2THREADS_H +#define COMPAT_OS2THREADS_H #define INCL_DOS #include @@ -32,59 +32,71 @@ #undef __STRICT_ANSI__ /* for _beginthread() */ #include -#include "libavutil/mem.h" +#include +#include + +#include "libavutil/attributes.h" + +typedef struct { + TID tid; + void *(*start_routine)(void *); + void *arg; + void *result; +} pthread_t; -typedef TID pthread_t; typedef void pthread_attr_t; typedef HMTX pthread_mutex_t; typedef void pthread_mutexattr_t; typedef struct { - HEV event_sem; - int wait_count; + HEV event_sem; + HEV ack_sem; + volatile unsigned wait_count; } pthread_cond_t; typedef void pthread_condattr_t; -struct thread_arg { - void *(*start_routine)(void *); - void *arg; -}; +typedef struct { + volatile int done; + _fmutex mtx; +} pthread_once_t; + +#define PTHREAD_ONCE_INIT {0, _FMUTEX_INITIALIZER} static void thread_entry(void *arg) { - struct thread_arg *thread_arg = arg; + pthread_t *thread = arg; - thread_arg->start_routine(thread_arg->arg); - - av_free(thread_arg); + thread->result = thread->start_routine(thread->arg); } -static av_always_inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) +static av_always_inline int pthread_create(pthread_t *thread, + const pthread_attr_t *attr, + void *(*start_routine)(void*), + void *arg) { - struct thread_arg *thread_arg; - - thread_arg = av_mallocz(sizeof(struct thread_arg)); - if (!thread_arg) - return ENOMEM; + thread->start_routine = start_routine; + thread->arg = arg; + thread->result = NULL; - thread_arg->start_routine = start_routine; - thread_arg->arg = arg; - - *thread = _beginthread(thread_entry, NULL, 256 * 1024, thread_arg); + thread->tid = _beginthread(thread_entry, NULL, 1024 * 1024, thread); return 0; } static av_always_inline int pthread_join(pthread_t thread, void **value_ptr) { - DosWaitThread((PTID)&thread, DCWW_WAIT); + DosWaitThread(&thread.tid, DCWW_WAIT); + + if (value_ptr) + *value_ptr = thread.result; return 0; } -static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) +static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, + const pthread_mutexattr_t *attr) { DosCreateMutexSem(NULL, (PHMTX)mutex, 0, FALSE); @@ -112,9 +124,11 @@ static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex) return 0; } -static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) +static av_always_inline int pthread_cond_init(pthread_cond_t *cond, + const pthread_condattr_t *attr) { DosCreateEventSem(NULL, &cond->event_sem, DCE_POSTONE, FALSE); + DosCreateEventSem(NULL, &cond->ack_sem, DCE_POSTONE, FALSE); cond->wait_count = 0; @@ -124,16 +138,16 @@ static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthrea static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond) { DosCloseEventSem(cond->event_sem); + DosCloseEventSem(cond->ack_sem); return 0; } static av_always_inline int pthread_cond_signal(pthread_cond_t *cond) { - if (cond->wait_count > 0) { + if (!__atomic_cmpxchg32(&cond->wait_count, 0, 0)) { DosPostEventSem(cond->event_sem); - - cond->wait_count--; + DosWaitEventSem(cond->ack_sem, SEM_INDEFINITE_WAIT); } return 0; @@ -141,26 +155,47 @@ static av_always_inline int pthread_cond_signal(pthread_cond_t *cond) static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond) { - while (cond->wait_count > 0) { - DosPostEventSem(cond->event_sem); - - cond->wait_count--; - } + while (!__atomic_cmpxchg32(&cond->wait_count, 0, 0)) + pthread_cond_signal(cond); return 0; } -static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) +static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, + pthread_mutex_t *mutex) { - cond->wait_count++; + __atomic_increment(&cond->wait_count); pthread_mutex_unlock(mutex); DosWaitEventSem(cond->event_sem, SEM_INDEFINITE_WAIT); + __atomic_decrement(&cond->wait_count); + + DosPostEventSem(cond->ack_sem); + pthread_mutex_lock(mutex); return 0; } -#endif /* AVCODEC_OS2PTHREADS_H */ +static av_always_inline int pthread_once(pthread_once_t *once_control, + void (*init_routine)(void)) +{ + if (!once_control->done) + { + _fmutex_request(&once_control->mtx, 0); + + if (!once_control->done) + { + init_routine(); + + once_control->done = 1; + } + + _fmutex_release(&once_control->mtx); + } + + return 0; +} +#endif /* COMPAT_OS2THREADS_H */ diff --git a/compat/solaris/make_sunver.pl b/compat/solaris/make_sunver.pl new file mode 100755 index 00000000..0e9ed1d3 --- /dev/null +++ b/compat/solaris/make_sunver.pl @@ -0,0 +1,352 @@ +#!/usr/bin/env perl + +# make_sunver.pl +# +# Copyright (C) 2010, 2011, 2012, 2013 +# Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING.GPLv3. If not see +# . + +# This script takes at least two arguments, a GNU style version script and +# a list of object and archive files, and generates a corresponding Sun +# style version script as follows: +# +# Each glob pattern, C++ mangled pattern or literal in the input script is +# matched against all global symbols in the input objects, emitting those +# that matched (or nothing if no match was found). +# A comment with the original pattern and its type is left in the output +# file to make it easy to understand the matches. +# +# It uses elfdump when present (native), GNU readelf otherwise. +# It depends on the GNU version of c++filt, since it must understand the +# GNU mangling style. + +use FileHandle; +use IPC::Open2; + +# Enforce C locale. +$ENV{'LC_ALL'} = "C"; +$ENV{'LANG'} = "C"; + +# Input version script, GNU style. +my $symvers = shift; + +########## +# Get all the symbols from the library, match them, and add them to a hash. + +my %sym_hash = (); + +# List of objects and archives to process. +my @OBJECTS = (); + +# List of shared objects to omit from processing. +my @SHAREDOBJS = (); + +# Filter out those input archives that have corresponding shared objects to +# avoid adding all symbols matched in the archive to the output map. +foreach $file (@ARGV) { + if (($so = $file) =~ s/\.a$/.so/ && -e $so) { + printf STDERR "omitted $file -> $so\n"; + push (@SHAREDOBJS, $so); + } else { + push (@OBJECTS, $file); + } +} + +# We need to detect and ignore hidden symbols. Solaris nm can only detect +# this in the harder to parse default output format, and GNU nm not at all, +# so use elfdump -s in the native case and GNU readelf -s otherwise. +# GNU objdump -t cannot be used since it produces a variable number of +# columns. + +# The path to elfdump. +my $elfdump = "/usr/ccs/bin/elfdump"; + +if (-f $elfdump) { + open ELFDUMP,$elfdump.' -s '.(join ' ',@OBJECTS).'|' or die $!; + my $skip_arsym = 0; + + while () { + chomp; + + # Ignore empty lines. + if (/^$/) { + # End of archive symbol table, stop skipping. + $skip_arsym = 0 if $skip_arsym; + next; + } + + # Keep skipping until end of archive symbol table. + next if ($skip_arsym); + + # Ignore object name header for individual objects and archives. + next if (/:$/); + + # Ignore table header lines. + next if (/^Symbol Table Section:/); + next if (/index.*value.*size/); + + # Start of archive symbol table: start skipping. + if (/^Symbol Table: \(archive/) { + $skip_arsym = 1; + next; + } + + # Split table. + (undef, undef, undef, undef, $bind, $oth, undef, $shndx, $name) = split; + + # Error out for unknown input. + die "unknown input line:\n$_" unless defined($bind); + + # Ignore local symbols. + next if ($bind eq "LOCL"); + # Ignore hidden symbols. + next if ($oth eq "H"); + # Ignore undefined symbols. + next if ($shndx eq "UNDEF"); + # Error out for unhandled cases. + if ($bind !~ /^(GLOB|WEAK)/ or $oth ne "D") { + die "unhandled symbol:\n$_"; + } + + # Remember symbol. + $sym_hash{$name}++; + } + close ELFDUMP or die "$elfdump error"; +} else { + open READELF, 'readelf -s -W '.(join ' ',@OBJECTS).'|' or die $!; + # Process each symbol. + while () { + chomp; + + # Ignore empty lines. + next if (/^$/); + + # Ignore object name header. + next if (/^File: .*$/); + + # Ignore table header lines. + next if (/^Symbol table.*contains.*:/); + next if (/Num:.*Value.*Size/); + + # Split table. + (undef, undef, undef, undef, $bind, $vis, $ndx, $name) = split; + + # Error out for unknown input. + die "unknown input line:\n$_" unless defined($bind); + + # Ignore local symbols. + next if ($bind eq "LOCAL"); + # Ignore hidden symbols. + next if ($vis eq "HIDDEN"); + # Ignore undefined symbols. + next if ($ndx eq "UND"); + # Error out for unhandled cases. + if ($bind !~ /^(GLOBAL|WEAK)/ or $vis ne "DEFAULT") { + die "unhandled symbol:\n$_"; + } + + # Remember symbol. + $sym_hash{$name}++; + } + close READELF or die "readelf error"; +} + +########## +# The various types of glob patterns. +# +# A glob pattern that is to be applied to the demangled name: 'cxx'. +# A glob patterns that applies directly to the name in the .o files: 'glob'. +# This pattern is ignored; used for local variables (usually just '*'): 'ign'. + +# The type of the current pattern. +my $glob = 'glob'; + +# We're currently inside `extern "C++"', which Sun ld doesn't understand. +my $in_extern = 0; + +# The c++filt command to use. This *must* be GNU c++filt; the Sun Studio +# c++filt doesn't handle the GNU mangling style. +my $cxxfilt = $ENV{'CXXFILT'} || "c++filt"; + +# The current version name. +my $current_version = ""; + +# Was there any attempt to match a symbol to this version? +my $matches_attempted; + +# The number of versions which matched this symbol. +my $matched_symbols; + +open F,$symvers or die $!; + +# Print information about generating this file +print "# This file was generated by make_sunver.pl. DO NOT EDIT!\n"; +print "# It was generated by:\n"; +printf "# %s %s %s\n", $0, $symvers, (join ' ',@ARGV); +printf "# Omitted archives with corresponding shared libraries: %s\n", + (join ' ', @SHAREDOBJS) if $#SHAREDOBJS >= 0; +print "#\n\n"; + +print "\$mapfile_version 2\n"; + +while () { + # Lines of the form '};' + if (/^([ \t]*)(\}[ \t]*;[ \t]*)$/) { + $glob = 'glob'; + if ($in_extern) { + $in_extern--; + print "$1##$2\n"; + } else { + print; + } + next; + } + + # Lines of the form '} SOME_VERSION_NAME_1.0;' + if (/^[ \t]*\}[ \tA-Z0-9_.a-z]+;[ \t]*$/) { + $glob = 'glob'; + # We tried to match symbols agains this version, but none matched. + # Emit dummy hidden symbol to avoid marking this version WEAK. + if ($matches_attempted && $matched_symbols == 0) { + print " hidden:\n"; + print " .force_WEAK_off_$current_version = DATA S0x0 V0x0;\n"; + } + print; next; + } + + # Comment and blank lines + if (/^[ \t]*\#/) { print; next; } + if (/^[ \t]*$/) { print; next; } + + # Lines of the form '{' + if (/^([ \t]*){$/) { + if ($in_extern) { + print "$1##{\n"; + } else { + print; + } + next; + } + + # Lines of the form 'SOME_VERSION_NAME_1.1 {' + if (/^([A-Z0-9_.]+)[ \t]+{$/) { + # Record version name. + $current_version = $1; + # Reset match attempts, #matched symbols for this version. + $matches_attempted = 0; + $matched_symbols = 0; + print "SYMBOL_VERSION $1 {\n"; + next; + } + + # Ignore 'global:' + if (/^[ \t]*global:$/) { print; next; } + + # After 'local:', globs should be ignored, they won't be exported. + if (/^[ \t]*local:$/) { + $glob = 'ign'; + print; + next; + } + + # After 'extern "C++"', globs are C++ patterns + if (/^([ \t]*)(extern \"C\+\+\"[ \t]*)$/) { + $in_extern++; + $glob = 'cxx'; + # Need to comment, Sun ld cannot handle this. + print "$1##$2\n"; next; + } + + # Chomp newline now we're done with passing through the input file. + chomp; + + # Catch globs. Note that '{}' is not allowed in globs by this script, + # so only '*' and '[]' are available. + if (/^([ \t]*)([^ \t;{}#]+);?[ \t]*$/) { + my $ws = $1; + my $ptn = $2; + # Turn the glob into a regex by replacing '*' with '.*', '?' with '.'. + # Keep $ptn so we can still print the original form. + ($pattern = $ptn) =~ s/\*/\.\*/g; + $pattern =~ s/\?/\./g; + + if ($glob eq 'ign') { + # We're in a local: * section; just continue. + print "$_\n"; + next; + } + + # Print the glob commented for human readers. + print "$ws##$ptn ($glob)\n"; + # We tried to match a symbol to this version. + $matches_attempted++; + + if ($glob eq 'glob') { + my %ptn_syms = (); + + # Match ptn against symbols in %sym_hash. + foreach my $sym (keys %sym_hash) { + # Maybe it matches one of the patterns based on the symbol in + # the .o file. + $ptn_syms{$sym}++ if ($sym =~ /^$pattern$/); + } + + foreach my $sym (sort keys(%ptn_syms)) { + $matched_symbols++; + print "$ws$sym;\n"; + } + } elsif ($glob eq 'cxx') { + my %dem_syms = (); + + # Verify that we're actually using GNU c++filt. Other versions + # most likely cannot handle GNU style symbol mangling. + my $cxxout = `$cxxfilt --version 2>&1`; + $cxxout =~ m/GNU/ or die "$0 requires GNU c++filt to function"; + + # Talk to c++filt through a pair of file descriptors. + # Need to start a fresh instance per pattern, otherwise the + # process grows to 500+ MB. + my $pid = open2(*FILTIN, *FILTOUT, $cxxfilt) or die $!; + + # Match ptn against symbols in %sym_hash. + foreach my $sym (keys %sym_hash) { + # No? Well, maybe its demangled form matches one of those + # patterns. + printf FILTOUT "%s\n",$sym; + my $dem = ; + chomp $dem; + $dem_syms{$sym}++ if ($dem =~ /^$pattern$/); + } + + close FILTOUT or die "c++filt error"; + close FILTIN or die "c++filt error"; + # Need to wait for the c++filt process to avoid lots of zombies. + waitpid $pid, 0; + + foreach my $sym (sort keys(%dem_syms)) { + $matched_symbols++; + print "$ws$sym;\n"; + } + } else { + # No? Well, then ignore it. + } + next; + } + # Important sanity check. This script can't handle lots of formats + # that GNU ld can, so be sure to error out if one is seen! + die "strange line `$_'"; +} +close F; diff --git a/compat/tms470/math.h b/compat/tms470/math.h index 6234cc59..0a42743a 100644 --- a/compat/tms470/math.h +++ b/compat/tms470/math.h @@ -16,8 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef FFMPEG_COMPAT_TMS470_MATH_H -#define FFMPEG_COMPAT_TMS470_MATH_H +#ifndef COMPAT_TMS470_MATH_H +#define COMPAT_TMS470_MATH_H #include_next @@ -27,4 +27,4 @@ #define INFINITY (*(const float*)((const unsigned []){ 0x7f800000 })) #define NAN (*(const float*)((const unsigned []){ 0x7fc00000 })) -#endif /* FFMPEG_COMPAT_TMS470_MATH_H */ +#endif /* COMPAT_TMS470_MATH_H */ diff --git a/compat/va_copy.h b/compat/va_copy.h index 3cb5ebee..a40bbe66 100644 --- a/compat/va_copy.h +++ b/compat/va_copy.h @@ -19,6 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef COMPAT_VA_COPY_H +#define COMPAT_VA_COPY_H + #include #if !defined(va_copy) && defined(_MSC_VER) @@ -27,3 +30,5 @@ #if !defined(va_copy) && defined(__GNUC__) && __GNUC__ < 3 #define va_copy(dst, src) __va_copy(dst, src) #endif + +#endif /* COMPAT_VA_COPY_H */ diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h index 87e816ff..4ac2a995 100644 --- a/compat/w32pthreads.h +++ b/compat/w32pthreads.h @@ -26,8 +26,8 @@ * w32threads to pthreads wrapper */ -#ifndef FFMPEG_COMPAT_W32PTHREADS_H -#define FFMPEG_COMPAT_W32PTHREADS_H +#ifndef COMPAT_W32PTHREADS_H +#define COMPAT_W32PTHREADS_H /* Build up a pthread-like API using underlying Windows API. Have only static * methods so as to not conflict with a potentially linked in pthread-win32 @@ -39,6 +39,11 @@ #include #include +#if _WIN32_WINNT < 0x0600 && defined(__MINGW32__) +#undef MemoryBarrier +#define MemoryBarrier __sync_synchronize +#endif + #include "libavutil/attributes.h" #include "libavutil/common.h" #include "libavutil/internal.h" @@ -82,19 +87,29 @@ static av_unused int pthread_create(pthread_t *thread, const void *unused_attr, { thread->func = start_routine; thread->arg = arg; +#if HAVE_WINRT + thread->handle = (void*)CreateThread(NULL, 0, win32thread_worker, thread, + 0, NULL); +#else thread->handle = (void*)_beginthreadex(NULL, 0, win32thread_worker, thread, 0, NULL); +#endif return !thread->handle; } -static av_unused void pthread_join(pthread_t thread, void **value_ptr) +static av_unused int pthread_join(pthread_t thread, void **value_ptr) { DWORD ret = WaitForSingleObject(thread.handle, INFINITE); - if (ret != WAIT_OBJECT_0) - return; + if (ret != WAIT_OBJECT_0) { + if (ret == WAIT_ABANDONED) + return EINVAL; + else + return EDEADLK; + } if (value_ptr) *value_ptr = thread.ret; CloseHandle(thread.handle); + return 0; } static inline int pthread_mutex_init(pthread_mutex_t *m, void* attr) @@ -119,6 +134,19 @@ static inline int pthread_mutex_unlock(pthread_mutex_t *m) } #if _WIN32_WINNT >= 0x0600 +typedef INIT_ONCE pthread_once_t; +#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT + +static av_unused int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) +{ + BOOL pending = FALSE; + InitOnceBeginInitialize(once_control, 0, &pending, NULL); + if (pending) + init_routine(); + InitOnceComplete(once_control, 0, NULL); + return 0; +} + static inline int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) { InitializeConditionVariable(cond); @@ -126,14 +154,15 @@ static inline int pthread_cond_init(pthread_cond_t *cond, const void *unused_att } /* native condition variables do not destroy */ -static inline void pthread_cond_destroy(pthread_cond_t *cond) +static inline int pthread_cond_destroy(pthread_cond_t *cond) { - return; + return 0; } -static inline void pthread_cond_broadcast(pthread_cond_t *cond) +static inline int pthread_cond_broadcast(pthread_cond_t *cond) { WakeAllConditionVariable(cond); + return 0; } static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) @@ -142,14 +171,77 @@ static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex return 0; } -static inline void pthread_cond_signal(pthread_cond_t *cond) +static inline int pthread_cond_signal(pthread_cond_t *cond) { WakeConditionVariable(cond); + return 0; } #else // _WIN32_WINNT < 0x0600 + +/* atomic init state of dynamically loaded functions */ +static LONG w32thread_init_state = 0; +static av_unused void w32thread_init(void); + +/* for pre-Windows 6.0 platforms, define INIT_ONCE struct, + * compatible to the one used in the native API */ + +typedef union pthread_once_t { + void * Ptr; ///< For the Windows 6.0+ native functions + LONG state; ///< For the pre-Windows 6.0 compat code +} pthread_once_t; + +#define PTHREAD_ONCE_INIT {0} + +/* function pointers to init once API on windows 6.0+ kernels */ +static BOOL (WINAPI *initonce_begin)(pthread_once_t *lpInitOnce, DWORD dwFlags, BOOL *fPending, void **lpContext); +static BOOL (WINAPI *initonce_complete)(pthread_once_t *lpInitOnce, DWORD dwFlags, void *lpContext); + +/* pre-Windows 6.0 compat using a spin-lock */ +static inline void w32thread_once_fallback(LONG volatile *state, void (*init_routine)(void)) +{ + switch (InterlockedCompareExchange(state, 1, 0)) { + /* Initial run */ + case 0: + init_routine(); + InterlockedExchange(state, 2); + break; + /* Another thread is running init */ + case 1: + while (1) { + MemoryBarrier(); + if (*state == 2) + break; + Sleep(0); + } + break; + /* Initialization complete */ + case 2: + break; + } +} + +static av_unused int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) +{ + w32thread_once_fallback(&w32thread_init_state, w32thread_init); + + /* Use native functions on Windows 6.0+ */ + if (initonce_begin && initonce_complete) { + BOOL pending = FALSE; + initonce_begin(once_control, 0, &pending, NULL); + if (pending) + init_routine(); + initonce_complete(once_control, 0, NULL); + return 0; + } + + w32thread_once_fallback(&once_control->state, init_routine); + return 0; +} + /* for pre-Windows 6.0 platforms we need to define and use our own condition * variable and api */ + typedef struct win32_cond_t { pthread_mutex_t mtx_broadcast; pthread_mutex_t mtx_waiter_count; @@ -169,6 +261,9 @@ static BOOL (WINAPI *cond_wait)(pthread_cond_t *cond, pthread_mutex_t *mutex, static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) { win32_cond_t *win32_cond = NULL; + + w32thread_once_fallback(&w32thread_init_state, w32thread_init); + if (cond_init) { cond_init(cond); return 0; @@ -191,12 +286,12 @@ static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_ return 0; } -static av_unused void pthread_cond_destroy(pthread_cond_t *cond) +static av_unused int pthread_cond_destroy(pthread_cond_t *cond) { win32_cond_t *win32_cond = cond->Ptr; /* native condition variables do not destroy */ if (cond_init) - return; + return 0; /* non native condition variables */ CloseHandle(win32_cond->semaphore); @@ -205,16 +300,17 @@ static av_unused void pthread_cond_destroy(pthread_cond_t *cond) pthread_mutex_destroy(&win32_cond->mtx_broadcast); av_freep(&win32_cond); cond->Ptr = NULL; + return 0; } -static av_unused void pthread_cond_broadcast(pthread_cond_t *cond) +static av_unused int pthread_cond_broadcast(pthread_cond_t *cond) { win32_cond_t *win32_cond = cond->Ptr; int have_waiter; if (cond_broadcast) { cond_broadcast(cond); - return; + return 0; } /* non native condition variables */ @@ -236,6 +332,7 @@ static av_unused void pthread_cond_broadcast(pthread_cond_t *cond) } else pthread_mutex_unlock(&win32_cond->mtx_waiter_count); pthread_mutex_unlock(&win32_cond->mtx_broadcast); + return 0; } static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) @@ -270,13 +367,13 @@ static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mu return pthread_mutex_lock(mutex); } -static av_unused void pthread_cond_signal(pthread_cond_t *cond) +static av_unused int pthread_cond_signal(pthread_cond_t *cond) { win32_cond_t *win32_cond = cond->Ptr; int have_waiter; if (cond_signal) { cond_signal(cond); - return; + return 0; } pthread_mutex_lock(&win32_cond->mtx_broadcast); @@ -293,6 +390,7 @@ static av_unused void pthread_cond_signal(pthread_cond_t *cond) } pthread_mutex_unlock(&win32_cond->mtx_broadcast); + return 0; } #endif @@ -309,8 +407,12 @@ static av_unused void w32thread_init(void) (void*)GetProcAddress(kernel_dll, "WakeConditionVariable"); cond_wait = (void*)GetProcAddress(kernel_dll, "SleepConditionVariableCS"); + initonce_begin = + (void*)GetProcAddress(kernel_dll, "InitOnceBeginInitialize"); + initonce_complete = + (void*)GetProcAddress(kernel_dll, "InitOnceComplete"); #endif } -#endif /* FFMPEG_COMPAT_W32PTHREADS_H */ +#endif /* COMPAT_W32PTHREADS_H */ diff --git a/compat/windows/mslink b/compat/windows/mslink new file mode 100755 index 00000000..07b2b3e3 --- /dev/null +++ b/compat/windows/mslink @@ -0,0 +1,9 @@ +#!/bin/sh + +LINK_EXE_PATH=$(dirname "$(command -v cl)")/link +if [ -x "$LINK_EXE_PATH" ]; then + "$LINK_EXE_PATH" $@ +else + link $@ +fi +exit $? diff --git a/configure b/configure index 7f1b5c00..206b1690 100755 --- a/configure +++ b/configure @@ -128,7 +128,6 @@ Component options: --disable-avdevice disable libavdevice build --disable-avcodec disable libavcodec build --disable-avformat disable libavformat build - --disable-avutil disable libavutil build --disable-swresample disable libswresample build --disable-swscale disable libswscale build --disable-postproc disable libpostproc build @@ -155,6 +154,7 @@ Hardware accelerators: --disable-vaapi disable VAAPI code [autodetect] --disable-vda disable VDA code [autodetect] --disable-vdpau disable VDPAU code [autodetect] + --enable-videotoolbox enable VideoToolbox code [autodetect] Individual component options: --disable-everything disable all components listed below @@ -196,13 +196,17 @@ Individual component options: External library support: --enable-avisynth enable reading of AviSynth script files [no] --disable-bzlib disable bzlib [autodetect] + --enable-chromaprint enable audio fingerprinting with chromaprint [no] --enable-fontconfig enable fontconfig, useful for drawtext filter [no] --enable-frei0r enable frei0r video filtering [no] + --enable-gcrypt enable gcrypt, needed for rtmp(t)e support + if openssl, librtmp or gmp is not used [no] + --enable-gmp enable gmp, needed for rtmp(t)e support + if openssl or librtmp is not used [no] --enable-gnutls enable gnutls, needed for https support if openssl is not used [no] --disable-iconv disable iconv [autodetect] --enable-ladspa enable LADSPA audio filtering [no] - --enable-libaacplus enable AAC+ encoding via libaacplus [no] --enable-libass enable libass subtitles rendering, needed for subtitles and ass filter [no] --enable-libbluray enable BluRay reading using libbluray [no] @@ -222,6 +226,7 @@ External library support: --enable-libgsm enable GSM de/encoding via libgsm [no] --enable-libiec61883 enable iec61883 via libiec61883 [no] --enable-libilbc enable iLBC de/encoding via libilbc [no] + --enable-libkvazaar enable HEVC encoding via libkvazaar [no] --enable-libmfx enable HW acceleration through libmfx --enable-libmodplug enable ModPlug via libmodplug [no] --enable-libmp3lame enable MP3 encoding via libmp3lame [no] @@ -234,21 +239,21 @@ External library support: --enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no] --enable-libopus enable Opus de/encoding via libopus [no] --enable-libpulse enable Pulseaudio input via libpulse [no] - --enable-libquvi enable quvi input via libquvi [no] + --enable-librubberband enable rubberband needed for rubberband filter [no] --enable-librtmp enable RTMP[E] support via librtmp [no] --enable-libschroedinger enable Dirac de/encoding via libschroedinger [no] --enable-libshine enable fixed-point MP3 encoding via libshine [no] --enable-libsmbclient enable Samba protocol via libsmbclient [no] + --enable-libsnappy enable Snappy compression, needed for hap encoding [no] --enable-libsoxr enable Include libsoxr resampling [no] --enable-libspeex enable Speex de/encoding via libspeex [no] --enable-libssh enable SFTP protocol via libssh [no] - --enable-libstagefright-h264 enable H.264 decoding via libstagefright [no] + --enable-libtesseract enable Tesseract, needed for ocr filter [no] --enable-libtheora enable Theora encoding via libtheora [no] --enable-libtwolame enable MP2 encoding via libtwolame [no] --enable-libutvideo enable Ut Video encoding and decoding via libutvideo [no] --enable-libv4l2 enable libv4l2/v4l-utils [no] --enable-libvidstab enable video stabilization using vid.stab [no] - --enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no] --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no] --enable-libvorbis enable Vorbis en/decoding via libvorbis, native implementation exists [no] @@ -264,17 +269,21 @@ External library support: --enable-libxcb-shape enable X11 grabbing shape rendering [autodetect] --enable-libxvid enable Xvid encoding via xvidcore, native MPEG-4/Xvid encoder exists [no] + --enable-libzimg enable z.lib, needed for zscale filter [no] --enable-libzmq enable message passing via libzmq [no] --enable-libzvbi enable teletext support via libzvbi [no] --disable-lzma disable lzma [autodetect] - --enable-decklink enable Blackmagick DeckLink I/O support [no] + --enable-decklink enable Blackmagic DeckLink I/O support [no] --enable-mmal enable decoding via MMAL [no] + --enable-netcdf enable NetCDF, needed for sofalizer filter [no] --enable-nvenc enable NVIDIA NVENC support [no] --enable-openal enable OpenAL 1.1 capture support [no] --enable-opencl enable OpenCL code --enable-opengl enable OpenGL rendering [no] --enable-openssl enable openssl, needed for https support if gnutls is not used [no] + --disable-schannel disable SChannel SSP, needed for TLS support on + Windows if openssl and gnutls are not used [autodetect] --disable-sdl disable sdl [autodetect] --disable-securetransport disable Secure Transport, needed for TLS support on OSX if openssl and gnutls are not used [autodetect] @@ -304,6 +313,7 @@ Toolchain options: --yasmexe=EXE use yasm-compatible assembler EXE [$yasmexe_default] --cc=CC use C compiler CC [$cc_default] --cxx=CXX use C compiler CXX [$cxx_default] + --objcc=OCC use ObjC compiler OCC [$cc_default] --dep-cc=DEPCC use dependency generator DEPCC [$cc_default] --ld=LD use linker LD [$ld_default] --pkg-config=PKGCONFIG use pkg-config tool PKGCONFIG [$pkg_config_default] @@ -319,8 +329,10 @@ Toolchain options: --host-os=OS compiler host OS [$target_os] --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS] --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS] + --extra-objcflags=FLAGS add FLAGS to OBJCFLAGS [$CFLAGS] --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS] --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS] + --extra-ldlibflags=ELDFLAGS add ELDFLAGS to LDLIBFLAGS [$LDLIBFLAGS] --extra-libs=ELIBS add ELIBS [$ELIBS] --extra-version=STRING version string suffix [] --optflags=OPTFLAGS override optimization-related compiler flags @@ -332,6 +344,7 @@ Toolchain options: Advanced options (experts only): --malloc-prefix=PREFIX prefix malloc and related names with PREFIX + --custom-allocator=NAME use a supported custom allocator --disable-symver disable symbol versioning --enable-hardcoded-tables use hardcoded tables instead of runtime generation --disable-safe-bitstream-reader @@ -360,6 +373,7 @@ Optimization options (experts only): --disable-fma3 disable FMA3 optimizations --disable-fma4 disable FMA4 optimizations --disable-avx2 disable AVX2 optimizations + --disable-aesni disable AESNI optimizations --disable-armv5te disable armv5te optimizations --disable-armv6 disable armv6 optimizations --disable-armv6t2 disable armv6t2 optimizations @@ -367,13 +381,11 @@ Optimization options (experts only): --disable-neon disable NEON optimizations --disable-inline-asm disable use of inline assembly --disable-yasm disable use of nasm/yasm assembly - --disable-mips32r5 disable MIPS32R5 optimizations - --disable-mips64r6 disable MIPS64R6 optimizations - --disable-mipsdspr1 disable MIPS DSP ASE R1 optimizations + --disable-mipsdsp disable MIPS DSP ASE R1 optimizations --disable-mipsdspr2 disable MIPS DSP ASE R2 optimizations --disable-msa disable MSA optimizations --disable-mipsfpu disable floating point MIPS optimizations - --disable-loongson3 disable Loongson-3 SIMD optimizations + --disable-mmi disable Loongson SIMD optimizations --disable-fast-unaligned consider unaligned accesses slow Developer options (useful when working on FFmpeg itself): @@ -412,6 +424,18 @@ EOF } quotes='""' +if test -t 1 && which tput >/dev/null 2>&1; then + ncolors=$(tput colors) + if test -n "$ncolors" && test $ncolors -ge 8; then + bold_color=$(tput bold) + warn_color=$(tput setaf 3) + error_color=$(tput setaf 1) + reset_color=$(tput sgr0) + fi + # 72 used instead of 80 since that's the default of pr + ncols=$(tput cols) +fi +: ${ncols:=72} log(){ echo "$@" >> $logfile @@ -423,18 +447,14 @@ log_file(){ log END $1 } -echolog(){ - log "$@" - echo "$@" -} - warn(){ log "WARNING: $*" WARNINGS="${WARNINGS}WARNING: $*\n" } die(){ - echolog "$@" + log "$@" + echo "$error_color$bold_color$@$reset_color" cat < $TMPM log_file $TMPM - check_cmd $cc -Werror=missing-prototypes $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPM + check_cmd $objcc -Werror=missing-prototypes $CPPFLAGS $CFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) $TMPM } check_cpp(){ @@ -885,6 +913,25 @@ void foo(void){ __asm__ volatile($code); } EOF } +check_inline_asm_flags(){ + log check_inline_asm_flags "$@" + name="$1" + code="$2" + flags='' + shift 2 + while [ "$1" != "" ]; do + append flags $1 + shift + done; + disable $name + cat > $TMPC <" echo "int main(void) { return 0; }" - } | check_oc && check_stat "$TMPO" && enable_safe $headers + } | check_objcc && check_stat "$TMPO" && enable_safe $headers } check_func(){ @@ -1024,6 +1084,21 @@ int main(void){ $func(); } EOF } +check_complexfunc(){ + log check_complexfunc "$@" + func=$1 + narg=$2 + shift 2 + test $narg = 2 && args="f, g" || args="f * I" + disable $func + check_ld "cc" "$@" < +#include +float foo(complex float f, complex float g) { return $func($args); } +int main(void){ return (int) foo; } +EOF +} + check_mathfunc(){ log check_mathfunc "$@" func=$1 @@ -1304,12 +1379,6 @@ check_host_cpp_condition(){ EOF } -apply(){ - file=$1 - shift - "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp" -} - cp_if_changed(){ cmp -s "$1" "$2" && echo "$2 is unchanged" && return mkdir -p "$(dirname $2)" @@ -1319,23 +1388,42 @@ cp_if_changed(){ # CONFIG_LIST contains configurable options, while HAVE_LIST is for # system-dependent things. -COMPONENT_LIST=" +AVCODEC_COMPONENTS=" bsfs decoders - demuxers encoders - filters hwaccels + parsers +" + +AVDEVICE_COMPONENTS=" indevs - muxers outdevs - parsers +" +AVFILTER_COMPONENTS=" + filters +" +AVFORMAT_COMPONENTS=" + demuxers + muxers protocols " +AVRESAMPLE_COMPONENTS="" +AVUTIL_COMPONENTS="" + +COMPONENT_LIST=" + $AVCODEC_COMPONENTS + $AVDEVICE_COMPONENTS + $AVFILTER_COMPONENTS + $AVFORMAT_COMPONENTS + $AVRESAMPLE_COMPONENTS + $AVUTIL_COMPONENTS +" + EXAMPLE_LIST=" avio_reading_example - avio_list_dir_example + avio_dir_cmd_example decoding_encoding_example demuxing_decoding_example extract_mvs_example @@ -1355,13 +1443,15 @@ EXAMPLE_LIST=" EXTERNAL_LIBRARY_LIST=" avisynth bzlib + chromaprint crystalhd decklink frei0r + gcrypt + gmp gnutls iconv ladspa - libaacplus libass libbluray libbs2b @@ -1380,6 +1470,7 @@ EXTERNAL_LIBRARY_LIST=" libgsm libiec61883 libilbc + libkvazaar libmfx libmodplug libmp3lame @@ -1391,21 +1482,21 @@ EXTERNAL_LIBRARY_LIST=" libopenjpeg libopus libpulse - libquvi librtmp + librubberband libschroedinger libshine libsmbclient + libsnappy libsoxr libspeex libssh - libstagefright_h264 + libtesseract libtheora libtwolame libutvideo libv4l2 libvidstab - libvo_aacenc libvo_amrwbenc libvorbis libvpx @@ -1419,15 +1510,18 @@ EXTERNAL_LIBRARY_LIST=" libxcb_shape libxcb_xfixes libxvid + libzimg libzmq libzvbi lzma mmal + netcdf nvenc openal opencl opengl openssl + schannel sdl securetransport x11grab @@ -1461,6 +1555,7 @@ HWACCEL_LIST=" vaapi vda vdpau + videotoolbox xvmc " @@ -1582,17 +1677,22 @@ ARCH_EXT_LIST_MIPS=" mipsfpu mips32r2 mips32r5 + mips64r2 + mips32r6 mips64r6 - mipsdspr1 + mipsdsp mipsdspr2 msa " ARCH_EXT_LIST_LOONGSON=" + loongson2 loongson3 + mmi " ARCH_EXT_LIST_X86_SIMD=" + aesni amd3dnow amd3dnowext avx @@ -1679,6 +1779,7 @@ HEADERS_LIST=" dev_video_bktr_ioctl_bt848_h dev_video_meteor_ioctl_meteor_h direct_h + dirent_h dlfcn_h d3d11_h dxva_h @@ -1689,6 +1790,9 @@ HEADERS_LIST=" machine_ioctl_bt848_h machine_ioctl_meteor_h malloc_h + opencv2_core_core_c_h + openjpeg_2_1_openjpeg_h + openjpeg_2_0_openjpeg_h openjpeg_1_5_openjpeg_h OpenGL_gl3_h poll_h @@ -1714,15 +1818,24 @@ INTRINSICS_LIST=" intrinsics_neon " +COMPLEX_FUNCS=" + cabs + cexp +" + MATH_FUNCS=" atanf atan2f cbrt cbrtf + copysign cosf + erf exp2 exp2f expf + hypot + isfinite isinf isnan ldexpf @@ -1745,6 +1858,7 @@ MATH_FUNCS=" SYSTEM_FUNCS=" access aligned_malloc + arc4random clock_gettime closesocket CommandLineToArgvW @@ -1761,7 +1875,6 @@ SYSTEM_FUNCS=" GetProcessMemoryInfo GetProcessTimes getrusage - getservbyport GetSystemTimeAsFileTime gettimeofday glob @@ -1772,6 +1885,7 @@ SYSTEM_FUNCS=" jack_port_get_latency_range kbhit localtime_r + lstat lzo1x_999_compress mach_absolute_time MapViewOfFile @@ -1785,6 +1899,7 @@ SYSTEM_FUNCS=" pthread_cancel sched_getaffinity SetConsoleTextAttribute + SetConsoleCtrlHandler setmode setrlimit Sleep @@ -1792,6 +1907,7 @@ SYSTEM_FUNCS=" sysconf sysctl usleep + UTGetOSTypeFromString VirtualAlloc wglGetProcAddress " @@ -1808,9 +1924,9 @@ TOOLCHAIN_FEATURES=" gnu_as gnu_windres ibm_asm + inline_asm_direct_symbol_refs inline_asm_labels inline_asm_nonlocal_labels - inline_asm_direct_symbol_refs pragma_deprecated rsync_contimeout symver_asm_label @@ -1844,6 +1960,7 @@ HAVE_LIST=" $ARCH_FEATURES $ATOMICS_LIST $BUILTIN_LIST + $COMPLEX_FUNCS $HAVE_LIST_CMDLINE $HAVE_LIST_PUB $HEADERS_LIST @@ -1855,8 +1972,8 @@ HAVE_LIST=" $TYPES_LIST atomics_native dos_paths - dxva2api_cobj dxva2_lib + dxva2api_cobj libc_msvcrt libdc1394_1 libdc1394_2 @@ -1870,6 +1987,7 @@ HAVE_LIST=" threads vaapi_x11 vdpau_x11 + winrt xlib " @@ -1882,15 +2000,16 @@ CONFIG_EXTRA=" blockdsp bswapdsp cabac + dirac_parse dvprofile exif faandct faanidct fdctdsp + flacdsp fmtconvert frame_thread_encoder - gcrypt - gmp + g722dsp golomb gplv3 h263dsp @@ -1906,17 +2025,21 @@ CONFIG_EXTRA=" iirfilter imdct15 intrax8 + ividsp jpegtables lgplv3 + libx262 llauddsp llviddsp lpc + lzf me_cmp mpeg_er mpegaudio mpegaudiodsp mpegvideo mpegvideoenc + mss34dsp pixblockdsp qpeldsp qsv @@ -1927,12 +2050,19 @@ CONFIG_EXTRA=" riffenc rtpdec rtpenc_chain + rv34dsp sinewin + snappy startcode + texturedsp + texturedspenc tpeldsp videodsp vp3dsp + vp56dsp + vp8dsp wma_freqs + wmv2dsp " CMDLINE_SELECT=" @@ -1971,8 +2101,10 @@ CMDLINE_SET=" assert_level build_suffix cc + objcc cpu cross_prefix + custom_allocator cxx dep_cc doxygen @@ -2014,6 +2146,7 @@ CMDLINE_SET=" CMDLINE_APPEND=" extra_cflags extra_cxxflags + extra_objcflags host_cppflags " @@ -2034,13 +2167,15 @@ setend_deps="arm" map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM mipsfpu_deps="mips" -mipsdspr1_deps="mips" +mipsdsp_deps="mips" mipsdspr2_deps="mips" mips32r2_deps="mips" mips32r5_deps="mips" +mips32r6_deps="mips" +mips64r2_deps="mips" mips64r6_deps="mips" -msa_deps="mips" -loongson3_deps="mips" +msa_deps="mipsfpu" +mmi_deps="mips" altivec_deps="ppc" dcbzl_deps="ppc" @@ -2064,6 +2199,7 @@ sse3_deps="sse2" ssse3_deps="sse3" sse4_deps="ssse3" sse42_deps="sse4" +aesni_deps="sse42" avx_deps="sse42" xop_deps="avx" fma3_deps="avx" @@ -2101,30 +2237,34 @@ threads_if_any="$THREADS_LIST" # subsystems dct_select="rdft" +dirac_parse_select="golomb" error_resilience_select="me_cmp" faandct_deps="faan fdctdsp" faanidct_deps="faan idctdsp" frame_thread_encoder_deps="encoders threads" intrax8_select="error_resilience" mdct_select="fft" -rdft_select="fft" me_cmp_select="fdctdsp idctdsp pixblockdsp" mpeg_er_select="error_resilience" mpegaudio_select="mpegaudiodsp" mpegaudiodsp_select="dct" -mpegvideo_select="blockdsp h264chroma hpeldsp idctdsp me_cmp videodsp" +mpegvideo_select="blockdsp h264chroma hpeldsp idctdsp me_cmp mpeg_er videodsp" mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp" qsvdec_select="qsv" qsvenc_select="qsv" +rdft_select="fft" # decoders / encoders aac_decoder_select="imdct15 mdct sinewin" -aac_encoder_select="audio_frame_queue iirfilter mdct sinewin" +aac_fixed_decoder_select="mdct sinewin" +aac_encoder_select="audio_frame_queue iirfilter lpc mdct sinewin" aac_latm_decoder_select="aac_decoder aac_latm_parser" ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct" ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp mdct" ac3_encoder_select="ac3dsp audiodsp mdct me_cmp" ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp" +adpcm_g722_decoder_select="g722dsp" +adpcm_g722_encoder_select="g722dsp" aic_decoder_select="golomb idctdsp" alac_encoder_select="lpc" als_decoder_select="bswapdsp" @@ -2152,13 +2292,15 @@ comfortnoise_encoder_select="lpc" cook_decoder_select="audiodsp mdct sinewin" cscd_decoder_select="lzo" cscd_decoder_suggest="zlib" -dca_decoder_select="fmtconvert mdct" -dirac_decoder_select="dwt golomb videodsp mpegvideoenc" +dca_decoder_select="mdct" +dds_decoder_select="texturedsp" +dirac_decoder_select="dirac_parse dwt golomb videodsp mpegvideoenc" dnxhd_decoder_select="blockdsp idctdsp" dnxhd_encoder_select="aandcttables blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp" dvvideo_decoder_select="dvprofile idctdsp" dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp" dxa_decoder_select="zlib" +dxv_decoder_select="lzf texturedsp" eac3_decoder_select="ac3_decoder" eac3_encoder_select="ac3_encoder" eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpegvideo" @@ -2170,21 +2312,21 @@ ffv1_encoder_select="rangecoder" ffvhuff_decoder_select="huffyuv_decoder" ffvhuff_encoder_select="huffyuv_encoder" fic_decoder_select="golomb" -flac_decoder_select="golomb" -flac_encoder_select="bswapdsp golomb lpc" +flac_decoder_select="flacdsp golomb" +flac_encoder_select="bswapdsp flacdsp golomb lpc" +flashsv2_decoder_select="zlib" +flashsv2_encoder_select="zlib" flashsv_decoder_select="zlib" flashsv_encoder_select="zlib" -flashsv2_encoder_select="zlib" -flashsv2_decoder_select="zlib" flv_decoder_select="h263_decoder" flv_encoder_select="h263_encoder" fourxm_decoder_select="blockdsp bswapdsp" fraps_decoder_select="bswapdsp huffman" g2m_decoder_select="blockdsp idctdsp jpegtables zlib" g729_decoder_select="audiodsp" -h261_decoder_select="mpeg_er mpegvideo" +h261_decoder_select="mpegvideo" h261_encoder_select="aandcttables mpegvideoenc" -h263_decoder_select="error_resilience h263_parser h263dsp mpeg_er mpegvideo qpeldsp" +h263_decoder_select="h263_parser h263dsp mpegvideo qpeldsp" h263_encoder_select="aandcttables h263dsp mpegvideoenc" h263i_decoder_select="h263_decoder" h263p_decoder_select="h263_decoder" @@ -2195,12 +2337,21 @@ h264_qsv_decoder_deps="libmfx" h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec h264_qsv_hwaccel" h264_qsv_encoder_deps="libmfx" h264_qsv_encoder_select="qsvenc" +hap_decoder_select="snappy texturedsp" +hap_encoder_deps="libsnappy" +hap_encoder_select="texturedspenc" hevc_decoder_select="bswapdsp cabac golomb videodsp" +hevc_qsv_decoder_deps="libmfx" +hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec hevc_qsv_hwaccel" +hevc_qsv_encoder_deps="libmfx" +hevc_qsv_encoder_select="qsvenc" huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp" huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llviddsp" iac_decoder_select="imc_decoder" imc_decoder_select="bswapdsp fft mdct sinewin" indeo3_decoder_select="hpeldsp" +indeo4_decoder_select="ividsp" +indeo5_decoder_select="ividsp" interplay_video_decoder_select="hpeldsp" jpegls_decoder_select="golomb mjpeg_decoder" jpegls_encoder_select="golomb" @@ -2230,19 +2381,25 @@ mpc7_decoder_select="bswapdsp mpegaudiodsp" mpc8_decoder_select="mpegaudiodsp" mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h" mpeg_xvmc_decoder_select="mpeg2video_decoder" -mpegvideo_decoder_select="error_resilience mpeg_er mpegvideo" -mpeg1video_decoder_select="error_resilience mpeg_er mpegvideo" +mpegvideo_decoder_select="mpegvideo" +mpeg1video_decoder_select="mpegvideo" mpeg1video_encoder_select="aandcttables mpegvideoenc h263dsp" -mpeg2video_decoder_select="error_resilience mpeg_er mpegvideo" +mpeg2video_decoder_select="mpegvideo" mpeg2video_encoder_select="aandcttables mpegvideoenc h263dsp" +mpeg2_qsv_decoder_deps="libmfx" +mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel" +mpeg2_qsv_encoder_deps="libmfx" +mpeg2_qsv_encoder_select="qsvenc" mpeg4_decoder_select="h263_decoder mpeg4video_parser" mpeg4_encoder_select="h263_encoder" +msa1_decoder_select="mss34dsp" msmpeg4v1_decoder_select="h263_decoder" msmpeg4v2_decoder_select="h263_decoder" msmpeg4v2_encoder_select="h263_encoder" msmpeg4v3_decoder_select="h263_decoder" msmpeg4v3_encoder_select="h263_encoder" -mss2_decoder_select="error_resilience mpeg_er qpeldsp vc1_decoder" +mss2_decoder_select="vc1_decoder" +mts2_decoder_select="mss34dsp" mxpeg_decoder_select="mjpeg_decoder" nellymoser_decoder_select="mdct sinewin" nellymoser_encoder_select="audio_frame_queue mdct sinewin" @@ -2256,17 +2413,19 @@ prores_decoder_select="blockdsp idctdsp" prores_encoder_select="fdctdsp" qcelp_decoder_select="lsp" qdm2_decoder_select="mdct rdft mpegaudiodsp" -ra_144_encoder_select="audio_frame_queue lpc audiodsp" ra_144_decoder_select="audiodsp" +ra_144_encoder_select="audio_frame_queue lpc audiodsp" ralf_decoder_select="golomb" rawvideo_decoder_select="bswapdsp" +rscc_decoder_select="zlib" rtjpeg_decoder_select="me_cmp" -rv10_decoder_select="error_resilience h263_decoder h263dsp mpeg_er" +rv10_decoder_select="h263_decoder" rv10_encoder_select="h263_encoder" -rv20_decoder_select="error_resilience h263_decoder h263dsp mpeg_er" +rv20_decoder_select="h263_decoder" rv20_encoder_select="h263_encoder" -rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo videodsp" -rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo videodsp" +rv30_decoder_select="golomb h264pred h264qpel mpegvideo rv34dsp" +rv40_decoder_select="golomb h264pred h264qpel mpegvideo rv34dsp" +screenpresso_decoder_select="zlib" shorten_decoder_select="golomb" sipr_decoder_select="lsp" snow_decoder_select="dwt h264qpel hpeldsp me_cmp rangecoder videodsp" @@ -2290,22 +2449,25 @@ truemotion2_decoder_select="bswapdsp" truespeech_decoder_select="bswapdsp" tscc_decoder_select="zlib" twinvq_decoder_select="mdct lsp sinewin" +txd_decoder_select="texturedsp" utvideo_decoder_select="bswapdsp" utvideo_encoder_select="bswapdsp huffman huffyuvencdsp" vble_decoder_select="huffyuvdsp" -vc1_decoder_select="blockdsp error_resilience h263_decoder h264chroma h264qpel intrax8 mpeg_er qpeldsp startcode" +vc1_decoder_select="blockdsp h263_decoder h264qpel intrax8 qpeldsp startcode" +vc1_qsv_decoder_deps="libmfx" +vc1_qsv_decoder_select="qsvdec vc1_qsv_hwaccel" vc1image_decoder_select="vc1_decoder" vorbis_decoder_select="mdct" vorbis_encoder_select="mdct" vp3_decoder_select="hpeldsp vp3dsp videodsp" -vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp" -vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp" +vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp vp56dsp" +vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp vp56dsp" vp6a_decoder_select="vp6_decoder" vp6f_decoder_select="vp6_decoder" -vp7_decoder_select="h264pred videodsp" -vp8_decoder_select="h264pred videodsp" +vp7_decoder_select="h264pred videodsp vp8dsp" +vp8_decoder_select="h264pred videodsp vp8dsp" vp9_decoder_select="videodsp vp9_parser" -webp_decoder_select="vp8_decoder" +webp_decoder_select="vp8_decoder exif" wmalossless_decoder_select="llauddsp" wmapro_decoder_select="mdct sinewin wma_freqs" wmav1_decoder_select="mdct sinewin wma_freqs" @@ -2315,10 +2477,12 @@ wmav2_encoder_select="mdct sinewin wma_freqs" wmavoice_decoder_select="lsp rdft dct mdct sinewin" wmv1_decoder_select="h263_decoder" wmv1_encoder_select="h263_encoder" -wmv2_decoder_select="blockdsp h263_decoder idctdsp intrax8 videodsp" -wmv2_encoder_select="h263_encoder" +wmv2_decoder_select="blockdsp h263_decoder idctdsp intrax8 videodsp wmv2dsp" +wmv2_encoder_select="h263_encoder wmv2dsp" wmv3_decoder_select="vc1_decoder" wmv3image_decoder_select="wmv3_decoder" +xma1_decoder_select="wmapro_decoder" +xma2_decoder_select="wmapro_decoder" zerocodec_decoder_select="zlib" zlib_decoder_select="zlib" zlib_encoder_select="zlib" @@ -2327,27 +2491,28 @@ zmbv_encoder_select="zlib" # hardware accelerators crystalhd_deps="libcrystalhd_libcrystalhd_if_h" -d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder" +d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder ID3D11VideoContext" dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode" vaapi_deps="va_va_h" vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads" vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore" vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h" +videotoolbox_deps="VideoToolbox_VideoToolbox_h pthreads" +videotoolbox_extralibs="-framework CoreFoundation -framework VideoToolbox -framework CoreMedia -framework QuartzCore -framework CoreVideo" xvmc_deps="X11_extensions_XvMClib_h" h263_vaapi_hwaccel_deps="vaapi" h263_vaapi_hwaccel_select="h263_decoder" -h263_vdpau_hwaccel_deps="vdpau" -h263_vdpau_hwaccel_select="h263_decoder" +h263_videotoolbox_hwaccel_deps="videotoolbox" +h263_videotoolbox_hwaccel_select="h263_decoder" h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser" h264_d3d11va_hwaccel_deps="d3d11va" h264_d3d11va_hwaccel_select="h264_decoder" h264_dxva2_hwaccel_deps="dxva2" h264_dxva2_hwaccel_select="h264_decoder" h264_mmal_decoder_deps="mmal" +h264_mmal_decoder_select="mmal" h264_mmal_hwaccel_deps="mmal" -h264_mmal_decoder_select="h264_decoder" -h264_mmal_encoder_deps="mmal" h264_qsv_hwaccel_deps="libmfx" h264_vaapi_hwaccel_deps="vaapi" h264_vaapi_hwaccel_select="h264_decoder" @@ -2361,10 +2526,17 @@ h264_vdpau_decoder_deps="vdpau" h264_vdpau_decoder_select="h264_decoder" h264_vdpau_hwaccel_deps="vdpau" h264_vdpau_hwaccel_select="h264_decoder" +h264_videotoolbox_hwaccel_deps="videotoolbox" +h264_videotoolbox_hwaccel_select="h264_decoder" hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" hevc_d3d11va_hwaccel_select="hevc_decoder" hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" hevc_dxva2_hwaccel_select="hevc_decoder" +hevc_qsv_hwaccel_deps="libmfx" +hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC" +hevc_vaapi_hwaccel_select="hevc_decoder" +hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC" +hevc_vdpau_hwaccel_select="hevc_decoder" mpeg_vdpau_decoder_deps="vdpau" mpeg_vdpau_decoder_select="mpeg2video_decoder" mpeg_xvmc_hwaccel_deps="xvmc" @@ -2373,6 +2545,8 @@ mpeg1_vdpau_decoder_deps="vdpau" mpeg1_vdpau_decoder_select="mpeg1video_decoder" mpeg1_vdpau_hwaccel_deps="vdpau" mpeg1_vdpau_hwaccel_select="mpeg1video_decoder" +mpeg1_videotoolbox_hwaccel_deps="videotoolbox" +mpeg1_videotoolbox_hwaccel_select="mpeg1video_decoder" mpeg1_xvmc_hwaccel_deps="xvmc" mpeg1_xvmc_hwaccel_select="mpeg1video_decoder" mpeg2_crystalhd_decoder_select="crystalhd" @@ -2380,31 +2554,54 @@ mpeg2_d3d11va_hwaccel_deps="d3d11va" mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder" mpeg2_dxva2_hwaccel_deps="dxva2" mpeg2_dxva2_hwaccel_select="mpeg2video_decoder" +mpeg2_mmal_decoder_deps="mmal" +mpeg2_mmal_decoder_select="mmal" +mpeg2_mmal_hwaccel_deps="mmal" +mpeg2_qsv_hwaccel_deps="libmfx" +mpeg2_qsv_hwaccel_select="qsvdec_mpeg2" mpeg2_vaapi_hwaccel_deps="vaapi" mpeg2_vaapi_hwaccel_select="mpeg2video_decoder" mpeg2_vdpau_hwaccel_deps="vdpau" mpeg2_vdpau_hwaccel_select="mpeg2video_decoder" +mpeg2_videotoolbox_hwaccel_deps="videotoolbox" +mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder" mpeg2_xvmc_hwaccel_deps="xvmc" mpeg2_xvmc_hwaccel_select="mpeg2video_decoder" mpeg4_crystalhd_decoder_select="crystalhd" +mpeg4_mmal_decoder_deps="mmal" +mpeg4_mmal_decoder_select="mmal" +mpeg4_mmal_hwaccel_deps="mmal" mpeg4_vaapi_hwaccel_deps="vaapi" mpeg4_vaapi_hwaccel_select="mpeg4_decoder" mpeg4_vdpau_decoder_deps="vdpau" mpeg4_vdpau_decoder_select="mpeg4_decoder" mpeg4_vdpau_hwaccel_deps="vdpau" mpeg4_vdpau_hwaccel_select="mpeg4_decoder" +mpeg4_videotoolbox_hwaccel_deps="videotoolbox" +mpeg4_videotoolbox_hwaccel_select="mpeg4_decoder" msmpeg4_crystalhd_decoder_select="crystalhd" vc1_crystalhd_decoder_select="crystalhd" vc1_d3d11va_hwaccel_deps="d3d11va" vc1_d3d11va_hwaccel_select="vc1_decoder" vc1_dxva2_hwaccel_deps="dxva2" vc1_dxva2_hwaccel_select="vc1_decoder" +vc1_mmal_decoder_deps="mmal" +vc1_mmal_decoder_select="mmal" +vc1_mmal_hwaccel_deps="mmal" +vc1_qsv_hwaccel_deps="libmfx" +vc1_qsv_hwaccel_select="qsvdec_vc1" vc1_vaapi_hwaccel_deps="vaapi" vc1_vaapi_hwaccel_select="vc1_decoder" vc1_vdpau_decoder_deps="vdpau" vc1_vdpau_decoder_select="vc1_decoder" vc1_vdpau_hwaccel_deps="vdpau" vc1_vdpau_hwaccel_select="vc1_decoder" +vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9" +vp9_d3d11va_hwaccel_select="vp9_decoder" +vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" +vp9_dxva2_hwaccel_select="vp9_decoder" +vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9" +vp9_vaapi_hwaccel_select="vp9_decoder" wmv3_crystalhd_decoder_select="crystalhd" wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel" wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel" @@ -2414,16 +2611,16 @@ wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel" # parsers h264_parser_select="h264_decoder" -hevc_parser_select="hevc_decoder" +hevc_parser_select="golomb" mpegvideo_parser_select="mpegvideo" -mpeg4video_parser_select="error_resilience h263dsp mpeg_er mpegvideo qpeldsp" +mpeg4video_parser_select="h263dsp mpegvideo qpeldsp" vc1_parser_select="mpegvideo startcode vc1_decoder" # bitstream_filters mjpeg2jpeg_bsf_select="jpegtables" # external libraries -libaacplus_encoder_deps="libaacplus" +chromaprint_muxer_deps="chromaprint" libcelt_decoder_deps="libcelt" libdcadec_decoder_deps="libdcadec" libfaac_encoder_deps="libfaac" @@ -2438,6 +2635,7 @@ libgsm_ms_decoder_deps="libgsm" libgsm_ms_encoder_deps="libgsm" libilbc_decoder_deps="libilbc" libilbc_encoder_deps="libilbc" +libkvazaar_encoder_deps="libkvazaar" libmodplug_demuxer_deps="libmodplug" libmp3lame_encoder_deps="libmp3lame" libmp3lame_encoder_select="audio_frame_queue" @@ -2451,7 +2649,6 @@ libopenjpeg_encoder_deps="libopenjpeg" libopus_decoder_deps="libopus" libopus_encoder_deps="libopus" libopus_encoder_select="audio_frame_queue" -libquvi_demuxer_deps="libquvi" libschroedinger_decoder_deps="libschroedinger" libschroedinger_encoder_deps="libschroedinger" libshine_encoder_deps="libshine" @@ -2459,11 +2656,10 @@ libshine_encoder_select="audio_frame_queue" libspeex_decoder_deps="libspeex" libspeex_encoder_deps="libspeex" libspeex_encoder_select="audio_frame_queue" -libstagefright_h264_decoder_deps="libstagefright_h264" libtheora_encoder_deps="libtheora" libtwolame_encoder_deps="libtwolame" -libvo_aacenc_encoder_deps="libvo_aacenc" -libvo_aacenc_encoder_select="audio_frame_queue" +libutvideo_decoder_deps="libutvideo" +libutvideo_encoder_deps="libutvideo" libvo_amrwbenc_encoder_deps="libvo_amrwbenc" libvorbis_decoder_deps="libvorbis" libvorbis_encoder_deps="libvorbis" @@ -2475,14 +2671,13 @@ libvpx_vp9_encoder_deps="libvpx" libwavpack_encoder_deps="libwavpack" libwebp_encoder_deps="libwebp" libwebp_anim_encoder_deps="libwebp" +libx262_encoder_deps="libx262" libx264_encoder_deps="libx264" libx264rgb_encoder_deps="libx264" libx264rgb_encoder_select="libx264_encoder" libx265_encoder_deps="libx265" libxavs_encoder_deps="libxavs" libxvid_encoder_deps="libxvid" -libutvideo_decoder_deps="libutvideo" -libutvideo_encoder_deps="libutvideo" libzvbi_teletext_decoder_deps="libzvbi" nvenc_encoder_deps="nvenc" nvenc_h264_encoder_deps="nvenc" @@ -2491,6 +2686,7 @@ nvenc_hevc_encoder_deps="nvenc" # demuxers / muxers ac3_demuxer_select="ac3_parser" asf_demuxer_select="riffdec" +asf_o_demuxer_select="riffdec" asf_muxer_select="riffenc" asf_stream_muxer_select="asf_muxer" avi_demuxer_select="riffdec exif" @@ -2533,7 +2729,7 @@ mxf_opatom_muxer_select="mxf_muxer" nut_muxer_select="riffenc" nuv_demuxer_select="riffdec" oga_muxer_select="ogg_muxer" -ogg_demuxer_select="golomb" +ogg_demuxer_select="dirac_parse" opus_muxer_select="ogg_muxer" psp_muxer_select="mov_muxer" rtp_demuxer_select="sdp_demuxer" @@ -2546,6 +2742,7 @@ sdp_demuxer_select="rtpdec" smoothstreaming_muxer_select="ismv_muxer" spdif_muxer_select="aac_parser" spx_muxer_select="ogg_muxer" +swf_demuxer_suggest="zlib" tak_demuxer_select="tak_parser" tg2_muxer_select="mov_muxer" tgp_muxer_select="mov_muxer" @@ -2567,10 +2764,10 @@ avfoundation_indev_extralibs="-framework CoreVideo -framework Foundation -framew avfoundation_indev_select="avfoundation" bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h" caca_outdev_deps="libcaca" -decklink_outdev_deps="decklink pthreads" -decklink_outdev_extralibs="-lstdc++" decklink_indev_deps="decklink pthreads" decklink_indev_extralibs="-lstdc++" +decklink_outdev_deps="decklink pthreads" +decklink_outdev_extralibs="-lstdc++" dshow_indev_deps="IBaseFilter" dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid -loleaut32 -lshlwapi" dv1394_indev_deps="dv1394" @@ -2602,12 +2799,13 @@ v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h" v4l2_outdev_deps_any="linux_videodev2_h sys_videoio_h" vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines" vfwcap_indev_extralibs="-lavicap32" -xv_outdev_deps="X11_extensions_Xvlib_h XvGetPortAttribute" -xv_outdev_extralibs="-lXv -lX11 -lXext" x11grab_indev_deps="x11grab" x11grab_xcb_indev_deps="libxcb" +xv_outdev_deps="X11_extensions_Xvlib_h XvGetPortAttribute" +xv_outdev_extralibs="-lXv -lX11 -lXext" # protocols +async_protocol_deps="threads" bluray_protocol_deps="libbluray" ffrtmpcrypt_protocol_deps="!librtmp_protocol" ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl" @@ -2642,19 +2840,23 @@ sctp_protocol_deps="struct_sctp_event_subscribe" sctp_protocol_select="network" srtp_protocol_select="rtp_protocol" tcp_protocol_select="network" -tls_gnutls_protocol_deps="gnutls !tls_securetransport_protocol" +tls_gnutls_protocol_deps="gnutls !tls_schannel_protocol !tls_securetransport_protocol" tls_gnutls_protocol_select="tcp_protocol" -tls_openssl_protocol_deps="openssl !tls_securetransport_protocol !tls_gnutls_protocol" +tls_openssl_protocol_deps="openssl !tls_schannel_protocol !tls_securetransport_protocol !tls_gnutls_protocol" tls_openssl_protocol_select="tcp_protocol" +tls_schannel_protocol_deps="schannel" +tls_schannel_protocol_select="tcp_protocol" tls_securetransport_protocol_deps="securetransport" tls_securetransport_protocol_select="tcp_protocol" -tls_protocol_deps_any="tls_securetransport_protocol tls_gnutls_protocol tls_openssl_protocol" +tls_protocol_deps_any="tls_schannel_protocol tls_securetransport_protocol tls_gnutls_protocol tls_openssl_protocol" udp_protocol_select="network" udplite_protocol_select="network" unix_protocol_deps="sys_un_h" unix_protocol_select="network" # filters +afftfilt_filter_deps="avcodec" +afftfilt_filter_select="fft" amovie_filter_deps="avcodec avformat" aresample_filter_deps="swresample" ass_filter_deps="libass" @@ -2675,8 +2877,8 @@ ebur128_filter_deps="gpl" eq_filter_deps="gpl" fftfilt_filter_deps="avcodec" fftfilt_filter_select="rdft" -flite_filter_deps="libflite" find_rect_filter_deps="avcodec avformat gpl" +flite_filter_deps="libflite" frei0r_filter_deps="frei0r dlopen" frei0r_src_filter_deps="frei0r dlopen" fspp_filter_deps="gpl" @@ -2692,44 +2894,57 @@ mpdecimate_filter_deps="gpl" mpdecimate_filter_select="pixelutils" mptestsrc_filter_deps="gpl" negate_filter_deps="lut_filter" -perspective_filter_deps="gpl" -pp7_filter_deps="gpl" +nnedi_filter_deps="gpl" +ocr_filter_deps="libtesseract" ocv_filter_deps="libopencv" owdenoise_filter_deps="gpl" pan_filter_deps="swresample" +perspective_filter_deps="gpl" phase_filter_deps="gpl" +pp7_filter_deps="gpl" pp_filter_deps="gpl postproc" pullup_filter_deps="gpl" removelogo_filter_deps="avcodec avformat swscale" repeatfields_filter_deps="gpl" resample_filter_deps="avresample" +rubberband_filter_deps="librubberband" sab_filter_deps="gpl swscale" +scale2ref_filter_deps="swscale" scale_filter_deps="swscale" select_filter_select="pixelutils" -smartblur_filter_deps="gpl swscale" -showcqt_filter_deps="avcodec" +showcqt_filter_deps="avcodec avformat swscale" showcqt_filter_select="fft" +showfreqs_filter_deps="avcodec" +showfreqs_filter_select="fft" showspectrum_filter_deps="avcodec" -showspectrum_filter_select="rdft" +showspectrum_filter_select="fft" +showspectrumpic_filter_deps="avcodec" +showspectrumpic_filter_select="fft" +smartblur_filter_deps="gpl swscale" +sofalizer_filter_deps="netcdf avcodec" +sofalizer_filter_select="fft" +spectrumsynth_filter_deps="avcodec" +spectrumsynth_filter_select="fft" spp_filter_deps="gpl avcodec" spp_filter_select="fft idctdsp fdctdsp me_cmp pixblockdsp" stereo3d_filter_deps="gpl" subtitles_filter_deps="avformat avcodec libass" super2xsai_filter_deps="gpl" -tinterlace_filter_deps="gpl" -vidstabdetect_filter_deps="libvidstab" -vidstabtransform_filter_deps="libvidstab" pixfmts_super2xsai_test_deps="super2xsai_filter" +tinterlace_filter_deps="gpl" tinterlace_merge_test_deps="tinterlace_filter" tinterlace_pad_test_deps="tinterlace_filter" uspp_filter_deps="gpl avcodec" +vidstabdetect_filter_deps="libvidstab" +vidstabtransform_filter_deps="libvidstab" zmq_filter_deps="libzmq" zoompan_filter_deps="swscale" +zscale_filter_deps="libzimg" # examples -avio_reading="avformat avcodec avutil" -avio_list_dir="avformat avutil" avcodec_example_deps="avcodec avutil" +avio_dir_cmd="avformat avutil" +avio_reading="avformat avcodec avutil" decoding_encoding_example_deps="avcodec avformat avutil" demuxing_decoding_example_deps="avcodec avformat avutil" extract_mvs_example_deps="avcodec avformat avutil" @@ -2800,11 +3015,7 @@ ln_s="ln -s -f" nm_default="nm -g" objformat="elf" pkg_config_default=pkg-config -if ranlib 2>&1 | grep -q "\-D "; then - ranlib_default="ranlib -D" -else - ranlib_default="ranlib" -fi +ranlib_default="ranlib" strip_default="strip" yasmexe_default="yasm" windres_default="windres" @@ -2845,7 +3056,7 @@ sws_max_filter_size_default=256 set_default sws_max_filter_size # Enable hwaccels by default. -enable d3d11va dxva2 vaapi vda vdpau xvmc +enable d3d11va dxva2 vaapi vda vdpau videotoolbox xvmc enable xlib # build settings @@ -2874,6 +3085,9 @@ CC_E='-E -o $@' CC_O='-o $@' CXX_C='-c' CXX_O='-o $@' +OBJCC_C='-c' +OBJCC_E='-E -o $@' +OBJCC_O='-o $@' LD_O='-o $@' LD_LIB='-l%' LD_PATH='-L' @@ -2890,7 +3104,7 @@ target_path='$(CURDIR)' # since the object filename is not given with the -MM flag, the compiler # is only able to print the basename, and we must add the path ourselves -DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)' +DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>/dev/null | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(@F),$(@D)/$(@F)," > $(@:.o=.d)' DEPFLAGS='-MM' # find source path @@ -2898,8 +3112,9 @@ if test -f configure; then source_path=. else source_path=$(cd $(dirname "$0"); pwd) - echo "$source_path" | grep -q '[[:blank:]]' && - die "Out of tree builds are impossible with whitespace in source path." + case "$source_path" in + *[[:blank:]]*) die "Out of tree builds are impossible with whitespace in source path." ;; + esac test -e "$source_path/config.h" && die "Out of tree builds are impossible with config.h in source dir." fi @@ -2958,14 +3173,15 @@ die_unknown(){ exit 1 } -print_3_columns() { - cat | tr ' ' '\n' | sort | pr -r -3 -t +print_in_columns() { + cols=$(expr $ncols / 24) + cat | tr ' ' '\n' | sort | pr -r "-$cols" -w $ncols -t } show_list() { suffix=_$1 shift - echo $* | sed s/$suffix//g | print_3_columns + echo $* | sed s/$suffix//g | print_in_columns exit 0 } @@ -2999,6 +3215,9 @@ for opt do --extra-ldexeflags=*) add_ldexeflags $optval ;; + --extra-ldlibflags=*) + add_ldlibflags $optval + ;; --extra-libs=*) add_extralibs $optval ;; @@ -3017,6 +3236,7 @@ for opt do --disable-all) map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST disable $LIBRARY_LIST $PROGRAM_LIST doc + enable avutil ;; --enable-random|--disable-random) action=${opt%%-random} @@ -3077,6 +3297,18 @@ done disabled logging && logfile=/dev/null +# Disable all the library-specific components if the library itself +# is disabled, see AVCODEC_LIST and following _LIST variables. + +disable_components(){ + disabled ${1} && disable $( + eval components="\$$(toupper ${1})_COMPONENTS" + map 'eval echo \${$(toupper ${v%s})_LIST}' $components + ) +} + +map 'disable_components $v' $LIBRARY_LIST + echo "# $0 $FFMPEG_CONFIGURATION" > $logfile set >> $logfile @@ -3134,9 +3366,14 @@ case "$toolchain" in else cc_default="c99wrap cl" fi - ld_default="link" + ld_default="$source_path/compat/windows/mslink" nm_default="dumpbin -symbols" ar_default="lib" + case "$arch" in + arm*) + as_default="armasm" + ;; + esac target_os_default="win32" # Use a relative path for TMPDIR. This makes sure all the # ffconf temp files are written with a relative path, avoiding @@ -3178,7 +3415,11 @@ cc_default="${cross_prefix}${cc_default}" cxx_default="${cross_prefix}${cxx_default}" nm_default="${cross_prefix}${nm_default}" pkg_config_default="${cross_prefix}${pkg_config_default}" -ranlib_default="${cross_prefix}${ranlib_default}" +if ${cross_prefix}${ranlib_default} 2>&1 | grep -q "\-D "; then + ranlib_default="${cross_prefix}${ranlib_default} -D" +else + ranlib_default="${cross_prefix}${ranlib_default}" +fi strip_default="${cross_prefix}${strip_default}" windres_default="${cross_prefix}${windres_default}" @@ -3205,7 +3446,7 @@ fi exesuf() { case $1 in - mingw32*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;; + mingw32*|mingw64*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;; esac } @@ -3328,7 +3569,9 @@ msvc_common_flags(){ -lz) echo zlib.lib ;; -lavifil32) echo vfw32.lib ;; -lavicap32) echo vfw32.lib user32.lib ;; + -lx264) echo libx264.lib ;; -l*) echo ${flag#-l}.lib ;; + -LARGEADDRESSAWARE) echo $flag ;; -L*) echo -libpath:${flag#-L} ;; *) echo $flag ;; esac @@ -3457,6 +3700,7 @@ tms470_flags(){ probe_cc(){ pfx=$1 _cc=$2 + first=$3 unset _type _ident _cc_c _cc_e _cc_o _flags _cflags unset _ld_o _ldflags _ld_lib _ld_path @@ -3467,8 +3711,8 @@ probe_cc(){ true # no-op to avoid reading stdin in following checks elif $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then _type=llvm_gcc - gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)') - _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver" + gcc_extra_ver=$(expr "$($_cc --version 2>/dev/null | head -n1)" : '.*\((.*)\)') + _ident="llvm-gcc $($_cc -dumpversion 2>/dev/null) $gcc_extra_ver" _depflags='-MMD -MF $(@:.o=.d) -MT $@' _cflags_speed='-O3' _cflags_size='-Os' @@ -3479,8 +3723,16 @@ probe_cc(){ gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)') gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)") _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver") - if ! $_cc -dumpversion | grep -q '^2\.'; then - _depflags='-MMD -MF $(@:.o=.d) -MT $@' + case $gcc_basever in + 2) ;; + 2.*) ;; + *) _depflags='-MMD -MF $(@:.o=.d) -MT $@' ;; + esac + if [ "$first" = true ]; then + case $gcc_basever in + 4.2*) + warn "gcc 4.2 is outdated and may miscompile FFmpeg. Please use a newer compiler." ;; + esac fi _cflags_speed='-O3' _cflags_size='-Os' @@ -3532,7 +3784,7 @@ probe_cc(){ _flags_filter=tms470_flags elif $_cc -v 2>&1 | grep -q clang; then _type=clang - _ident=$($_cc --version | head -n1) + _ident=$($_cc --version 2>/dev/null | head -n1) _depflags='-MMD -MF $(@:.o=.d) -MT $@' _cflags_speed='-O3' _cflags_size='-Os' @@ -3595,16 +3847,16 @@ probe_cc(){ _flags='-nologo -Qdiag-error:4044,10157' # -Qvec- -Qsimd- to prevent miscompilation, -GS, fp:precise for consistency # with MSVC which enables it by default. - _cflags='-D_USE_MATH_DEFINES -FIstdlib.h -Dstrtoll=_strtoi64 -Qms0 -Qvec- -Qsimd- -GS -fp:precise' + _cflags='-D_USE_MATH_DEFINES -Qms0 -Qvec- -Qsimd- -GS -fp:precise' disable stripping - elif $_cc 2>&1 | grep -q Microsoft; then + elif $_cc -nologo- 2>&1 | grep -q Microsoft; then _type=msvc _ident=$($_cc 2>&1 | head -n1) _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' _cflags_speed="-O2" _cflags_size="-O1" - if $_cc 2>&1 | grep -q Linker; then + if $_cc -nologo- 2>&1 | grep -q Linker; then _ld_o='-out:$@' else _ld_o='-Fe$@' @@ -3615,7 +3867,7 @@ probe_cc(){ _ld_lib='lib%.a' _ld_path='-libpath:' _flags='-nologo' - _cflags='-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64' + _cflags='-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS' disable stripping elif $_cc --version 2>/dev/null | grep -q ^cparser; then _type=cparser @@ -3644,7 +3896,7 @@ set_ccvars(){ fi } -probe_cc cc "$cc" +probe_cc cc "$cc" "true" cflags_filter=$_flags_filter cflags_speed=$_cflags_speed cflags_size=$_cflags_size @@ -3662,16 +3914,22 @@ test -n "$cc_type" && enable $cc_type || warn "Unknown C compiler $cc, unable to select optimal CFLAGS" : ${as_default:=$cc} +: ${objcc_default:=$cc} : ${dep_cc_default:=$cc} : ${ld_default:=$cc} : ${host_ld_default:=$host_cc} -set_default ar as dep_cc ld host_ld windres +set_default ar as objcc dep_cc ld host_ld windres probe_cc as "$as" asflags_filter=$_flags_filter add_asflags $_flags $_cflags set_ccvars AS +probe_cc objcc "$objcc" +objcflags_filter=$_flags_filter +add_objcflags $_flags $_cflags +set_ccvars OBJC + probe_cc ld "$ld" ldflags_filter=$_flags_filter add_ldflags $_flags $_ldflags @@ -3711,6 +3969,7 @@ fi add_cflags $extra_cflags add_cxxflags $extra_cxxflags +add_objcflags $extra_objcflags add_asflags $extra_cflags if test -n "$sysroot"; then @@ -3745,6 +4004,17 @@ if test "$cpu" = host; then } cpu=$(check_native -march || check_native -mcpu) ;; + clang) + check_native(){ + $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return + sed -n "/cc1.*-target-cpu /{ + s/.*-target-cpu \\([^ ]*\\).*/\\1/ + p + q + }" $TMPE + } + cpu=$(check_native -march) + ;; esac test "${cpu:-host}" = host && @@ -3760,6 +4030,16 @@ case "$arch" in arch="arm" ;; mips*|IP*) + case "$arch" in + *el) + add_cppflags -EL + add_ldflags -EL + ;; + *eb) + add_cppflags -EB + add_ldflags -EB + ;; + esac arch="mips" ;; parisc*|hppa*) @@ -3894,85 +4174,90 @@ elif enabled mips; then cpuflags="-march=$cpu" - case $cpu in - 24kc) - disable mips32r5 - disable mips64r6 - disable mipsfpu - disable mipsdspr1 - disable mipsdspr2 - disable msa - ;; - 24kf*) - disable mips32r5 - disable mips64r6 - disable mipsdspr1 - disable mipsdspr2 - disable msa - ;; - 24kec|34kc|1004kc) - disable mips32r5 - disable mips64r6 - disable mipsfpu - disable mipsdspr2 - disable msa - ;; - 24kef*|34kf*|1004kf*) - disable mips32r5 - disable mips64r6 - disable mipsdspr2 - disable msa - ;; - 74kc) - disable mips32r5 - disable mips64r6 - disable mipsfpu - disable msa - ;; - 74kf) - disable mips32r5 - disable mips64r6 - disable msa - ;; - p5600) - disable mips64r6 - disable mipsdspr1 - disable mipsdspr2 + if [ "$cpu" != "generic" ]; then + disable mips32r2 + disable mips32r5 + disable mips64r2 + disable mips32r6 + disable mips64r6 + disable loongson2 + disable loongson3 + + case $cpu in + 24kc|24kf*|24kec|34kc|1004kc|24kef*|34kf*|1004kf*|74kc|74kf) + enable mips32r2 + disable msa + ;; + p5600|i6400) + disable mipsdsp + disable mipsdspr2 + ;; + loongson*) + enable loongson2 + enable loongson3 + enable local_aligned_8 local_aligned_16 local_aligned_32 + enable simd_align_16 + enable fast_64bit + enable fast_clz + enable fast_cmov + enable fast_unaligned + disable aligned_stack + case $cpu in + loongson3*) + cpuflags="-march=loongson3a -mhard-float -fno-expensive-optimizations" + ;; + loongson2e) + cpuflags="-march=loongson2e -mhard-float -fno-expensive-optimizations" + ;; + loongson2f) + cpuflags="-march=loongson2f -mhard-float -fno-expensive-optimizations" + ;; + esac + ;; + *) + # Unknown CPU. Disable everything. + warn "unknown CPU. Disabling all MIPS optimizations." + disable mipsfpu + disable mipsdsp + disable mipsdspr2 + disable msa + disable mmi + ;; + esac - check_cflags "-mtune=p5600" - ;; - i6400) - disable mips32r5 - disable mipsdspr1 - disable mipsdspr2 - disable mipsfpu - - check_cflags "-mtune=i6400 -mabi=64" - check_ldflags "-mabi=64" - ;; - loongson3*) - disable mipsfpu - disable mips32r2 - disable mips32r5 - disable mips64r6 - disable mipsdspr1 - disable mipsdspr2 - disable msa - enable local_aligned_8 local_aligned_16 - enable simd_align_16 - enable fast_64bit - enable fast_clz - enable fast_cmov - enable fast_unaligned - disable aligned_stack - cpuflags="-march=loongson3a -mhard-float" - ;; - generic) - disable mips32r5 - disable mips64r6 - disable msa - ;; - esac + case $cpu in + 24kc) + disable mipsfpu + disable mipsdsp + disable mipsdspr2 + ;; + 24kf*) + disable mipsdsp + disable mipsdspr2 + ;; + 24kec|34kc|1004kc) + disable mipsfpu + disable mipsdspr2 + ;; + 24kef*|34kf*|1004kf*) + disable mipsdspr2 + ;; + 74kc) + disable mipsfpu + ;; + p5600) + enable mips32r5 + check_cflags "-mtune=p5600" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" + ;; + i6400) + enable mips64r6 + check_cflags "-mtune=i6400 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64" + ;; + esac + else + # We do not disable anything. Is up to the user to disable the unwanted features. + warn 'generic cpu selected' + fi elif enabled ppc; then @@ -4079,6 +4364,7 @@ fi if [ "$cpu" != generic ]; then add_cflags $cpuflags add_asflags $cpuflags + test "$cc_type" = "$ld_type" && add_ldflags $cpuflags fi # compiler sanity check @@ -4172,8 +4458,7 @@ case $target_os in enable section_data_rel_ro SLIB_INSTALL_NAME='$(SLIBNAME)' SLIB_INSTALL_LINKS= - # soname not set on purpose - SHFLAGS=-shared + SHFLAGS='-shared -Wl,-soname,$(SLIBNAME)' ;; haiku) prefix_default="/boot/common" @@ -4194,6 +4479,7 @@ case $target_os in echo "hwcap_1 = OVERRIDE;" > mapfile && add_ldflags -Wl,-M,mapfile nm_default='nm -P -g' + SLIB_CREATE_DEF_CMD='$(Q)perl $(SRC_PATH)/compat/solaris/make_sunver.pl $$(filter %.ver,$$^) $(OBJS) | grep -v @ > $(SUBDIR)lib$(NAME).ver-sol2' ;; netbsd) disable symver @@ -4232,12 +4518,17 @@ case $target_os in enabled_any pic shared x86_64 || { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; } ;; - mingw32*) + msys*) + die "Native MSYS builds are discouraged, please use the MINGW environment."; + ;; + mingw32*|mingw64*) if test $target_os = "mingw32ce"; then disable network else target_os=mingw32 fi + decklink_outdev_extralibs="$decklink_outdev_extralibs -lole32 -loleaut32" + decklink_indev_extralibs="$decklink_indev_extralibs -lole32 -loleaut32" LIBTARGET=i386 if enabled x86_64; then LIBTARGET="i386:x86-64" @@ -4245,8 +4536,6 @@ case $target_os in LIBTARGET=arm-wince fi enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres - check_ldflags -Wl,--nxcompat - check_ldflags -Wl,--dynamicbase enabled x86_32 && check_ldflags -Wl,--large-address-aware shlibdir_default="$bindir_default" SLIBPREF="" @@ -4266,10 +4555,25 @@ case $target_os in SLIB_INSTALL_LINKS= SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)' SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)' - SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.orig.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base' + SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.orig.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--disable-auto-image-base' objformat="win32" ranlib=: enable dos_paths + check_ldflags -Wl,--nxcompat,--dynamicbase + # Lets work around some stupidity in binutils. + # ld will strip relocations from executables even though we need them + # for dynamicbase (ASLR). Using -pie does retain the reloc section + # however ld then forgets what the entry point should be (oops) so we + # have to manually (re)set it. + if enabled x86_32; then + add_ldexeflags -Wl,--pic-executable,-e,_mainCRTStartup + elif enabled x86_64; then + add_ldexeflags -Wl,--pic-executable,-e,mainCRTStartup + check_ldflags -Wl,--high-entropy-va # binutils 2.25 + # Set image base >4GB for extra entropy with HEASLR + add_ldexeflags -Wl,--image-base,0x140000000 + append SHFLAGS -Wl,--image-base,0x180000000 + fi ;; win32|win64) disable symver @@ -4393,6 +4697,26 @@ case $target_os in ;; esac +# test if creating links works +link_dest=$(mktemp -u $TMPDIR/dest_XXXXXXXX) +link_name=$(mktemp -u $TMPDIR/name_XXXXXXXX) +mkdir "$link_dest" +$ln_s "$link_dest" "$link_name" +touch "$link_dest/test_file" +if [ "$source_path" != "." ] && ([ ! -d src ] || [ -L src ]) && [ -e "$link_name/test_file" ]; then + # create link to source path + [ -e src ] && rm src + $ln_s "$source_path" src + source_link=src +else + # creating directory links doesn't work + # fall back to using the full source path + source_link="$source_path" +fi +# cleanup +rm -r "$link_dest" +rm -r "$link_name" + # determine libc flavour probe_libc(){ @@ -4446,8 +4770,19 @@ probe_libc(){ # in such new versions and producing binaries requiring windows 7.0. # Therefore explicitly set the default to XP unless the user has # set something else on the command line. + # Don't do this if WINAPI_FAMILY is set and is set to a non-desktop + # family. For these cases, configure is free to use any functions + # found in the SDK headers by default. (Alternatively, we could force + # _WIN32_WINNT to 0x0602 in that case.) check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" || - add_${pfx}cppflags -D_WIN32_WINNT=0x0502 + { check_${pfx}cpp < +#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#error not desktop +#endif +#endif +EOF elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then eval ${pfx}libc_type=klibc elif check_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then @@ -4531,6 +4866,7 @@ die_license_disabled_gpl() { die_license_disabled gpl frei0r die_license_disabled gpl libcdio +die_license_disabled gpl librubberband die_license_disabled gpl libsmbclient die_license_disabled gpl libutvideo die_license_disabled gpl libvidstab @@ -4538,19 +4874,17 @@ die_license_disabled gpl libx264 die_license_disabled gpl libx265 die_license_disabled gpl libxavs die_license_disabled gpl libxvid -die_license_disabled gpl libzvbi die_license_disabled gpl x11grab -die_license_disabled nonfree libaacplus die_license_disabled nonfree libfaac die_license_disabled nonfree nvenc enabled gpl && die_license_disabled_gpl nonfree libfdk_aac enabled gpl && die_license_disabled_gpl nonfree openssl +die_license_disabled version3 gmp die_license_disabled version3 libopencore_amrnb die_license_disabled version3 libopencore_amrwb die_license_disabled version3 libsmbclient -die_license_disabled version3 libvo_aacenc die_license_disabled version3 libvo_amrwbenc enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; } @@ -4676,6 +5010,8 @@ elif enabled alpha; then elif enabled arm; then + enabled msvc && check_cpp_condition stddef.h "defined _M_ARMT" && enable thumb + check_cpp_condition stddef.h "defined __thumb__" && check_cc <= 30"; then + enable vfp_args + elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__" && [ $target_os != darwin ]; then case "${cross_prefix:-$cc}" in *hardfloat*) enable vfp_args; fpabi=vfp ;; *) check_ld "cc" <= 2.0.0" aacplus.h aacplusEncOpen -laacplus enabled libass && require_pkg_config libass ass/ass.h ass_library_init enabled libbluray && require_pkg_config libbluray libbluray/bluray.h bd_open enabled libbs2b && require_pkg_config libbs2b bs2b.h bs2b_open @@ -5091,7 +5454,7 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && { check_lib celt/celt.h celt_decoder_create_custom -lcelt0 || die "ERROR: libcelt must be installed and version must be >= 0.11.0."; } enabled libcaca && require_pkg_config caca caca.h caca_create_canvas -enabled libdcadec && require_pkg_config dcadec libdcadec/dca_context.h dcadec_context_create +enabled libdcadec && require_pkg_config "dcadec >= 0.1.0" libdcadec/dca_context.h dcadec_context_create enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac enabled libfdk_aac && { use_pkg_config fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen || { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac && @@ -5107,32 +5470,35 @@ enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do check_lib "${gsm_hdr}" gsm_create -lgsm && break; done || die "ERROR: libgsm not found"; } enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc +enabled libkvazaar && require_pkg_config "kvazaar >= 0.8.1" kvazaar.h kvz_api_get enabled libmfx && require_pkg_config libmfx "mfx/mfxvideo.h" MFXInit enabled libmodplug && require_pkg_config libmodplug libmodplug/modplug.h ModPlug_Load enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame enabled libnut && require libnut libnut.h nut_demuxer_init -lnut enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -enabled libopencv && require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader +enabled libopencv && { check_header opencv2/core/core_c.h && + require_pkg_config opencv opencv2/core/core_c.h cvCreateImageHeader || + require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader; } enabled libopenh264 && require_pkg_config openh264 wels/codec_api.h WelsGetCodecVersion -enabled libopenjpeg && { check_lib openjpeg.h opj_version -lopenmj2 -DOPJ_STATIC || +enabled libopenjpeg && { check_lib openjpeg-2.1/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC || + check_lib openjpeg-2.0/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC || check_lib openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC || check_lib openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC || die "ERROR: libopenjpeg not found"; } enabled libopus && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create enabled libpulse && require_pkg_config libpulse pulse/pulseaudio.h pa_context_new -enabled libquvi && require_pkg_config libquvi quvi/quvi.h quvi_init enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket +enabled librubberband && require_pkg_config "rubberband >= 1.8.1" rubberband/rubberband-c.h rubberband_new enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init enabled libshine && require_pkg_config shine shine/layer3.h shine_encode_buffer enabled libsmbclient && { use_pkg_config smbclient libsmbclient.h smbc_init || require smbclient libsmbclient.h smbc_init -lsmbclient; } -enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr +enabled libsnappy && require snappy snappy-c.h snappy_compress -lsnappy +enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr && LIBSOXR="-lsoxr" enabled libssh && require_pkg_config libssh libssh/sftp.h sftp_init enabled libspeex && require_pkg_config speex speex/speex.h speex_decoder_init -lspeex -enabled libstagefright_h264 && require_cpp libstagefright_h264 "binder/ProcessState.h media/stagefright/MetaData.h - media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h - media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder -lgnustl_static +enabled libtesseract && require_pkg_config tesseract tesseract/capi.h TessBaseAPICreate enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame && { check_lib twolame.h twolame_encode_buffer_float32_interleaved -ltwolame || @@ -5140,16 +5506,35 @@ enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame enabled libutvideo && require_cpp utvideo "stdint.h stdlib.h utvideo/utvideo.h utvideo/Codec.h" 'CCodec*' -lutvideo -lstdc++ enabled libv4l2 && require_pkg_config libv4l2 libv4l2.h v4l2_ioctl enabled libvidstab && require_pkg_config "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit -enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg + enabled libvpx && { - enabled libvpx_vp8_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx || - die "ERROR: libvpx decoder version must be >=0.9.1"; } - enabled libvpx_vp8_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VP8E_SET_MAX_INTRA_BITRATE_PCT" -lvpx || - die "ERROR: libvpx encoder version must be >=0.9.7"; } - enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; } - enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VP9E_SET_AQ_MODE" -lvpx || disable libvpx_vp9_encoder; } } + enabled libvpx_vp8_decoder && { + use_pkg_config "vpx >= 0.9.1" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx || + check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx || + die "ERROR: libvpx decoder version must be >=0.9.1"; + } + enabled libvpx_vp8_encoder && { + use_pkg_config "vpx >= 0.9.7" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx || + check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VP8E_SET_MAX_INTRA_BITRATE_PCT" -lvpx || + die "ERROR: libvpx encoder version must be >=0.9.7"; + } + enabled libvpx_vp9_decoder && { + use_pkg_config "vpx >= 1.3.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx || + check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || + disable libvpx_vp9_decoder; + } + enabled libvpx_vp9_encoder && { + use_pkg_config "vpx >= 1.3.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx || + check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VP9E_SET_AQ_MODE" -lvpx || + disable libvpx_vp9_encoder; + } + if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder; then + die "libvpx enabled but no supported decoders found" + fi +} + enabled libwavpack && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput -lwavpack enabled libwebp && { enabled libwebp_encoder && require_pkg_config "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion @@ -5158,14 +5543,19 @@ enabled libx264 && { use_pkg_config x264 "stdint.h x264.h" x264_encode { require libx264 x264.h x264_encoder_encode -lx264 && warn "using libx264 without pkg-config"; } } && { check_cpp_condition x264.h "X264_BUILD >= 118" || - die "ERROR: libx264 must be installed and version must be >= 0.118."; } + die "ERROR: libx264 must be installed and version must be >= 0.118."; } && + { check_cpp_condition x264.h "X264_MPEG2" && + enable libx262; } enabled libx265 && require_pkg_config x265 x265.h x265_api_get && - { check_cpp_condition x265.h "X265_BUILD >= 57" || - die "ERROR: libx265 version must be >= 57."; } + { check_cpp_condition x265.h "X265_BUILD >= 68" || + die "ERROR: libx265 version must be >= 68."; } enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore +enabled libzimg && require_pkg_config zimg zimg.h zimg_get_api_version enabled libzmq && require_pkg_config libzmq zmq.h zmq_ctx_new -enabled libzvbi && require libzvbi libzvbi.h vbi_decoder_new -lzvbi +enabled libzvbi && require libzvbi libzvbi.h vbi_decoder_new -lzvbi && + { check_cpp_condition libzvbi.h "VBI_VERSION_MAJOR > 0 || VBI_VERSION_MINOR > 2 || VBI_VERSION_MINOR == 2 && VBI_VERSION_MICRO >= 28" || + enabled gpl || die "ERROR: libzvbi requires version 0.2.28 or --enable-gpl."; } enabled mmal && { check_lib interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host || { ! enabled cross_compile && { add_cflags -isystem/opt/vc/include/ -isystem/opt/vc/include/interface/vmcs_host/linux -isystem/opt/vc/include/interface/vcos/pthreads -fgnu89-inline ; @@ -5173,6 +5563,11 @@ enabled mmal && { check_lib interface/mmal/mmal.h mmal_port_connect check_lib interface/mmal/mmal.h mmal_port_connect ; } check_lib interface/mmal/mmal.h mmal_port_connect ; } || die "ERROR: mmal not found"; } +enabled mmal && + (check_code cc interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS" || + die "ERROR: mmal firmware headers too old") + +enabled netcdf && require_pkg_config netcdf netcdf.h nc_inq_libvers enabled nvenc && { check_header nvEncodeAPI.h || die "ERROR: nvEncodeAPI.h not found."; } && { check_cpp_condition nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 5" || die "ERROR: NVENC API version 4 or older is not supported"; } && @@ -5194,16 +5589,12 @@ enabled opengl && { check_lib GL/glx.h glXGetProcAddress "-lGL" || check_lib2 ES2/gl.h glGetError "-isysroot=${sysroot} -Wl,-framework,OpenGLES" || die "ERROR: opengl not found." } -enabled openssl && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto || +enabled openssl && { use_pkg_config openssl openssl/ssl.h SSL_library_init || + check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto || check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 || check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 || die "ERROR: openssl not found"; } -enabled qtkit_indev && { check_header_oc QTKit/QTKit.h || disable qtkit_indev; } - -if enabled gnutls; then - { check_lib2 gmp.h mpz_export -lgmp && enable gmp; } || - { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; } -fi +enabled qtkit_indev && { check_header_objcc QTKit/QTKit.h || disable qtkit_indev; } # libdc1394 check if enabled libdc1394; then @@ -5213,6 +5604,20 @@ if enabled libdc1394; then enable libdc1394_1; } || die "ERROR: No version of libdc1394 found " fi + +if enabled gcrypt; then + GCRYPT_CONFIG="${cross_prefix}libgcrypt-config" + if "${GCRYPT_CONFIG}" --version > /dev/null 2>&1; then + gcrypt_cflags=$("${GCRYPT_CONFIG}" --cflags) + gcrypt_libs=$("${GCRYPT_CONFIG}" --libs) + check_func_headers gcrypt.h gcry_mpi_new $gcrypt_cflags $gcrypt_libs || + die "ERROR: gcrypt not found" + add_cflags $gcrypt_cflags && add_extralibs $gcrypt_libs + else + require2 gcrypt gcrypt.h gcry_mpi_new -lgcrypt + fi +fi + if ! disabled sdl; then SDL_CONFIG="${cross_prefix}sdl-config" if check_pkg_config sdl SDL_events.h SDL_PollEvent; then @@ -5233,6 +5638,9 @@ if ! disabled sdl; then disable sdl fi fi + if test $target_os = "mingw32"; then + sdl_libs="$sdl_libs -mconsole" + fi fi enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs @@ -5240,6 +5648,9 @@ disabled securetransport || { check_func SecIdentityCreate "-Wl,-framework,CoreF check_lib2 "Security/SecureTransport.h Security/Security.h" "SSLCreateContext SecItemImport" "-Wl,-framework,CoreFoundation -Wl,-framework,Security" && enable securetransport; } +disabled schannel || { check_func_headers "windows.h Security.h" InitializeSecurityContext -DSECURITY_WIN32 -lSecur32 && + check_cpp_condition winerror.h "defined(SEC_I_CONTEXT_EXPIRED)" && enable schannel && add_extralibs -lSecur32; } + makeinfo --version > /dev/null 2>&1 && enable makeinfo || disable makeinfo enabled makeinfo \ && [ 0$(makeinfo --version | grep "texinfo" | sed 's/.*texinfo[^0-9]*\([0-9]*\)\..*/\1/') -ge 5 ] \ @@ -5381,6 +5792,7 @@ check_cflags -Wno-pointer-to-int-cast check_cflags -Wstrict-prototypes check_cflags -Wempty-body enabled extra_warnings && check_cflags -Winline +enabled extra_warnings && check_cflags -Wcast-qual check_disable_warning(){ warning_flag=-W${1#-Wno-} @@ -5391,11 +5803,13 @@ check_disable_warning -Wno-parentheses check_disable_warning -Wno-switch check_disable_warning -Wno-format-zero-length check_disable_warning -Wno-pointer-sign +check_disable_warning -Wno-unused-const-variable # add some linker flags check_ldflags -Wl,--warn-common check_ldflags -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample enabled rpath && add_ldexeflags -Wl,-rpath,$libdir +enabled rpath && add_ldlibflags -Wl,-rpath,$libdir test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic # add some strip flags @@ -5420,7 +5834,6 @@ enabled xmm_clobber_test && -Wl,--wrap,avcodec_decode_video2 \ -Wl,--wrap,avcodec_decode_subtitle2 \ -Wl,--wrap,avcodec_encode_audio2 \ - -Wl,--wrap,avcodec_encode_video \ -Wl,--wrap,avcodec_encode_video2 \ -Wl,--wrap,avcodec_encode_subtitle \ -Wl,--wrap,swr_convert \ @@ -5428,10 +5841,14 @@ enabled xmm_clobber_test && -Wl,--wrap,sws_scale || disable xmm_clobber_test -echo "X{};" > $TMPV +echo "X { local: *; };" > $TMPV if test_ldflags -Wl,--version-script,$TMPV; then append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver' - check_cc <= 12" || disable log2 + # The CRT headers contain __declspec(restrict) in a few places, but if redefining + # restrict, this might break. MSVC 2010 and 2012 fail with __declspec(__restrict) + # (as it ends up if the restrict redefine is done before including stdlib.h), while + # MSVC 2013 and newer can handle it fine. + # If this declspec fails, force including stdlib.h before the restrict redefinition + # happens in config.h. + if [ $_restrict != restrict ]; then + check_cc < $TMPH <> $TMPH mkdir -p doc mkdir -p tests -echo "@c auto-generated by configure" > doc/config.texi +mkdir -p tests/api +echo "@c auto-generated by configure - do not modify! " > doc/config.texi print_config ARCH_ "$config_files" $ARCH_LIST print_config HAVE_ "$config_files" $HAVE_LIST @@ -6011,7 +6470,7 @@ echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH cp_if_changed $TMPH libavutil/avconfig.h if test -n "$WARNINGS"; then - printf "\n$WARNINGS" + printf "\n%s%s$WARNINGS%s" "$warn_color" "$bold_color" "$reset_color" enabled fatal_warnings && exit 1 fi @@ -6075,4 +6534,4 @@ pkgconfig_generate libavfilter "FFmpeg audio/video filtering library" "$LIBAVF pkgconfig_generate libpostproc "FFmpeg postprocessing library" "$LIBPOSTPROC_VERSION" "" pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$LIBM" pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" -pkgconfig_generate libswresample "FFmpeg audio resampling library" "$LIBSWRESAMPLE_VERSION" "$LIBM" +pkgconfig_generate libswresample "FFmpeg audio resampling library" "$LIBSWRESAMPLE_VERSION" "$LIBM $LIBSOXR" diff --git a/doc/APIchanges b/doc/APIchanges index 6e64a05f..85d4db70 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,19 +2,156 @@ Never assume the API of libav* to be stable unless at least 1 month has passed since the last major version increase or the API was added. The last version increases were: -libavcodec: 2014-08-09 -libavdevice: 2014-08-09 -libavfilter: 2014-08-09 -libavformat: 2014-08-09 -libavresample: 2014-08-09 -libpostproc: 2014-08-09 -libswresample: 2014-08-09 -libswscale: 2014-08-09 -libavutil: 2014-08-09 +libavcodec: 2015-08-28 +libavdevice: 2015-08-28 +libavfilter: 2015-08-28 +libavformat: 2015-08-28 +libavresample: 2015-08-28 +libpostproc: 2015-08-28 +libswresample: 2015-08-28 +libswscale: 2015-08-28 +libavutil: 2015-08-28 API changes, most recent first: +-------- 8< --------- FFmpeg 3.0 was cut here -------- 8< --------- + +2016-02-10 - bc9a596 / 9f61abc - lavf 57.25.100 / 57.3.0 - avformat.h + Add AVFormatContext.opaque, io_open and io_close, allowing custom IO + +2016-02-01 - 1dba837 - lavf 57.24.100 - avformat.h, avio.h + Add protocol_whitelist to AVFormatContext, AVIOContext + +2016-01-31 - 66e9d2f - lavu 55.17.100 - frame.h + Add AV_FRAME_DATA_GOP_TIMECODE for exporting MPEG1/2 GOP timecodes. + +2016-01-01 - 5e8b053 / 2c68113 - lavc 57.21.100 / 57.12.0 - avcodec.h + Add AVCodecDescriptor.profiles and avcodec_profile_name(). + +2015-12-28 - 1f9139b - lavf 57.21.100 - avformat.h + Add automatic bitstream filtering; add av_apply_bitstream_filters() + +2015-12-22 - 39a09e9 - lavfi 6.21.101 - avfilter.h + Deprecate avfilter_link_set_closed(). + Applications are not supposed to mess with links, + they should close the sinks. + +2015-12-17 - lavc 57.18.100 / 57.11.0 - avcodec.h dirac.h + xxxxxxx - Add av_packet_add_side_data(). + xxxxxxx - Add AVCodecContext.coded_side_data. + xxxxxxx - Add AVCPBProperties API. + xxxxxxx - Add a new public header dirac.h containing + av_dirac_parse_sequence_header() + +2015-12-11 - 676a93f - lavf 57.20.100 - avformat.h + Add av_program_add_stream_index() + +2015-11-29 - 93fb4a4 - lavc 57.16.101 - avcodec.h + Deprecate rtp_callback without replacement, i.e. it won't be possible to + get image slices before the full frame is encoded any more. The libavformat + rtpenc muxer can still be used for RFC-2190 packetization. + +2015-11-22 - fe20e34 - lavc 57.16.100 - avcodec.h + Add AV_PKT_DATA_FALLBACK_TRACK for making fallback associations between + streams. + +2015-11-22 - ad317c9 - lavf 57.19.100 - avformat.h + Add av_stream_new_side_data(). + +2015-11-22 - e12f403 - lavu 55.8.100 - xtea.h + Add av_xtea_le_init and av_xtea_le_crypt + +2015-11-18 - lavu 55.7.100 - mem.h + Add av_fast_mallocz() + +2015-10-29 - lavc 57.12.100 / 57.8.0 - avcodec.h + xxxxxx - Deprecate av_free_packet(). Use av_packet_unref() as replacement, + it resets the packet in a more consistent way. + xxxxxx - Deprecate av_dup_packet(), it is a no-op for most cases. + Use av_packet_ref() to make a non-refcounted AVPacket refcounted. + xxxxxx - Add av_packet_alloc(), av_packet_clone(), av_packet_free(). + They match the AVFrame functions with the same name. + +2015-10-27 - 1e477a9 - lavu 55.5.100 - cpu.h + Add AV_CPU_FLAG_AESNI. + +2015-10-22 - ee573b4 / a17a766 - lavc 57.9.100 / 57.5.0 - avcodec.h + Add data and linesize array to AVSubtitleRect, to be used instead of + the ones from the embedded AVPicture. + +2015-10-22 - 866a417 / dc923bc - lavc 57.8.100 / 57.0.0 - qsv.h + Add an API for allocating opaque surfaces. + +2015-10-15 - 2c2d162 - lavf 57.4.100 + Remove the latm demuxer that was a duplicate of the loas demuxer. + +2015-10-14 - b994788 / 11c5f43 - lavu 55.4.100 / 55.2.0 - dict.h + Change return type of av_dict_copy() from void to int, so that a proper + error code can be reported. + +2015-09-29 - b01891a / 948f3c1 - lavc 57.3.100 / 57.2.0 - avcodec.h + Change type of AVPacket.duration from int to int64_t. + +2015-09-17 - 7c46f24 / e3d4784 - lavc 57.3.100 / 57.2.0 - d3d11va.h + Add av_d3d11va_alloc_context(). This function must from now on be used for + allocating AVD3D11VAContext. + +2015-09-15 - lavf 57.2.100 - avformat.h + probesize and max_analyze_duration switched to 64bit, both + are only accessible through AVOptions + +2015-09-15 - lavf 57.1.100 - avformat.h + bit_rate was changed to 64bit, make sure you update any + printf() or other type sensitive code + +2015-09-15 - lavc 57.2.100 - avcodec.h + bit_rate/rc_max_rate/rc_min_rate were changed to 64bit, make sure you update + any printf() or other type sensitive code + +2015-09-07 - lavu 55.0.100 / 55.0.0 + c734b34 / b8b5d82 - Change type of AVPixFmtDescriptor.flags from uint8_t to uint64_t. + f53569a / 6b3ef7f - Change type of AVComponentDescriptor fields from uint16_t to int + and drop bit packing. + 151aa2e / 2268db2 - Add step, offset, and depth to AVComponentDescriptor to replace + the deprecated step_minus1, offset_plus1, and depth_minus1. + +-------- 8< --------- FFmpeg 2.8 was cut here -------- 8< --------- + +2015-08-27 - 1dd854e1 - lavc 56.58.100 - vaapi.h + Deprecate old VA-API context (vaapi_context) fields that were only + set and used by libavcodec. They are all managed internally now. + +2015-08-19 - 9f8e57ef - lavu 54.31.100 - pixfmt.h + Add a unique pixel format for VA-API (AV_PIX_FMT_VAAPI) that + indicates the nature of the underlying storage: a VA surface. This + yields the same value as AV_PIX_FMT_VAAPI_VLD. + Deprecate old VA-API related pixel formats: AV_PIX_FMT_VAAPI_MOCO, + AV_PIX_FMT_VAAPI_IDCT, AV_PIX_FMT_VAAPI_VLD. + +2015-08-02 - lavu 54.30.100 / 54.17.0 + 9ed59f1 / 7a7df34c - Add av_blowfish_alloc(). + a130ec9 / ae365453 - Add av_rc4_alloc(). + 9ca1997 / 5d8bea3b - Add av_xtea_alloc(). + 3cf08e9 / d9e8b47e - Add av_des_alloc(). + +2015-07-27 - lavc 56.56.100 / 56.35.0 - avcodec.h + 94d68a4 / 7c6eb0a1 - Rename CODEC_FLAG* defines to AV_CODEC_FLAG*. + 444e987 / def97856 - Rename CODEC_CAP_* defines to AV_CODEC_CAP_*. + 29d147c / 059a9348 - Rename FF_INPUT_BUFFER_PADDING_SIZE and FF_MIN_BUFFER_SIZE + to AV_INPUT_BUFFER_PADDING_SIZE and AV_INPUT_BUFFER_MIN_SIZE. + +2015-07-22 - c40ecff - lavc 56.51.100 - avcodec.h + Add AV_PKT_DATA_QUALITY_STATS to export the quality value, PSNR, and pict_type + of an AVPacket. + +2015-07-16 - 8dad213 - lavc 56.49.100 + Add av_codec_get_codec_properties(), FF_CODEC_PROPERTY_LOSSLESS + and FF_CODEC_PROPERTY_CLOSED_CAPTIONS + +2015-07-03 - d563e13 / 83212943 - lavu 54.28.100 / 56.15.0 + Add av_version_info(). + -------- 8< --------- FFmpeg 2.7 was cut here -------- 8< --------- 2015-06-04 - cc17b43 - lswr 1.2.100 @@ -692,6 +829,9 @@ API changes, most recent first: av_ripemd_update() av_ripemd_final() +2013-06-10 - 82ef670 - lavu 52.35.101 - hmac.h + Add AV_HMAC_SHA224, AV_HMAC_SHA256, AV_HMAC_SHA384, AV_HMAC_SHA512 + 2013-06-04 - 30b491f / fc962d4 - lavu 52.35.100 / 52.13.0 - mem.h Add av_realloc_array and av_reallocp_array @@ -981,15 +1121,14 @@ lavd 54.4.100 / 54.0.0, lavfi 3.5.0 Add avresample_set_channel_mapping() for input channel reordering, duplication, and silencing. -2012-12-29 - 2ce43b3 / d8fd06c - lavu 52.13.100 / 52.3.0 - avstring.h - Add av_basename() and av_dirname(). +2012-12-29 - lavu 52.13.100 / 52.3.0 - avstring.h + 2ce43b3 / d8fd06c - Add av_basename() and av_dirname(). + e13d5e9 / c1a02e8 - Add av_pix_fmt_get_chroma_sub_sample and deprecate + avcodec_get_chroma_sub_sample. 2012-11-11 - 03b0787 / 5980f5d - lavu 52.6.100 / 52.2.0 - audioconvert.h Rename audioconvert.h to channel_layout.h. audioconvert.h is now deprecated. -2012-11-05 - 7d26be6 / dfde8a3 - lavu 52.5.100 / 52.1.0 - intmath.h - Add av_ctz() for trailing zero bit count - 2012-10-21 - e3a91c5 / a893655 - lavu 51.77.100 / 51.45.0 - error.h Add AVERROR_EXPERIMENTAL diff --git a/doc/Doxyfile b/doc/Doxyfile index 1b116d4d..845d8dc0 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 2.7.2 +PROJECT_NUMBER = 3.0.2 # With the PROJECT_LOGO tag one can specify a logo or icon that is included # in the documentation. The maximum height of the logo should not exceed 55 @@ -1360,6 +1360,7 @@ PREDEFINED = "__attribute__(x)=" \ "offsetof(x,y)=0x42" \ av_alloc_size \ AV_GCC_VERSION_AT_LEAST(x,y)=1 \ + AV_GCC_VERSION_AT_MOST(x,y)=0 \ __GNUC__=1 \ # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then diff --git a/doc/Makefile b/doc/Makefile index 45735311..4a77aac1 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -36,7 +36,7 @@ DOCS-$(CONFIG_MANPAGES) += $(MANPAGES) DOCS-$(CONFIG_TXTPAGES) += $(TXTPAGES) DOCS = $(DOCS-yes) -DOC_EXAMPLES-$(CONFIG_AVIO_LIST_DIR_EXAMPLE) += avio_list_dir +DOC_EXAMPLES-$(CONFIG_AVIO_DIR_CMD_EXAMPLE) += avio_dir_cmd DOC_EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading DOC_EXAMPLES-$(CONFIG_AVCODEC_EXAMPLE) += avcodec DOC_EXAMPLES-$(CONFIG_DECODING_ENCODING_EXAMPLE) += decoding_encoding @@ -124,11 +124,12 @@ $(DOCS) doc/doxy/html: | doc/ $(DOC_EXAMPLES:%$(EXESUF)=%.o): | doc/examples OBJDIRS += doc/examples -DOXY_INPUT = $(addprefix $(SRC_PATH)/, $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXESUF)=%.c) $(LIB_EXAMPLES:%$(EXESUF)=%.c)) +DOXY_INPUT = $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXESUF)=%.c) $(LIB_EXAMPLES:%$(EXESUF)=%.c) +DOXY_INPUT_DEPS = $(addprefix $(SRC_PATH)/, $(DOXY_INPUT)) doc/doxy/html: TAG = DOXY -doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(SRC_PATH)/doc/doxy-wrapper.sh $(DOXY_INPUT) - $(M)$(SRC_PATH)/doc/doxy-wrapper.sh $(SRC_PATH) $< $(DOXYGEN) $(DOXY_INPUT) +doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(SRC_PATH)/doc/doxy-wrapper.sh $(DOXY_INPUT_DEPS) + $(M)OUT_DIR=$$PWD/doc/doxy; cd $(SRC_PATH); ./doc/doxy-wrapper.sh $$OUT_DIR $< $(DOXYGEN) $(DOXY_INPUT); install-doc: install-html install-man diff --git a/doc/build_system.txt b/doc/build_system.txt index 1efe6b53..a9bd4eb6 100644 --- a/doc/build_system.txt +++ b/doc/build_system.txt @@ -9,7 +9,7 @@ V DBG Preprocess x86 external assembler files to a .dbg.asm file in the object - directory, which then gets compiled. Helps developping those assembler + directory, which then gets compiled. Helps in developing those assembler files. DESTDIR @@ -25,10 +25,10 @@ all Default target, builds all the libraries and the executables. fate - Run the fate test suite, note you must have installed it + Run the fate test suite, note that you must have installed it. fate-list - Will list all fate/regression test targets + List all fate/regression test targets. install Install headers, libraries and programs. @@ -43,22 +43,22 @@ libavcodec/api-example Build the libavcodec basic example. libswscale/swscale-test - Build the swscale self-test (useful also as example). + Build the swscale self-test (useful also as an example). config - Reconfigure the project with current configuration. + Reconfigure the project with the current configuration. Useful standard make commands: make -t - Touch all files that otherwise would be build, this is useful to reduce - unneeded rebuilding when changing headers, but note you must force rebuilds + Touch all files that otherwise would be built, this is useful to reduce + unneeded rebuilding when changing headers, but note that you must force rebuilds of files that actually need it by hand then. make -j - rebuild with multiple jobs at the same time. Faster on multi processor systems + Rebuild with multiple jobs at the same time. Faster on multi processor systems. make -k - continue build in case of errors, this is useful for the regression tests - sometimes but note it will still not run all reg tests. + Continue build in case of errors, this is useful for the regression tests + sometimes but note that it will still not run all reg tests. diff --git a/doc/codecs.texi b/doc/codecs.texi index 3c035a5e..b481b4a0 100644 --- a/doc/codecs.texi +++ b/doc/codecs.texi @@ -129,7 +129,7 @@ should be @code{1 / frame_rate} and timestamp increments should be identically 1. @item g @var{integer} (@emph{encoding,video}) -Set the group of picture size. Default value is 12. +Set the group of picture (GOP) size. Default value is 12. @item ar @var{integer} (@emph{decoding/encoding,audio}) Set audio sampling rate (in Hz). @@ -475,6 +475,9 @@ per-block quantization parameter (QP) motion vector @item dct_coeff +@item green_metadata +display complexity metadata for the upcoming frame, GoP or for a given duration. + @item skip @item startcode @@ -814,13 +817,17 @@ for codecs that support it. See also @file{doc/examples/export_mvs.c}. Deprecated, use mpegvideo private options instead. @item threads @var{integer} (@emph{decoding/encoding,video}) +Set the number of threads to be used, in case the selected codec +implementation supports multi-threading. Possible values: @table @samp -@item auto -detect a good number of threads +@item auto, 0 +automatically select the number of threads to set @end table +Default value is @samp{auto}. + @item me_threshold @var{integer} (@emph{encoding,video}) Set motion estimation threshold. @@ -1042,7 +1049,11 @@ Possible values: @item color_primaries @var{integer} (@emph{decoding/encoding,video}) @item color_trc @var{integer} (@emph{decoding/encoding,video}) @item colorspace @var{integer} (@emph{decoding/encoding,video}) + @item color_range @var{integer} (@emph{decoding/encoding,video}) +If used as input parameter, it serves as a hint to the decoder, which +color_range the input has. + @item chroma_sample_location @var{integer} (@emph{decoding/encoding,video}) @item log_level_offset @var{integer} diff --git a/doc/decoders.texi b/doc/decoders.texi index 2fb533ae..35771140 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -25,6 +25,13 @@ enabled decoders. A description of some of the currently available video decoders follows. +@section hevc + +HEVC / H.265 decoder. + +Note: the @option{skip_loop_filter} option has effect only at level +@code{all}. + @section rawvideo Raw video decoder. @@ -188,6 +195,25 @@ without this library. @chapter Subtitles Decoders @c man begin SUBTILES DECODERS +@section dvbsub + +@subsection Options + +@table @option +@item compute_clut +@table @option +@item -1 +Compute clut if no matching CLUT is in the stream. +@item 0 +Never compute CLUT +@item 1 +Always compute CLUT and override the one provided in the stream. +@end table +@item dvb_substream +Selects the dvb substream, or all substreams if -1 which is default. + +@end table + @section dvdsub This codec decodes the bitmap subtitles used in DVDs; the same subtitles can @@ -256,7 +282,13 @@ Sets the display duration of the decoded teletext pages or subtitles in miliseconds. Default value is 30000 which is 30 seconds. @item txt_transparent Force transparent background of the generated teletext bitmaps. Default value -is 0 which means an opaque (black) background. +is 0 which means an opaque background. +@item txt_opacity +Sets the opacity (0-255) of the teletext background. If +@option{txt_transparent} is not set, it only affects characters between a start +box and an end box, typically subtitles. Default value is 0 if +@option{txt_transparent} is set, 255 otherwise. + @end table @c man end SUBTILES DECODERS diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 35a15614..3947bf64 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -18,6 +18,12 @@ enabled demuxers. The description of some of the currently available demuxers follows. +@section aa + +Audible Format 2, 3, and 4 demuxer. + +This demuxer is used to demux Audible Format 2, 3, and 4 (.aa) files. + @section applehttp Apple HTTP Live Streaming demuxer. @@ -98,7 +104,7 @@ All subsequent file-related directives apply to that file. @item @code{ffconcat version 1.0} Identify the script type and version. It also sets the @option{safe} option -to 1 if it was to its default -1. +to 1 if it was -1. To make FFmpeg recognize the format automatically, this directive must appears exactly as is (no extra space or byte-order-mark) on the very first @@ -112,6 +118,47 @@ file is not available or accurate. If the duration is set for all files, then it is possible to seek in the whole concatenated video. +@item @code{inpoint @var{timestamp}} +In point of the file. When the demuxer opens the file it instantly seeks to the +specified timestamp. Seeking is done so that all streams can be presented +successfully at In point. + +This directive works best with intra frame codecs, because for non-intra frame +ones you will usually get extra packets before the actual In point and the +decoded content will most likely contain frames before In point too. + +For each file, packets before the file In point will have timestamps less than +the calculated start timestamp of the file (negative in case of the first +file), and the duration of the files (if not specified by the @code{duration} +directive) will be reduced based on their specified In point. + +Because of potential packets before the specified In point, packet timestamps +may overlap between two concatenated files. + +@item @code{outpoint @var{timestamp}} +Out point of the file. When the demuxer reaches the specified decoding +timestamp in any of the streams, it handles it as an end of file condition and +skips the current and all the remaining packets from all streams. + +Out point is exclusive, which means that the demuxer will not output packets +with a decoding timestamp greater or equal to Out point. + +This directive works best with intra frame codecs and formats where all streams +are tightly interleaved. For non-intra frame codecs you will usually get +additional packets with presentation timestamp after Out point therefore the +decoded content will most likely contain frames after Out point too. If your +streams are not tightly interleaved you may not get all the packets from all +streams before Out point and you may only will be able to decode the earliest +stream until Out point. + +The duration of the files (if not specified by the @code{duration} +directive) will be reduced based on their specified Out point. + +@item @code{file_packet_metadata @var{key=value}} +Metadata of the packets of the file. The specified metadata will be set for +each file packet. You can specify this directive multiple times to add multiple +metadata entries. + @item @code{stream} Introduce a stream in the virtual file. All subsequent stream-related directives apply to the last introduced @@ -145,7 +192,9 @@ component. If set to 0, any file name is accepted. -The default is -1, it is equivalent to 1 if the format was automatically +The default is 1. + +-1 is equivalent to 1 if the format was automatically probed and 0 otherwise. @item auto_convert @@ -157,8 +206,43 @@ Currently, the only conversion is adding the h264_mp4toannexb bitstream filter to H.264 streams in MP4 format. This is necessary in particular if there are resolution changes. +@item segment_time_metadata +If set to 1, every packet will contain the @var{lavf.concat.start_time} and the +@var{lavf.concat.duration} packet metadata values which are the start_time and +the duration of the respective file segments in the concatenated output +expressed in microseconds. The duration metadata is only set if it is known +based on the concat file. +The default is 0. + @end table +@subsection Examples + +@itemize +@item +Use absolute filenames and include some comments: +@example +# my first filename +file /mnt/share/file-1.wav +# my second filename including whitespace +file '/mnt/share/file 2.wav' +# my third filename including whitespace plus single quote +file '/mnt/share/file 3'\''.wav' +@end example + +@item +Allow for input format auto-probing, use safe filenames and set the duration of +the first file: +@example +ffconcat version 1.0 + +file file-1.wav +duration 20.0 + +file subdir/file-2.wav +@end example +@end itemize + @section flv Adobe Flash Video Format demuxer. @@ -183,18 +267,6 @@ track. Track indexes start at 0. The demuxer exports the number of tracks as For very large files, the @option{max_size} option may have to be adjusted. -@section libquvi - -Play media from Internet services using the quvi project. - -The demuxer accepts a @option{format} option to request a specific quality. It -is by default set to @var{best}. - -See @url{http://quvi.sourceforge.net/} for more information. - -FFmpeg needs to be built with @code{--enable-libquvi} for this demuxer to be -enabled. - @section gif Animated GIF demuxer. @@ -369,17 +441,62 @@ ffmpeg -framerate 10 -pattern_type glob -i "*.png" out.mkv @end example @end itemize +@section mov/mp4/3gp/Quicktme + +Quicktime / MP4 demuxer. + +This demuxer accepts the following options: +@table @option +@item enable_drefs +Enable loading of external tracks, disabled by default. +Enabling this can theoretically leak information in some use cases. + +@item use_absolute_path +Allows loading of external tracks via absolute paths, disabled by default. +Enabling this poses a security risk. It should only be enabled if the source +is known to be non malicious. + +@end table + @section mpegts MPEG-2 transport stream demuxer. +This demuxer accepts the following options: @table @option +@item resync_size +Set size limit for looking up a new synchronization. Default value is +65536. @item fix_teletext_pts -Overrides teletext packet PTS and DTS values with the timestamps calculated +Override teletext packet PTS and DTS values with the timestamps calculated from the PCR of the first program which the teletext stream is part of and is not discarded. Default value is 1, set this option to 0 if you want your teletext packet PTS and DTS values untouched. + +@item ts_packetsize +Output option carrying the raw packet size in bytes. +Show the detected raw packet size, cannot be set by the user. + +@item scan_all_pmts +Scan and combine all PMTs. The value is an integer with value from -1 +to 1 (-1 means automatic setting, 1 means enabled, 0 means +disabled). Default value is -1. +@end table + +@section mpjpeg + +MJPEG encapsulated in multi-part MIME demuxer. + +This demuxer allows reading of MJPEG, where each frame is represented as a part of +multipart/x-mixed-replace stream. +@table @option + +@item strict_mime_boundary +Default implementation applies a relaxed standard to multi-part MIME boundary detection, +to prevent regression with numerous existing endpoints not generating a proper MIME +MJPEG stream. Turning this option on by setting it to 1 will result in a stricter check +of the boundary value. @end table @section rawvideo diff --git a/doc/developer.texi b/doc/developer.texi index d9ccf7b9..6db93cef 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -28,14 +28,14 @@ this document. For more detailed legal information about the use of FFmpeg in external programs read the @file{LICENSE} file in the source tree and -consult @url{http://ffmpeg.org/legal.html}. +consult @url{https://ffmpeg.org/legal.html}. @section Contributing -There are 3 ways by which code gets into ffmpeg. +There are 3 ways by which code gets into FFmpeg. @itemize @bullet -@item Submitting Patches to the main developer mailing list - see @ref{Submitting patches} for details. +@item Submitting patches to the main developer mailing list. + See @ref{Submitting patches} for details. @item Directly committing changes to the main tree. @item Committing changes to a git clone, for example on github.com or gitorious.org. And asking us to merge these changes. @@ -65,6 +65,9 @@ rejected by the git repository. @item You should try to limit your code lines to 80 characters; however, do so if and only if this improves readability. + +@item +K&R coding style is used. @end itemize The presentation is one inspired by 'indent -i4 -kr -nut'. @@ -124,10 +127,10 @@ the @samp{inline} keyword; @samp{//} comments; @item -designated struct initializers (@samp{struct s x = @{ .i = 17 @};}) +designated struct initializers (@samp{struct s x = @{ .i = 17 @};}); @item -compound literals (@samp{x = (struct s) @{ 17, 23 @};}) +compound literals (@samp{x = (struct s) @{ 17, 23 @};}). @end itemize These features are supported by all compilers we care about, so we will not @@ -156,7 +159,7 @@ GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}). All names should be composed with underscores (_), not CamelCase. For example, @samp{avfilter_get_video_buffer} is an acceptable function name and @samp{AVFilterGetVideo} is not. The exception from this are type names, like -for example structs and enums; they should always be in the CamelCase +for example structs and enums; they should always be in CamelCase. There are the following conventions for naming variables and functions: @@ -394,8 +397,8 @@ or obfuscates the code. Make sure that no parts of the codebase that you maintain are missing from the @file{MAINTAINERS} file. If something that you want to maintain is missing add it with your name after it. -If at some point you no longer want to maintain some code, then please help -finding a new maintainer and also don't forget updating the @file{MAINTAINERS} file. +If at some point you no longer want to maintain some code, then please help in +finding a new maintainer and also don't forget to update the @file{MAINTAINERS} file. @end enumerate We think our rules are not too hard. If you have comments, contact us. @@ -407,7 +410,7 @@ First, read the @ref{Coding Rules} above if you did not yet, in particular the rules regarding patch submission. When you submit your patch, please use @code{git format-patch} or -@code{git send-email}. We cannot read other diffs :-) +@code{git send-email}. We cannot read other diffs :-). Also please do not submit a patch which contains several unrelated changes. Split it into separate, self-contained pieces. This does not mean splitting @@ -430,7 +433,7 @@ Also please if you send several patches, send each patch as a separate mail, do not attach several unrelated patches to the same mail. Patches should be posted to the -@uref{http://lists.ffmpeg.org/mailman/listinfo/ffmpeg-devel, ffmpeg-devel} +@uref{https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-devel, ffmpeg-devel} mailing list. Use @code{git send-email} when possible since it will properly send patches without requiring extra care. If you cannot, then send patches as base64-encoded attachments, so your patch is not trashed during @@ -543,6 +546,10 @@ tools/trasher, the noise bitstream filter, and should not crash, end in a (near) infinite loop, or allocate ridiculous amounts of memory when fed damaged data. +@item +Did you test your decoder or demuxer against sample files? +Samples may be obtained at @url{https://samples.ffmpeg.org}. + @item Does the patch not mix functional and cosmetic changes? @@ -563,7 +570,7 @@ If the patch fixes a bug, did you provide a verbose analysis of the bug? If the patch fixes a bug, did you provide enough information, including a sample, so the bug can be reproduced and the fix can be verified? Note please do not attach samples >100k to mails but rather provide a -URL, you can upload to ftp://upload.ffmpeg.org +URL, you can upload to ftp://upload.ffmpeg.org. @item Did you provide a verbose summary about what the patch does change? @@ -592,10 +599,10 @@ Lines with similar content should be aligned vertically when doing so improves readability. @item -Consider to add a regression test for your code. +Consider adding a regression test for your code. @item -If you added YASM code please check that things still work with --disable-yasm +If you added YASM code please check that things still work with --disable-yasm. @item Make sure you check the return values of function and return appropriate @@ -633,6 +640,10 @@ not related to the comments received during review. Such patches will be rejected. Instead, submit significant changes or new features as separate patches. +Everyone is welcome to review patches. Also if you are waiting for your patch +to be reviewed, please consider helping to review other patches, that is a great +way to get everyone's patches reviewed sooner. + @anchor{Regression tests} @section Regression tests @@ -656,7 +667,6 @@ Once you have a working fate test and fate sample, provide in the commit message or introductory message for the patch series that you post to the ffmpeg-devel mailing list, a direct link to download the sample media. - @subsection Visualizing Test Coverage The FFmpeg build system allows visualizing the test coverage in an easy @@ -704,7 +714,7 @@ FFmpeg maintains a set of @strong{release branches}, which are the recommended deliverable for system integrators and distributors (such as Linux distributions, etc.). At regular times, a @strong{release manager} prepares, tests and publishes tarballs on the -@url{http://ffmpeg.org} website. +@url{https://ffmpeg.org} website. There are two kinds of releases: @@ -783,7 +793,7 @@ Prepare the release tarballs in @code{bz2} and @code{gz} formats, and supplementing files that contain @code{gpg} signatures @item -Publish the tarballs at @url{http://ffmpeg.org/releases}. Create and +Publish the tarballs at @url{https://ffmpeg.org/releases}. Create and push an annotated tag in the form @code{nX}, with @code{X} containing the version number. @@ -795,7 +805,7 @@ with a news entry for the website. Publish the news entry. @item -Send announcement to the mailing list. +Send an announcement to the mailing list. @end enumerate @bye diff --git a/doc/doxy-wrapper.sh b/doc/doxy-wrapper.sh index 9720e540..fe0102b5 100755 --- a/doc/doxy-wrapper.sh +++ b/doc/doxy-wrapper.sh @@ -1,21 +1,21 @@ #!/bin/sh -SRC_PATH="${1}" +OUT_DIR="${1}" DOXYFILE="${2}" DOXYGEN="${3}" shift 3 -if [ -e "$SRC_PATH/VERSION" ]; then - VERSION=`cat "$SRC_PATH/VERSION"` +if [ -e "VERSION" ]; then + VERSION=`cat "VERSION"` else - VERSION=`cd "$SRC_PATH"; git describe` + VERSION=`git describe` fi $DOXYGEN - < @option{GopPicSize} + +@item +@option{bf/max_b_frames}+1 -> @option{GopRefDist} + +@item +@option{rc_init_occupancy/rc_initial_buffer_occupancy} -> +@option{InitialDelayInKB} + +@item +@option{slices} -> @option{NumSlice} + +@item +@option{refs} -> @option{NumRefFrame} + +@item +@option{b_strategy/b_frame_strategy} -> @option{BRefType} + +@item +@option{cgop/CLOSED_GOP} codec flag -> @option{GopOptFlag} + +@item +For the @var{CQP} mode, the @option{i_qfactor/i_qoffset} and +@option{b_qfactor/b_qoffset} set the difference between @var{QPP} and @var{QPI}, +and @var{QPP} and @var{QPB} respectively. + +@item +Setting the @option{coder} option to the value @var{vlc} will make the H.264 +encoder use CAVLC instead of CABAC. + +@end itemize + +@section vc2 + +SMPTE VC-2 (previously BBC Dirac Pro). This codec was primarily aimed at +professional broadcasting but since it supports yuv420, yuv422 and yuv444 at +8 (limited range or full range), 10 or 12 bits, this makes it suitable for +other tasks which require low overhead and low compression (like screen +recording). + +@subsection Options + +@table @option + +@item b +Sets target video bitrate. Usually that's around 1:6 of the uncompressed +video bitrate (e.g. for 1920x1080 50fps yuv422p10 that's around 400Mbps). Higher +values (close to the uncompressed bitrate) turn on lossless compression mode. + +@item field_order +Enables field coding when set (e.g. to tt - top field first) for interlaced +inputs. Should increase compression with interlaced content as it splits the +fields and encodes each separately. + +@item wavelet_depth +Sets the total amount of wavelet transforms to apply, between 1 and 5 (default). +Lower values reduce compression and quality. Less capable decoders may not be +able to handle values of @option{wavelet_depth} over 3. + +@item wavelet_type +Sets the transform type. Currently only @var{5_3} (LeGall) and @var{9_7} +(Deslauriers-Dubuc) +are implemented, with 9_7 being the one with better compression and thus +is the default. + +@item slice_width +@item slice_height +Sets the slice size for each slice. Larger values result in better compression. +For compatibility with other more limited decoders use @option{slice_width} of +32 and @option{slice_height} of 8. + +@item tolerance +Sets the undershoot tolerance of the rate control system in percent. This is +to prevent an expensive search from being run. + +@item qm +Sets the quantization matrix preset to use by default or when @option{wavelet_depth} +is set to 5 +@itemize @minus +@item +@var{default} +Uses the default quantization matrix from the specifications, extended with +values for the fifth level. This provides a good balance between keeping detail +and omitting artifacts. + +@item +@var{flat} +Use a completely zeroed out quantization matrix. This increases PSNR but might +reduce perception. Use in bogus benchmarks. + +@item +@var{color} +Reduces detail but attempts to preserve color at extremely low bitrates. +@end itemize + +@end table + @c man end VIDEO ENCODERS @chapter Subtitles Encoders diff --git a/doc/errno.txt b/doc/errno.txt index 31cab26f..933a4de5 100644 --- a/doc/errno.txt +++ b/doc/errno.txt @@ -76,7 +76,7 @@ EMFILE POSIX ++++++ Too many open files EMLINK POSIX ++++++ Too many links EMSGSIZE POSIX +++..+ Message too long EMULTIHOP POSIX ++4... Multihop attempted -ENAMETOOLONG POSIX - ++++++ Filen ame too long +ENAMETOOLONG POSIX - ++++++ File name too long ENAVAIL +..... No XENIX semaphores available ENEEDAUTH .++... Need authenticator ENETDOWN POSIX +++..+ Network is down diff --git a/doc/examples/Makefile b/doc/examples/Makefile index 9699f11d..af381599 100644 --- a/doc/examples/Makefile +++ b/doc/examples/Makefile @@ -11,13 +11,14 @@ CFLAGS += -Wall -g CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS) LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS) -EXAMPLES= avio_list_dir \ +EXAMPLES= avio_dir_cmd \ avio_reading \ decoding_encoding \ demuxing_decoding \ extract_mvs \ filtering_video \ filtering_audio \ + http_multiclient \ metadata \ muxing \ remuxing \ diff --git a/doc/examples/avio_list_dir.c b/doc/examples/avio_dir_cmd.c similarity index 66% rename from doc/examples/avio_list_dir.c rename to doc/examples/avio_dir_cmd.c index 4060ba62..50c435cf 100644 --- a/doc/examples/avio_list_dir.c +++ b/doc/examples/avio_dir_cmd.c @@ -54,28 +54,13 @@ static const char *type_string(int type) return ""; } -int main(int argc, char *argv[]) +static int list_op(const char *input_dir) { - const char *input_dir = NULL; AVIODirEntry *entry = NULL; AVIODirContext *ctx = NULL; int cnt, ret; char filemode[4], uid_and_gid[20]; - av_log_set_level(AV_LOG_DEBUG); - - if (argc != 2) { - fprintf(stderr, "usage: %s input_dir\n" - "API example program to show how to list files in directory " - "accessed through AVIOContext.\n", argv[0]); - return 1; - } - input_dir = argv[1]; - - /* register codecs and formats and other lavf/lavc components*/ - av_register_all(); - avformat_network_init(); - if ((ret = avio_open_dir(&ctx, input_dir, NULL)) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot open directory: %s.\n", av_err2str(ret)); goto fail; @@ -114,6 +99,81 @@ int main(int argc, char *argv[]) fail: avio_close_dir(&ctx); + return ret; +} + +static int del_op(const char *url) +{ + int ret = avpriv_io_delete(url); + if (ret < 0) + av_log(NULL, AV_LOG_ERROR, "Cannot delete '%s': %s.\n", url, av_err2str(ret)); + return ret; +} + +static int move_op(const char *src, const char *dst) +{ + int ret = avpriv_io_move(src, dst); + if (ret < 0) + av_log(NULL, AV_LOG_ERROR, "Cannot move '%s' into '%s': %s.\n", src, dst, av_err2str(ret)); + return ret; +} + + +static void usage(const char *program_name) +{ + fprintf(stderr, "usage: %s OPERATION entry1 [entry2]\n" + "API example program to show how to manipulate resources " + "accessed through AVIOContext.\n" + "OPERATIONS:\n" + "list list content of the directory\n" + "move rename content in directory\n" + "del delete content in directory\n", + program_name); +} + +int main(int argc, char *argv[]) +{ + const char *op = NULL; + int ret; + + av_log_set_level(AV_LOG_DEBUG); + + if (argc < 2) { + usage(argv[0]); + return 1; + } + + /* register codecs and formats and other lavf/lavc components*/ + av_register_all(); + avformat_network_init(); + + op = argv[1]; + if (strcmp(op, "list") == 0) { + if (argc < 3) { + av_log(NULL, AV_LOG_INFO, "Missing argument for list operation.\n"); + ret = AVERROR(EINVAL); + } else { + ret = list_op(argv[2]); + } + } else if (strcmp(op, "del") == 0) { + if (argc < 3) { + av_log(NULL, AV_LOG_INFO, "Missing argument for del operation.\n"); + ret = AVERROR(EINVAL); + } else { + ret = del_op(argv[2]); + } + } else if (strcmp(op, "move") == 0) { + if (argc < 4) { + av_log(NULL, AV_LOG_INFO, "Missing argument for move operation.\n"); + ret = AVERROR(EINVAL); + } else { + ret = move_op(argv[2], argv[3]); + } + } else { + av_log(NULL, AV_LOG_INFO, "Invalid operation %s\n", op); + ret = AVERROR(EINVAL); + } + avformat_network_deinit(); return ret < 0 ? 1 : 0; diff --git a/doc/examples/decoding_encoding.c b/doc/examples/decoding_encoding.c index 80da6643..06a98a63 100644 --- a/doc/examples/decoding_encoding.c +++ b/doc/examples/decoding_encoding.c @@ -211,7 +211,7 @@ static void audio_encode_example(const char *filename) } if (got_output) { fwrite(pkt.data, 1, pkt.size, f); - av_free_packet(&pkt); + av_packet_unref(&pkt); } } @@ -225,7 +225,7 @@ static void audio_encode_example(const char *filename) if (got_output) { fwrite(pkt.data, 1, pkt.size, f); - av_free_packet(&pkt); + av_packet_unref(&pkt); } } fclose(f); @@ -245,7 +245,7 @@ static void audio_decode_example(const char *outfilename, const char *filename) AVCodecContext *c= NULL; int len; FILE *f, *outfile; - uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; + uint8_t inbuf[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; AVPacket avpkt; AVFrame *decoded_frame = NULL; @@ -454,7 +454,7 @@ static void video_encode_example(const char *filename, int codec_id) if (got_output) { printf("Write frame %3d (size=%5d)\n", i, pkt.size); fwrite(pkt.data, 1, pkt.size, f); - av_free_packet(&pkt); + av_packet_unref(&pkt); } } @@ -471,7 +471,7 @@ static void video_encode_example(const char *filename, int codec_id) if (got_output) { printf("Write frame %3d (size=%5d)\n", i, pkt.size); fwrite(pkt.data, 1, pkt.size, f); - av_free_packet(&pkt); + av_packet_unref(&pkt); } } @@ -521,7 +521,7 @@ static int decode_write_frame(const char *outfilename, AVCodecContext *avctx, /* the picture is allocated by the decoder, no need to free it */ snprintf(buf, sizeof(buf), outfilename, *frame_count); pgm_save(frame->data[0], frame->linesize[0], - avctx->width, avctx->height, buf); + frame->width, frame->height, buf); (*frame_count)++; } if (pkt->data) { @@ -538,13 +538,13 @@ static void video_decode_example(const char *outfilename, const char *filename) int frame_count; FILE *f; AVFrame *frame; - uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; + uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; AVPacket avpkt; av_init_packet(&avpkt); /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */ - memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE); printf("Decode video file %s to %s\n", filename, outfilename); @@ -561,8 +561,8 @@ static void video_decode_example(const char *outfilename, const char *filename) exit(1); } - if(codec->capabilities&CODEC_CAP_TRUNCATED) - c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */ + if (codec->capabilities & AV_CODEC_CAP_TRUNCATED) + c->flags |= AV_CODEC_FLAG_TRUNCATED; // we do not send complete frames /* For some codecs, such as msmpeg4 and mpeg4, width and height MUST be initialized there because this information is not diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c index 98b3a830..59e0ccc9 100644 --- a/doc/examples/demuxing_decoding.c +++ b/doc/examples/demuxing_decoding.c @@ -55,17 +55,11 @@ static AVPacket pkt; static int video_frame_count = 0; static int audio_frame_count = 0; -/* The different ways of decoding and managing data memory. You are not - * supposed to support all the modes in your application but pick the one most - * appropriate to your needs. Look for the use of api_mode in this example to - * see what are the differences of API usage between them */ -enum { - API_MODE_OLD = 0, /* old method, deprecated */ - API_MODE_NEW_API_REF_COUNT = 1, /* new method, using the frame reference counting */ - API_MODE_NEW_API_NO_REF_COUNT = 2, /* new method, without reference counting */ -}; - -static int api_mode = API_MODE_OLD; +/* Enable or disable frame reference counting. You are not supposed to support + * both paths in your application but pick the one most appropriate to your + * needs. Look for the use of refcount in this example to see what are the + * differences of API usage between them. */ +static int refcount = 0; static int decode_packet(int *got_frame, int cached) { @@ -145,9 +139,9 @@ static int decode_packet(int *got_frame, int cached) } } - /* If we use the new API with reference counting, we own the data and need + /* If we use frame reference counting, we own the data and need * to de-reference it when we don't use it anymore */ - if (*got_frame && api_mode == API_MODE_NEW_API_REF_COUNT) + if (*got_frame && refcount) av_frame_unref(frame); return decoded; @@ -181,8 +175,7 @@ static int open_codec_context(int *stream_idx, } /* Init the decoders, with or without reference counting */ - if (api_mode == API_MODE_NEW_API_REF_COUNT) - av_dict_set(&opts, "refcounted_frames", "1", 0); + av_dict_set(&opts, "refcounted_frames", refcount ? "1" : "0", 0); if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 0) { fprintf(stderr, "Failed to open %s codec\n", av_get_media_type_string(type)); @@ -228,28 +221,19 @@ int main (int argc, char **argv) int ret = 0, got_frame; if (argc != 4 && argc != 5) { - fprintf(stderr, "usage: %s [-refcount=] " - "input_file video_output_file audio_output_file\n" + fprintf(stderr, "usage: %s [-refcount] input_file video_output_file audio_output_file\n" "API example program to show how to read frames from an input file.\n" "This program reads frames from a file, decodes them, and writes decoded\n" "video frames to a rawvideo file named video_output_file, and decoded\n" "audio frames to a rawaudio file named audio_output_file.\n\n" "If the -refcount option is specified, the program use the\n" "reference counting frame system which allows keeping a copy of\n" - "the data for longer than one decode call. If unset, it's using\n" - "the classic old method.\n" + "the data for longer than one decode call.\n" "\n", argv[0]); exit(1); } - if (argc == 5) { - const char *mode = argv[1] + strlen("-refcount="); - if (!strcmp(mode, "old")) api_mode = API_MODE_OLD; - else if (!strcmp(mode, "new_norefcount")) api_mode = API_MODE_NEW_API_NO_REF_COUNT; - else if (!strcmp(mode, "new_refcount")) api_mode = API_MODE_NEW_API_REF_COUNT; - else { - fprintf(stderr, "unknow mode '%s'\n", mode); - exit(1); - } + if (argc == 5 && !strcmp(argv[1], "-refcount")) { + refcount = 1; argv++; } src_filename = argv[1]; @@ -315,12 +299,7 @@ int main (int argc, char **argv) goto end; } - /* When using the new API, you need to use the libavutil/frame.h API, while - * the classic frame management is available in libavcodec */ - if (api_mode == API_MODE_OLD) - frame = avcodec_alloc_frame(); - else - frame = av_frame_alloc(); + frame = av_frame_alloc(); if (!frame) { fprintf(stderr, "Could not allocate frame\n"); ret = AVERROR(ENOMEM); @@ -347,7 +326,7 @@ int main (int argc, char **argv) pkt.data += ret; pkt.size -= ret; } while (pkt.size > 0); - av_free_packet(&orig_pkt); + av_packet_unref(&orig_pkt); } /* flush cached frames */ @@ -397,10 +376,7 @@ int main (int argc, char **argv) fclose(video_dst_file); if (audio_dst_file) fclose(audio_dst_file); - if (api_mode == API_MODE_OLD) - avcodec_free_frame(&frame); - else - av_frame_free(&frame); + av_frame_free(&frame); av_free(video_dst_data[0]); return ret < 0; diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c index d6fd6133..975189c7 100644 --- a/doc/examples/extract_mvs.c +++ b/doc/examples/extract_mvs.c @@ -167,7 +167,7 @@ int main(int argc, char **argv) pkt.data += ret; pkt.size -= ret; } while (pkt.size > 0); - av_free_packet(&orig_pkt); + av_packet_unref(&orig_pkt); } /* flush cached frames */ diff --git a/doc/examples/filtering_audio.c b/doc/examples/filtering_audio.c index f5cb8eb8..89c80cfd 100644 --- a/doc/examples/filtering_audio.c +++ b/doc/examples/filtering_audio.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -274,10 +273,10 @@ int main(int argc, char **argv) } if (packet.size <= 0) - av_free_packet(&packet0); + av_packet_unref(&packet0); } else { /* discard non-wanted packets */ - av_free_packet(&packet0); + av_packet_unref(&packet0); } } end: diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c index c02040ae..3dabf13b 100644 --- a/doc/examples/filtering_video.c +++ b/doc/examples/filtering_video.c @@ -33,12 +33,14 @@ #include #include #include -#include #include #include #include -const char *filter_descr = "scale=78:24"; +const char *filter_descr = "scale=78:24,transpose=cclock"; +/* other way: + scale=78:24 [scl]; [scl] transpose=cclock // assumes "[in]" and "[out]" to be input output pads respectively + */ static AVFormatContext *fmt_ctx; static AVCodecContext *dec_ctx; @@ -260,7 +262,7 @@ int main(int argc, char **argv) av_frame_unref(frame); } } - av_free_packet(&packet); + av_packet_unref(&packet); } end: avfilter_graph_free(&filter_graph); diff --git a/doc/examples/http_multiclient.c b/doc/examples/http_multiclient.c new file mode 100644 index 00000000..b9a306d8 --- /dev/null +++ b/doc/examples/http_multiclient.c @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2015 Stephan Holljes + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * @file + * libavformat multi-client network API usage example. + * + * @example http_multiclient.c + * This example will serve a file without decoding or demuxing it over http. + * Multiple clients can connect and will receive the same file. + */ + +#include +#include +#include + +void process_client(AVIOContext *client, const char *in_uri) +{ + AVIOContext *input = NULL; + uint8_t buf[1024]; + int ret, n, reply_code; + char *resource = NULL; + while ((ret = avio_handshake(client)) > 0) { + av_opt_get(client, "resource", AV_OPT_SEARCH_CHILDREN, &resource); + // check for strlen(resource) is necessary, because av_opt_get() + // may return empty string. + if (resource && strlen(resource)) + break; + } + if (ret < 0) + goto end; + av_log(client, AV_LOG_TRACE, "resource=%p\n", resource); + if (resource && resource[0] == '/' && !strcmp((resource + 1), in_uri)) { + reply_code = 200; + } else { + reply_code = AVERROR_HTTP_NOT_FOUND; + } + if ((ret = av_opt_set_int(client, "reply_code", reply_code, AV_OPT_SEARCH_CHILDREN)) < 0) { + av_log(client, AV_LOG_ERROR, "Failed to set reply_code: %s.\n", av_err2str(ret)); + goto end; + } + av_log(client, AV_LOG_TRACE, "Set reply code to %d\n", reply_code); + + while ((ret = avio_handshake(client)) > 0); + + if (ret < 0) + goto end; + + fprintf(stderr, "Handshake performed.\n"); + if (reply_code != 200) + goto end; + fprintf(stderr, "Opening input file.\n"); + if ((ret = avio_open2(&input, in_uri, AVIO_FLAG_READ, NULL, NULL)) < 0) { + av_log(input, AV_LOG_ERROR, "Failed to open input: %s: %s.\n", in_uri, + av_err2str(ret)); + goto end; + } + for(;;) { + n = avio_read(input, buf, sizeof(buf)); + if (n < 0) { + if (n == AVERROR_EOF) + break; + av_log(input, AV_LOG_ERROR, "Error reading from input: %s.\n", + av_err2str(n)); + break; + } + avio_write(client, buf, n); + avio_flush(client); + } +end: + fprintf(stderr, "Flushing client\n"); + avio_flush(client); + fprintf(stderr, "Closing client\n"); + avio_close(client); + fprintf(stderr, "Closing input\n"); + avio_close(input); +} + +int main(int argc, char **argv) +{ + av_log_set_level(AV_LOG_TRACE); + AVDictionary *options = NULL; + AVIOContext *client = NULL, *server = NULL; + const char *in_uri, *out_uri; + int ret, pid; + if (argc < 3) { + printf("usage: %s input http://hostname[:port]\n" + "API example program to serve http to multiple clients.\n" + "\n", argv[0]); + return 1; + } + + in_uri = argv[1]; + out_uri = argv[2]; + + av_register_all(); + avformat_network_init(); + + if ((ret = av_dict_set(&options, "listen", "2", 0)) < 0) { + fprintf(stderr, "Failed to set listen mode for server: %s\n", av_err2str(ret)); + return ret; + } + if ((ret = avio_open2(&server, out_uri, AVIO_FLAG_WRITE, NULL, &options)) < 0) { + fprintf(stderr, "Failed to open server: %s\n", av_err2str(ret)); + return ret; + } + fprintf(stderr, "Entering main loop.\n"); + for(;;) { + if ((ret = avio_accept(server, &client)) < 0) + goto end; + fprintf(stderr, "Accepted client, forking process.\n"); + // XXX: Since we don't reap our children and don't ignore signals + // this produces zombie processes. + pid = fork(); + if (pid < 0) { + perror("Fork failed"); + ret = AVERROR(errno); + goto end; + } + if (pid == 0) { + fprintf(stderr, "In child.\n"); + process_client(client, in_uri); + avio_close(server); + exit(0); + } + if (pid > 0) + avio_close(client); + } +end: + avio_close(server); + if (ret < 0 && ret != AVERROR_EOF) { + fprintf(stderr, "Some errors occurred: %s\n", av_err2str(ret)); + return 1; + } + return 0; +} diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c index 8b0ea60b..d4dac5cd 100644 --- a/doc/examples/muxing.c +++ b/doc/examples/muxing.c @@ -172,7 +172,7 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc, /* Some formats want stream headers to be separate. */ if (oc->oformat->flags & AVFMT_GLOBALHEADER) - c->flags |= CODEC_FLAG_GLOBAL_HEADER; + c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; } /**************************************************************/ @@ -230,7 +230,7 @@ static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A /* increment frequency by 110 Hz per second */ ost->tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate; - if (c->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE) + if (c->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) nb_samples = 10000; else nb_samples = c->frame_size; @@ -493,44 +493,25 @@ static int write_video_frame(AVFormatContext *oc, OutputStream *ost) AVCodecContext *c; AVFrame *frame; int got_packet = 0; + AVPacket pkt = { 0 }; c = ost->st->codec; frame = get_video_frame(ost); - if (oc->oformat->flags & AVFMT_RAWPICTURE) { - /* a hack to avoid data copy with some raw video muxers */ - AVPacket pkt; - av_init_packet(&pkt); - - if (!frame) - return 1; - - pkt.flags |= AV_PKT_FLAG_KEY; - pkt.stream_index = ost->st->index; - pkt.data = (uint8_t *)frame; - pkt.size = sizeof(AVPicture); + av_init_packet(&pkt); - pkt.pts = pkt.dts = frame->pts; - av_packet_rescale_ts(&pkt, c->time_base, ost->st->time_base); + /* encode the image */ + ret = avcodec_encode_video2(c, &pkt, frame, &got_packet); + if (ret < 0) { + fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret)); + exit(1); + } - ret = av_interleaved_write_frame(oc, &pkt); + if (got_packet) { + ret = write_frame(oc, &c->time_base, ost->st, &pkt); } else { - AVPacket pkt = { 0 }; - av_init_packet(&pkt); - - /* encode the image */ - ret = avcodec_encode_video2(c, &pkt, frame, &got_packet); - if (ret < 0) { - fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret)); - exit(1); - } - - if (got_packet) { - ret = write_frame(oc, &c->time_base, ost->st, &pkt); - } else { - ret = 0; - } + ret = 0; } if (ret < 0) { diff --git a/doc/examples/qsvdec.c b/doc/examples/qsvdec.c index 6dbb2103..fd934beb 100644 --- a/doc/examples/qsvdec.c +++ b/doc/examples/qsvdec.c @@ -116,15 +116,6 @@ static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req, static mfxStatus frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp) { - DecodeContext *decode = pthis; - - if (decode->surfaces) - vaDestroySurfaces(decode->va_dpy, decode->surfaces, decode->nb_surfaces); - av_freep(&decode->surfaces); - av_freep(&decode->surface_ids); - av_freep(&decode->surface_used); - decode->nb_surfaces = 0; - return MFX_ERR_NONE; } @@ -144,6 +135,16 @@ static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) return MFX_ERR_NONE; } +static void free_surfaces(DecodeContext *decode) +{ + if (decode->surfaces) + vaDestroySurfaces(decode->va_dpy, decode->surfaces, decode->nb_surfaces); + av_freep(&decode->surfaces); + av_freep(&decode->surface_ids); + av_freep(&decode->surface_used); + decode->nb_surfaces = 0; +} + static void free_buffer(void *opaque, uint8_t *data) { int *used = opaque; @@ -405,7 +406,7 @@ int main(int argc, char **argv) decoder_ctx->codec_id = AV_CODEC_ID_H264; if (video_st->codec->extradata_size) { decoder_ctx->extradata = av_mallocz(video_st->codec->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!decoder_ctx->extradata) { ret = AVERROR(ENOMEM); goto finish; @@ -467,6 +468,12 @@ int main(int argc, char **argv) av_frame_free(&frame); + if (decoder_ctx) + av_freep(&decoder_ctx->hwaccel_context); + avcodec_free_context(&decoder_ctx); + + free_surfaces(&decode); + if (decode.mfx_session) MFXClose(decode.mfx_session); if (decode.va_dpy) @@ -474,10 +481,6 @@ int main(int argc, char **argv) if (dpy) XCloseDisplay(dpy); - if (decoder_ctx) - av_freep(&decoder_ctx->hwaccel_context); - avcodec_free_context(&decoder_ctx); - avio_close(output_ctx); return ret; diff --git a/doc/examples/remuxing.c b/doc/examples/remuxing.c index e9758a8d..65437d9a 100644 --- a/doc/examples/remuxing.c +++ b/doc/examples/remuxing.c @@ -101,7 +101,7 @@ int main(int argc, char **argv) } out_stream->codec->codec_tag = 0; if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) - out_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; + out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; } av_dump_format(ofmt_ctx, 0, out_filename, 1); @@ -143,7 +143,7 @@ int main(int argc, char **argv) fprintf(stderr, "Error muxing packet\n"); break; } - av_free_packet(&pkt); + av_packet_unref(&pkt); } av_write_trailer(ofmt_ctx); diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c index 339d65c7..486e54c2 100644 --- a/doc/examples/transcode_aac.c +++ b/doc/examples/transcode_aac.c @@ -192,7 +192,7 @@ static int open_output_file(const char *filename, * Mark the encoder so that it behaves accordingly. */ if ((*output_format_context)->oformat->flags & AVFMT_GLOBALHEADER) - (*output_codec_context)->flags |= CODEC_FLAG_GLOBAL_HEADER; + (*output_codec_context)->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; /** Open the encoder for the audio stream to use it later. */ if ((error = avcodec_open2(*output_codec_context, output_codec, NULL)) < 0) { @@ -332,7 +332,7 @@ static int decode_audio_frame(AVFrame *frame, data_present, &input_packet)) < 0) { fprintf(stderr, "Could not decode frame (error '%s')\n", get_error_text(error)); - av_free_packet(&input_packet); + av_packet_unref(&input_packet); return error; } @@ -342,7 +342,7 @@ static int decode_audio_frame(AVFrame *frame, */ if (*finished && *data_present) *finished = 0; - av_free_packet(&input_packet); + av_packet_unref(&input_packet); return 0; } @@ -571,7 +571,7 @@ static int encode_audio_frame(AVFrame *frame, frame, data_present)) < 0) { fprintf(stderr, "Could not encode frame (error '%s')\n", get_error_text(error)); - av_free_packet(&output_packet); + av_packet_unref(&output_packet); return error; } @@ -580,11 +580,11 @@ static int encode_audio_frame(AVFrame *frame, if ((error = av_write_frame(output_format_context, &output_packet)) < 0) { fprintf(stderr, "Could not write frame (error '%s')\n", get_error_text(error)); - av_free_packet(&output_packet); + av_packet_unref(&output_packet); return error; } - av_free_packet(&output_packet); + av_packet_unref(&output_packet); } return 0; diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c index 980e1f10..d5d410b1 100644 --- a/doc/examples/transcoding.c +++ b/doc/examples/transcoding.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -161,7 +160,7 @@ static int open_output_file(const char *filename) } if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) - enc_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; + enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; } av_dump_format(ofmt_ctx, 0, filename, 1); @@ -449,7 +448,7 @@ static int flush_encoder(unsigned int stream_index) int got_frame; if (!(ofmt_ctx->streams[stream_index]->codec->codec->capabilities & - CODEC_CAP_DELAY)) + AV_CODEC_CAP_DELAY)) return 0; while (1) { @@ -537,7 +536,7 @@ int main(int argc, char **argv) if (ret < 0) goto end; } - av_free_packet(&packet); + av_packet_unref(&packet); } /* flush filters and encoders */ @@ -561,7 +560,7 @@ int main(int argc, char **argv) av_write_trailer(ofmt_ctx); end: - av_free_packet(&packet); + av_packet_unref(&packet); av_frame_free(&frame); for (i = 0; i < ifmt_ctx->nb_streams; i++) { avcodec_close(ifmt_ctx->streams[i]->codec); diff --git a/doc/faq.texi b/doc/faq.texi index 5fe716b8..ef111c70 100644 --- a/doc/faq.texi +++ b/doc/faq.texi @@ -147,7 +147,7 @@ exec /usr/bin/pkg-config "$@@" Try a @code{make distclean} in the ffmpeg source directory before the build. If this does not help see -(@url{http://ffmpeg.org/bugreports.html}). +(@url{https://ffmpeg.org/bugreports.html}). @section How do I encode single pictures into movies? @@ -311,18 +311,18 @@ invoking ffmpeg with several @option{-i} options. For audio, to put all channels together in a single stream (example: two mono streams into one stereo stream): this is sometimes called to @emph{merge} them, and can be done using the -@url{http://ffmpeg.org/ffmpeg-filters.html#amerge, @code{amerge}} filter. +@url{https://ffmpeg.org/ffmpeg-filters.html#amerge, @code{amerge}} filter. @item For audio, to play one on top of the other: this is called to @emph{mix} them, and can be done by first merging them into a single stream and then -using the @url{http://ffmpeg.org/ffmpeg-filters.html#pan, @code{pan}} filter to mix +using the @url{https://ffmpeg.org/ffmpeg-filters.html#pan, @code{pan}} filter to mix the channels at will. @item For video, to display both together, side by side or one on top of a part of the other; it can be done using the -@url{http://ffmpeg.org/ffmpeg-filters.html#overlay, @code{overlay}} video filter. +@url{https://ffmpeg.org/ffmpeg-filters.html#overlay, @code{overlay}} video filter. @end itemize @@ -333,19 +333,19 @@ There are several solutions, depending on the exact circumstances. @subsection Concatenating using the concat @emph{filter} -FFmpeg has a @url{http://ffmpeg.org/ffmpeg-filters.html#concat, +FFmpeg has a @url{https://ffmpeg.org/ffmpeg-filters.html#concat, @code{concat}} filter designed specifically for that, with examples in the documentation. This operation is recommended if you need to re-encode. @subsection Concatenating using the concat @emph{demuxer} -FFmpeg has a @url{http://www.ffmpeg.org/ffmpeg-formats.html#concat, +FFmpeg has a @url{https://www.ffmpeg.org/ffmpeg-formats.html#concat, @code{concat}} demuxer which you can use when you want to avoid a re-encode and your format doesn't support file level concatenation. @subsection Concatenating using the concat @emph{protocol} (file level) -FFmpeg has a @url{http://ffmpeg.org/ffmpeg-protocols.html#concat, +FFmpeg has a @url{https://ffmpeg.org/ffmpeg-protocols.html#concat, @code{concat}} protocol designed specifically for that, with examples in the documentation. @@ -485,7 +485,7 @@ scaling adjusts the SAR to keep the DAR constant. If you want to stretch, or “unstretch”, the image, you need to override the information with the -@url{http://ffmpeg.org/ffmpeg-filters.html#setdar_002c-setsar, @code{setdar or setsar filters}}. +@url{https://ffmpeg.org/ffmpeg-filters.html#setdar_002c-setsar, @code{setdar or setsar filters}}. Do not forget to examine carefully the original video to check whether the stretching comes from the image or from the aspect ratio information. @@ -589,7 +589,7 @@ see @file{libavformat/aviobuf.c} in FFmpeg and @file{libmpdemux/demux_lavf.c} in @section Where is the documentation about ffv1, msmpeg4, asv1, 4xm? -see @url{http://www.ffmpeg.org/~michael/} +see @url{https://www.ffmpeg.org/~michael/} @section How do I feed H.263-RTP (and other codecs in RTP) to libavcodec? diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 1078ea11..e02807cb 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -253,6 +253,10 @@ Overwrite output files without asking. Do not overwrite output files, and exit immediately if a specified output file already exists. +@item -stream_loop @var{number} (@emph{input}) +Set number of times input stream shall be looped. Loop 0 means no loop, +loop -1 means infinite loop. + @item -c[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream}) @itemx -codec[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream}) Select an encoder (when used before an output file) or a decoder (when used @@ -280,23 +284,27 @@ data read from the input file. When used as an output option (before an output filename), stop writing the output after its duration reaches @var{duration}. -@var{duration} may be a number in seconds, or in @code{hh:mm:ss[.xxx]} form. +@var{duration} must be a time duration specification, +see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}. -to and -t are mutually exclusive and -t has priority. @item -to @var{position} (@emph{output}) Stop writing the output at @var{position}. -@var{position} may be a number in seconds, or in @code{hh:mm:ss[.xxx]} form. +@var{position} must be a time duration specification, +see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}. -to and -t are mutually exclusive and -t has priority. @item -fs @var{limit_size} (@emph{output}) -Set the file size limit, expressed in bytes. +Set the file size limit, expressed in bytes. No further chunk of bytes is written +after the limit is exceeded. The size of the output file is slightly more than the +requested file size. @item -ss @var{position} (@emph{input/output}) When used as an input option (before @code{-i}), seeks in this input file to -@var{position}. Note the in most formats it is not possible to seek exactly, so -@command{ffmpeg} will seek to the closest seek point before @var{position}. +@var{position}. Note that in most formats it is not possible to seek exactly, +so @command{ffmpeg} will seek to the closest seek point before @var{position}. When transcoding and @option{-accurate_seek} is enabled (the default), this extra segment between the seek point and @var{position} will be decoded and discarded. When doing stream copy or when @option{-noaccurate_seek} is used, it @@ -305,7 +313,13 @@ will be preserved. When used as an output option (before an output filename), decodes but discards input until the timestamps reach @var{position}. -@var{position} may be either in seconds or in @code{hh:mm:ss[.xxx]} form. +@var{position} must be a time duration specification, +see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}. + +@item -sseof @var{position} (@emph{input/output}) + +Like the @code{-ss} option but relative to the "end of file". That is negative +values are earlier in the file, 0 is at EOF. @item -itsoffset @var{offset} (@emph{input}) Set the input time offset. @@ -320,15 +334,15 @@ the time duration specified in @var{offset}. @item -timestamp @var{date} (@emph{output}) Set the recording timestamp in the container. -@var{date} must be a time duration specification, +@var{date} must be a date specification, see @ref{date syntax,,the Date section in the ffmpeg-utils(1) manual,ffmpeg-utils}. @item -metadata[:metadata_specifier] @var{key}=@var{value} (@emph{output,per-metadata}) Set a metadata key/value pair. An optional @var{metadata_specifier} may be given to set metadata -on streams or chapters. See @code{-map_metadata} documentation for -details. +on streams, chapters or programs. See @code{-map_metadata} +documentation for details. This option overrides metadata set with @code{-map_metadata}. It is also possible to delete metadata by using an empty value. @@ -343,6 +357,11 @@ To set the language of the first audio stream: ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT @end example +@item -program [title=@var{title}:][program_num=@var{program_num}:]st=@var{stream}[:st=@var{stream}...] (@emph{output}) + +Creates a program with the specified @var{title}, @var{program_num} and adds the specified +@var{stream}(s) to it. + @item -target @var{type} (@emph{output}) Specify target file type (@code{vcd}, @code{svcd}, @code{dvd}, @code{dv}, @code{dv50}). @var{type} may be prefixed with @code{pal-}, @code{ntsc-} or @@ -663,6 +682,16 @@ Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration. @item dxva2 Use DXVA2 (DirectX Video Acceleration) hardware acceleration. + +@item qsv +Use the Intel QuickSync Video acceleration for video transcoding. + +Unlike most other values, this option does not enable accelerated decoding (that +is used automatically whenever a qsv decoder is selected), but accelerated +transcoding, without copying the frames into the system memory. + +For it to work, both the decoder and the encoder must support QSV acceleration +and no filters must be used. @end table This option has no effect if the selected hwaccel is not available or not @@ -689,9 +718,27 @@ is not specified, the value of the @var{DISPLAY} environment variable is used @item dxva2 For DXVA2, this option should contain the number of the display adapter to use. If this option is not specified, the default adapter is used. + +@item qsv +For QSV, this option corresponds to the valus of MFX_IMPL_* . Allowed values +are: +@table @option +@item auto +@item sw +@item hw +@item auto_any +@item hw_any +@item hw2 +@item hw3 +@item hw4 @end table @end table +@item -hwaccels +List all hardware acceleration methods supported in this build of ffmpeg. + +@end table + @section Audio Options @table @option @@ -1193,9 +1240,9 @@ The option is intended for cases where features are needed that cannot be specified to @command{ffserver} but can be to @command{ffmpeg}. @item -sdp_file @var{file} (@emph{global}) -Print sdp information to @var{file}. +Print sdp information for an output stream to @var{file}. This allows dumping sdp information when at least one output isn't an -rtp stream. +rtp stream. (Requires at least one of the output formats to be rtp). @item -discard (@emph{input}) Allows discarding specific streams or frames of streams at the demuxer. @@ -1221,6 +1268,14 @@ Discard all frames excepts keyframes. Discard all frames. @end table +@item -abort_on @var{flags} (@emph{global}) +Stop and abort on various conditions. The following flags are available: + +@table @option +@item empty_output +No packets were passed to the muxer, the output is empty. +@end table + @item -xerror (@emph{global}) Stop and exit on error @@ -1299,47 +1354,6 @@ If no such file is found, then ffmpeg will search for a file named @c man end OPTIONS -@chapter Tips -@c man begin TIPS - -@itemize -@item -For streaming at very low bitrates, use a low frame rate -and a small GOP size. This is especially true for RealVideo where -the Linux player does not seem to be very fast, so it can miss -frames. An example is: - -@example -ffmpeg -g 3 -r 3 -t 10 -b:v 50k -s qcif -f rv10 /tmp/b.rm -@end example - -@item -The parameter 'q' which is displayed while encoding is the current -quantizer. The value 1 indicates that a very good quality could -be achieved. The value 31 indicates the worst quality. If q=31 appears -too often, it means that the encoder cannot compress enough to meet -your bitrate. You must either increase the bitrate, decrease the -frame rate or decrease the frame size. - -@item -If your computer is not fast enough, you can speed up the -compression at the expense of the compression ratio. You can use -'-me zero' to speed up motion estimation, and '-g 0' to disable -motion estimation completely (you have only I-frames, which means it -is about as good as JPEG compression). - -@item -To have very low audio bitrates, reduce the sampling frequency -(down to 22050 Hz for MPEG audio, 22050 or 11025 for AC-3). - -@item -To have a constant quality (but a variable bitrate), use the option -'-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst -quality). - -@end itemize -@c man end TIPS - @chapter Examples @c man begin EXAMPLES diff --git a/doc/ffplay.texi b/doc/ffplay.texi index 1ee3c304..4bc3ced3 100644 --- a/doc/ffplay.texi +++ b/doc/ffplay.texi @@ -47,9 +47,17 @@ Disable video. @item -sn Disable subtitles. @item -ss @var{pos} -Seek to a given position in seconds. +Seek to @var{pos}. Note that in most formats it is not possible to seek +exactly, so @command{ffplay} will seek to the nearest seek point to +@var{pos}. + +@var{pos} must be a time duration specification, +see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}. @item -t @var{duration} -play seconds of audio/video +Play @var{duration} seconds of audio/video. + +@var{duration} must be a time duration specification, +see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}. @item -bytes Seek by bytes. @item -nodisp @@ -189,6 +197,15 @@ Toggle full screen. @item p, SPC Pause. +@item m +Toggle mute. + +@item 9, 0 +Decrease and increase volume respectively. + +@item /, * +Decrease and increase volume respectively. + @item a Cycle audio channel in the current program. @@ -221,9 +238,12 @@ Seek to the previous/next chapter. or if there are no chapters Seek backward/forward 10 minutes. -@item mouse click +@item right mouse click Seek to percentage in file corresponding to fraction of width. +@item left mouse double-click +Toggle full screen. + @end table @c man end diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi new file mode 100644 index 00000000..509c8bca --- /dev/null +++ b/doc/fftools-common-opts.texi @@ -0,0 +1,389 @@ +All the numerical options, if not specified otherwise, accept a string +representing a number as input, which may be followed by one of the SI +unit prefixes, for example: 'K', 'M', or 'G'. + +If 'i' is appended to the SI unit prefix, the complete prefix will be +interpreted as a unit prefix for binary multiples, which are based on +powers of 1024 instead of powers of 1000. Appending 'B' to the SI unit +prefix multiplies the value by 8. This allows using, for example: +'KB', 'MiB', 'G' and 'B' as number suffixes. + +Options which do not take arguments are boolean options, and set the +corresponding value to true. They can be set to false by prefixing +the option name with "no". For example using "-nofoo" +will set the boolean option with name "foo" to false. + +@anchor{Stream specifiers} +@section Stream specifiers +Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers +are used to precisely specify which stream(s) a given option belongs to. + +A stream specifier is a string generally appended to the option name and +separated from it by a colon. E.g. @code{-codec:a:1 ac3} contains the +@code{a:1} stream specifier, which matches the second audio stream. Therefore, it +would select the ac3 codec for the second audio stream. + +A stream specifier can match several streams, so that the option is applied to all +of them. E.g. the stream specifier in @code{-b:a 128k} matches all audio +streams. + +An empty stream specifier matches all streams. For example, @code{-codec copy} +or @code{-codec: copy} would copy all the streams without reencoding. + +Possible forms of stream specifiers are: +@table @option +@item @var{stream_index} +Matches the stream with this index. E.g. @code{-threads:1 4} would set the +thread count for the second stream to 4. +@item @var{stream_type}[:@var{stream_index}] +@var{stream_type} is one of following: 'v' or 'V' for video, 'a' for audio, 's' +for subtitle, 'd' for data, and 't' for attachments. 'v' matches all video +streams, 'V' only matches video streams which are not attached pictures, video +thumbnails or cover arts. If @var{stream_index} is given, then it matches +stream number @var{stream_index} of this type. Otherwise, it matches all +streams of this type. +@item p:@var{program_id}[:@var{stream_index}] +If @var{stream_index} is given, then it matches the stream with number @var{stream_index} +in the program with the id @var{program_id}. Otherwise, it matches all streams in the +program. +@item #@var{stream_id} or i:@var{stream_id} +Match the stream by stream id (e.g. PID in MPEG-TS container). +@item m:@var{key}[:@var{value}] +Matches streams with the metadata tag @var{key} having the specified value. If +@var{value} is not given, matches streams that contain the given tag with any +value. +@item u +Matches streams with usable configuration, the codec must be defined and the +essential information such as video dimension or audio sample rate must be present. + +Note that in @command{ffmpeg}, matching by metadata will only work properly for +input files. +@end table + +@section Generic options + +These options are shared amongst the ff* tools. + +@table @option + +@item -L +Show license. + +@item -h, -?, -help, --help [@var{arg}] +Show help. An optional parameter may be specified to print help about a specific +item. If no argument is specified, only basic (non advanced) tool +options are shown. + +Possible values of @var{arg} are: +@table @option +@item long +Print advanced tool options in addition to the basic tool options. + +@item full +Print complete list of options, including shared and private options +for encoders, decoders, demuxers, muxers, filters, etc. + +@item decoder=@var{decoder_name} +Print detailed information about the decoder named @var{decoder_name}. Use the +@option{-decoders} option to get a list of all decoders. + +@item encoder=@var{encoder_name} +Print detailed information about the encoder named @var{encoder_name}. Use the +@option{-encoders} option to get a list of all encoders. + +@item demuxer=@var{demuxer_name} +Print detailed information about the demuxer named @var{demuxer_name}. Use the +@option{-formats} option to get a list of all demuxers and muxers. + +@item muxer=@var{muxer_name} +Print detailed information about the muxer named @var{muxer_name}. Use the +@option{-formats} option to get a list of all muxers and demuxers. + +@item filter=@var{filter_name} +Print detailed information about the filter name @var{filter_name}. Use the +@option{-filters} option to get a list of all filters. +@end table + +@item -version +Show version. + +@item -formats +Show available formats (including devices). + +@item -devices +Show available devices. + +@item -codecs +Show all codecs known to libavcodec. + +Note that the term 'codec' is used throughout this documentation as a shortcut +for what is more correctly called a media bitstream format. + +@item -decoders +Show available decoders. + +@item -encoders +Show all available encoders. + +@item -bsfs +Show available bitstream filters. + +@item -protocols +Show available protocols. + +@item -filters +Show available libavfilter filters. + +@item -pix_fmts +Show available pixel formats. + +@item -sample_fmts +Show available sample formats. + +@item -layouts +Show channel names and standard channel layouts. + +@item -colors +Show recognized color names. + +@item -sources @var{device}[,@var{opt1}=@var{val1}[,@var{opt2}=@var{val2}]...] +Show autodetected sources of the intput device. +Some devices may provide system-dependent source names that cannot be autodetected. +The returned list cannot be assumed to be always complete. +@example +ffmpeg -sources pulse,server=192.168.0.4 +@end example + +@item -sinks @var{device}[,@var{opt1}=@var{val1}[,@var{opt2}=@var{val2}]...] +Show autodetected sinks of the output device. +Some devices may provide system-dependent sink names that cannot be autodetected. +The returned list cannot be assumed to be always complete. +@example +ffmpeg -sinks pulse,server=192.168.0.4 +@end example + +@item -loglevel [repeat+]@var{loglevel} | -v [repeat+]@var{loglevel} +Set the logging level used by the library. +Adding "repeat+" indicates that repeated log output should not be compressed +to the first line and the "Last message repeated n times" line will be +omitted. "repeat" can also be used alone. +If "repeat" is used alone, and with no prior loglevel set, the default +loglevel will be used. If multiple loglevel parameters are given, using +'repeat' will not change the loglevel. +@var{loglevel} is a string or a number containing one of the following values: +@table @samp +@item quiet, -8 +Show nothing at all; be silent. +@item panic, 0 +Only show fatal errors which could lead the process to crash, such as +and assert failure. This is not currently used for anything. +@item fatal, 8 +Only show fatal errors. These are errors after which the process absolutely +cannot continue after. +@item error, 16 +Show all errors, including ones which can be recovered from. +@item warning, 24 +Show all warnings and errors. Any message related to possibly +incorrect or unexpected events will be shown. +@item info, 32 +Show informative messages during processing. This is in addition to +warnings and errors. This is the default value. +@item verbose, 40 +Same as @code{info}, except more verbose. +@item debug, 48 +Show everything, including debugging information. +@item trace, 56 +@end table + +By default the program logs to stderr, if coloring is supported by the +terminal, colors are used to mark errors and warnings. Log coloring +can be disabled setting the environment variable +@env{AV_LOG_FORCE_NOCOLOR} or @env{NO_COLOR}, or can be forced setting +the environment variable @env{AV_LOG_FORCE_COLOR}. +The use of the environment variable @env{NO_COLOR} is deprecated and +will be dropped in a following FFmpeg version. + +@item -report +Dump full command line and console output to a file named +@code{@var{program}-@var{YYYYMMDD}-@var{HHMMSS}.log} in the current +directory. +This file can be useful for bug reports. +It also implies @code{-loglevel verbose}. + +Setting the environment variable @env{FFREPORT} to any value has the +same effect. If the value is a ':'-separated key=value sequence, these +options will affect the report; option values must be escaped if they +contain special characters or the options delimiter ':' (see the +``Quoting and escaping'' section in the ffmpeg-utils manual). + +The following options are recognized: +@table @option +@item file +set the file name to use for the report; @code{%p} is expanded to the name +of the program, @code{%t} is expanded to a timestamp, @code{%%} is expanded +to a plain @code{%} +@item level +set the log verbosity level using a numerical value (see @code{-loglevel}). +@end table + +For example, to output a report to a file named @file{ffreport.log} +using a log level of @code{32} (alias for log level @code{info}): + +@example +FFREPORT=file=ffreport.log:level=32 ffmpeg -i input output +@end example + +Errors in parsing the environment variable are not fatal, and will not +appear in the report. + +@item -hide_banner +Suppress printing banner. + +All FFmpeg tools will normally show a copyright notice, build options +and library versions. This option can be used to suppress printing +this information. + +@item -cpuflags flags (@emph{global}) +Allows setting and clearing cpu flags. This option is intended +for testing. Do not use it unless you know what you're doing. +@example +ffmpeg -cpuflags -sse+mmx ... +ffmpeg -cpuflags mmx ... +ffmpeg -cpuflags 0 ... +@end example +Possible flags for this option are: +@table @samp +@item x86 +@table @samp +@item mmx +@item mmxext +@item sse +@item sse2 +@item sse2slow +@item sse3 +@item sse3slow +@item ssse3 +@item atom +@item sse4.1 +@item sse4.2 +@item avx +@item avx2 +@item xop +@item fma3 +@item fma4 +@item 3dnow +@item 3dnowext +@item bmi1 +@item bmi2 +@item cmov +@end table +@item ARM +@table @samp +@item armv5te +@item armv6 +@item armv6t2 +@item vfp +@item vfpv3 +@item neon +@item setend +@end table +@item AArch64 +@table @samp +@item armv8 +@item vfp +@item neon +@end table +@item PowerPC +@table @samp +@item altivec +@end table +@item Specific Processors +@table @samp +@item pentium2 +@item pentium3 +@item pentium4 +@item k6 +@item k62 +@item athlon +@item athlonxp +@item k8 +@end table +@end table + +@item -opencl_bench +This option is used to benchmark all available OpenCL devices and print the +results. This option is only available when FFmpeg has been compiled with +@code{--enable-opencl}. + +When FFmpeg is configured with @code{--enable-opencl}, the options for the +global OpenCL context are set via @option{-opencl_options}. See the +"OpenCL Options" section in the ffmpeg-utils manual for the complete list of +supported options. Amongst others, these options include the ability to select +a specific platform and device to run the OpenCL code on. By default, FFmpeg +will run on the first device of the first platform. While the options for the +global OpenCL context provide flexibility to the user in selecting the OpenCL +device of their choice, most users would probably want to select the fastest +OpenCL device for their system. + +This option assists the selection of the most efficient configuration by +identifying the appropriate device for the user's system. The built-in +benchmark is run on all the OpenCL devices and the performance is measured for +each device. The devices in the results list are sorted based on their +performance with the fastest device listed first. The user can subsequently +invoke @command{ffmpeg} using the device deemed most appropriate via +@option{-opencl_options} to obtain the best performance for the OpenCL +accelerated code. + +Typical usage to use the fastest OpenCL device involve the following steps. + +Run the command: +@example +ffmpeg -opencl_bench +@end example +Note down the platform ID (@var{pidx}) and device ID (@var{didx}) of the first +i.e. fastest device in the list. +Select the platform and device using the command: +@example +ffmpeg -opencl_options platform_idx=@var{pidx}:device_idx=@var{didx} ... +@end example + +@item -opencl_options options (@emph{global}) +Set OpenCL environment options. This option is only available when +FFmpeg has been compiled with @code{--enable-opencl}. + +@var{options} must be a list of @var{key}=@var{value} option pairs +separated by ':'. See the ``OpenCL Options'' section in the +ffmpeg-utils manual for the list of supported options. +@end table + +@section AVOptions + +These options are provided directly by the libavformat, libavdevice and +libavcodec libraries. To see the list of available AVOptions, use the +@option{-help} option. They are separated into two categories: +@table @option +@item generic +These options can be set for any container, codec or device. Generic options +are listed under AVFormatContext options for containers/devices and under +AVCodecContext options for codecs. +@item private +These options are specific to the given container, device or codec. Private +options are listed under their corresponding containers/devices/codecs. +@end table + +For example to write an ID3v2.3 header instead of a default ID3v2.4 to +an MP3 file, use the @option{id3v2_version} private option of the MP3 +muxer: +@example +ffmpeg -i input.flac -id3v2_version 3 out.mp3 +@end example + +All codec AVOptions are per-stream, and thus a stream specifier +should be attached to them. + +Note: the @option{-nooption} syntax cannot be used for boolean +AVOptions, use @option{-option 0}/@option{-option 1}. + +Note: the old undocumented way of specifying per-stream AVOptions by +prepending v/a/s to the options name is now obsolete and will be +removed soon. diff --git a/doc/filter_design.txt b/doc/filter_design.txt index fca24a94..e8a7c53e 100644 --- a/doc/filter_design.txt +++ b/doc/filter_design.txt @@ -98,7 +98,7 @@ Buffer references ownership and permissions The AVFilterLink structure has a few AVFilterBufferRef fields. The cur_buf and out_buf were used with the deprecated start_frame/draw_slice/end_frame API and should no longer be used. - src_buf, cur_buf_copy and partial_buf are used by libavfilter internally + src_buf and partial_buf are used by libavfilter internally and must not be accessed by filters. Reference permissions @@ -232,7 +232,8 @@ Frame scheduling one of its inputs, repeatedly until at least one frame has been pushed. Return values: - if request_frame could produce a frame, it should return 0; + if request_frame could produce a frame, or at least make progress + towards producing a frame, it should return 0; if it could not for temporary reasons, it should return AVERROR(EAGAIN); if it could not because there are no more frames, it should return AVERROR_EOF. @@ -244,20 +245,18 @@ Frame scheduling push_one_frame(); return 0; } - while (!frame_pushed) { - input = input_where_a_frame_is_most_needed(); - ret = ff_request_frame(input); - if (ret == AVERROR_EOF) { - process_eof_on_input(); - } else if (ret < 0) { - return ret; - } + input = input_where_a_frame_is_most_needed(); + ret = ff_request_frame(input); + if (ret == AVERROR_EOF) { + process_eof_on_input(); + } else if (ret < 0) { + return ret; } return 0; Note that, except for filters that can have queued frames, request_frame does not push frames: it requests them to its input, and as a reaction, - the filter_frame method will be called and do the work. + the filter_frame method possibly will be called and do the work. Legacy API ========== diff --git a/doc/filters.texi b/doc/filters.texi index 4b5c3c11..68f54f19 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -318,6 +318,129 @@ build. Below is a description of the currently available audio filters. +@section acompressor + +A compressor is mainly used to reduce the dynamic range of a signal. +Especially modern music is mostly compressed at a high ratio to +improve the overall loudness. It's done to get the highest attention +of a listener, "fatten" the sound and bring more "power" to the track. +If a signal is compressed too much it may sound dull or "dead" +afterwards or it may start to "pump" (which could be a powerful effect +but can also destroy a track completely). +The right compression is the key to reach a professional sound and is +the high art of mixing and mastering. Because of its complex settings +it may take a long time to get the right feeling for this kind of effect. + +Compression is done by detecting the volume above a chosen level +@code{threshold} and dividing it by the factor set with @code{ratio}. +So if you set the threshold to -12dB and your signal reaches -6dB a ratio +of 2:1 will result in a signal at -9dB. Because an exact manipulation of +the signal would cause distortion of the waveform the reduction can be +levelled over the time. This is done by setting "Attack" and "Release". +@code{attack} determines how long the signal has to rise above the threshold +before any reduction will occur and @code{release} sets the time the signal +has to fall below the threshold to reduce the reduction again. Shorter signals +than the chosen attack time will be left untouched. +The overall reduction of the signal can be made up afterwards with the +@code{makeup} setting. So compressing the peaks of a signal about 6dB and +raising the makeup to this level results in a signal twice as loud than the +source. To gain a softer entry in the compression the @code{knee} flattens the +hard edge at the threshold in the range of the chosen decibels. + +The filter accepts the following options: + +@table @option +@item level_in +Set input gain. Default is 1. Range is between 0.015625 and 64. + +@item threshold +If a signal of second stream rises above this level it will affect the gain +reduction of the first stream. +By default it is 0.125. Range is between 0.00097563 and 1. + +@item ratio +Set a ratio by which the signal is reduced. 1:2 means that if the level +rose 4dB above the threshold, it will be only 2dB above after the reduction. +Default is 2. Range is between 1 and 20. + +@item attack +Amount of milliseconds the signal has to rise above the threshold before gain +reduction starts. Default is 20. Range is between 0.01 and 2000. + +@item release +Amount of milliseconds the signal has to fall below the threshold before +reduction is decreased again. Default is 250. Range is between 0.01 and 9000. + +@item makeup +Set the amount by how much signal will be amplified after processing. +Default is 2. Range is from 1 and 64. + +@item knee +Curve the sharp knee around the threshold to enter gain reduction more softly. +Default is 2.82843. Range is between 1 and 8. + +@item link +Choose if the @code{average} level between all channels of input stream +or the louder(@code{maximum}) channel of input stream affects the +reduction. Default is @code{average}. + +@item detection +Should the exact signal be taken in case of @code{peak} or an RMS one in case +of @code{rms}. Default is @code{rms} which is mostly smoother. + +@item mix +How much to use compressed signal in output. Default is 1. +Range is between 0 and 1. +@end table + +@section acrossfade + +Apply cross fade from one input audio stream to another input audio stream. +The cross fade is applied for specified duration near the end of first stream. + +The filter accepts the following options: + +@table @option +@item nb_samples, ns +Specify the number of samples for which the cross fade effect has to last. +At the end of the cross fade effect the first input audio will be completely +silent. Default is 44100. + +@item duration, d +Specify the duration of the cross fade effect. See +@ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils} +for the accepted syntax. +By default the duration is determined by @var{nb_samples}. +If set this option is used instead of @var{nb_samples}. + +@item overlap, o +Should first stream end overlap with second stream start. Default is enabled. + +@item curve1 +Set curve for cross fade transition for first stream. + +@item curve2 +Set curve for cross fade transition for second stream. + +For description of available curve types see @ref{afade} filter description. +@end table + +@subsection Examples + +@itemize +@item +Cross fade from one input to another: +@example +ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:c1=exp:c2=exp output.flac +@end example + +@item +Cross fade from one input to another but without overlapping: +@example +ffmpeg -i first.flac -i second.flac -filter_complex acrossfade=d=10:o=0:c1=exp:c2=exp output.flac +@end example +@end itemize + @section adelay Delay one or more audio channels. @@ -405,6 +528,52 @@ aecho=0.8:0.9:1000|1800:0.3|0.25 @end example @end itemize +@section aemphasis +Audio emphasis filter creates or restores material directly taken from LPs or +emphased CDs with different filter curves. E.g. to store music on vinyl the +signal has to be altered by a filter first to even out the disadvantages of +this recording medium. +Once the material is played back the inverse filter has to be applied to +restore the distortion of the frequency response. + +The filter accepts the following options: + +@table @option +@item level_in +Set input gain. + +@item level_out +Set output gain. + +@item mode +Set filter mode. For restoring material use @code{reproduction} mode, otherwise +use @code{production} mode. Default is @code{reproduction} mode. + +@item type +Set filter type. Selects medium. Can be one of the following: + +@table @option +@item col +select Columbia. +@item emi +select EMI. +@item bsi +select BSI (78RPM). +@item riaa +select RIAA. +@item cd +select Compact Disc (CD). +@item 50fm +select 50µs (FM). +@item 75fm +select 75µs (FM). +@item 50kf +select 50µs (FM-KF). +@item 75kf +select 75µs (FM-KF). +@end table +@end table + @section aeval Modify an audio signal according to the specified expressions. @@ -469,6 +638,7 @@ aeval=val(0)|-val(1) @end example @end itemize +@anchor{afade} @section afade Apply fade-in/out effect to input audio. @@ -522,7 +692,7 @@ select half of sine wave select exponential sine wave @item log select logarithmic -@item par +@item ipar select inverted parabola @item qua select quadratic @@ -532,6 +702,18 @@ select cubic select square root @item cbr select cubic root +@item par +select parabola +@item exp +select exponential +@item iqsin +select inverted quarter of sine wave +@item ihsin +select inverted half of sine wave +@item dese +select double-exponential seat +@item desi +select double-exponential sigmoid @end table @end table @@ -551,6 +733,83 @@ afade=t=out:st=875:d=25 @end example @end itemize +@section afftfilt +Apply arbitrary expressions to samples in frequency domain. + +@table @option +@item real +Set frequency domain real expression for each separate channel separated +by '|'. Default is "1". +If the number of input channels is greater than the number of +expressions, the last specified expression is used for the remaining +output channels. + +@item imag +Set frequency domain imaginary expression for each separate channel +separated by '|'. If not set, @var{real} option is used. + +Each expression in @var{real} and @var{imag} can contain the following +constants: + +@table @option +@item sr +sample rate + +@item b +current frequency bin number + +@item nb +number of available bins + +@item ch +channel number of the current expression + +@item chs +number of channels + +@item pts +current frame pts +@end table + +@item win_size +Set window size. + +It accepts the following values: +@table @samp +@item w16 +@item w32 +@item w64 +@item w128 +@item w256 +@item w512 +@item w1024 +@item w2048 +@item w4096 +@item w8192 +@item w16384 +@item w32768 +@item w65536 +@end table +Default is @code{w4096} + +@item win_func +Set window function. Default is @code{hann}. + +@item overlap +Set window overlap. If set to 1, the recommended overlap for selected +window function will be picked. Default is @code{0.75}. +@end table + +@subsection Examples + +@itemize +@item +Leave almost only low frequencies in audio: +@example +afftfilt="1-clip((b/nb)*b,0,1)" +@end example +@end itemize + @anchor{aformat} @section aformat @@ -580,6 +839,111 @@ Force the output to either unsigned 8-bit or signed 16-bit stereo aformat=sample_fmts=u8|s16:channel_layouts=stereo @end example +@section agate + +A gate is mainly used to reduce lower parts of a signal. This kind of signal +processing reduces disturbing noise between useful signals. + +Gating is done by detecting the volume below a chosen level @var{threshold} +and divide it by the factor set with @var{ratio}. The bottom of the noise +floor is set via @var{range}. Because an exact manipulation of the signal +would cause distortion of the waveform the reduction can be levelled over +time. This is done by setting @var{attack} and @var{release}. + +@var{attack} determines how long the signal has to fall below the threshold +before any reduction will occur and @var{release} sets the time the signal +has to raise above the threshold to reduce the reduction again. +Shorter signals than the chosen attack time will be left untouched. + +@table @option +@item level_in +Set input level before filtering. +Default is 1. Allowed range is from 0.015625 to 64. + +@item range +Set the level of gain reduction when the signal is below the threshold. +Default is 0.06125. Allowed range is from 0 to 1. + +@item threshold +If a signal rises above this level the gain reduction is released. +Default is 0.125. Allowed range is from 0 to 1. + +@item ratio +Set a ratio about which the signal is reduced. +Default is 2. Allowed range is from 1 to 9000. + +@item attack +Amount of milliseconds the signal has to rise above the threshold before gain +reduction stops. +Default is 20 milliseconds. Allowed range is from 0.01 to 9000. + +@item release +Amount of milliseconds the signal has to fall below the threshold before the +reduction is increased again. Default is 250 milliseconds. +Allowed range is from 0.01 to 9000. + +@item makeup +Set amount of amplification of signal after processing. +Default is 1. Allowed range is from 1 to 64. + +@item knee +Curve the sharp knee around the threshold to enter gain reduction more softly. +Default is 2.828427125. Allowed range is from 1 to 8. + +@item detection +Choose if exact signal should be taken for detection or an RMS like one. +Default is rms. Can be peak or rms. + +@item link +Choose if the average level between all channels or the louder channel affects +the reduction. +Default is average. Can be average or maximum. +@end table + +@section alimiter + +The limiter prevents input signal from raising over a desired threshold. +This limiter uses lookahead technology to prevent your signal from distorting. +It means that there is a small delay after signal is processed. Keep in mind +that the delay it produces is the attack time you set. + +The filter accepts the following options: + +@table @option +@item level_in +Set input gain. Default is 1. + +@item level_out +Set output gain. Default is 1. + +@item limit +Don't let signals above this level pass the limiter. Default is 1. + +@item attack +The limiter will reach its attenuation level in this amount of time in +milliseconds. Default is 5 milliseconds. + +@item release +Come back from limiting to attenuation 1.0 in this amount of milliseconds. +Default is 50 milliseconds. + +@item asc +When gain reduction is always needed ASC takes care of releasing to an +average reduction level rather than reaching a reduction of 0 in the release +time. + +@item asc_level +Select how much the release time is affected by ASC, 0 means nearly no changes +in release time while 1 produces higher release times. + +@item level +Auto level output signal. Default is enabled. +This normalizes audio back to 0dB if enabled. +@end table + +Depending on picked setting it is recommended to upsample input 2x or 4x times +with @ref{aresample} before applying this filter. + @section allpass Apply a two-pole all-pass filter with central frequency (in Hz) @@ -610,6 +974,7 @@ slope Specify the band-width of a filter in width_type units. @end table +@anchor{amerge} @section amerge Merge two or more audio streams into a single multi-channel stream. @@ -704,6 +1069,100 @@ stream ends. The default value is 2 seconds. @end table +@section anequalizer + +High-order parametric multiband equalizer for each channel. + +It accepts the following parameters: +@table @option +@item params + +This option string is in format: +"c@var{chn} f=@var{cf} w=@var{w} g=@var{g} t=@var{f} | ..." +Each equalizer band is separated by '|'. + +@table @option +@item chn +Set channel number to which equalization will be applied. +If input doesn't have that channel the entry is ignored. + +@item cf +Set central frequency for band. +If input doesn't have that frequency the entry is ignored. + +@item w +Set band width in hertz. + +@item g +Set band gain in dB. + +@item f +Set filter type for band, optional, can be: + +@table @samp +@item 0 +Butterworth, this is default. + +@item 1 +Chebyshev type 1. + +@item 2 +Chebyshev type 2. +@end table +@end table + +@item curves +With this option activated frequency response of anequalizer is displayed +in video stream. + +@item size +Set video stream size. Only useful if curves option is activated. + +@item mgain +Set max gain that will be displayed. Only useful if curves option is activated. +Setting this to reasonable value allows to display gain which is derived from +neighbour bands which are too close to each other and thus produce higher gain +when both are activated. + +@item fscale +Set frequency scale used to draw frequency response in video output. +Can be linear or logarithmic. Default is logarithmic. + +@item colors +Set color for each channel curve which is going to be displayed in video stream. +This is list of color names separated by space or by '|'. +Unrecognised or missing colors will be replaced by white color. +@end table + +@subsection Examples + +@itemize +@item +Lower gain by 10 of central frequency 200Hz and width 100 Hz +for first 2 channels using Chebyshev type 1 filter: +@example +anequalizer=c0 f=200 w=100 g=-10 t=1|c1 f=200 w=100 g=-10 t=1 +@end example +@end itemize + +@subsection Commands + +This filter supports the following commands: +@table @option +@item change +Alter existing filter parameters. +Syntax for the commands is : "@var{fN}|f=@var{freq}|w=@var{width}|g=@var{gain}" + +@var{fN} is existing filter number, starting from 0, if no such filter is available +error is returned. +@var{freq} set new frequency parameter. +@var{width} set new width parameter in herz. +@var{gain} set new gain parameter in dB. + +Full filter invocation with asendcmd may look like this: +asendcmd=c='4.0 anequalizer change 0|f=200|w=50|g=1',anequalizer=... +@end table + @section anull Pass the audio source unchanged to the output. @@ -797,6 +1256,63 @@ It accepts the following values: @end table @end table +@section apulsator + +Audio pulsator is something between an autopanner and a tremolo. +But it can produce funny stereo effects as well. Pulsator changes the volume +of the left and right channel based on a LFO (low frequency oscillator) with +different waveforms and shifted phases. +This filter have the ability to define an offset between left and right +channel. An offset of 0 means that both LFO shapes match each other. +The left and right channel are altered equally - a conventional tremolo. +An offset of 50% means that the shape of the right channel is exactly shifted +in phase (or moved backwards about half of the frequency) - pulsator acts as +an autopanner. At 1 both curves match again. Every setting in between moves the +phase shift gapless between all stages and produces some "bypassing" sounds with +sine and triangle waveforms. The more you set the offset near 1 (starting from +the 0.5) the faster the signal passes from the left to the right speaker. + +The filter accepts the following options: + +@table @option +@item level_in +Set input gain. By default it is 1. Range is [0.015625 - 64]. + +@item level_out +Set output gain. By default it is 1. Range is [0.015625 - 64]. + +@item mode +Set waveform shape the LFO will use. Can be one of: sine, triangle, square, +sawup or sawdown. Default is sine. + +@item amount +Set modulation. Define how much of original signal is affected by the LFO. + +@item offset_l +Set left channel offset. Default is 0. Allowed range is [0 - 1]. + +@item offset_r +Set right channel offset. Default is 0.5. Allowed range is [0 - 1]. + +@item width +Set pulse width. Default is 1. Allowed range is [0 - 2]. + +@item timing +Set possible timing mode. Can be one of: bpm, ms or hz. Default is hz. + +@item bpm +Set bpm. Default is 120. Allowed range is [30 - 300]. Only used if timing +is set to bpm. + +@item ms +Set ms. Default is 500. Allowed range is [10 - 2000]. Only used if timing +is set to ms. + +@item hz +Set frequency in Hz. Default is 2. Allowed range is [0.01 - 100]. Only used +if timing is set to hz. +@end table + @anchor{aresample} @section aresample @@ -929,6 +1445,52 @@ It accepts the following option: @item length Short window length in seconds, used for peak and trough RMS measurement. Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}. + +@item metadata + +Set metadata injection. All the metadata keys are prefixed with @code{lavfi.astats.X}, +where @code{X} is channel number starting from 1 or string @code{Overall}. Default is +disabled. + +Available keys for each channel are: +DC_offset +Min_level +Max_level +Min_difference +Max_difference +Mean_difference +Peak_level +RMS_peak +RMS_trough +Crest_factor +Flat_factor +Peak_count +Bit_depth + +and for Overall: +DC_offset +Min_level +Max_level +Min_difference +Max_difference +Mean_difference +Peak_level +RMS_level +RMS_peak +RMS_trough +Flat_factor +Peak_count +Bit_depth +Number_of_samples + +For example full key look like this @code{lavfi.astats.1.DC_offset} or +this @code{lavfi.astats.Overall.Peak_count}. + +For description what each key means read below. + +@item reset +Set number of frame after which stats are going to be recalculated. +Default is disabled. @end table A description of each shown parameter follows: @@ -943,6 +1505,16 @@ Minimal sample level. @item Max level Maximal sample level. +@item Min difference +Minimal difference between two consecutive samples. + +@item Max difference +Maximal difference between two consecutive samples. + +@item Mean difference +Mean difference between two consecutive samples. +The average of each difference between two consecutive samples. + @item Peak level dB @item RMS level dB Standard peak and RMS level measured in dBFS. @@ -961,44 +1533,11 @@ Flatness (i.e. consecutive samples with the same value) of the signal at its pea @item Peak count Number of occasions (not the number of samples) that the signal attained either @var{Min level} or @var{Max level}. -@end table - -@section astreamsync - -Forward two audio streams and control the order the buffers are forwarded. -The filter accepts the following options: - -@table @option -@item expr, e -Set the expression deciding which stream should be -forwarded next: if the result is negative, the first stream is forwarded; if -the result is positive or zero, the second stream is forwarded. It can use -the following variables: - -@table @var -@item b1 b2 -number of buffers forwarded so far on each stream -@item s1 s2 -number of samples forwarded so far on each stream -@item t1 t2 -current timestamp of each stream -@end table - -The default value is @code{t1-t2}, which means to always forward the stream -that has a smaller timestamp. +@item Bit depth +Overall bit depth of audio. Number of bits used for each sample. @end table -@subsection Examples - -Stress-test @code{amerge} by randomly sending buffers on the wrong -input, while avoiding too much of a desynchronization: -@example -amovie=file.ogg [a] ; amovie=file.mp3 [b] ; -[a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ; -[a2] [b2] amerge -@end example - @section asyncts Synchronize audio data with timestamps by squeezing/stretching it and/or @@ -1291,7 +1830,7 @@ the input. To fix a 5.1 WAV improperly encoded in AAC's native channel order @example -ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:channel_layout=5.1' out.wav +ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:5.1' out.wav @end example @section channelsplit @@ -1391,6 +1930,8 @@ situations, the attack time (response to the audio getting louder) should be shorter than the decay time, because the human ear is more sensitive to sudden loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and a typical value for decay is 0.8 seconds. +If specified number of attacks & decays is lower than number of channels, the last +set attack/decay will be used for all remaining channels. @item points A list of points for the transfer function, specified in dB relative to the @@ -1436,6 +1977,11 @@ noisy environment: compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2 @end example +Another example for audio with whisper and explosion parts: +@example +compand=0|0:1|1:-90/-900|-70/-70|-30/-9|0/-3:6:0:0:0 +@end example + @item A noise gate for when the noise is at a lower level than the signal: @example @@ -1448,29 +1994,301 @@ than the signal (making it, in some ways, similar to squelch): @example compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1 @end example -@end itemize -@section dcshift -Apply a DC shift to the audio. +@item +2:1 compression starting at -6dB: +@example +compand=points=-80/-80|-6/-6|0/-3.8|20/3.5 +@end example -This can be useful to remove a DC offset (caused perhaps by a hardware problem -in the recording chain) from the audio. The effect of a DC offset is reduced -headroom and hence volume. The @ref{astats} filter can be used to determine if -a signal has a DC offset. +@item +2:1 compression starting at -9dB: +@example +compand=points=-80/-80|-9/-9|0/-5.3|20/2.9 +@end example -@table @option -@item shift -Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift -the audio. +@item +2:1 compression starting at -12dB: +@example +compand=points=-80/-80|-12/-12|0/-6.8|20/1.9 +@end example -@item limitergain -Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is -used to prevent clipping. -@end table +@item +2:1 compression starting at -18dB: +@example +compand=points=-80/-80|-18/-18|0/-9.8|20/0.7 +@end example -@section earwax +@item +3:1 compression starting at -15dB: +@example +compand=points=-80/-80|-15/-15|0/-10.8|20/-5.2 +@end example -Make audio easier to listen to on headphones. +@item +Compressor/Gate: +@example +compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6 +@end example + +@item +Expander: +@example +compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3 +@end example + +@item +Hard limiter at -6dB: +@example +compand=attacks=0:points=-80/-80|-6/-6|20/-6 +@end example + +@item +Hard limiter at -12dB: +@example +compand=attacks=0:points=-80/-80|-12/-12|20/-12 +@end example + +@item +Hard noise gate at -35 dB: +@example +compand=attacks=0:points=-80/-115|-35.1/-80|-35/-35|20/20 +@end example + +@item +Soft limiter: +@example +compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8 +@end example +@end itemize + +@section compensationdelay + +Compensation Delay Line is a metric based delay to compensate differing +positions of microphones or speakers. + +For example, you have recorded guitar with two microphones placed in +different location. Because the front of sound wave has fixed speed in +normal conditions, the phasing of microphones can vary and depends on +their location and interposition. The best sound mix can be achieved when +these microphones are in phase (synchronized). Note that distance of +~30 cm between microphones makes one microphone to capture signal in +antiphase to another microphone. That makes the final mix sounding moody. +This filter helps to solve phasing problems by adding different delays +to each microphone track and make them synchronized. + +The best result can be reached when you take one track as base and +synchronize other tracks one by one with it. +Remember that synchronization/delay tolerance depends on sample rate, too. +Higher sample rates will give more tolerance. + +It accepts the following parameters: + +@table @option +@item mm +Set millimeters distance. This is compensation distance for fine tuning. +Default is 0. + +@item cm +Set cm distance. This is compensation distance for tightening distance setup. +Default is 0. + +@item m +Set meters distance. This is compensation distance for hard distance setup. +Default is 0. + +@item dry +Set dry amount. Amount of unprocessed (dry) signal. +Default is 0. + +@item wet +Set wet amount. Amount of processed (wet) signal. +Default is 1. + +@item temp +Set temperature degree in Celsius. This is the temperature of the environment. +Default is 20. +@end table + +@section dcshift +Apply a DC shift to the audio. + +This can be useful to remove a DC offset (caused perhaps by a hardware problem +in the recording chain) from the audio. The effect of a DC offset is reduced +headroom and hence volume. The @ref{astats} filter can be used to determine if +a signal has a DC offset. + +@table @option +@item shift +Set the DC shift, allowed range is [-1, 1]. It indicates the amount to shift +the audio. + +@item limitergain +Optional. It should have a value much less than 1 (e.g. 0.05 or 0.02) and is +used to prevent clipping. +@end table + +@section dynaudnorm +Dynamic Audio Normalizer. + +This filter applies a certain amount of gain to the input audio in order +to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in +contrast to more "simple" normalization algorithms, the Dynamic Audio +Normalizer *dynamically* re-adjusts the gain factor to the input audio. +This allows for applying extra gain to the "quiet" sections of the audio +while avoiding distortions or clipping the "loud" sections. In other words: +The Dynamic Audio Normalizer will "even out" the volume of quiet and loud +sections, in the sense that the volume of each section is brought to the +same target level. Note, however, that the Dynamic Audio Normalizer achieves +this goal *without* applying "dynamic range compressing". It will retain 100% +of the dynamic range *within* each section of the audio file. + +@table @option +@item f +Set the frame length in milliseconds. In range from 10 to 8000 milliseconds. +Default is 500 milliseconds. +The Dynamic Audio Normalizer processes the input audio in small chunks, +referred to as frames. This is required, because a peak magnitude has no +meaning for just a single sample value. Instead, we need to determine the +peak magnitude for a contiguous sequence of sample values. While a "standard" +normalizer would simply use the peak magnitude of the complete file, the +Dynamic Audio Normalizer determines the peak magnitude individually for each +frame. The length of a frame is specified in milliseconds. By default, the +Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has +been found to give good results with most files. +Note that the exact frame length, in number of samples, will be determined +automatically, based on the sampling rate of the individual input audio file. + +@item g +Set the Gaussian filter window size. In range from 3 to 301, must be odd +number. Default is 31. +Probably the most important parameter of the Dynamic Audio Normalizer is the +@code{window size} of the Gaussian smoothing filter. The filter's window size +is specified in frames, centered around the current frame. For the sake of +simplicity, this must be an odd number. Consequently, the default value of 31 +takes into account the current frame, as well as the 15 preceding frames and +the 15 subsequent frames. Using a larger window results in a stronger +smoothing effect and thus in less gain variation, i.e. slower gain +adaptation. Conversely, using a smaller window results in a weaker smoothing +effect and thus in more gain variation, i.e. faster gain adaptation. +In other words, the more you increase this value, the more the Dynamic Audio +Normalizer will behave like a "traditional" normalization filter. On the +contrary, the more you decrease this value, the more the Dynamic Audio +Normalizer will behave like a dynamic range compressor. + +@item p +Set the target peak value. This specifies the highest permissible magnitude +level for the normalized audio input. This filter will try to approach the +target peak magnitude as closely as possible, but at the same time it also +makes sure that the normalized signal will never exceed the peak magnitude. +A frame's maximum local gain factor is imposed directly by the target peak +magnitude. The default value is 0.95 and thus leaves a headroom of 5%*. +It is not recommended to go above this value. + +@item m +Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0. +The Dynamic Audio Normalizer determines the maximum possible (local) gain +factor for each input frame, i.e. the maximum gain factor that does not +result in clipping or distortion. The maximum gain factor is determined by +the frame's highest magnitude sample. However, the Dynamic Audio Normalizer +additionally bounds the frame's maximum gain factor by a predetermined +(global) maximum gain factor. This is done in order to avoid excessive gain +factors in "silent" or almost silent frames. By default, the maximum gain +factor is 10.0, For most inputs the default value should be sufficient and +it usually is not recommended to increase this value. Though, for input +with an extremely low overall volume level, it may be necessary to allow even +higher gain factors. Note, however, that the Dynamic Audio Normalizer does +not simply apply a "hard" threshold (i.e. cut off values above the threshold). +Instead, a "sigmoid" threshold function will be applied. This way, the +gain factors will smoothly approach the threshold value, but never exceed that +value. + +@item r +Set the target RMS. In range from 0.0 to 1.0. Default is 0.0 - disabled. +By default, the Dynamic Audio Normalizer performs "peak" normalization. +This means that the maximum local gain factor for each frame is defined +(only) by the frame's highest magnitude sample. This way, the samples can +be amplified as much as possible without exceeding the maximum signal +level, i.e. without clipping. Optionally, however, the Dynamic Audio +Normalizer can also take into account the frame's root mean square, +abbreviated RMS. In electrical engineering, the RMS is commonly used to +determine the power of a time-varying signal. It is therefore considered +that the RMS is a better approximation of the "perceived loudness" than +just looking at the signal's peak magnitude. Consequently, by adjusting all +frames to a constant RMS value, a uniform "perceived loudness" can be +established. If a target RMS value has been specified, a frame's local gain +factor is defined as the factor that would result in exactly that RMS value. +Note, however, that the maximum local gain factor is still restricted by the +frame's highest magnitude sample, in order to prevent clipping. + +@item n +Enable channels coupling. By default is enabled. +By default, the Dynamic Audio Normalizer will amplify all channels by the same +amount. This means the same gain factor will be applied to all channels, i.e. +the maximum possible gain factor is determined by the "loudest" channel. +However, in some recordings, it may happen that the volume of the different +channels is uneven, e.g. one channel may be "quieter" than the other one(s). +In this case, this option can be used to disable the channel coupling. This way, +the gain factor will be determined independently for each channel, depending +only on the individual channel's highest magnitude sample. This allows for +harmonizing the volume of the different channels. + +@item c +Enable DC bias correction. By default is disabled. +An audio signal (in the time domain) is a sequence of sample values. +In the Dynamic Audio Normalizer these sample values are represented in the +-1.0 to 1.0 range, regardless of the original input format. Normally, the +audio signal, or "waveform", should be centered around the zero point. +That means if we calculate the mean value of all samples in a file, or in a +single frame, then the result should be 0.0 or at least very close to that +value. If, however, there is a significant deviation of the mean value from +0.0, in either positive or negative direction, this is referred to as a +DC bias or DC offset. Since a DC bias is clearly undesirable, the Dynamic +Audio Normalizer provides optional DC bias correction. +With DC bias correction enabled, the Dynamic Audio Normalizer will determine +the mean value, or "DC correction" offset, of each input frame and subtract +that value from all of the frame's sample values which ensures those samples +are centered around 0.0 again. Also, in order to avoid "gaps" at the frame +boundaries, the DC correction offset values will be interpolated smoothly +between neighbouring frames. + +@item b +Enable alternative boundary mode. By default is disabled. +The Dynamic Audio Normalizer takes into account a certain neighbourhood +around each frame. This includes the preceding frames as well as the +subsequent frames. However, for the "boundary" frames, located at the very +beginning and at the very end of the audio file, not all neighbouring +frames are available. In particular, for the first few frames in the audio +file, the preceding frames are not known. And, similarly, for the last few +frames in the audio file, the subsequent frames are not known. Thus, the +question arises which gain factors should be assumed for the missing frames +in the "boundary" region. The Dynamic Audio Normalizer implements two modes +to deal with this situation. The default boundary mode assumes a gain factor +of exactly 1.0 for the missing frames, resulting in a smooth "fade in" and +"fade out" at the beginning and at the end of the input, respectively. + +@item s +Set the compress factor. In range from 0.0 to 30.0. Default is 0.0. +By default, the Dynamic Audio Normalizer does not apply "traditional" +compression. This means that signal peaks will not be pruned and thus the +full dynamic range will be retained within each local neighbourhood. However, +in some cases it may be desirable to combine the Dynamic Audio Normalizer's +normalization algorithm with a more "traditional" compression. +For this purpose, the Dynamic Audio Normalizer provides an optional compression +(thresholding) function. If (and only if) the compression feature is enabled, +all input frames will be processed by a soft knee thresholding function prior +to the actual normalization process. Put simply, the thresholding function is +going to prune all samples whose magnitude exceeds a certain threshold value. +However, the Dynamic Audio Normalizer does not simply apply a fixed threshold +value. Instead, the threshold value will be adjusted for each individual +frame. +In general, smaller parameters result in stronger compression, and vice versa. +Values below 3.0 are not recommended, because audible distortion may appear. +@end table + +@section earwax + +Make audio easier to listen to on headphones. This filter adds `cues' to 44.1kHz stereo (i.e. audio CD format) audio so that when listened to on headphones the stereo image is moved from @@ -1531,6 +2349,23 @@ equalizer=f=1000:width_type=q:width=1:g=2,equalizer=f=100:width_type=q:width=2:g @end example @end itemize +@section extrastereo + +Linearly increases the difference between left and right channels which +adds some sort of "live" effect to playback. + +The filter accepts the following option: + +@table @option +@item m +Sets the difference coefficient (default: 2.5). 0.0 means mono sound +(average of both channels), with 1.0 sound will be unchanged, with +-1.0 left and right channels will be swapped. + +@item c +Enable clipping. By default is enabled. +@end table + @section flanger Apply a flanging effect to the audio. @@ -1667,6 +2502,9 @@ threshold or gain). Controls need to be defined using the following syntax: c0=@var{value0}|c1=@var{value1}|c2=@var{value2}|..., where @var{valuei} is the value set on the @var{i}-th control. +Alternatively they can be also defined using the following syntax: +@var{value0}|@var{value1}|@var{value2}|..., where +@var{valuei} is the value set on the @var{i}-th control. If @option{controls} is set to @code{help}, all available controls and their valid ranges are printed. @@ -1738,6 +2576,20 @@ Apply @code{C* Eq10X2 - Stereo 10-band equaliser} effect: @example ladspa=caps:Eq10X2:c=c0=-48|c9=-24|c3=12|c4=2 @end example + +@item +Increase volume by 20dB using fast lookahead limiter from Steve Harris +@code{SWH Plugins} collection: +@example +ladspa=fast_lookahead_limiter_1913:fastLookaheadLimiter:20|0|2 +@end example + +@item +Attenuate low frequencies using Multiband EQ from Steve Harris +@code{SWH Plugins} collection: +@example +ladspa=mbeq_1197:mbeq:-24|-24|-24|0|0|0|0|0|0|0|0|0|0|0|0 +@end example @end itemize @subsection Commands @@ -1784,6 +2636,7 @@ Applies only to double-pole filter. The default is 0.707q and gives a Butterworth response. @end table +@anchor{pan} @section pan Mix channels with specific gain levels. The filter accepts the output @@ -1885,6 +2738,221 @@ At end of filtering it displays @code{track_gain} and @code{track_peak}. Convert the audio sample format, sample rate and channel layout. It is not meant to be used directly. +@section rubberband +Apply time-stretching and pitch-shifting with librubberband. + +The filter accepts the following options: + +@table @option +@item tempo +Set tempo scale factor. + +@item pitch +Set pitch scale factor. + +@item transients +Set transients detector. +Possible values are: +@table @var +@item crisp +@item mixed +@item smooth +@end table + +@item detector +Set detector. +Possible values are: +@table @var +@item compound +@item percussive +@item soft +@end table + +@item phase +Set phase. +Possible values are: +@table @var +@item laminar +@item independent +@end table + +@item window +Set processing window size. +Possible values are: +@table @var +@item standard +@item short +@item long +@end table + +@item smoothing +Set smoothing. +Possible values are: +@table @var +@item off +@item on +@end table + +@item formant +Enable formant preservation when shift pitching. +Possible values are: +@table @var +@item shifted +@item preserved +@end table + +@item pitchq +Set pitch quality. +Possible values are: +@table @var +@item quality +@item speed +@item consistency +@end table + +@item channels +Set channels. +Possible values are: +@table @var +@item apart +@item together +@end table +@end table + +@section sidechaincompress + +This filter acts like normal compressor but has the ability to compress +detected signal using second input signal. +It needs two input streams and returns one output stream. +First input stream will be processed depending on second stream signal. +The filtered signal then can be filtered with other filters in later stages of +processing. See @ref{pan} and @ref{amerge} filter. + +The filter accepts the following options: + +@table @option +@item level_in +Set input gain. Default is 1. Range is between 0.015625 and 64. + +@item threshold +If a signal of second stream raises above this level it will affect the gain +reduction of first stream. +By default is 0.125. Range is between 0.00097563 and 1. + +@item ratio +Set a ratio about which the signal is reduced. 1:2 means that if the level +raised 4dB above the threshold, it will be only 2dB above after the reduction. +Default is 2. Range is between 1 and 20. + +@item attack +Amount of milliseconds the signal has to rise above the threshold before gain +reduction starts. Default is 20. Range is between 0.01 and 2000. + +@item release +Amount of milliseconds the signal has to fall below the threshold before +reduction is decreased again. Default is 250. Range is between 0.01 and 9000. + +@item makeup +Set the amount by how much signal will be amplified after processing. +Default is 2. Range is from 1 and 64. + +@item knee +Curve the sharp knee around the threshold to enter gain reduction more softly. +Default is 2.82843. Range is between 1 and 8. + +@item link +Choose if the @code{average} level between all channels of side-chain stream +or the louder(@code{maximum}) channel of side-chain stream affects the +reduction. Default is @code{average}. + +@item detection +Should the exact signal be taken in case of @code{peak} or an RMS one in case +of @code{rms}. Default is @code{rms} which is mainly smoother. + +@item level_sc +Set sidechain gain. Default is 1. Range is between 0.015625 and 64. + +@item mix +How much to use compressed signal in output. Default is 1. +Range is between 0 and 1. +@end table + +@subsection Examples + +@itemize +@item +Full ffmpeg example taking 2 audio inputs, 1st input to be compressed +depending on the signal of 2nd input and later compressed signal to be +merged with 2nd input: +@example +ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge" +@end example +@end itemize + +@section sidechaingate + +A sidechain gate acts like a normal (wideband) gate but has the ability to +filter the detected signal before sending it to the gain reduction stage. +Normally a gate uses the full range signal to detect a level above the +threshold. +For example: If you cut all lower frequencies from your sidechain signal +the gate will decrease the volume of your track only if not enough highs +appear. With this technique you are able to reduce the resonation of a +natural drum or remove "rumbling" of muted strokes from a heavily distorted +guitar. +It needs two input streams and returns one output stream. +First input stream will be processed depending on second stream signal. + +The filter accepts the following options: + +@table @option +@item level_in +Set input level before filtering. +Default is 1. Allowed range is from 0.015625 to 64. + +@item range +Set the level of gain reduction when the signal is below the threshold. +Default is 0.06125. Allowed range is from 0 to 1. + +@item threshold +If a signal rises above this level the gain reduction is released. +Default is 0.125. Allowed range is from 0 to 1. + +@item ratio +Set a ratio about which the signal is reduced. +Default is 2. Allowed range is from 1 to 9000. + +@item attack +Amount of milliseconds the signal has to rise above the threshold before gain +reduction stops. +Default is 20 milliseconds. Allowed range is from 0.01 to 9000. + +@item release +Amount of milliseconds the signal has to fall below the threshold before the +reduction is increased again. Default is 250 milliseconds. +Allowed range is from 0.01 to 9000. + +@item makeup +Set amount of amplification of signal after processing. +Default is 1. Allowed range is from 1 to 64. + +@item knee +Curve the sharp knee around the threshold to enter gain reduction more softly. +Default is 2.828427125. Allowed range is from 1 to 8. + +@item detection +Choose if exact signal should be taken for detection or an RMS like one. +Default is rms. Can be peak or rms. + +@item link +Choose if the average level between all channels or the louder channel affects +the reduction. +Default is average. Can be average or maximum. + +@item level_sc +Set sidechain gain. Default is 1. Range is from 0.015625 to 64. +@end table + @section silencedetect Detect silence in an audio stream. @@ -1978,6 +3046,14 @@ at the beginning of each period of silence. For example, if you want to remove long pauses between words but do not want to remove the pauses completely. Default value is @code{0}. +@item detection +Set how is silence detected. Can be @code{rms} or @code{peak}. Second is faster +and works better with digital silence which is exactly 0. +Default value is @code{rms}. + +@item window +Set ratio used to calculate size of window for detecting silence. +Default value is @code{0.02}. Allowed range is from @code{0} to @code{10}. @end table @subsection Examples @@ -1990,8 +3066,177 @@ pressing the record button and the start of the performance: @example silenceremove=1:5:0.02 @end example + +@item +Trim all silence encountered from begining to end where there is more than 1 +second of silence in audio: +@example +silenceremove=0:0:0:-1:1:-90dB +@end example @end itemize +@section sofalizer + +SOFAlizer uses head-related transfer functions (HRTFs) to create virtual +loudspeakers around the user for binaural listening via headphones (audio +formats up to 9 channels supported). +The HRTFs are stored in SOFA files (see @url{http://www.sofacoustics.org/} for a database). +SOFAlizer is developed at the Acoustics Research Institute (ARI) of the +Austrian Academy of Sciences. + +To enable compilation of this filter you need to configure FFmpeg with +@code{--enable-netcdf}. + +The filter accepts the following options: + +@table @option +@item sofa +Set the SOFA file used for rendering. + +@item gain +Set gain applied to audio. Value is in dB. Default is 0. + +@item rotation +Set rotation of virtual loudspeakers in deg. Default is 0. + +@item elevation +Set elevation of virtual speakers in deg. Default is 0. + +@item radius +Set distance in meters between loudspeakers and the listener with near-field +HRTFs. Default is 1. + +@item type +Set processing type. Can be @var{time} or @var{freq}. @var{time} is +processing audio in time domain which is slow but gives high quality output. +@var{freq} is processing audio in frequency domain which is fast but gives +mediocre output. Default is @var{freq}. +@end table + +@section stereotools + +This filter has some handy utilities to manage stereo signals, for converting +M/S stereo recordings to L/R signal while having control over the parameters +or spreading the stereo image of master track. + +The filter accepts the following options: + +@table @option +@item level_in +Set input level before filtering for both channels. Defaults is 1. +Allowed range is from 0.015625 to 64. + +@item level_out +Set output level after filtering for both channels. Defaults is 1. +Allowed range is from 0.015625 to 64. + +@item balance_in +Set input balance between both channels. Default is 0. +Allowed range is from -1 to 1. + +@item balance_out +Set output balance between both channels. Default is 0. +Allowed range is from -1 to 1. + +@item softclip +Enable softclipping. Results in analog distortion instead of harsh digital 0dB +clipping. Disabled by default. + +@item mutel +Mute the left channel. Disabled by default. + +@item muter +Mute the right channel. Disabled by default. + +@item phasel +Change the phase of the left channel. Disabled by default. + +@item phaser +Change the phase of the right channel. Disabled by default. + +@item mode +Set stereo mode. Available values are: + +@table @samp +@item lr>lr +Left/Right to Left/Right, this is default. + +@item lr>ms +Left/Right to Mid/Side. + +@item ms>lr +Mid/Side to Left/Right. + +@item lr>ll +Left/Right to Left/Left. + +@item lr>rr +Left/Right to Right/Right. + +@item lr>l+r +Left/Right to Left + Right. + +@item lr>rl +Left/Right to Right/Left. +@end table + +@item slev +Set level of side signal. Default is 1. +Allowed range is from 0.015625 to 64. + +@item sbal +Set balance of side signal. Default is 0. +Allowed range is from -1 to 1. + +@item mlev +Set level of the middle signal. Default is 1. +Allowed range is from 0.015625 to 64. + +@item mpan +Set middle signal pan. Default is 0. Allowed range is from -1 to 1. + +@item base +Set stereo base between mono and inversed channels. Default is 0. +Allowed range is from -1 to 1. + +@item delay +Set delay in milliseconds how much to delay left from right channel and +vice versa. Default is 0. Allowed range is from -20 to 20. + +@item sclevel +Set S/C level. Default is 1. Allowed range is from 1 to 100. + +@item phase +Set the stereo phase in degrees. Default is 0. Allowed range is from 0 to 360. +@end table + +@section stereowiden + +This filter enhance the stereo effect by suppressing signal common to both +channels and by delaying the signal of left into right and vice versa, +thereby widening the stereo effect. + +The filter accepts the following options: + +@table @option +@item delay +Time in milliseconds of the delay of left signal into right and vice versa. +Default is 20 milliseconds. + +@item feedback +Amount of gain in delayed signal into right and vice versa. Gives a delay +effect of left signal in right output and vice versa which gives widening +effect. Default is 0.3. + +@item crossfeed +Cross feed of left into right with inverted phase. This helps in suppressing +the mono. If the value is 1 it will cancel all the signal common to both +channels. Default is 0.3. + +@item drymix +Set level of input signal of original channel. Default is 0.8. +@end table + @section treble Boost or cut treble (upper) frequencies of the audio using a two-pole @@ -2028,7 +3273,42 @@ slope Determine how steep is the filter's shelf transition. @end table -@section volume +@section tremolo + +Sinusoidal amplitude modulation. + +The filter accepts the following options: + +@table @option +@item f +Modulation frequency in Hertz. Modulation frequencies in the subharmonic range +(20 Hz or lower) will result in a tremolo effect. +This filter may also be used as a ring modulator by specifying +a modulation frequency higher than 20 Hz. +Range is 0.1 - 20000.0. Default value is 5.0 Hz. + +@item d +Depth of modulation as a percentage. Range is 0.0 - 1.0. +Default value is 0.5. +@end table + +@section vibrato + +Sinusoidal phase modulation. + +The filter accepts the following options: + +@table @option +@item f +Modulation frequency in Hertz. +Range is 0.1 - 20000.0. Default value is 5.0 Hz. + +@item d +Depth of modulation as a percentage. Range is 0.0 - 1.0. +Default value is 0.5. +@end table + +@section volume Adjust the input audio volume. @@ -2486,6 +3766,46 @@ ffplay -f lavfi flite=text='No more be grieved for which that thou hast done.' For more information about libflite, check: @url{http://www.speech.cs.cmu.edu/flite/} +@section anoisesrc + +Generate a noise audio signal. + +The filter accepts the following options: + +@table @option +@item sample_rate, r +Specify the sample rate. Default value is 48000 Hz. + +@item amplitude, a +Specify the amplitude (0.0 - 1.0) of the generated audio stream. Default value +is 1.0. + +@item duration, d +Specify the duration of the generated audio stream. Not specifying this option +results in noise with an infinite length. + +@item color, colour, c +Specify the color of noise. Available noise colors are white, pink, and brown. +Default color is white. + +@item seed, s +Specify a value used to seed the PRNG. + +@item nb_samples, n +Set the number of samples per each output frame, default is 1024. +@end table + +@subsection Examples + +@itemize + +@item +Generate 60 seconds of pink noise, with a 44.1 kHz sampling rate and an amplitude of 0.5: +@example +anoisesrc=d=60:c=pink:r=44100:a=0.5 +@end example +@end itemize + @section sine Generate an audio signal made of a sine wave with amplitude 1/8. @@ -2510,7 +3830,26 @@ Specify the sample rate, default is 44100. Specify the duration of the generated audio stream. @item samples_per_frame -Set the number of samples per output frame, default is 1024. +Set the number of samples per output frame. + +The expression can contain the following constants: + +@table @option +@item n +The (sequential) number of the output audio frame, starting from 0. + +@item pts +The PTS (Presentation TimeStamp) of the output audio frame, +expressed in @var{TB} units. + +@item t +The PTS of the output audio frame, expressed in seconds. + +@item TB +The timebase of the output audio frames. +@end table + +Default is @code{1024}. @end table @subsection Examples @@ -2531,6 +3870,12 @@ sine=f=220:b=4:d=5 sine=frequency=220:beep_factor=4:duration=5 @end example +@item +Generate a 1 kHz sine wave following @code{1602,1601,1602,1601,1602} NTSC +pattern: +@example +sine=1000:samples_per_frame='st(0,mod(n,5)); 1602-not(not(eq(ld(0),1)+eq(ld(0),3)))' +@end example @end itemize @c man end AUDIO SOURCES @@ -2620,6 +3965,44 @@ Slower shaper using OpenType for substitutions and positioning The default is @code{auto}. @end table +@section atadenoise +Apply an Adaptive Temporal Averaging Denoiser to the video input. + +The filter accepts the following options: + +@table @option +@item 0a +Set threshold A for 1st plane. Default is 0.02. +Valid range is 0 to 0.3. + +@item 0b +Set threshold B for 1st plane. Default is 0.04. +Valid range is 0 to 5. + +@item 1a +Set threshold A for 2nd plane. Default is 0.02. +Valid range is 0 to 0.3. + +@item 1b +Set threshold B for 2nd plane. Default is 0.04. +Valid range is 0 to 5. + +@item 2a +Set threshold A for 3rd plane. Default is 0.02. +Valid range is 0 to 0.3. + +@item 2b +Set threshold B for 3rd plane. Default is 0.04. +Valid range is 0 to 5. + +Threshold A is designed to react on abrupt changes in the input signal and +threshold B is designed to react on continuous changes in the input signal. + +@item s +Set number of frames filter will use for averaging. Default is 33. Must be odd +number in range [5, 129]. +@end table + @section bbox Compute the bounding box for the non-black pixels in the input frame @@ -2739,6 +4122,7 @@ of @var{all_mode}. Default value is @code{normal}. Available values for component modes are: @table @samp @item addition +@item addition128 @item and @item average @item burn @@ -2754,6 +4138,7 @@ Available values for component modes are: @item lighten @item linearlight @item multiply +@item multiply128 @item negation @item normal @item or @@ -2858,6 +4243,12 @@ Apply uncover up-left effect: blend=all_expr='if(gte(T*SH*40+Y,H)*gte((T*40*SW+X)*W/H,W),A,B)' @end example +@item +Split diagonally video and shows top and bottom layer on each side: +@example +blend=all_expr=if(gt(X,Y*(W/H)),A,B) +@end example + @item Display differences between the current and the previous frame: @example @@ -2953,6 +4344,51 @@ boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chrom @end example @end itemize +@section chromakey +YUV colorspace color/chroma keying. + +The filter accepts the following options: + +@table @option +@item color +The color which will be replaced with transparency. + +@item similarity +Similarity percentage with the key color. + +0.01 matches only the exact key color, while 1.0 matches everything. + +@item blend +Blend percentage. + +0.0 makes pixels either fully transparent, or not transparent at all. + +Higher values result in semi-transparent pixels, with a higher transparency +the more similar the pixels color is to the key color. + +@item yuv +Signals that the color passed is already in YUV instead of RGB. + +Litteral colors like "green" or "red" don't make sense with this enabled anymore. +This can be used to pass exact YUV values as hexadecimal numbers. +@end table + +@subsection Examples + +@itemize +@item +Make every green pixel in the input image transparent: +@example +ffmpeg -i input.png -vf chromakey=green out.png +@end example + +@item +Overlay a greenscreen-video on top of a static black background. +@example +ffmpeg -f lavfi -i color=c=black:s=1280x720 -i video.mp4 -shortest -filter_complex "[1:v]chromakey=0x70de77:0.1:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.mkv +@end example +@end itemize + @section codecview Visualize information exported by some codecs. @@ -2977,6 +4413,9 @@ forward predicted MVs of B-frames @item bb backward predicted MVs of B-frames @end table + +@item qp +Display quantization parameters using the chroma planes @end table @subsection Examples @@ -3029,6 +4468,45 @@ colorbalance=rs=.3 @end example @end itemize +@section colorkey +RGB colorspace color keying. + +The filter accepts the following options: + +@table @option +@item color +The color which will be replaced with transparency. + +@item similarity +Similarity percentage with the key color. + +0.01 matches only the exact key color, while 1.0 matches everything. + +@item blend +Blend percentage. + +0.0 makes pixels either fully transparent, or not transparent at all. + +Higher values result in semi-transparent pixels, with a higher transparency +the more similar the pixels color is to the key color. +@end table + +@subsection Examples + +@itemize +@item +Make every green pixel in the input image transparent: +@example +ffmpeg -i input.png -vf colorkey=green out.png +@end example + +@item +Overlay a greenscreen-video on top of a static background image. +@example +ffmpeg -i background.png -i video.mp4 -filter_complex "[1:v]colorkey=0x3BBD1E:0.3:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.flv +@end example +@end itemize + @section colorlevels Adjust video input frames using levels. @@ -3191,6 +4669,68 @@ For example to convert from BT.601 to SMPTE-240M, use the command: colormatrix=bt601:smpte240m @end example +@section convolution + +Apply convolution 3x3 or 5x5 filter. + +The filter accepts the following options: + +@table @option +@item 0m +@item 1m +@item 2m +@item 3m +Set matrix for each plane. +Matrix is sequence of 9 or 25 signed integers. + +@item 0rdiv +@item 1rdiv +@item 2rdiv +@item 3rdiv +Set multiplier for calculated value for each plane. + +@item 0bias +@item 1bias +@item 2bias +@item 3bias +Set bias for each plane. This value is added to the result of the multiplication. +Useful for making the overall image brighter or darker. Default is 0.0. +@end table + +@subsection Examples + +@itemize +@item +Apply sharpen: +@example +convolution="0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0" +@end example + +@item +Apply blur: +@example +convolution="1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1/9:1/9:1/9:1/9" +@end example + +@item +Apply edge enhance: +@example +convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:5:1:1:1:0:128:128:128" +@end example + +@item +Apply edge detect: +@example +convolution="0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:5:5:5:1:0:128:128:128" +@end example + +@item +Apply emboss: +@example +convolution="-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2" +@end example +@end itemize + @section copy Copy the input source unchanged to the output. This is mainly useful for @@ -3206,12 +4746,12 @@ It accepts the following parameters: @item w, out_w The width of the output video. It defaults to @code{iw}. This expression is evaluated only once during the filter -configuration. +configuration, or when the @samp{w} or @samp{out_w} command is sent. @item h, out_h The height of the output video. It defaults to @code{ih}. This expression is evaluated only once during the filter -configuration. +configuration, or when the @samp{h} or @samp{out_h} command is sent. @item x The horizontal position, in the input video, of the left edge of the output @@ -3371,6 +4911,22 @@ crop=in_w/2:in_h/2:y:10+10*sin(n/10) @end example @end itemize +@subsection Commands + +This filter supports the following commands: +@table @option +@item w, out_w +@item h, out_h +@item x +@item y +Set width/height of the output video and the horizontal/vertical position +in the input video. +The command accepts the same syntax of the corresponding option. + +If the specified expression is not valid, it is kept at its current +value. +@end table + @section cropdetect Auto-detect the crop size. @@ -3471,7 +5027,7 @@ Can be used in addition to the other key points component options. In this case, the unset component(s) will fallback on this @option{all} setting. @item psfile -Specify a Photoshop curves file (@code{.asv}) to import the settings from. +Specify a Photoshop curves file (@code{.acv}) to import the settings from. @end table To avoid some filtergraph syntax conflicts, each key points list need to be @@ -3516,7 +5072,7 @@ curves=vintage @item Use a Photoshop preset and redefine the points of the green component: @example -curves=psfile='MyCurvesPresets/purple.asv':green='0.45/0.53' +curves=psfile='MyCurvesPresets/purple.acv':green='0.45/0.53' @end example @end itemize @@ -3587,6 +5143,43 @@ Violent denoise using a block size of @code{16x16}: dctdnoiz=15:n=4 @end example +@section deband + +Remove banding artifacts from input video. +It works by replacing banded pixels with average value of referenced pixels. + +The filter accepts the following options: + +@table @option +@item 1thr +@item 2thr +@item 3thr +@item 4thr +Set banding detection threshold for each plane. Default is 0.02. +Valid range is 0.00003 to 0.5. +If difference between current pixel and reference pixel is less than threshold, +it will be considered as banded. + +@item range, r +Banding detection range in pixels. Default is 16. If positive, random number +in range 0 to set value will be used. If negative, exact absolute value +will be used. +The range defines square of four pixels around current pixel. + +@item direction, d +Set direction in radians from which four pixel will be compared. If positive, +random direction from 0 to set direction will be picked. If negative, exact of +absolute value will be picked. For example direction 0, -PI or -2*PI radians +will pick only pixels on same row and -PI/2 will pick only pixels on same +column. + +@item blur +If enabled, current pixel is compared with average value of all four +surrounding pixels. The default is enabled. If disabled current pixel is +compared with all four surrounding pixels. The pixel is considered banded +if only all four differences with surrounding pixels are less than threshold. +@end table + @anchor{decimate} @section decimate @@ -3627,6 +5220,24 @@ Set whether or not chroma is considered in the metric calculations. Default is @code{1}. @end table +@section deflate + +Apply deflate effect to the video. + +This filter replaces the pixel by the local(3x3) average by taking into account +only values lower than the pixel. + +It accepts the following options: + +@table @option +@item threshold0 +@item threshold1 +@item threshold2 +@item threshold3 +Limit the maximum change for each plane, default is 65535. +If 0, plane will remain unchanged. +@end table + @section dejudder Remove judder produced by partially interlaced telecined content. @@ -3680,7 +5291,9 @@ specified. @item band, t Specify the thickness of the fuzzy edge of the rectangle (added to -@var{w} and @var{h}). The default value is 4. +@var{w} and @var{h}). The default value is 1. This option is +deprecated, setting higher values should no longer be necessary and +is not recommended. @item show When set to 1, a green rectangle is drawn on the screen to simplify @@ -3813,6 +5426,85 @@ A number representing position of the first frame with respect to the telecine pattern. This is to be used if the stream is cut. The default value is @code{0}. @end table +@section dilation + +Apply dilation effect to the video. + +This filter replaces the pixel by the local(3x3) maximum. + +It accepts the following options: + +@table @option +@item threshold0 +@item threshold1 +@item threshold2 +@item threshold3 +Limit the maximum change for each plane, default is 65535. +If 0, plane will remain unchanged. + +@item coordinates +Flag which specifies the pixel to refer to. Default is 255 i.e. all eight +pixels are used. + +Flags to local 3x3 coordinates maps like this: + + 1 2 3 + 4 5 + 6 7 8 +@end table + +@section displace + +Displace pixels as indicated by second and third input stream. + +It takes three input streams and outputs one stream, the first input is the +source, and second and third input are displacement maps. + +The second input specifies how much to displace pixels along the +x-axis, while the third input specifies how much to displace pixels +along the y-axis. +If one of displacement map streams terminates, last frame from that +displacement map will be used. + +Note that once generated, displacements maps can be reused over and over again. + +A description of the accepted options follows. + +@table @option +@item edge +Set displace behavior for pixels that are out of range. + +Available values are: +@table @samp +@item blank +Missing pixels are replaced by black pixels. + +@item smear +Adjacent pixels will spread out to replace missing pixels. + +@item wrap +Out of range pixels are wrapped so they point to pixels of other side. +@end table +Default is @samp{smear}. + +@end table + +@subsection Examples + +@itemize +@item +Add ripple effect to rgb input of video size hd720: +@example +ffmpeg -i INPUT -f lavfi -i nullsrc=s=hd720,lutrgb=128:128:128 -f lavfi -i nullsrc=s=hd720,geq='r=128+30*sin(2*PI*X/400+T):g=128+30*sin(2*PI*X/400+T):b=128+30*sin(2*PI*X/400+T)' -lavfi '[0][1][2]displace' OUTPUT +@end example + +@item +Add wave effect to rgb input of video size hd720: +@example +ffmpeg -i INPUT -f lavfi -i nullsrc=hd720,geq='r=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T)):g=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T)):b=128+80*(sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/220*2*PI+T))' -lavfi '[1]split[x][y],[0][x][y]displace' OUTPUT +@end example +@end itemize + @section drawbox Draw a colored box on the input image. @@ -3909,28 +5601,130 @@ drawbox=x=-t:y=0.5*(ih-iw/2.4)-t:w=iw+t*2:h=iw/2.4+t*2:t=2:c=red @end example @end itemize -@section drawgrid +@section drawgraph, adrawgraph -Draw a grid on the input image. +Draw a graph using input video or audio metadata. It accepts the following parameters: @table @option -@item x -@item y -The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0. +@item m1 +Set 1st frame metadata key from which metadata values will be used to draw a graph. -@item width, w -@item height, h -The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the -input width and height, respectively, minus @code{thickness}, so image gets -framed. Default to 0. +@item fg1 +Set 1st foreground color expression. -@item color, c -Specify the color of the grid. For the general syntax of this option, -check the "Color" section in the ffmpeg-utils manual. If the special -value @code{invert} is used, the grid color is the same as the -video with inverted luma. +@item m2 +Set 2nd frame metadata key from which metadata values will be used to draw a graph. + +@item fg2 +Set 2nd foreground color expression. + +@item m3 +Set 3rd frame metadata key from which metadata values will be used to draw a graph. + +@item fg3 +Set 3rd foreground color expression. + +@item m4 +Set 4th frame metadata key from which metadata values will be used to draw a graph. + +@item fg4 +Set 4th foreground color expression. + +@item min +Set minimal value of metadata value. + +@item max +Set maximal value of metadata value. + +@item bg +Set graph background color. Default is white. + +@item mode +Set graph mode. + +Available values for mode is: +@table @samp +@item bar +@item dot +@item line +@end table + +Default is @code{line}. + +@item slide +Set slide mode. + +Available values for slide is: +@table @samp +@item frame +Draw new frame when right border is reached. + +@item replace +Replace old columns with new ones. + +@item scroll +Scroll from right to left. + +@item rscroll +Scroll from left to right. +@end table + +Default is @code{frame}. + +@item size +Set size of graph video. For the syntax of this option, check the +@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. +The default value is @code{900x256}. + +The foreground color expressions can use the following variables: +@table @option +@item MIN +Minimal value of metadata value. + +@item MAX +Maximal value of metadata value. + +@item VAL +Current metadata key value. +@end table + +The color is defined as 0xAABBGGRR. +@end table + +Example using metadata from @ref{signalstats} filter: +@example +signalstats,drawgraph=lavfi.signalstats.YAVG:min=0:max=255 +@end example + +Example using metadata from @ref{ebur128} filter: +@example +ebur128=metadata=1,adrawgraph=lavfi.r128.M:min=-120:max=5 +@end example + +@section drawgrid + +Draw a grid on the input image. + +It accepts the following parameters: + +@table @option +@item x +@item y +The expressions which specify the coordinates of some point of grid intersection (meant to configure offset). Both default to 0. + +@item width, w +@item height, h +The expressions which specify the width and height of the grid cell, if 0 they are interpreted as the +input width and height, respectively, minus @code{thickness}, so image gets +framed. Default to 0. + +@item color, c +Specify the color of the grid. For the general syntax of this option, +check the "Color" section in the ffmpeg-utils manual. If the special +value @code{invert} is used, the grid color is the same as the +video with inverted luma. @item thickness, t The expression which sets the thickness of the grid line. Default value is @code{1}. @@ -4305,14 +6099,20 @@ A 1 character description of the current picture type. @item pts The timestamp of the current frame. -It can take up to two arguments. +It can take up to three arguments. The first argument is the format of the timestamp; it defaults to @code{flt} for seconds as a decimal number with microsecond accuracy; @code{hms} stands for a formatted @var{[-]HH:MM:SS.mmm} timestamp with millisecond accuracy. +@code{gmtime} stands for the timestamp of the frame formatted as UTC time; +@code{localtime} stands for the timestamp of the frame formatted as +local time zone time. The second argument is an offset added to the timestamp. +If the format is set to @code{localtime} or @code{gmtime}, +a third argument may be supplied: a strftime() format string. +By default, @var{YYYY-MM-DD HH:MM:SS} format will be used. @end table @subsection Examples @@ -4343,7 +6143,7 @@ within the parameter list. @item Show the text at the center of the video frame: @example -drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2" +drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h)/2" @end example @item @@ -4467,7 +6267,7 @@ The filter accepts the following options: @table @option @item contrast Set the contrast expression. The value must be a float value in range -@code{-2.0} to @code{2.0}. The default value is "0". +@code{-2.0} to @code{2.0}. The default value is "1". @item brightness Set the brightness expression. The value must be a float value in @@ -4569,6 +6369,33 @@ value. @end table +@section erosion + +Apply erosion effect to the video. + +This filter replaces the pixel by the local(3x3) minimum. + +It accepts the following options: + +@table @option +@item threshold0 +@item threshold1 +@item threshold2 +@item threshold3 +Limit the maximum change for each plane, default is 65535. +If 0, plane will remain unchanged. + +@item coordinates +Flag which specifies the pixel to refer to. Default is 255 i.e. all eight +pixels are used. + +Flags to local 3x3 coordinates maps like this: + + 1 2 3 + 4 5 + 6 7 8 +@end table + @section extractplanes Extract color channel components from input video stream into @@ -4631,6 +6458,10 @@ computation time. Default value is 1. Set a random seed, must be an integer included between 0 and UINT32_MAX. If not specified, or if explicitly set to -1, the filter will try to use a good random seed on a best effort basis. + +@item pal8 +Set pal8 output pixel format. This option does not work with codebook +length greater than 256. @end table @section fade @@ -4783,6 +6614,12 @@ Sharpen: fftfilt=dc_Y=0:weight_Y='1+squish(1-(Y+X)/100)' @end example +@item +Blur: +@example +fftfilt=dc_Y=0:weight_Y='exp(-4 * ((Y+X)/(W+H)))' +@end example + @end itemize @section field @@ -4828,8 +6665,9 @@ which @code{fieldmatch} is based on. While the semantic and usage are very close, some behaviour and options names can differ. The @ref{decimate} filter currently only works for constant frame rate input. -Do not use @code{fieldmatch} and @ref{decimate} if your input has mixed -telecined and progressive content with changing framerate. +If your input has mixed telecined (30fps) and progressive content with a lower +framerate like 24fps use the following filterchain to produce the necessary cfr +stream: @code{dejudder,fps=30000/1001,fieldmatch,decimate}. The filter accepts the following options: @@ -5157,7 +6995,7 @@ For example: ffmpeg -i in.vob -vf "fieldorder=bff" out.dv @end example -@section fifo +@section fifo, afifo Buffer input images and send them when they are requested. @@ -5367,6 +7205,51 @@ ffmpeg -i LEFT -i RIGHT -filter_complex framepack=frameseq OUTPUT ffmpeg -i LEFT -i RIGHT -filter_complex [0:v]scale=w=iw/2[left],[1:v]scale=w=iw/2[right],[left][right]framepack=sbs OUTPUT @end example +@section framerate + +Change the frame rate by interpolating new video output frames from the source +frames. + +This filter is not designed to function correctly with interlaced media. If +you wish to change the frame rate of interlaced media then you are required +to deinterlace before this filter and re-interlace after this filter. + +A description of the accepted options follows. + +@table @option +@item fps +Specify the output frames per second. This option can also be specified +as a value alone. The default is @code{50}. + +@item interp_start +Specify the start of a range where the output frame will be created as a +linear interpolation of two frames. The range is [@code{0}-@code{255}], +the default is @code{15}. + +@item interp_end +Specify the end of a range where the output frame will be created as a +linear interpolation of two frames. The range is [@code{0}-@code{255}], +the default is @code{240}. + +@item scene +Specify the level at which a scene change is detected as a value between +0 and 100 to indicate a new scene; a low value reflects a low +probability for the current frame to introduce a new scene, while a higher +value means the current frame is more likely to be one. +The default is @code{7}. + +@item flags +Specify flags influencing the filter process. + +Available value for @var{flags} is: + +@table @option +@item scene_change_detect, scd +Enable scene change detection using the value of the option @var{scene}. +This flag is enabled by default. +@end table +@end table + @section framestep Select one frame every N-th frame. @@ -5601,12 +7484,9 @@ geq=lum=255*gauss((X/W-0.5)*3)*gauss((Y/H-0.5)*3)/gauss(0)/gauss(0),format=gray @end example @item -Create a linear gradient to use as a mask for another filter, then -compose with @ref{overlay}. In this example the video will gradually -become more blurry from the top to the bottom of the y-axis as defined -by the linear gradient: +Diagonal split screen to compare filter effect: @example -ffmpeg -i input.mp4 -filter_complex "geq=lum=255*(Y/H),format=gray[grad];[0:v]boxblur=4[blur];[blur][grad]alphamerge[alpha];[0:v][alpha]overlay" output.mp4 +ffmpeg -i input -filter_complex "[0:v]geq=lum=if(gt(X\,Y*(W/H))\,255),format=gray[alpha];[0:v][alpha]alphamerge,curves=preset=color_negative[filtered];[0:v][filtered]overlay" output @end example @end itemize @@ -5782,106 +7662,43 @@ Compute and draw a color distribution histogram for the input video. The computed histogram is a representation of the color component distribution in an image. -The filter accepts the following options: - -@table @option -@item mode -Set histogram mode. - -It accepts the following values: -@table @samp -@item levels -Standard histogram that displays the color components distribution in an -image. Displays color graph for each color component. Shows distribution of +Standard histogram displays the color components distribution in an image. +Displays color graph for each color component. Shows distribution of the Y, U, V, A or R, G, B components, depending on input format, in the current frame. Below each graph a color component scale meter is shown. -@item color -Displays chroma values (U/V color placement) in a two dimensional -graph (which is called a vectorscope). The brighter a pixel in the -vectorscope, the more pixels of the input frame correspond to that pixel -(i.e., more pixels have this chroma value). The V component is displayed on -the horizontal (X) axis, with the leftmost side being V = 0 and the rightmost -side being V = 255. The U component is displayed on the vertical (Y) axis, -with the top representing U = 0 and the bottom representing U = 255. - -The position of a white pixel in the graph corresponds to the chroma value of -a pixel of the input clip. The graph can therefore be used to read the hue -(color flavor) and the saturation (the dominance of the hue in the color). As -the hue of a color changes, it moves around the square. At the center of the -square the saturation is zero, which means that the corresponding pixel has no -color. If the amount of a specific color is increased (while leaving the other -colors unchanged) the saturation increases, and the indicator moves towards -the edge of the square. - -@item color2 -Chroma values in vectorscope, similar as @code{color} but actual chroma values -are displayed. - -@item waveform -Per row/column color component graph. In row mode, the graph on the left side -represents color component value 0 and the right side represents value = 255. -In column mode, the top side represents color component value = 0 and bottom -side represents value = 255. -@end table -Default value is @code{levels}. +The filter accepts the following options: +@table @option @item level_height -Set height of level in @code{levels}. Default value is @code{200}. +Set height of level. Default value is @code{200}. Allowed range is [50, 2048]. @item scale_height -Set height of color scale in @code{levels}. Default value is @code{12}. +Set height of color scale. Default value is @code{12}. Allowed range is [0, 40]. -@item step -Set step for @code{waveform} mode. Smaller values are useful to find out how -many values of the same luminance are distributed across input rows/columns. -Default value is @code{10}. Allowed range is [1, 255]. - -@item waveform_mode -Set mode for @code{waveform}. Can be either @code{row}, or @code{column}. -Default is @code{row}. - -@item waveform_mirror -Set mirroring mode for @code{waveform}. @code{0} means unmirrored, @code{1} -means mirrored. In mirrored mode, higher values will be represented on the left -side for @code{row} mode and at the top for @code{column} mode. Default is -@code{0} (unmirrored). - @item display_mode -Set display mode for @code{waveform} and @code{levels}. +Set display mode. It accepts the following values: @table @samp @item parade -Display separate graph for the color components side by side in -@code{row} waveform mode or one below the other in @code{column} waveform mode -for @code{waveform} histogram mode. For @code{levels} histogram mode, -per color component graphs are placed below each other. - -Using this display mode in @code{waveform} histogram mode makes it easy to -spot color casts in the highlights and shadows of an image, by comparing the -contours of the top and the bottom graphs of each waveform. Since whites, -grays, and blacks are characterized by exactly equal amounts of red, green, -and blue, neutral areas of the picture should display three waveforms of -roughly equal width/height. If not, the correction is easy to perform by -making level adjustments the three waveforms. +Per color component graphs are placed below each other. @item overlay Presents information identical to that in the @code{parade}, except that the graphs representing color components are superimposed directly over one another. - -This display mode in @code{waveform} histogram mode makes it easier to spot -relative differences or similarities in overlapping areas of the color -components that are supposed to be identical, such as neutral whites, grays, -or blacks. @end table Default is @code{parade}. @item levels_mode -Set mode for @code{levels}. Can be either @code{linear}, or @code{logarithmic}. +Set mode. Can be either @code{linear}, or @code{logarithmic}. Default is @code{linear}. + +@item components +Set what color components to display. +Default is @code{7}. @end table @subsection Examples @@ -5937,6 +7754,25 @@ Set the scaling dimension: @code{2} for @code{hq2x}, @code{3} for Default is @code{3}. @end table +@section hstack +Stack input videos horizontally. + +All streams must be of same pixel format and of same height. + +Note that this filter is faster than using @ref{overlay} and @ref{pad} filter +to create same output. + +The filter accept the following option: + +@table @option +@item inputs +Set number of input streams. Default is 2. + +@item shortest +If set to 1, force the output to terminate when the shortest input +terminates. Default value is 0. +@end table + @section hue Modify the hue and/or the saturation of the input. @@ -6166,6 +8002,24 @@ Default value is @code{none}. Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}. @end table +@section inflate + +Apply inflate effect to the video. + +This filter replaces the pixel by the local(3x3) average by taking into account +only values higher than the pixel. + +It accepts the following options: + +@table @option +@item threshold0 +@item threshold1 +@item threshold2 +@item threshold3 +Limit the maximum change for each plane, default is 65535. +If 0, plane will remain unchanged. +@end table + @section interlace Simple interlacing filter from progressive contents. This interleaves upper (or @@ -6472,6 +8326,69 @@ lutyuv=y='bitand(val, 128+64+32)' @end example @end itemize +@section maskedmerge + +Merge the first input stream with the second input stream using per pixel +weights in the third input stream. + +A value of 0 in the third stream pixel component means that pixel component +from first stream is returned unchanged, while maximum value (eg. 255 for +8-bit videos) means that pixel component from second stream is returned +unchanged. Intermediate values define the amount of merging between both +input stream's pixel components. + +This filter accepts the following options: +@table @option +@item planes +Set which planes will be processed as bitmap, unprocessed planes will be +copied from first stream. +By default value 0xf, all planes will be processed. +@end table + +@section mcdeint + +Apply motion-compensation deinterlacing. + +It needs one field per frame as input and must thus be used together +with yadif=1/3 or equivalent. + +This filter accepts the following options: +@table @option +@item mode +Set the deinterlacing mode. + +It accepts one of the following values: +@table @samp +@item fast +@item medium +@item slow +use iterative motion estimation +@item extra_slow +like @samp{slow}, but use multiple reference frames. +@end table +Default value is @samp{fast}. + +@item parity +Set the picture field parity assumed for the input video. It must be +one of the following values: + +@table @samp +@item 0, tff +assume top field first +@item 1, bff +assume bottom field first +@end table + +Default value is @samp{bff}. + +@item qp +Set per-block quantization parameter (QP) used by the internal +encoder. + +Higher values should result in a smoother motion vector field but less +optimal individual vectors. Default value is 1. +@end table + @section mergeplanes Merge color channel components from several video streams. @@ -6531,74 +8448,129 @@ format=rgb24,mergeplanes=0x000102:yuv444p @end example @end itemize -@section mcdeint - -Apply motion-compensation deinterlacing. +@section metadata, ametadata -It needs one field per frame as input and must thus be used together -with yadif=1/3 or equivalent. +Manipulate frame metadata. This filter accepts the following options: + @table @option @item mode -Set the deinterlacing mode. - -It accepts one of the following values: -@table @samp -@item fast -@item medium -@item slow -use iterative motion estimation -@item extra_slow -like @samp{slow}, but use multiple reference frames. -@end table -Default value is @samp{fast}. +Set mode of operation of the filter. -@item parity -Set the picture field parity assumed for the input video. It must be -one of the following values: +Can be one of the following: @table @samp -@item 0, tff -assume top field first -@item 1, bff -assume bottom field first -@end table +@item select +If both @code{value} and @code{key} is set, select frames +which have such metadata. If only @code{key} is set, select +every frame that has such key in metadata. -Default value is @samp{bff}. +@item add +Add new metadata @code{key} and @code{value}. If key is already available +do nothing. -@item qp -Set per-block quantization parameter (QP) used by the internal -encoder. +@item modify +Modify value of already present key. -Higher values should result in a smoother motion vector field but less -optimal individual vectors. Default value is 1. +@item delete +If @code{value} is set, delete only keys that have such value. +Otherwise, delete key. + +@item print +Print key and its value if metadata was found. If @code{key} is not set print all +metadata values available in frame. @end table -@section mpdecimate +@item key +Set key used with all modes. Must be set for all modes except @code{print}. -Drop frames that do not differ greatly from the previous frame in -order to reduce frame rate. +@item value +Set metadata value which will be used. This option is mandatory for +@code{modify} and @code{add} mode. -The main use of this filter is for very-low-bitrate encoding -(e.g. streaming over dialup modem), but it could in theory be used for -fixing movies that were inverse-telecined incorrectly. +@item function +Which function to use when comparing metadata value and @code{value}. -A description of the accepted options follows. +Can be one of following: -@table @option -@item max -Set the maximum number of consecutive frames which can be dropped (if -positive), or the minimum interval between dropped frames (if -negative). If the value is 0, the frame is dropped unregarding the -number of previous sequentially dropped frames. +@table @samp +@item same_str +Values are interpreted as strings, returns true if metadata value is same as @code{value}. -Default value is 0. +@item starts_with +Values are interpreted as strings, returns true if metadata value starts with +the @code{value} option string. -@item hi -@item lo -@item frac -Set the dropping threshold values. +@item less +Values are interpreted as floats, returns true if metadata value is less than @code{value}. + +@item equal +Values are interpreted as floats, returns true if @code{value} is equal with metadata value. + +@item greater +Values are interpreted as floats, returns true if metadata value is greater than @code{value}. + +@item expr +Values are interpreted as floats, returns true if expression from option @code{expr} +evaluates to true. +@end table + +@item expr +Set expression which is used when @code{function} is set to @code{expr}. +The expression is evaluated through the eval API and can contain the following +constants: + +@table @option +@item VALUE1 +Float representation of @code{value} from metadata key. + +@item VALUE2 +Float representation of @code{value} as supplied by user in @code{value} option. +@end table + +@item file +If specified in @code{print} mode, output is written to the named file. When +filename equals "-" data is written to standard output. +If @code{file} option is not set, output is written to the log with AV_LOG_INFO +loglevel. +@end table + +@subsection Examples + +@itemize +@item +Print all metadata values for frames with key @code{lavfi.singnalstats.YDIF} with values +between 0 and 1. +@example +@end example +signalstats,metadata=print:key=lavfi.signalstats.YDIF:value=0:function=expr:expr='between(VALUE1,0,1)' +@end itemize + +@section mpdecimate + +Drop frames that do not differ greatly from the previous frame in +order to reduce frame rate. + +The main use of this filter is for very-low-bitrate encoding +(e.g. streaming over dialup modem), but it could in theory be used for +fixing movies that were inverse-telecined incorrectly. + +A description of the accepted options follows. + +@table @option +@item max +Set the maximum number of consecutive frames which can be dropped (if +positive), or the minimum interval between dropped frames (if +negative). If the value is 0, the frame is dropped unregarding the +number of previous sequentially dropped frames. + +Default value is 0. + +@item hi +@item lo +@item frac +Set the dropping threshold values. Values for @option{hi} and @option{lo} are for 8x8 pixel blocks and represent actual pixel value differences, so a threshold of 64 @@ -6621,6 +8593,115 @@ Negate input video. It accepts an integer in input; if non-zero it negates the alpha component (if available). The default value in input is 0. +@section nnedi + +Deinterlace video using neural network edge directed interpolation. + +This filter accepts the following options: + +@table @option +@item weights +Mandatory option, without binary file filter can not work. +Currently file can be found here: +https://github.com/dubhater/vapoursynth-nnedi3/blob/master/src/nnedi3_weights.bin + +@item deint +Set which frames to deinterlace, by default it is @code{all}. +Can be @code{all} or @code{interlaced}. + +@item field +Set mode of operation. + +Can be one of the following: + +@table @samp +@item af +Use frame flags, both fields. +@item a +Use frame flags, single field. +@item t +Use top field only. +@item b +Use bottom field only. +@item ft +Use both fields, top first. +@item fb +Use both fields, bottom first. +@end table + +@item planes +Set which planes to process, by default filter process all frames. + +@item nsize +Set size of local neighborhood around each pixel, used by the predictor neural +network. + +Can be one of the following: + +@table @samp +@item s8x6 +@item s16x6 +@item s32x6 +@item s48x6 +@item s8x4 +@item s16x4 +@item s32x4 +@end table + +@item nns +Set the number of neurons in predicctor neural network. +Can be one of the following: + +@table @samp +@item n16 +@item n32 +@item n64 +@item n128 +@item n256 +@end table + +@item qual +Controls the number of different neural network predictions that are blended +together to compute the final output value. Can be @code{fast}, default or +@code{slow}. + +@item etype +Set which set of weights to use in the predictor. +Can be one of the following: + +@table @samp +@item a +weights trained to minimize absolute error +@item s +weights trained to minimize squared error +@end table + +@item pscrn +Controls whether or not the prescreener neural network is used to decide +which pixels should be processed by the predictor neural network and which +can be handled by simple cubic interpolation. +The prescreener is trained to know whether cubic interpolation will be +sufficient for a pixel or whether it should be predicted by the predictor nn. +The computational complexity of the prescreener nn is much less than that of +the predictor nn. Since most pixels can be handled by cubic interpolation, +using the prescreener generally results in much faster processing. +The prescreener is pretty accurate, so the difference between using it and not +using it is almost always unnoticeable. + +Can be one of the following: + +@table @samp +@item none +@item original +@item new +@end table + +Default is @code{new}. + +@item fapprox +Set various debugging flags. +@end table + @section noformat Force libavfilter not to use any of the specified pixel formats for the @@ -6705,6 +8786,30 @@ noise=alls=20:allf=t+u Pass the video source unchanged to the output. +@section ocr +Optical Character Recognition + +This filter uses Tesseract for optical character recognition. + +It accepts the following options: + +@table @option +@item datapath +Set datapath to tesseract data. Default is to use whatever was +set at installation. + +@item language +Set language, default is "eng". + +@item whitelist +Set character whitelist. + +@item blacklist +Set character blacklist. +@end table + +The filter exports recognized text as the frame metadata @code{lavfi.ocr.text}. + @section ocv Apply a video transform using libopencv. @@ -7066,6 +9171,7 @@ Set chroma strength. Must be a double value in the range 0-1000, default is @code{1.0}. @end table +@anchor{pad} @section pad Add paddings to the input image, and place the original input at the @@ -7682,7 +9788,8 @@ The description of the accepted parameters follows. @table @option @item stats_file, f If specified the filter will use the named file to save the PSNR of -each individual frame. +each individual frame. When filename equals "-" the data is sent to +standard output. @end table The file printed if @var{stats_file} is selected, contains a sequence of @@ -7815,6 +9922,128 @@ qp=2+2*sin(PI*qp) @end example @end itemize +@section random + +Flush video frames from internal cache of frames into a random order. +No frame is discarded. +Inspired by @ref{frei0r} nervous filter. + +@table @option +@item frames +Set size in number of frames of internal cache, in range from @code{2} to +@code{512}. Default is @code{30}. + +@item seed +Set seed for random number generator, must be an integer included between +@code{0} and @code{UINT32_MAX}. If not specified, or if explicitly set to +less than @code{0}, the filter will try to use a good random seed on a +best effort basis. +@end table + +@section removegrain + +The removegrain filter is a spatial denoiser for progressive video. + +@table @option +@item m0 +Set mode for the first plane. + +@item m1 +Set mode for the second plane. + +@item m2 +Set mode for the third plane. + +@item m3 +Set mode for the fourth plane. +@end table + +Range of mode is from 0 to 24. Description of each mode follows: + +@table @var +@item 0 +Leave input plane unchanged. Default. + +@item 1 +Clips the pixel with the minimum and maximum of the 8 neighbour pixels. + +@item 2 +Clips the pixel with the second minimum and maximum of the 8 neighbour pixels. + +@item 3 +Clips the pixel with the third minimum and maximum of the 8 neighbour pixels. + +@item 4 +Clips the pixel with the fourth minimum and maximum of the 8 neighbour pixels. +This is equivalent to a median filter. + +@item 5 +Line-sensitive clipping giving the minimal change. + +@item 6 +Line-sensitive clipping, intermediate. + +@item 7 +Line-sensitive clipping, intermediate. + +@item 8 +Line-sensitive clipping, intermediate. + +@item 9 +Line-sensitive clipping on a line where the neighbours pixels are the closest. + +@item 10 +Replaces the target pixel with the closest neighbour. + +@item 11 +[1 2 1] horizontal and vertical kernel blur. + +@item 12 +Same as mode 11. + +@item 13 +Bob mode, interpolates top field from the line where the neighbours +pixels are the closest. + +@item 14 +Bob mode, interpolates bottom field from the line where the neighbours +pixels are the closest. + +@item 15 +Bob mode, interpolates top field. Same as 13 but with a more complicated +interpolation formula. + +@item 16 +Bob mode, interpolates bottom field. Same as 14 but with a more complicated +interpolation formula. + +@item 17 +Clips the pixel with the minimum and maximum of respectively the maximum and +minimum of each pair of opposite neighbour pixels. + +@item 18 +Line-sensitive clipping using opposite neighbours whose greatest distance from +the current pixel is minimal. + +@item 19 +Replaces the pixel with the average of its 8 neighbours. + +@item 20 +Averages the 9 pixels ([1 1 1] horizontal and vertical blur). + +@item 21 +Clips pixels using the averages of opposite neighbour. + +@item 22 +Same as mode 21 but simpler and faster. + +@item 23 +Small edge and halo removal, but reputed useless. + +@item 24 +Similar as 23. +@end table + @section removelogo Suppress a TV station logo, using an image file to determine which @@ -7850,6 +10079,23 @@ pixels will slow things down on a large logo. This filter uses the repeat_field flag from the Video ES headers and hard repeats fields based on its value. +@section reverse, areverse + +Reverse a clip. + +Warning: This filter requires memory to buffer the entire clip, so trimming +is suggested. + +@subsection Examples + +@itemize +@item +Take the first 5 seconds of a clip, and reverse it. +@example +trim=end=5,reverse +@end example +@end itemize + @section rotate Rotate video by an arbitrary angle expressed in radians. @@ -8059,6 +10305,21 @@ dimension is divisible by n and adjust the value if necessary. See below for the list of accepted constants for use in the dimension expression. +@item eval +Specify when to evaluate @var{width} and @var{height} expression. It accepts the following values: + +@table @samp +@item init +Only evaluate expressions once during the filter initialization or when a command is processed. + +@item frame +Evaluate expressions for each incoming frame. + +@end table + +Default value is @samp{init}. + + @item interl Set the interlacing mode. It accepts the following values: @@ -8082,6 +10343,15 @@ Set libswscale scaling flags. See complete list of values. If not explicitly specified the filter applies the default flags. + +@item param0, param1 +Set libswscale input parameters for scaling algorithms that need them. See +@ref{sws_params,,the ffmpeg-scaler manual,ffmpeg-scaler} for the +complete documentation. If not explicitly specified the filter applies +empty parameters. + + + @item size, s Set the video size. For the syntax of this option, check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. @@ -8304,6 +10574,103 @@ scale=w='min(500\, iw*3/2):h=-1' @end example @end itemize +@subsection Commands + +This filter supports the following commands: +@table @option +@item width, w +@item height, h +Set the output video dimension expression. +The command accepts the same syntax of the corresponding option. + +If the specified expression is not valid, it is kept at its current +value. +@end table + +@section scale2ref + +Scale (resize) the input video, based on a reference video. + +See the scale filter for available options, scale2ref supports the same but +uses the reference video instead of the main input as basis. + +@subsection Examples + +@itemize +@item +Scale a subtitle stream to match the main video in size before overlaying +@example +'scale2ref[b][a];[a][b]overlay' +@end example +@end itemize + +@section selectivecolor + +Adjust cyan, magenta, yellow and black (CMYK) to certain ranges of colors (such +as "reds", "yellows", "greens", "cyans", ...). The adjustment range is defined +by the "purity" of the color (that is, how saturated it already is). + +This filter is similar to the Adobe Photoshop Selective Color tool. + +The filter accepts the following options: + +@table @option +@item correction_method +Select color correction method. + +Available values are: +@table @samp +@item absolute +Specified adjustments are applied "as-is" (added/subtracted to original pixel +component value). +@item relative +Specified adjustments are relative to the original component value. +@end table +Default is @code{absolute}. +@item reds +Adjustments for red pixels (pixels where the red component is the maximum) +@item yellows +Adjustments for yellow pixels (pixels where the blue component is the minimum) +@item greens +Adjustments for green pixels (pixels where the green component is the maximum) +@item cyans +Adjustments for cyan pixels (pixels where the red component is the minimum) +@item blues +Adjustments for blue pixels (pixels where the blue component is the maximum) +@item magentas +Adjustments for magenta pixels (pixels where the green component is the minimum) +@item whites +Adjustments for white pixels (pixels where all components are greater than 128) +@item neutrals +Adjustments for all pixels except pure black and pure white +@item blacks +Adjustments for black pixels (pixels where all components are lesser than 128) +@item psfile +Specify a Photoshop selective color file (@code{.asv}) to import the settings from. +@end table + +All the adjustment settings (@option{reds}, @option{yellows}, ...) accept up to +4 space separated floating point adjustment values in the [-1,1] range, +respectively to adjust the amount of cyan, magenta, yellow and black for the +pixels of its range. + +@subsection Examples + +@itemize +@item +Increase cyan by 50% and reduce yellow by 33% in every green areas, and +increase magenta by 27% in blue areas: +@example +selectivecolor=greens=.5 0 -.33 0:blues=0 .27 +@end example + +@item +Use a Photoshop selective color preset: +@example +selectivecolor=psfile=MySelectiveColorPresets/Misty.asv +@end example +@end itemize + @section separatefields The @code{separatefields} takes a frame-based video input and splits @@ -8519,6 +10886,26 @@ Set the size of the box used to represent one palette color entry. Default is @code{30} (for a @code{30x30} pixel box). @end table +@section shuffleframes + +Reorder and/or duplicate video frames. + +It accepts the following parameters: + +@table @option +@item mapping +Set the destination indexes of input frames. +This is space or '|' separated list of indexes that maps input frames to output +frames. Number of indexes also sets maximal value that each index may have. +@end table + +The first frame has the index 0. The default is to keep the input unchanged. + +Swap second and third frame of every three frames of the input: +@example +ffmpeg -i INPUT -vf "shuffleframes=0 2 1" OUTPUT +@end example + @section shuffleplanes Reorder and/or duplicate video planes. @@ -8548,6 +10935,7 @@ Swap the second and third planes of the input: ffmpeg -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT @end example +@anchor{signalstats} @section signalstats Evaluate various visual metrics that assist in determining issues associated with the digitization of analog video media. @@ -8778,18 +11166,77 @@ in [-30,0] will filter edges. Default value is 0. If a chroma option is not explicitly set, the corresponding luma value is set. -@section stereo3d +@section ssim -Convert between different stereoscopic image formats. +Obtain the SSIM (Structural SImilarity Metric) between two input videos. -The filters accept the following options: +This filter takes in input two input videos, the first input is +considered the "main" source and is passed unchanged to the +output. The second input is used as a "reference" video for computing +the SSIM. -@table @option -@item in -Set stereoscopic image format of input. +Both video inputs must have the same resolution and pixel format for +this filter to work correctly. Also it assumes that both inputs +have the same number of frames, which are compared one by one. -Available values for input image formats are: -@table @samp +The filter stores the calculated SSIM of each frame. + +The description of the accepted parameters follows. + +@table @option +@item stats_file, f +If specified the filter will use the named file to save the SSIM of +each individual frame. When filename equals "-" the data is sent to +standard output. +@end table + +The file printed if @var{stats_file} is selected, contains a sequence of +key/value pairs of the form @var{key}:@var{value} for each compared +couple of frames. + +A description of each shown parameter follows: + +@table @option +@item n +sequential number of the input frame, starting from 1 + +@item Y, U, V, R, G, B +SSIM of the compared frames for the component specified by the suffix. + +@item All +SSIM of the compared frames for the whole frame. + +@item dB +Same as above but in dB representation. +@end table + +For example: +@example +movie=ref_movie.mpg, setpts=PTS-STARTPTS [main]; +[main][ref] ssim="stats_file=stats.log" [out] +@end example + +On this example the input file being processed is compared with the +reference file @file{ref_movie.mpg}. The SSIM of each individual frame +is stored in @file{stats.log}. + +Another example with both psnr and ssim at same time: +@example +ffmpeg -i main.mpg -i ref.mpg -lavfi "ssim;[0:v][1:v]psnr" -f null - +@end example + +@section stereo3d + +Convert between different stereoscopic image formats. + +The filters accept the following options: + +@table @option +@item in +Set stereoscopic image format of input. + +Available values for input image formats are: +@table @samp @item sbsl side by side parallel (left eye left, right eye right) @@ -8824,14 +11271,65 @@ alternating frames (left eye first, right eye second) @item ar alternating frames (right eye first, left eye second) +@item irl +interleaved rows (left eye has top row, right eye starts on next row) + +@item irr +interleaved rows (right eye has top row, left eye starts on next row) + +@item icl +interleaved columns, left eye first + +@item icr +interleaved columns, right eye first + Default value is @samp{sbsl}. @end table @item out Set stereoscopic image format of output. -Available values for output image formats are all the input formats as well as: @table @samp +@item sbsl +side by side parallel (left eye left, right eye right) + +@item sbsr +side by side crosseye (right eye left, left eye right) + +@item sbs2l +side by side parallel with half width resolution +(left eye left, right eye right) + +@item sbs2r +side by side crosseye with half width resolution +(right eye left, left eye right) + +@item abl +above-below (left eye above, right eye below) + +@item abr +above-below (right eye above, left eye below) + +@item ab2l +above-below with half height resolution +(left eye above, right eye below) + +@item ab2r +above-below with half height resolution +(right eye above, left eye below) + +@item al +alternating frames (left eye first, right eye second) + +@item ar +alternating frames (right eye first, left eye second) + +@item irl +interleaved rows (left eye has top row, right eye starts on next row) + +@item irr +interleaved rows (right eye has top row, left eye starts on next row) + @item arbg anaglyph red/blue gray (red filter on left eye, blue filter on right eye) @@ -8888,17 +11386,23 @@ anaglyph yellow/blue colored anaglyph yellow/blue color optimized with the least squares projection of dubois (yellow filter on left eye, blue filter on right eye) -@item irl -interleaved rows (left eye has top row, right eye starts on next row) - -@item irr -interleaved rows (right eye has top row, left eye starts on next row) - @item ml mono output (left eye only) @item mr mono output (right eye only) + +@item chl +checkerboard, left eye first + +@item chr +checkerboard, right eye first + +@item icl +interleaved columns, left eye first + +@item icr +interleaved columns, right eye first @end table Default value is @samp{arcd}. @@ -8914,12 +11418,51 @@ stereo3d=sbsl:aybd @end example @item -Convert input video from above bellow (left eye above, right eye below) to side by side crosseye. +Convert input video from above below (left eye above, right eye below) to side by side crosseye. @example stereo3d=abl:sbsr @end example @end itemize +@section streamselect, astreamselect +Select video or audio streams. + +The filter accepts the following options: + +@table @option +@item inputs +Set number of inputs. Default is 2. + +@item map +Set input indexes to remap to outputs. +@end table + +@subsection Commands + +The @code{streamselect} and @code{astreamselect} filter supports the following +commands: + +@table @option +@item map +Set input indexes to remap to outputs. +@end table + +@subsection Examples + +@itemize +@item +Select first 5 seconds 1st stream and rest of time 2nd stream: +@example +sendcmd='5.0 streamselect map 1',streamselect=inputs=2:map=0 +@end example + +@item +Same as above, but for audio: +@example +asendcmd='5.0 astreamselect map 1',astreamselect=inputs=2:map=0 +@end example +@end itemize + @anchor{spp} @section spp @@ -8980,6 +11523,10 @@ was composed. For the syntax of this option, check the Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to correctly scale the fonts if the aspect ratio has been changed. +@item fontsdir +Set a directory path containing fonts that can be used by the filter. +These fonts will be used in addition to whatever the font provider uses. + @item charenc Set subtitles input character encoding. @code{subtitles} filter only. Only useful if not UTF-8. @@ -9029,6 +11576,60 @@ Interpolate) pixel art scaling algorithm. Useful for enlarging pixel art images without reducing sharpness. +@section swaprect + +Swap two rectangular objects in video. + +This filter accepts the following options: + +@table @option +@item w +Set object width. + +@item h +Set object height. + +@item x1 +Set 1st rect x coordinate. + +@item y1 +Set 1st rect y coordinate. + +@item x2 +Set 2nd rect x coordinate. + +@item y2 +Set 2nd rect y coordinate. + +All expressions are evaluated once for each frame. +@end table + +The all options are expressions containing the following constants: + +@table @option +@item w +@item h +The input width and height. + +@item a +same as @var{w} / @var{h} + +@item sar +input sample aspect ratio + +@item dar +input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar} + +@item n +The number of the input frame, starting from 0. + +@item t +The timestamp expressed in seconds. It's NAN if the input timestamp is unknown. + +@item pos +the position in the file of the input frame, NAN if unknown +@end table + @section swapuv Swap U & V plane. @@ -9333,6 +11934,29 @@ Output: 11111 11111 22222 22222 33333 33333 44444 @end example +@item mergex2, 7 +Move odd frames into the upper field, even into the lower field, +generating a double height frame at same frame rate. +@example + ------> time +Input: +Frame 1 Frame 2 Frame 3 Frame 4 + +11111 22222 33333 44444 +11111 22222 33333 44444 +11111 22222 33333 44444 +11111 22222 33333 44444 + +Output: +11111 33333 33333 55555 +22222 22222 44444 44444 +11111 33333 33333 55555 +22222 22222 44444 44444 +11111 33333 33333 55555 +22222 22222 44444 44444 +11111 33333 33333 55555 +22222 22222 44444 44444 +@end example @end table @@ -9599,6 +12223,69 @@ Force a constant quantization parameter. If not set, the filter will use the QP from the video stream (if available). @end table +@section vectorscope + +Display 2 color component values in the two dimensional graph (which is called +a vectorscope). + +This filter accepts the following options: + +@table @option +@item mode, m +Set vectorscope mode. + +It accepts the following values: +@table @samp +@item gray +Gray values are displayed on graph, higher brightness means more pixels have +same component color value on location in graph. This is the default mode. + +@item color +Gray values are displayed on graph. Surrounding pixels values which are not +present in video frame are drawn in gradient of 2 color components which are +set by option @code{x} and @code{y}. + +@item color2 +Actual color components values present in video frame are displayed on graph. + +@item color3 +Similar as color2 but higher frequency of same values @code{x} and @code{y} +on graph increases value of another color component, which is luminance by +default values of @code{x} and @code{y}. + +@item color4 +Actual colors present in video frame are displayed on graph. If two different +colors map to same position on graph then color with higher value of component +not present in graph is picked. +@end table + +@item x +Set which color component will be represented on X-axis. Default is @code{1}. + +@item y +Set which color component will be represented on Y-axis. Default is @code{2}. + +@item intensity, i +Set intensity, used by modes: gray, color and color3 for increasing brightness +of color component which represents frequency of (X, Y) location in graph. + +@item envelope, e +@table @samp +@item none +No envelope, this is default. + +@item instant +Instant envelope, even darkest single pixel will be clearly highlighted. + +@item peak +Hold maximum and minimum values presented in graph over time. This way you +can still spot out of range values without constantly looking at vectorscope. + +@item peak+instant +Peak and instant envelope combined together. +@end table +@end table + @anchor{vidstabdetect} @section vidstabdetect @@ -9952,6 +12639,25 @@ vignette='PI/4+random(1)*PI/50':eval=frame @end itemize +@section vstack +Stack input videos vertically. + +All streams must be of same pixel format and of same width. + +Note that this filter is faster than using @ref{overlay} and @ref{pad} filter +to create same output. + +The filter accept the following option: + +@table @option +@item inputs +Set number of input streams. Default is 2. + +@item shortest +If set to 1, force the output to terminate when the shortest input +terminates. Default value is 0. +@end table + @section w3fdif Deinterlace the input video ("w3fdif" stands for "Weston 3 Field @@ -9991,27 +12697,124 @@ Only deinterlace frames marked as interlaced. Default value is @samp{all}. @end table -@section xbr -Apply the xBR high-quality magnification filter which is designed for pixel -art. It follows a set of edge-detection rules, see -@url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}. +@section waveform +Video waveform monitor. -It accepts the following option: +The waveform monitor plots color component intensity. By default luminance +only. Each column of the waveform corresponds to a column of pixels in the +source video. + +It accepts the following options: @table @option -@item n -Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for -@code{3xBR} and @code{4} for @code{4xBR}. -Default is @code{3}. -@end table +@item mode, m +Can be either @code{row}, or @code{column}. Default is @code{column}. +In row mode, the graph on the left side represents color component value 0 and +the right side represents value = 255. In column mode, the top side represents +color component value = 0 and bottom side represents value = 255. + +@item intensity, i +Set intensity. Smaller values are useful to find out how many values of the same +luminance are distributed across input rows/columns. +Default value is @code{0.04}. Allowed range is [0, 1]. + +@item mirror, r +Set mirroring mode. @code{0} means unmirrored, @code{1} means mirrored. +In mirrored mode, higher values will be represented on the left +side for @code{row} mode and at the top for @code{column} mode. Default is +@code{1} (mirrored). -@anchor{yadif} -@section yadif +@item display, d +Set display mode. +It accepts the following values: +@table @samp +@item overlay +Presents information identical to that in the @code{parade}, except +that the graphs representing color components are superimposed directly +over one another. -Deinterlace the input video ("yadif" means "yet another deinterlacing -filter"). +This display mode makes it easier to spot relative differences or similarities +in overlapping areas of the color components that are supposed to be identical, +such as neutral whites, grays, or blacks. -It accepts the following parameters: +@item parade +Display separate graph for the color components side by side in +@code{row} mode or one below the other in @code{column} mode. + +Using this display mode makes it easy to spot color casts in the highlights +and shadows of an image, by comparing the contours of the top and the bottom +graphs of each waveform. Since whites, grays, and blacks are characterized +by exactly equal amounts of red, green, and blue, neutral areas of the picture +should display three waveforms of roughly equal width/height. If not, the +correction is easy to perform by making level adjustments the three waveforms. +@end table +Default is @code{parade}. + +@item components, c +Set which color components to display. Default is 1, which means only luminance +or red color component if input is in RGB colorspace. If is set for example to +7 it will display all 3 (if) available color components. + +@item envelope, e +@table @samp +@item none +No envelope, this is default. + +@item instant +Instant envelope, minimum and maximum values presented in graph will be easily +visible even with small @code{step} value. + +@item peak +Hold minimum and maximum values presented in graph across time. This way you +can still spot out of range values without constantly looking at waveforms. + +@item peak+instant +Peak and instant envelope combined together. +@end table + +@item filter, f +@table @samp +@item lowpass +No filtering, this is default. + +@item flat +Luma and chroma combined together. + +@item aflat +Similar as above, but shows difference between blue and red chroma. + +@item chroma +Displays only chroma. + +@item achroma +Similar as above, but shows difference between blue and red chroma. + +@item color +Displays actual color value on waveform. +@end table +@end table + +@section xbr +Apply the xBR high-quality magnification filter which is designed for pixel +art. It follows a set of edge-detection rules, see +@url{http://www.libretro.com/forums/viewtopic.php?f=6&t=134}. + +It accepts the following option: + +@table @option +@item n +Set the scaling dimension: @code{2} for @code{2xBR}, @code{3} for +@code{3xBR} and @code{4} for @code{4xBR}. +Default is @code{3}. +@end table + +@anchor{yadif} +@section yadif + +Deinterlace the input video ("yadif" means "yet another deinterlacing +filter"). + +It accepts the following parameters: @table @option @@ -10084,6 +12887,9 @@ single input image. @item s Set the output image size, default is 'hd720'. + +@item fps +Set the output frame rate, default is '25'. @end table Each expression can contain the following constants: @@ -10149,8 +12955,242 @@ Zoom-in up to 1.5 and pan at same time to some spot near center of picture: @example zoompan=z='min(zoom+0.0015,1.5)':d=700:x='if(gte(zoom,1.5),x,x+1/a)':y='if(gte(zoom,1.5),y,y+1)':s=640x360 @end example + +@item +Zoom-in up to 1.5 and pan always at center of picture: +@example +zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)' +@end example @end itemize +@section zscale +Scale (resize) the input video, using the z.lib library: +https://github.com/sekrit-twc/zimg. + +The zscale filter forces the output display aspect ratio to be the same +as the input, by changing the output sample aspect ratio. + +If the input image format is different from the format requested by +the next filter, the zscale filter will convert the input to the +requested format. + +@subsection Options +The filter accepts the following options. + +@table @option +@item width, w +@item height, h +Set the output video dimension expression. Default value is the input +dimension. + +If the @var{width} or @var{w} is 0, the input width is used for the output. +If the @var{height} or @var{h} is 0, the input height is used for the output. + +If one of the values is -1, the zscale filter will use a value that +maintains the aspect ratio of the input image, calculated from the +other specified dimension. If both of them are -1, the input size is +used + +If one of the values is -n with n > 1, the zscale filter will also use a value +that maintains the aspect ratio of the input image, calculated from the other +specified dimension. After that it will, however, make sure that the calculated +dimension is divisible by n and adjust the value if necessary. + +See below for the list of accepted constants for use in the dimension +expression. + +@item size, s +Set the video size. For the syntax of this option, check the +@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. + +@item dither, d +Set the dither type. + +Possible values are: +@table @var +@item none +@item ordered +@item random +@item error_diffusion +@end table + +Default is none. + +@item filter, f +Set the resize filter type. + +Possible values are: +@table @var +@item point +@item bilinear +@item bicubic +@item spline16 +@item spline36 +@item lanczos +@end table + +Default is bilinear. + +@item range, r +Set the color range. + +Possible values are: +@table @var +@item input +@item limited +@item full +@end table + +Default is same as input. + +@item primaries, p +Set the color primaries. + +Possible values are: +@table @var +@item input +@item 709 +@item unspecified +@item 170m +@item 240m +@item 2020 +@end table + +Default is same as input. + +@item transfer, t +Set the transfer characteristics. + +Possible values are: +@table @var +@item input +@item 709 +@item unspecified +@item 601 +@item linear +@item 2020_10 +@item 2020_12 +@end table + +Default is same as input. + +@item matrix, m +Set the colorspace matrix. + +Possible value are: +@table @var +@item input +@item 709 +@item unspecified +@item 470bg +@item 170m +@item 2020_ncl +@item 2020_cl +@end table + +Default is same as input. + +@item rangein, rin +Set the input color range. + +Possible values are: +@table @var +@item input +@item limited +@item full +@end table + +Default is same as input. + +@item primariesin, pin +Set the input color primaries. + +Possible values are: +@table @var +@item input +@item 709 +@item unspecified +@item 170m +@item 240m +@item 2020 +@end table + +Default is same as input. + +@item transferin, tin +Set the input transfer characteristics. + +Possible values are: +@table @var +@item input +@item 709 +@item unspecified +@item 601 +@item linear +@item 2020_10 +@item 2020_12 +@end table + +Default is same as input. + +@item matrixin, min +Set the input colorspace matrix. + +Possible value are: +@table @var +@item input +@item 709 +@item unspecified +@item 470bg +@item 170m +@item 2020_ncl +@item 2020_cl +@end table +@end table + +The values of the @option{w} and @option{h} options are expressions +containing the following constants: + +@table @var +@item in_w +@item in_h +The input width and height + +@item iw +@item ih +These are the same as @var{in_w} and @var{in_h}. + +@item out_w +@item out_h +The output (scaled) width and height + +@item ow +@item oh +These are the same as @var{out_w} and @var{out_h} + +@item a +The same as @var{iw} / @var{ih} + +@item sar +input sample aspect ratio + +@item dar +The input display aspect ratio. Calculated from @code{(iw / ih) * sar}. + +@item hsub +@item vsub +horizontal and vertical input chroma subsample values. For example for the +pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. + +@item ohsub +@item ovsub +horizontal and vertical output chroma subsample values. For example for the +pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. +@end table + +@table @option +@end table + @c man end VIDEO FILTERS @chapter Video Sources @@ -10624,6 +13664,8 @@ ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_c @end example @end itemize +@anchor{allrgb} +@anchor{allyuv} @anchor{color} @anchor{haldclutsrc} @anchor{nullsrc} @@ -10631,7 +13673,11 @@ ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_c @anchor{smptebars} @anchor{smptehdbars} @anchor{testsrc} -@section color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc +@section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc + +The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors. + +The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors. The @code{color} source provides an uniformly colored input. @@ -10770,62 +13816,193 @@ tools. Below is a description of the currently available multimedia filters. -@section avectorscope - -Convert input audio to a video output, representing the audio vector -scope. +@section ahistogram -The filter is used to measure the difference between channels of stereo -audio stream. A monoaural signal, consisting of identical left and right -signal, results in straight vertical line. Any stereo separation is visible -as a deviation from this line, creating a Lissajous figure. -If the straight (or deviation from it) but horizontal line appears this -indicates that the left and right channels are out of phase. +Convert input audio to a video output, displaying the volume histogram. The filter accepts the following options: @table @option -@item mode, m -Set the vectorscope mode. +@item dmode +Specify how histogram is calculated. -Available values are: +It accepts the following values: @table @samp -@item lissajous -Lissajous rotated by 45 degrees. - -@item lissajous_xy -Same as above but not rotated. +@item single +Use single histogram for all channels. +@item separate +Use separate histogram for each channel. @end table +Default is @code{single}. -Default value is @samp{lissajous}. +@item rate, r +Set frame rate, expressed as number of frames per second. Default +value is "25". @item size, s -Set the video size for the output. For the syntax of this option, check the +Specify the video size for the output. For the syntax of this option, check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. -Default value is @code{400x400}. - -@item rate, r -Set the output frame rate. Default value is @code{25}. - -@item rc -@item gc -@item bc -Specify the red, green and blue contrast. Default values are @code{40}, @code{160} and @code{80}. -Allowed range is @code{[0, 255]}. +Default value is @code{hd720}. -@item rf -@item gf -@item bf -Specify the red, green and blue fade. Default values are @code{15}, @code{10} and @code{5}. -Allowed range is @code{[0, 255]}. +@item scale +Set display scale. -@item zoom -Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}. +It accepts the following values: +@table @samp +@item log +logarithmic +@item sqrt +square root +@item cbrt +cubic root +@item lin +linear +@item rlog +reverse logarithmic @end table +Default is @code{log}. -@subsection Examples +@item ascale +Set amplitude scale. -@itemize +It accepts the following values: +@table @samp +@item log +logarithmic +@item lin +linear +@end table +Default is @code{log}. + +@item acount +Set how much frames to accumulate in histogram. +Defauls is 1. Setting this to -1 accumulates all frames. + +@item rheight +Set histogram ratio of window height. + +@item slide +Set sonogram sliding. + +It accepts the following values: +@table @samp +@item replace +replace old rows with new ones. +@item scroll +scroll from top to bottom. +@end table +Default is @code{replace}. +@end table + +@section aphasemeter + +Convert input audio to a video output, displaying the audio phase. + +The filter accepts the following options: + +@table @option +@item rate, r +Set the output frame rate. Default value is @code{25}. + +@item size, s +Set the video size for the output. For the syntax of this option, check the +@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. +Default value is @code{800x400}. + +@item rc +@item gc +@item bc +Specify the red, green, blue contrast. Default values are @code{2}, +@code{7} and @code{1}. +Allowed range is @code{[0, 255]}. + +@item mpc +Set color which will be used for drawing median phase. If color is +@code{none} which is default, no median phase value will be drawn. +@end table + +The filter also exports the frame metadata @code{lavfi.aphasemeter.phase} which +represents mean phase of current audio frame. Value is in range @code{[-1, 1]}. +The @code{-1} means left and right channels are completely out of phase and +@code{1} means channels are in phase. + +@section avectorscope + +Convert input audio to a video output, representing the audio vector +scope. + +The filter is used to measure the difference between channels of stereo +audio stream. A monoaural signal, consisting of identical left and right +signal, results in straight vertical line. Any stereo separation is visible +as a deviation from this line, creating a Lissajous figure. +If the straight (or deviation from it) but horizontal line appears this +indicates that the left and right channels are out of phase. + +The filter accepts the following options: + +@table @option +@item mode, m +Set the vectorscope mode. + +Available values are: +@table @samp +@item lissajous +Lissajous rotated by 45 degrees. + +@item lissajous_xy +Same as above but not rotated. + +@item polar +Shape resembling half of circle. +@end table + +Default value is @samp{lissajous}. + +@item size, s +Set the video size for the output. For the syntax of this option, check the +@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. +Default value is @code{400x400}. + +@item rate, r +Set the output frame rate. Default value is @code{25}. + +@item rc +@item gc +@item bc +@item ac +Specify the red, green, blue and alpha contrast. Default values are @code{40}, +@code{160}, @code{80} and @code{255}. +Allowed range is @code{[0, 255]}. + +@item rf +@item gf +@item bf +@item af +Specify the red, green, blue and alpha fade. Default values are @code{15}, +@code{10}, @code{5} and @code{5}. +Allowed range is @code{[0, 255]}. + +@item zoom +Set the zoom factor. Default value is @code{1}. Allowed range is @code{[1, 10]}. + +@item draw +Set the vectorscope drawing mode. + +Available values are: +@table @samp +@item dot +Draw dot for each sample. + +@item line +Draw line between previous and current sample. +@end table + +Default value is @samp{dot}. +@end table + +@subsection Examples + +@itemize @item Complete example using @command{ffplay}: @example @@ -10914,6 +14091,7 @@ do not have exactly the same duration in the first file. @end itemize +@anchor{ebur128} @section ebur128 EBU R128 scanner filter. This filter takes an audio stream as input and outputs @@ -10994,6 +14172,15 @@ stream for better peak accuracy. It logs a message for true-peak. This mode requires a build with @code{libswresample}. @end table +@item dualmono +Treat mono input files as "dual mono". If a mono file is intended for playback +on a stereo system, its EBU R128 measurement will be perceptually incorrect. +If set to @code{true}, this option will compensate for this effect. +Multi-channel input files are not affected by this option. + +@item panlaw +Set a specific pan law to be used for the measurement of dual mono files. +This parameter is optional, and has a default value of -3.01dB. @end table @subsection Examples @@ -11099,6 +14286,22 @@ following one, the permission might not be received as expected in that following filter. Inserting a @ref{format} or @ref{aformat} filter before the perms/aperms filter can avoid this problem. +@section realtime, arealtime + +Slow down filtering to match real time approximatively. + +These filters will pause the filtering for a variable amount of time to +match the output rate with the input timestamps. +They are similar to the @option{re} option to @code{ffmpeg}. + +They accept the following options: + +@table @option +@item limit +Time limit for the pauses. Any pause longer than that will be considered +a timestamp discontinuity and reset the timer. Default is 2 seconds. +@end table + @section select, aselect Select frames to pass in output. @@ -11207,6 +14410,25 @@ value between 0 and 1 to indicate a new scene; a low value reflects a low probability for the current frame to introduce a new scene, while a higher value means the current frame is more likely to be one (see the example below) +@item concatdec_select +The concat demuxer can select only part of a concat input file by setting an +inpoint and an outpoint, but the output packets may not be entirely contained +in the selected interval. By using this variable, it is possible to skip frames +generated by the concat demuxer which are not exactly contained in the selected +interval. + +This works by comparing the frame pts against the @var{lavf.concat.start_time} +and the @var{lavf.concat.duration} packet metadata values which are also +present in the decoded frames. + +The @var{concatdec_select} variable is -1 if the frame pts is at least +start_time and either the duration metadata is missing or the frame pts is less +than start_time + duration, 0 otherwise, and NaN if the start_time metadata is +missing. + +That basically means that an input frame is selected if its pts is within the +interval set by the concat demuxer. + @end table The default value of the select expression is "1". @@ -11281,6 +14503,13 @@ Send even and odd frames to separate outputs, and compose them: @example select=n=2:e='mod(n, 2)+1' [odd][even]; [odd] pad=h=2*ih [tmp]; [tmp][even] overlay=y=h @end example + +@item +Select useful frames from an ffconcat file which is using inpoints and +outpoints but where the source files are not intra frame only. +@example +ffmpeg -copyts -vsync 0 -segment_time_metadata 1 -i input.ffconcat -vf select=concatdec_select -af aselect=concatdec_select output.avi +@end example @end itemize @section sendcmd, asendcmd @@ -11601,21 +14830,48 @@ settb=AVTB @end itemize @section showcqt -Convert input audio to a video output representing -frequency spectrum logarithmically (using constant Q transform with -Brown-Puckette algorithm), with musical tone scale, from E0 to D#10 (10 octaves). +Convert input audio to a video output representing frequency spectrum +logarithmically using Brown-Puckette constant Q transform algorithm with +direct frequency domain coefficient calculation (but the transform itself +is not really constant Q, instead the Q factor is actually variable/clamped), +with musical tone scale, from E0 to D#10. The filter accepts the following options: @table @option -@item volume -Specify transform volume (multiplier) expression. The expression can contain -variables: +@item size, s +Specify the video size for the output. It must be even. For the syntax of this option, +check the @ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. +Default value is @code{1920x1080}. + +@item fps, rate, r +Set the output frame rate. Default value is @code{25}. + +@item bar_h +Set the bargraph height. It must be even. Default value is @code{-1} which +computes the bargraph height automatically. + +@item axis_h +Set the axis height. It must be even. Default value is @code{-1} which computes +the axis height automatically. + +@item sono_h +Set the sonogram height. It must be even. Default value is @code{-1} which +computes the sonogram height automatically. + +@item fullhd +Set the fullhd resolution. This option is deprecated, use @var{size}, @var{s} +instead. Default value is @code{1}. + +@item sono_v, volume +Specify the sonogram volume expression. It can contain variables: @table @option +@item bar_v +the @var{bar_v} evaluated expression @item frequency, freq, f -the frequency where transform is evaluated +the frequency where it is evaluated @item timeclamp, tc -value of timeclamp option +the value of @var{timeclamp} option @end table and functions: @table @option @@ -11624,75 +14880,112 @@ A-weighting of equal loudness @item b_weighting(f) B-weighting of equal loudness @item c_weighting(f) -C-weighting of equal loudness +C-weighting of equal loudness. @end table Default value is @code{16}. -@item tlength -Specify transform length expression. The expression can contain variables: +@item bar_v, volume2 +Specify the bargraph volume expression. It can contain variables: @table @option +@item sono_v +the @var{sono_v} evaluated expression @item frequency, freq, f -the frequency where transform is evaluated +the frequency where it is evaluated @item timeclamp, tc -value of timeclamp option +the value of @var{timeclamp} option +@end table +and functions: +@table @option +@item a_weighting(f) +A-weighting of equal loudness +@item b_weighting(f) +B-weighting of equal loudness +@item c_weighting(f) +C-weighting of equal loudness. @end table -Default value is @code{384/f*tc/(384/f+tc)}. +Default value is @code{sono_v}. -@item timeclamp +@item sono_g, gamma +Specify the sonogram gamma. Lower gamma makes the spectrum more contrast, +higher gamma makes the spectrum having more range. Default value is @code{3}. +Acceptable range is @code{[1, 7]}. + +@item bar_g, gamma2 +Specify the bargraph gamma. Default value is @code{1}. Acceptable range is +@code{[1, 7]}. + +@item timeclamp, tc Specify the transform timeclamp. At low frequency, there is trade-off between accuracy in time domain and frequency domain. If timeclamp is lower, event in time domain is represented more accurately (such as fast bass drum), otherwise event in frequency domain is represented more accurately -(such as bass guitar). Acceptable value is [0.1, 1.0]. Default value is @code{0.17}. +(such as bass guitar). Acceptable range is @code{[0.1, 1]}. Default value is @code{0.17}. + +@item basefreq +Specify the transform base frequency. Default value is @code{20.01523126408007475}, +which is frequency 50 cents below E0. Acceptable range is @code{[10, 100000]}. + +@item endfreq +Specify the transform end frequency. Default value is @code{20495.59681441799654}, +which is frequency 50 cents above D#10. Acceptable range is @code{[10, 100000]}. @item coeffclamp -Specify the transform coeffclamp. If coeffclamp is lower, transform is -more accurate, otherwise transform is faster. Acceptable value is [0.1, 10.0]. -Default value is @code{1.0}. +This option is deprecated and ignored. -@item gamma -Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma -makes the spectrum having more range. Acceptable value is [1.0, 7.0]. -Default value is @code{3.0}. +@item tlength +Specify the transform length in time domain. Use this option to control accuracy +trade-off between time domain and frequency domain at every frequency sample. +It can contain variables: +@table @option +@item frequency, freq, f +the frequency where it is evaluated +@item timeclamp, tc +the value of @var{timeclamp} option. +@end table +Default value is @code{384*tc/(384+tc*f)}. + +@item count +Specify the transform count for every video frame. Default value is @code{6}. +Acceptable range is @code{[1, 30]}. -@item gamma2 -Specify gamma of bargraph. Acceptable value is [1.0, 7.0]. -Default value is @code{1.0}. +@item fcount +Specify the transform count for every single pixel. Default value is @code{0}, +which makes it computed automatically. Acceptable range is @code{[0, 10]}. @item fontfile -Specify font file for use with freetype. If not specified, use embedded font. +Specify font file for use with freetype to draw the axis. If not specified, +use embedded font. Note that drawing with font file or embedded font is not +implemented with custom @var{basefreq} and @var{endfreq}, use @var{axisfile} +option instead. @item fontcolor Specify font color expression. This is arithmetic expression that should return -integer value 0xRRGGBB. The expression can contain variables: +integer value 0xRRGGBB. It can contain variables: @table @option @item frequency, freq, f -the frequency where transform is evaluated +the frequency where it is evaluated @item timeclamp, tc -value of timeclamp option +the value of @var{timeclamp} option @end table and functions: @table @option @item midi(f) midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69) @item r(x), g(x), b(x) -red, green, and blue value of intensity x +red, green, and blue value of intensity x. @end table Default value is @code{st(0, (midi(f)-59.5)/12); st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0)); -r(1-ld(1)) + b(ld(1))} - -@item fullhd -If set to 1 (the default), the video size is 1920x1080 (full HD), -if set to 0, the video size is 960x540. Use this option to make CPU usage lower. +r(1-ld(1)) + b(ld(1))}. -@item fps -Specify video fps. Default value is @code{25}. +@item axisfile +Specify image file to draw the axis. This option override @var{fontfile} and +@var{fontcolor} option. -@item count -Specify number of transform per frame, so there are fps*count transforms -per second. Note that audio data rate must be divisible by fps*count. -Default value is @code{6}. +@item axis, text +Enable/disable drawing text to the axis. If it is set to @code{0}, drawing to +the axis is disabled, ignoring @var{fontfile} and @var{axisfile} option. +Default value is @code{1}. @end table @@ -11712,9 +15005,15 @@ ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fps=30:count=5 [out @end example @item -Playing at 960x540 and lower CPU usage: +Playing at 1280x720: +@example +ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=s=1280x720:count=4 [out0]' +@end example + +@item +Disable sonogram display: @example -ffplay -f lavfi 'amovie=a.mp3, asplit [a][out1]; [a] showcqt=fullhd=0:count=3 [out0]' +sono_h=0 @end example @item @@ -11725,38 +15024,173 @@ ffplay -f lavfi 'aevalsrc=0.1*sin(2*PI*55*t)+0.1*sin(4*PI*55*t)+0.1*sin(6*PI*55* @end example @item -Same as above, but with more accuracy in frequency domain (and slower): +Same as above, but with more accuracy in frequency domain: @example ffplay -f lavfi 'aevalsrc=0.1*sin(2*PI*55*t)+0.1*sin(4*PI*55*t)+0.1*sin(6*PI*55*t)+0.1*sin(8*PI*55*t), asplit[a][out1]; [a] showcqt=timeclamp=0.5 [out0]' @end example @item -B-weighting of equal loudness +Custom volume: @example -volume=16*b_weighting(f) +bar_v=10:sono_v=bar_v*a_weighting(f) @end example @item -Lower Q factor +Custom gamma, now spectrum is linear to the amplitude. @example -tlength=100/f*tc/(100/f+tc) +bar_g=2:sono_g=2 @end example @item -Custom fontcolor, C-note is colored green, others are colored blue +Custom tlength equation: @example -fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))' +tc=0.33:tlength='st(0,0.17); 384*tc / (384 / ld(0) + tc*f /(1-ld(0))) + 384*tc / (tc*f / ld(0) + 384 /(1-ld(0)))' @end example @item -Custom gamma, now spectrum is linear to the amplitude. +Custom fontcolor and fontfile, C-note is colored green, others are colored blue: @example -gamma=2:gamma2=2 +fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))':fontfile=myfont.ttf @end example +@item +Custom frequency range with custom axis using image file: +@example +axisfile=myaxis.png:basefreq=40:endfreq=10000 +@end example @end itemize +@section showfreqs + +Convert input audio to video output representing the audio power spectrum. +Audio amplitude is on Y-axis while frequency is on X-axis. + +The filter accepts the following options: + +@table @option +@item size, s +Specify size of video. For the syntax of this option, check the +@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. +Default is @code{1024x512}. + +@item mode +Set display mode. +This set how each frequency bin will be represented. + +It accepts the following values: +@table @samp +@item line +@item bar +@item dot +@end table +Default is @code{bar}. + +@item ascale +Set amplitude scale. + +It accepts the following values: +@table @samp +@item lin +Linear scale. + +@item sqrt +Square root scale. + +@item cbrt +Cubic root scale. + +@item log +Logarithmic scale. +@end table +Default is @code{log}. + +@item fscale +Set frequency scale. + +It accepts the following values: +@table @samp +@item lin +Linear scale. + +@item log +Logarithmic scale. + +@item rlog +Reverse logarithmic scale. +@end table +Default is @code{lin}. + +@item win_size +Set window size. + +It accepts the following values: +@table @samp +@item w16 +@item w32 +@item w64 +@item w128 +@item w256 +@item w512 +@item w1024 +@item w2048 +@item w4096 +@item w8192 +@item w16384 +@item w32768 +@item w65536 +@end table +Default is @code{w2048} + +@item win_func +Set windowing function. + +It accepts the following values: +@table @samp +@item rect +@item bartlett +@item hanning +@item hamming +@item blackman +@item welch +@item flattop +@item bharris +@item bnuttall +@item bhann +@item sine +@item nuttall +@item lanczos +@item gauss +@item tukey +@end table +Default is @code{hanning}. + +@item overlap +Set window overlap. In range @code{[0, 1]}. Default is @code{1}, +which means optimal overlap for selected window function will be picked. + +@item averaging +Set time averaging. Setting this to 0 will display current maximal peaks. +Default is @code{1}, which means time averaging is disabled. + +@item colors +Specify list of colors separated by space or by '|' which will be used to +draw channel frequencies. Unrecognized or missing colors will be replaced +by white color. + +@item cmode +Set channel display mode. + +It accepts the following values: +@table @samp +@item combined +@item separate +@end table +Default is @code{combined}. + +@end table + +@anchor{showspectrum} @section showspectrum Convert input audio to a video output, representing the audio frequency @@ -11779,6 +15213,8 @@ It accepts the following values: the samples start again on the left when they reach the right @item scroll the samples scroll from right to left +@item rscroll +the samples scroll from left to right @item fullframe frames are only produced when the samples reach the right @end table @@ -11806,7 +15242,21 @@ It accepts the following values: @item channel each channel is displayed in a separate color @item intensity -each channel is is displayed using the same color scheme +each channel is displayed using the same color scheme +@item rainbow +each channel is displayed using the rainbow color scheme +@item moreland +each channel is displayed using the moreland color scheme +@item nebulae +each channel is displayed using the nebulae color scheme +@item fire +each channel is displayed using the fire color scheme +@item fiery +each channel is displayed using the fiery color scheme +@item fruit +each channel is displayed using the fruit color scheme +@item cool +each channel is displayed using the cool color scheme @end table Default value is @samp{channel}. @@ -11822,6 +15272,10 @@ linear square root, default @item cbrt cubic root +@item 4thrt +4th root +@item 5thrt +5th root @item log logarithmic @end table @@ -11839,17 +15293,41 @@ Set window function. It accepts the following values: @table @samp -@item none -No samples pre-processing (do not expect this to be faster) +@item rect +@item bartlett @item hann -Hann window +@item hanning @item hamming -Hamming window @item blackman -Blackman window +@item welch +@item flattop +@item bharris +@item bnuttall +@item bhann +@item sine +@item nuttall +@item lanczos +@item gauss +@item tukey @end table Default value is @code{hann}. + +@item orientation +Set orientation of time vs frequency axis. Can be @code{vertical} or +@code{horizontal}. Default is @code{vertical}. + +@item overlap +Set ratio of overlap window. Default value is @code{0}. +When value is @code{1} overlap is set to recommended size for specific +window function currently used. + +@item gain +Set scale gain for calculating intensity color values. +Default value is @code{1}. + +@item data +Set which data to display. Can be @code{magnitude}, default or @code{phase}. @end table The usage is very similar to the showwaves filter; see the examples in that @@ -11872,6 +15350,172 @@ ffplay -f lavfi 'amovie=input.mp3, asplit [a][out1]; @end example @end itemize +@section showspectrumpic + +Convert input audio to a single video frame, representing the audio frequency +spectrum. + +The filter accepts the following options: + +@table @option +@item size, s +Specify the video size for the output. For the syntax of this option, check the +@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. +Default value is @code{4096x2048}. + +@item mode +Specify display mode. + +It accepts the following values: +@table @samp +@item combined +all channels are displayed in the same row +@item separate +all channels are displayed in separate rows +@end table +Default value is @samp{combined}. + +@item color +Specify display color mode. + +It accepts the following values: +@table @samp +@item channel +each channel is displayed in a separate color +@item intensity +each channel is displayed using the same color scheme +@item rainbow +each channel is displayed using the rainbow color scheme +@item moreland +each channel is displayed using the moreland color scheme +@item nebulae +each channel is displayed using the nebulae color scheme +@item fire +each channel is displayed using the fire color scheme +@item fiery +each channel is displayed using the fiery color scheme +@item fruit +each channel is displayed using the fruit color scheme +@item cool +each channel is displayed using the cool color scheme +@end table +Default value is @samp{intensity}. + +@item scale +Specify scale used for calculating intensity color values. + +It accepts the following values: +@table @samp +@item lin +linear +@item sqrt +square root, default +@item cbrt +cubic root +@item 4thrt +4th root +@item 5thrt +5th root +@item log +logarithmic +@end table +Default value is @samp{log}. + +@item saturation +Set saturation modifier for displayed colors. Negative values provide +alternative color scheme. @code{0} is no saturation at all. +Saturation must be in [-10.0, 10.0] range. +Default value is @code{1}. + +@item win_func +Set window function. + +It accepts the following values: +@table @samp +@item rect +@item bartlett +@item hann +@item hanning +@item hamming +@item blackman +@item welch +@item flattop +@item bharris +@item bnuttall +@item bhann +@item sine +@item nuttall +@item lanczos +@item gauss +@item tukey +@end table +Default value is @code{hann}. + +@item orientation +Set orientation of time vs frequency axis. Can be @code{vertical} or +@code{horizontal}. Default is @code{vertical}. + +@item gain +Set scale gain for calculating intensity color values. +Default value is @code{1}. + +@item legend +Draw time and frequency axes and legends. Default is enabled. +@end table + +@subsection Examples + +@itemize +@item +Extract an audio spectrogram of a whole audio track +in a 1024x1024 picture using @command{ffmpeg}: +@example +ffmpeg -i audio.flac -lavfi showspectrumpic=s=1024x1024 spectrogram.png +@end example +@end itemize + +@section showvolume + +Convert input audio volume to a video output. + +The filter accepts the following options: + +@table @option +@item rate, r +Set video rate. + +@item b +Set border width, allowed range is [0, 5]. Default is 1. + +@item w +Set channel width, allowed range is [80, 1080]. Default is 400. + +@item h +Set channel height, allowed range is [1, 100]. Default is 20. + +@item f +Set fade, allowed range is [0.001, 1]. Default is 0.95. + +@item c +Set volume color expression. + +The expression can use the following variables: + +@table @option +@item VOLUME +Current max volume of channel in dB. + +@item CHANNEL +Current channel number, starting from 0. +@end table + +@item t +If set, displays channel names. Default is enabled. + +@item v +If set, displays volume values. Default is enabled. +@end table + @section showwaves Convert input audio to a video output, representing the samples waves. @@ -11917,6 +15561,13 @@ option @var{n}. Default value is "25". @item split_channels Set if channels should be drawn separately or overlap. Default value is 0. +@item colors +Set colors separated by '|' which are going to be used for drawing of each channel. + +@item scale +Set amplitude scale. Can be linear @code{lin} or logarithmic @code{log}. +Default is linear. + @end table @subsection Examples @@ -11951,6 +15602,13 @@ Default value is @code{600x240}. @item split_channels Set if channels should be drawn separately or overlap. Default value is 0. + +@item colors +Set colors separated by '|' which are going to be used for drawing of each channel. + +@item scale +Set amplitude scale. Can be linear @code{lin} or logarithmic @code{log}. +Default is linear. @end table @subsection Examples @@ -11962,6 +15620,76 @@ in a 1024x800 picture using @command{ffmpeg}: @example ffmpeg -i audio.flac -lavfi showwavespic=split_channels=1:s=1024x800 waveform.png @end example + +@item +Colorize the waveform with colorchannelmixer. This example will make +the waveform a green color approximately RGB(66,217,150). Additional +channels will be shades of this color. +@example +ffmpeg -i audio.mp3 -filter_complex "showwavespic,colorchannelmixer=rr=66/255:gg=217/255:bb=150/255" waveform.png +@end example +@end itemize + +@section spectrumsynth + +Sythesize audio from 2 input video spectrums, first input stream represents +magnitude across time and second represents phase across time. +The filter will transform from frequency domain as displayed in videos back +to time domain as presented in audio output. + +This filter is primarly created for reversing processed @ref{showspectrum} +filter outputs, but can synthesize sound from other spectrograms too. +But in such case results are going to be poor if the phase data is not +available, because in such cases phase data need to be recreated, usually +its just recreated from random noise. +For best results use gray only output (@code{channel} color mode in +@ref{showspectrum} filter) and @code{log} scale for magnitude video and +@code{lin} scale for phase video. To produce phase, for 2nd video, use +@code{data} option. Inputs videos should generally use @code{fullframe} +slide mode as that saves resources needed for decoding video. + +The filter accepts the following options: + +@table @option +@item sample_rate +Specify sample rate of output audio, the sample rate of audio from which +spectrum was generated may differ. + +@item channels +Set number of channels represented in input video spectrums. + +@item scale +Set scale which was used when generating magnitude input spectrum. +Can be @code{lin} or @code{log}. Default is @code{log}. + +@item slide +Set slide which was used when generating inputs spectrums. +Can be @code{replace}, @code{scroll}, @code{fullframe} or @code{rscroll}. +Default is @code{fullframe}. + +@item win_func +Set window function used for resynthesis. + +@item overlap +Set window overlap. In range @code{[0, 1]}. Default is @code{1}, +which means optimal overlap for selected window function will be picked. + +@item orientation +Set orientation of input videos. Can be @code{vertical} or @code{horizontal}. +Default is @code{vertical}. +@end table + +@subsection Examples + +@itemize +@item +First create magnitude and phase videos from audio, assuming audio is stereo with 44100 sample rate, +then resynthesize videos back to audio with spectrumsynth: +@example +ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=log:overlap=0.875:color=channel:slide=fullframe:data=magnitude -an -c:v rawvideo magnitude.nut +ffmpeg -i input.flac -lavfi showspectrum=mode=separate:scale=lin:overlap=0.875:color=channel:slide=fullframe:data=phase -an -c:v rawvideo phase.nut +ffmpeg -i magnitude.nut -i phase.nut -lavfi spectrumsynth=channels=2:sample_rate=44100:win_func=hann:overlap=0.875:slide=fullframe output.flac +@end example @end itemize @section split, asplit diff --git a/doc/general.texi b/doc/general.texi index ba79503d..59ea4f44 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -53,14 +53,6 @@ instructions for installing the libraries. Then pass @code{--enable-libopencore-amrnb} and/or @code{--enable-libopencore-amrwb} to configure to enable them. -@subsection VisualOn AAC encoder library - -FFmpeg can make use of the VisualOn AACenc library for AAC encoding. - -Go to @url{http://sourceforge.net/projects/opencore-amr/} and follow the -instructions for installing the library. -Then pass @code{--enable-libvo-aacenc} to configure to enable it. - @subsection VisualOn AMR-WB encoder library FFmpeg can make use of the VisualOn AMR-WBenc library for AMR-WB encoding. @@ -145,6 +137,14 @@ x265 is under the GNU Public License Version 2 or later details), you must upgrade FFmpeg's license to GPL in order to use it. @end float +@section kvazaar + +FFmpeg can make use of the kvazaar library for HEVC encoding. + +Go to @url{https://github.com/ultravideo/kvazaar} and follow the +instructions for installing the library. Then pass +@code{--enable-libkvazaar} to configure to enable it. + @section libilbc iLBC is a narrowband speech codec that has been made freely available @@ -165,12 +165,6 @@ Go to @url{http://sourceforge.net/projects/zapping/} and follow the instructions installing the library. Then pass @code{--enable-libzvbi} to configure to enable it. -@float NOTE -libzvbi is licensed under the GNU General Public License Version 2 or later -(see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for details), -you must upgrade FFmpeg's license to GPL in order to use it. -@end float - @section AviSynth FFmpeg can read AviSynth scripts as input. To enable support, pass @@ -192,6 +186,17 @@ end user having AviSynth or AvxSynth installed - they'll only need to be installed to use AviSynth scripts (obviously). @end float +@section Intel QuickSync Video + +FFmpeg can use Intel QuickSync Video (QSV) for accelerated encoding and decoding +of multiple codecs. To use QSV, FFmpeg must be linked against the @code{libmfx} +dispatcher, which loads the actual decoding libraries. + +The dispatcher is open source and can be downloaded from +@url{https://github.com/lu-zero/mfx_dispatch.git}. FFmpeg needs to be configured +with the @code{--enable-libmfx} option and @code{pkg-config} needs to be able to +locate the dispatcher's @code{.pc} files. + @chapter Supported File Formats, Codecs or Features @@ -204,9 +209,14 @@ library: @multitable @columnfractions .4 .1 .1 .4 @item Name @tab Encoding @tab Decoding @tab Comments +@item 3dostr @tab @tab X @item 4xm @tab @tab X @tab 4X Technologies format, used in some games. @item 8088flex TMV @tab @tab X +@item AAX @tab @tab X + @tab Audible Enhanced Audio format, used in audiobooks. +@item AA @tab @tab X + @tab Audible Format 2, 3, and 4, used in audiobooks. @item ACT Voice @tab @tab X @tab contains G.729 audio @item Adobe Filmstrip @tab X @tab X @@ -218,10 +228,14 @@ library: @tab Multimedia format used in game Heart Of Darkness. @item Apple HTTP Live Streaming @tab @tab X @item Artworx Data Format @tab @tab X +@item Interplay ACM @tab @tab X + @tab Audio only format used in some Interplay games. @item ADP @tab @tab X @tab Audio format used on the Nintendo Gamecube. @item AFC @tab @tab X @tab Audio format used on the Nintendo Gamecube. +@item ADS/SS2 @tab @tab X + @tab Audio format used on the PS2. @item APNG @tab X @tab X @item ASF @tab X @tab X @item AST @tab X @tab X @@ -243,6 +257,8 @@ library: @tab Used in Z and Z95 games. @item Brute Force & Ignorance @tab @tab X @tab Used in the game Flash Traffic: City of Angels. +@item BFSTM @tab @tab X + @tab Audio format used on the Nintendo WiiU (based on BRSTM). @item BRSTM @tab @tab X @tab Audio format used on the Nintendo Wii. @item BWF @tab X @tab X @@ -260,6 +276,7 @@ library: @item CD+G @tab @tab X @tab Video format used by CD+G karaoke disks @item Phantom Cine @tab @tab X +@item Cineform HD @tab @tab X @item Commodore CDXL @tab @tab X @tab Amiga CD video format @item Core Audio Format @tab X @tab X @@ -271,8 +288,10 @@ library: @tab Audio format used in some games by CRYO Interactive Entertainment. @item D-Cinema audio @tab X @tab X @item Deluxe Paint Animation @tab @tab X +@item DCSTR @tab @tab X @item DFA @tab @tab X @tab This format is used in Chronomaster game +@item DirectDraw Surface @tab @tab X @item DSD Stream File (DSF) @tab @tab X @item DV video @tab X @tab X @item DXA @tab @tab X @@ -296,6 +315,8 @@ library: @item G.723.1 @tab X @tab X @item G.729 BIT @tab X @tab X @item G.729 raw @tab @tab X +@item GENH @tab @tab X + @tab Audio format for various games. @item GIF Animation @tab X @tab X @item GXF @tab X @tab X @tab General eXchange Format SMPTE 360M, used by Thomson Grass Valley @@ -318,6 +339,7 @@ library: @tab A format generated by IndigoVision 8000 video server. @item IVF (On2) @tab X @tab X @tab A format used by libvpx +@item Internet Video Recording @tab @tab X @item IRCAM @tab X @tab X @item LATM @tab X @tab X @item LMLM4 @tab @tab X @@ -354,6 +376,8 @@ library: @tab also known as DVB Transport Stream @item MPEG-4 @tab X @tab X @tab MPEG-4 is a variant of QuickTime. +@item MSF @tab @tab X + @tab Audio format used on the PS3. @item Mirillis FIC video @tab @tab X @tab No cursor rendering. @item MIME multipart JPEG @tab X @tab @@ -437,6 +461,7 @@ library: @item Redirector @tab @tab X @item RedSpark @tab @tab X @item Renderware TeXture Dictionary @tab @tab X +@item Resolume DXV @tab @tab X @item RL2 @tab @tab X @tab Audio and video format used in some games by Entertainment Software Partners. @item RPL/ARMovie @tab @tab X @@ -469,6 +494,8 @@ library: @item SoX native format @tab X @tab X @item SUN AU format @tab X @tab X @item SUP raw PGS subtitles @tab @tab X +@item SVAG @tab @tab X + @tab Audio format used in Konami PS2 games. @item TDSC @tab @tab X @item Text files @tab @tab X @item THP @tab @tab X @@ -476,8 +503,13 @@ library: @item Tiertex Limited SEQ @tab @tab X @tab Tiertex .seq files used in the DOS CD-ROM version of the game Flashback. @item True Audio @tab @tab X +@item VAG @tab @tab X + @tab Audio format used in many Sony PS2 games. @item VC-1 test bitstream @tab X @tab X +@item Vidvox Hap @tab X @tab X @item Vivo @tab @tab X +@item VPK @tab @tab X + @tab Audio format used in Sony PS games. @item WAV @tab X @tab X @item WavPack @tab X @tab X @item WebM @tab X @tab X @@ -488,8 +520,11 @@ library: @tab Multimedia format used in Westwood Studios games. @item Westwood Studios VQA @tab @tab X @tab Multimedia format used in Westwood Studios games. +@item WVE @tab @tab X @item XMV @tab @tab X @tab Microsoft video container used in Xbox games. +@item XVAG @tab @tab X + @tab Audio format used on the PS3. @item xWMA @tab @tab X @tab Microsoft audio container used by XAudio 2. @item eXtended BINary text (XBIN) @tab @tab X @@ -663,6 +698,8 @@ following image formats are supported: @tab Sorenson H.263 used in Flash @item Forward Uncompressed @tab @tab X @item Fraps @tab @tab X +@item Go2Meeting @tab @tab X + @tab fourcc: G2M2, G2M3 @item Go2Webinar @tab @tab X @tab fourcc: G2M4 @item H.261 @tab X @tab X @@ -671,7 +708,7 @@ following image formats are supported: @item H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 @tab E @tab X @tab encoding supported through external library libx264 and OpenH264 @item HEVC @tab X @tab X - @tab encoding supported through the external library libx265 + @tab encoding supported through external library libx265 and libkvazaar @item HNM version 4 @tab @tab X @item HuffYUV @tab X @tab X @item HuffYUV FFmpeg variant @tab X @tab X @@ -770,6 +807,7 @@ following image formats are supported: @tab Texture dictionaries used by the Renderware Engine. @item RL2 video @tab @tab X @tab used in some games by Entertainment Software Partners +@item Screenpresso @tab @tab X @item Sierra VMD video @tab @tab X @tab Used in Sierra VMD files. @item Silicon Graphics Motion Video Compressor 1 (MVC1) @tab @tab X @@ -836,12 +874,13 @@ following image formats are supported: @item Name @tab Encoding @tab Decoding @tab Comments @item 8SVX exponential @tab @tab X @item 8SVX fibonacci @tab @tab X -@item AAC+ @tab E @tab X - @tab encoding supported through external library libaacplus -@item AAC @tab E @tab X - @tab encoding supported through external library libfaac and libvo-aacenc +@item AAC @tab EX @tab X + @tab encoding supported through internal encoder and external libraries libfaac and libfdk-aac +@item AAC+ @tab E @tab IX + @tab encoding supported through external library libfdk-aac @item AC-3 @tab IX @tab IX @item ADPCM 4X Movie @tab @tab X +@item APDCM Yamaha AICA @tab @tab X @item ADPCM CDROM XA @tab @tab X @item ADPCM Creative Technology @tab @tab X @tab 16 -> 4, 8 -> 4, 8 -> 3, 8 -> 2 @@ -876,7 +915,8 @@ following image formats are supported: @item ADPCM MS IMA @tab X @tab X @item ADPCM Nintendo Gamecube AFC @tab @tab X @item ADPCM Nintendo Gamecube DTK @tab @tab X -@item ADPCM Nintendo Gamecube THP @tab @tab X +@item ADPCM Nintendo THP @tab @tab X +@item APDCM Playstation @tab @tab X @item ADPCM QT IMA @tab X @tab X @item ADPCM SEGA CRI ADX @tab X @tab X @tab Used in Sega Dreamcast games. @@ -884,7 +924,7 @@ following image formats are supported: @item ADPCM Sound Blaster Pro 2-bit @tab @tab X @item ADPCM Sound Blaster Pro 2.6-bit @tab @tab X @item ADPCM Sound Blaster Pro 4-bit @tab @tab X -@item ADPCM VIMA +@item ADPCM VIMA @tab @tab X @tab Used in LucasArts SMUSH animations. @item ADPCM Westwood Studios IMA @tab @tab X @tab Used in Westwood Studios games like Command and Conquer. @@ -915,6 +955,8 @@ following image formats are supported: @tab Used in Quake III, Jedi Knight 2 and other computer games. @item DPCM Interplay @tab @tab X @tab Used in various Interplay computer games. +@item DPCM Squareroot-Delta-Exact @tab @tab X + @tab Used in various games. @item DPCM Sierra Online @tab @tab X @tab Used in Sierra Online game audio files. @item DPCM Sol @tab @tab X @@ -929,7 +971,7 @@ following image formats are supported: @item Enhanced AC-3 @tab X @tab X @item EVRC (Enhanced Variable Rate Codec) @tab @tab X @item FLAC (Free Lossless Audio Codec) @tab X @tab IX -@item G.723.1 @tab X @tab X +@item G.723.1 @tab X @tab X @item G.729 @tab @tab X @item GSM @tab E @tab X @tab encoding supported through external library libgsm @@ -939,6 +981,7 @@ following image formats are supported: @item iLBC (Internet Low Bitrate Codec) @tab E @tab E @tab encoding and decoding supported through external library libilbc @item IMC (Intel Music Coder) @tab @tab X +@item Interplay ACM @tab @tab X @item MACE (Macintosh Audio Compression/Expansion) 3:1 @tab @tab X @item MACE (Macintosh Audio Compression/Expansion) 6:1 @tab @tab X @item MLP (Meridian Lossless Packing) @tab @tab X @@ -954,8 +997,8 @@ following image formats are supported: @item Musepack SV8 @tab @tab X @item Nellymoser Asao @tab X @tab X @item On2 AVC (Audio for Video Codec) @tab @tab X -@item Opus @tab E @tab E - @tab supported through external library libopus +@item Opus @tab E @tab X + @tab encoding supported through external library libopus @item PCM A-law @tab X @tab X @item PCM mu-law @tab X @tab X @item PCM signed 8-bit planar @tab X @tab X @@ -1023,6 +1066,8 @@ following image formats are supported: @item Windows Media Audio Lossless @tab @tab X @item Windows Media Audio Pro @tab @tab X @item Windows Media Audio Voice @tab @tab X +@item Xbox Media Audio 1 @tab @tab X +@item Xbox Media Audio 2 @tab @tab X @end multitable @code{X} means that encoding (resp. decoding) is supported. diff --git a/doc/git-howto.texi b/doc/git-howto.texi index b7b5d434..e5e3c817 100644 --- a/doc/git-howto.texi +++ b/doc/git-howto.texi @@ -1,10 +1,10 @@ \input texinfo @c -*- texinfo -*- @documentencoding UTF-8 -@settitle Using git to develop FFmpeg +@settitle Using Git to develop FFmpeg @titlepage -@center @titlefont{Using git to develop FFmpeg} +@center @titlefont{Using Git to develop FFmpeg} @end titlepage @top @@ -13,9 +13,9 @@ @chapter Introduction -This document aims in giving some quick references on a set of useful git +This document aims in giving some quick references on a set of useful Git commands. You should always use the extensive and detailed documentation -provided directly by git: +provided directly by Git: @example git --help @@ -32,22 +32,21 @@ man git- shows information about the subcommand . Additional information could be found on the -@url{http://gitref.org, Git Reference} website +@url{http://gitref.org, Git Reference} website. For more information about the Git project, visit the - -@url{http://git-scm.com/, Git website} +@url{http://git-scm.com/, Git website}. Consult these resources whenever you have problems, they are quite exhaustive. What follows now is a basic introduction to Git and some FFmpeg-specific -guidelines to ease the contribution to the project +guidelines to ease the contribution to the project. @chapter Basics Usage -@section Get GIT +@section Get Git -You can get git from @url{http://git-scm.com/} +You can get Git from @url{http://git-scm.com/} Most distribution and operating system provide a package for it. @@ -66,6 +65,21 @@ git clone git@@source.ffmpeg.org:ffmpeg This will put the FFmpeg sources into the directory @var{} and let you push back your changes to the remote repository. +@example +git clone gil@@ffmpeg.org:ffmpeg-web +@end example + +This will put the source of the FFmpeg website into the directory +@var{} and let you push back your changes to the remote repository. +(Note that @var{gil} stands for GItoLite and is not a typo of @var{git}.) + +If you don't have write-access to the ffmpeg-web repository, you can +create patches after making a read-only ffmpeg-web clone: + +@example +git clone git://ffmpeg.org/ffmpeg-web +@end example + Make sure that you do not have Windows line endings in your checkouts, otherwise you may experience spurious compilation failures. One way to achieve this is to run @@ -108,7 +122,7 @@ git add [-A] git rm [-r] @end example -GIT needs to get notified of all changes you make to your working +Git needs to get notified of all changes you make to your working directory that makes files appear or disappear. Line moves across files are automatically tracked. @@ -128,8 +142,8 @@ will show all local modifications in your working directory as unified diff. git log @end example -You may also use the graphical tools like gitview or gitk or the web -interface available at http://source.ffmpeg.org/ +You may also use the graphical tools like @command{gitview} or @command{gitk} +or the web interface available at @url{http://source.ffmpeg.org/}. @section Checking source tree status @@ -150,6 +164,7 @@ git diff --check to double check your changes before committing them to avoid trouble later on. All experienced developers do this on each and every commit, no matter how small. + Every one of them has been saved from looking like a fool by this many times. It's very easy for stray debug output or cosmetic modifications to slip in, please avoid problems through this extra level of scrutiny. @@ -172,14 +187,14 @@ to make sure you don't have untracked files or deletions. git add [-i|-p|-A] @end example -Make sure you have told git your name and email address +Make sure you have told Git your name and email address @example git config --global user.name "My Name" git config --global user.email my@@email.invalid @end example -Use @var{--global} to set the global configuration for all your git checkouts. +Use @option{--global} to set the global configuration for all your Git checkouts. Git will select the changes to the files for commit. Optionally you can use the interactive or the patch mode to select hunk by hunk what should be @@ -210,7 +225,7 @@ include filenames in log messages, Git provides that information. Possibly make the commit message have a terse, descriptive first line, an empty line and then a full description. The first line will be used to name -the patch by git format-patch. +the patch by @command{git format-patch}. @section Preparing a patchset @@ -326,10 +341,12 @@ faulty commit disappear from the history. @section Pushing changes to remote trees @example -git push +git push origin master --dry-run @end example -Will push the changes to the default remote (@var{origin}). +Will simulate a push of the local master branch to the default remote +(@var{origin}). And list which branches and ranges or commits would have been +pushed. Git will prevent you from pushing changes if the local and remote trees are out of sync. Refer to @ref{Updating the source tree to the latest revision}. @@ -350,23 +367,24 @@ branches matching the local ones. @section Finding a specific svn revision -Since version 1.7.1 git supports @var{:/foo} syntax for specifying commits +Since version 1.7.1 Git supports @samp{:/foo} syntax for specifying commits based on a regular expression. see man gitrevisions @example git show :/'as revision 23456' @end example -will show the svn changeset @var{r23456}. With older git versions searching in +will show the svn changeset @samp{r23456}. With older Git versions searching in the @command{git log} output is the easiest option (especially if a pager with search capabilities is used). + This commit can be checked out with @example git checkout -b svn_23456 :/'as revision 23456' @end example -or for git < 1.7.1 with +or for Git < 1.7.1 with @example git checkout -b svn_23456 $SHA1 @@ -375,7 +393,7 @@ git checkout -b svn_23456 $SHA1 where @var{$SHA1} is the commit hash from the @command{git log} output. -@chapter pre-push checklist +@chapter Pre-push checklist Once you have a set of commits that you feel are ready for pushing, work through the following checklist to doublecheck everything is in @@ -386,7 +404,7 @@ Apply your common sense, but if in doubt, err on the side of caution. First, make sure that the commits and branches you are going to push match what you want pushed and that nothing is missing, extraneous or wrong. You can see what will be pushed by running the git push command -with --dry-run first. And then inspecting the commits listed with +with @option{--dry-run} first. And then inspecting the commits listed with @command{git log -p 1234567..987654}. The @command{git status} command may help in finding local changes that have been forgotten to be added. @@ -395,7 +413,7 @@ Next let the code pass through a full run of our testsuite. @itemize @item @command{make distclean} @item @command{/path/to/ffmpeg/configure} -@item @command{make check} +@item @command{make fate} @item if fate fails due to missing samples run @command{make fate-rsync} and retry @end itemize @@ -413,5 +431,5 @@ recommended. @chapter Server Issues -Contact the project admins @email{root@@ffmpeg.org} if you have technical -problems with the GIT server. +Contact the project admins at @email{root@@ffmpeg.org} if you have technical +problems with the Git server. diff --git a/doc/indevs.texi b/doc/indevs.texi index d5415bbc..3fb852b1 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -51,6 +51,18 @@ ffmpeg -f alsa -i hw:0 alsaout.wav For more information see: @url{http://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html} +@subsection Options + +@table @option + +@item sample_rate +Set the sample rate in Hz. Default is 48000. + +@item channels +Set the number of channels. Default is 2. + +@end table + @section avfoundation AVFoundation input device. @@ -109,11 +121,24 @@ Specify the audio device by its index. Overrides anything given in the input fil @item -pixel_format Request the video device to use a specific pixel format. If the specified format is not supported, a list of available formats is given -und the first one in this list is used instead. Available pixel formats are: +and the first one in this list is used instead. Available pixel formats are: @code{monob, rgb555be, rgb555le, rgb565be, rgb565le, rgb24, bgr24, 0rgb, bgr0, 0bgr, rgb0, bgr48be, uyvy422, yuva444p, yuva444p16le, yuv444p, yuv422p16, yuv422p10, yuv444p10, yuv420p, nv12, yuyv422, gray} +@item -framerate +Set the grabbing frame rate. Default is @code{ntsc}, corresponding to a +frame rate of @code{30000/1001}. + +@item -video_size +Set the video frame size. + +@item -capture_cursor +Capture the mouse pointer. Default is 0. + +@item -capture_mouse_clicks +Capture the screen mouse clicks. Default is 0. + @end table @subsection Examples @@ -150,6 +175,36 @@ $ ffmpeg -f avfoundation -pixel_format bgr0 -i "default:none" out.avi BSD video input device. +@subsection Options + +@table @option + +@item framerate +Set the frame rate. + +@item video_size +Set the video frame size. Default is @code{vga}. + +@item standard + +Available values are: +@table @samp +@item pal + +@item ntsc + +@item secam + +@item paln + +@item palm + +@item ntscj + +@end table + +@end table + @section decklink The decklink input device provides capture capabilities for Blackmagic @@ -163,7 +218,8 @@ On Windows, you need to run the IDL files through @command{widl}. DeckLink is very picky about the formats it supports. Pixel format is uyvy422 or v210, framerate and video size must be determined for your device with @command{-list_formats 1}. Audio sample rate is always 48 kHz and the number -of channels can be 2, 8 or 16. +of channels can be 2, 8 or 16. Note that all audio channels are bundled in one single +audio track. @subsection Options @@ -181,6 +237,20 @@ Defaults to @option{false}. If set to @samp{1}, video is captured in 10 bit v210 instead of uyvy422. Not all Blackmagic devices support this option. +@item teletext_lines +If set to nonzero, an additional teletext stream will be captured from the +vertical ancillary data. This option is a bitmask of the VBI lines checked, +specifically lines 6 to 22, and lines 318 to 335. Line 6 is the LSB in the mask. +Selected lines which do not contain teletext information will be ignored. You +can use the special @option{all} constant to select all possible lines, or +@option{standard} to skip lines 6, 318 and 319, which are not compatible with all +receivers. Capturing teletext only works for SD PAL sources in 8 bit mode. +To use this option, ffmpeg needs to be compiled with @code{--enable-libzvbi}. + +@item channels +Defines number of audio channels to capture. Must be @samp{2}, @samp{8} or @samp{16}. +Defaults to @samp{2}. + @end table @subsection Examples @@ -212,15 +282,9 @@ ffmpeg -bm_v210 1 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -v @end example @item -Capture video clip at 720p50 with 32bit audio: -@example -ffmpeg -bm_audiodepth 32 -f decklink -i 'UltraStudio Mini Recorder@@14' -acodec copy -vcodec copy output.avi -@end example - -@item -Capture video clip at 576i50 with 8 audio channels: +Capture video clip at 1080i50 with 16 audio channels: @example -ffmpeg -bm_channels 8 -f decklink -i 'UltraStudio Mini Recorder@@3' -acodec copy -vcodec copy output.avi +ffmpeg -channels 16 -f decklink -i 'UltraStudio Mini Recorder@@11' -acodec copy -vcodec copy output.avi @end example @end itemize @@ -275,11 +339,11 @@ If set to @option{true}, print a list of selected device's options and exit. @item video_device_number -Set video device number for devices with same name (starts at 0, +Set video device number for devices with the same name (starts at 0, defaults to 0). @item audio_device_number -Set audio device number for devices with same name (starts at 0, +Set audio device number for devices with the same name (starts at 0, defaults to 0). @item pixel_format @@ -429,6 +493,27 @@ $ ffmpeg -f dshow -show_video_device_dialog true -crossbar_video_input_pin_numbe Linux DV 1394 input device. +@subsection Options + +@table @option + +@item framerate +Set the frame rate. Default is 25. + +@item standard + +Available values are: +@table @samp +@item pal + +@item ntsc + +@end table + +Default value is @code{ntsc}. + +@end table + @section fbdev Linux framebuffer input device. @@ -441,18 +526,27 @@ console. It is accessed through a file device node, usually For more detailed information read the file Documentation/fb/framebuffer.txt included in the Linux source tree. +See also @url{http://linux-fbdev.sourceforge.net/}, and fbset(1). + To record from the framebuffer device @file{/dev/fb0} with @command{ffmpeg}: @example -ffmpeg -f fbdev -r 10 -i /dev/fb0 out.avi +ffmpeg -f fbdev -framerate 10 -i /dev/fb0 out.avi @end example You can take a single screenshot image with the command: @example -ffmpeg -f fbdev -frames:v 1 -r 1 -i /dev/fb0 screenshot.jpeg +ffmpeg -f fbdev -framerate 1 -i /dev/fb0 -frames:v 1 screenshot.jpeg @end example -See also @url{http://linux-fbdev.sourceforge.net/}, and fbset(1). +@subsection Options + +@table @option + +@item framerate +Set the frame rate. Default is 25. + +@end table @section gdigrab @@ -638,6 +732,15 @@ $ jack_connect metro:120_bpm ffmpeg:input_1 For more information read: @url{http://jackaudio.org/} +@subsection Options + +@table @option + +@item channels +Set the number of channels. Default is 2. + +@end table + @section lavfi Libavfilter input virtual device. @@ -678,6 +781,9 @@ Set the filename of the filtergraph to be read and sent to the other filters. Syntax of the filtergraph is the same as the one specified by the option @var{graph}. +@item dumpgraph +Dump graph to stderr. + @end table @subsection Examples @@ -879,6 +985,19 @@ ffmpeg -f oss -i /dev/dsp /tmp/oss.wav For more information about OSS see: @url{http://manuals.opensound.com/usersguide/dsp.html} +@subsection Options + +@table @option + +@item sample_rate +Set the sample rate in Hz. Default is 48000. + +@item channels +Set the number of channels. Default is 2. + +@end table + + @section pulse PulseAudio input device. @@ -919,6 +1038,10 @@ Specify the number of bytes per frame, by default it is set to 1024. @item fragment_size Specify the minimal buffering fragment in PulseAudio, it will affect the audio latency. By default it is unset. + +@item wallclock +Set the initial PTS using the current time. Default is 1. + @end table @subsection Examples @@ -954,6 +1077,22 @@ ffmpeg -f qtkit -i "default" out.mpg ffmpeg -f qtkit -list_devices true -i "" @end example +@subsection Options + +@table @option + +@item frame_rate +Set frame rate. Default is 30. + +@item list_devices +If set to @code{true}, print a list of devices and exit. Default is +@code{false}. + +@item video_device_index +Select the video device by index for devices with the same name (starts at 0). + +@end table + @section sndio sndio input device. @@ -971,6 +1110,18 @@ command: ffmpeg -f sndio -i /dev/audio0 /tmp/oss.wav @end example +@subsection Options + +@table @option + +@item sample_rate +Set the sample rate in Hz. Default is 48000. + +@item channels +Set the number of channels. Default is 2. + +@end table + @section video4linux2, v4l2 Video4Linux2 input video device. @@ -1093,6 +1244,10 @@ Force conversion from monotonic to absolute timestamps. @end table Default value is @code{default}. + +@item use_libv4l2 +Use libv4l2 (v4l-utils) conversion functions. Default is 0. + @end table @section vfwcap @@ -1103,6 +1258,19 @@ The filename passed as input is the capture driver number, ranging from 0 to 9. You may use "list" as filename to print a list of drivers. Any other filename will be interpreted as device number 0. +@subsection Options + +@table @option + +@item video_size +Set the video frame size. + +@item framerate +Set the grabbing frame rate. Default value is @code{ntsc}, +corresponding to a frame rate of @code{30000/1001}. + +@end table + @section x11grab X11 video input device. @@ -1205,17 +1373,13 @@ Set the video frame size. Default value is @code{vga}. Use the MIT-SHM extension for shared memory. Default value is @code{1}. It may be necessary to disable it for remote displays (legacy x11grab only). -@end table - -@subsection @var{grab_x} @var{grab_y} AVOption - -The syntax is: -@example --grab_x @var{x_offset} -grab_y @var{y_offset} -@end example - -Set the grabbing region coordinates. They are expressed as offset from the top left -corner of the X11 window. The default value is 0. +@item grab_x +@item grab_y +Set the grabbing region coordinates. They are expressed as offset from +the top left corner of the X11 window and correspond to the +@var{x_offset} and @var{y_offset} parameters in the device name. The +default value for both options is 0. +@end table @c man end INPUT DEVICES diff --git a/doc/issue_tracker.txt b/doc/issue_tracker.txt index 095c04c5..e8e85304 100644 --- a/doc/issue_tracker.txt +++ b/doc/issue_tracker.txt @@ -1,8 +1,6 @@ FFmpeg's bug/feature request tracker manual ================================================= -NOTE: This is a draft. - Overview: --------- @@ -22,9 +20,9 @@ a mail for every change to every issue. (the above does all work already after light testing) The subscription URL for the ffmpeg-trac list is: -http(s)://lists.ffmpeg.org/mailman/listinfo/ffmpeg-trac +https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-trac The URL of the webinterface of the tracker is: -http(s)://trac.ffmpeg.org +https://trac.ffmpeg.org Type: ----- @@ -42,12 +40,16 @@ feature request / enhancement where the current implementation cannot be considered wrong. license violation - ticket to keep track of (L)GPL violations of ffmpeg by others + Ticket to keep track of (L)GPL violations of ffmpeg by others. sponsoring request Developer requests for hardware, software, specifications, money, refunds, etc. +task + A task/reminder such as setting up a FATE client, adding filters to + Trac, etc. + Priority: --------- critical @@ -66,7 +68,8 @@ important don't exist in a past revision or another branch. normal - + Default setting. Use this if the bug does not match the other + priorities or if you are unsure of what priority to choose. minor Bugs about things like spelling errors, "mp2" instead of @@ -163,14 +166,23 @@ Component: avcodec issues in libavcodec/* +avdevice + issues in libavdevice/* + +avfilter + issues in libavfilter/* + avformat issues in libavformat/* avutil issues in libavutil/* -regression test - issues in tests/* +build system + issues in or related to configure/Makefile + +documentation + issues in or related to doc/* ffmpeg issues in or related to ffmpeg.c @@ -184,11 +196,23 @@ ffprobe ffserver issues in or related to ffserver.c -build system - issues in or related to configure/Makefile +postproc + issues in libpostproc/* + +swresample + issues in libswresample/* -regression - bugs which were not present in a past revision +swscale + issues in libswscale/* trac issues related to our issue tracker + +undetermined + default component; choose this if unsure + +website + issues related to the website + +wiki + issues related to the wiki diff --git a/doc/mips.txt b/doc/mips.txt index 8c6779f6..a84e89ae 100644 --- a/doc/mips.txt +++ b/doc/mips.txt @@ -47,12 +47,16 @@ Files that have MIPS copyright notice in them: * libavutil/mips/ float_dsp_mips.c libm_mips.h + softfloat_tables.h * libavcodec/ fft_fixed_32.c fft_init_table.c fft_table.h mdct_fixed_32.c * libavcodec/mips/ + aacdec_fixed.c + aacsbr_fixed.c + aacsbr_template.c aaccoder_mips.c aacpsy_mips.h ac3dsp_mips.c diff --git a/doc/multithreading.txt b/doc/multithreading.txt index 2b992fcb..83849dea 100644 --- a/doc/multithreading.txt +++ b/doc/multithreading.txt @@ -54,7 +54,7 @@ thread. If the codec allocates writable tables in its init(), add an init_thread_copy() which re-allocates them for other threads. -Add CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little +Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. If there are inter-frame dependencies, so the codec calls diff --git a/doc/muxers.texi b/doc/muxers.texi index 95cdb8fa..2e6bb4ca 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -37,6 +37,61 @@ ID3v2.3 and ID3v2.4) are supported. The default is version 4. @end table +@anchor{asf} +@section asf + +Advanced Systems Format muxer. + +Note that Windows Media Audio (wma) and Windows Media Video (wmv) use this +muxer too. + +@subsection Options + +It accepts the following options: + +@table @option +@item packet_size +Set the muxer packet size. By tuning this setting you may reduce data +fragmentation or muxer overhead depending on your source. Default value is +3200, minimum is 100, maximum is 64k. + +@end table + +@anchor{chromaprint} +@section chromaprint + +Chromaprint fingerprinter + +This muxer feeds audio data to the Chromaprint library, which generates +a fingerprint for the provided audio data. It takes a single signed +native-endian 16-bit raw audio stream. + +@subsection Options + +@table @option +@item silence_threshold +Threshold for detecting silence, ranges from 0 to 32767. -1 for default +(required for use with the AcoustID service). + +@item algorithm +Algorithm index to fingerprint with. + +@item fp_format +Format to output the fingerprint as. Accepts the following options: +@table @samp +@item raw +Binary raw fingerprint + +@item compressed +Binary compressed fingerprint + +@item base64 +Base64 compressed fingerprint + +@end table + +@end table + @anchor{crc} @section crc @@ -263,6 +318,62 @@ ffmpeg in.nut -hls_segment_filename 'file%03d.ts' out.m3u8 This example will produce the playlist, @file{out.m3u8}, and segment files: @file{file000.ts}, @file{file001.ts}, @file{file002.ts}, etc. +@item hls_key_info_file @var{key_info_file} +Use the information in @var{key_info_file} for segment encryption. The first +line of @var{key_info_file} specifies the key URI written to the playlist. The +key URL is used to access the encryption key during playback. The second line +specifies the path to the key file used to obtain the key during the encryption +process. The key file is read as a single packed array of 16 octets in binary +format. The optional third line specifies the initialization vector (IV) as a +hexadecimal string to be used instead of the segment sequence number (default) +for encryption. Changes to @var{key_info_file} will result in segment +encryption with the new key/IV and an entry in the playlist for the new key +URI/IV. + +Key info file format: +@example +@var{key URI} +@var{key file path} +@var{IV} (optional) +@end example + +Example key URIs: +@example +http://server/file.key +/path/to/file.key +file.key +@end example + +Example key file paths: +@example +file.key +/path/to/file.key +@end example + +Example IV: +@example +0123456789ABCDEF0123456789ABCDEF +@end example + +Key info file example: +@example +http://server/file.key +/path/to/file.key +0123456789ABCDEF0123456789ABCDEF +@end example + +Example shell script: +@example +#!/bin/sh +BASE_URL=$@{1:-'.'@} +openssl rand 16 > file.key +echo $BASE_URL/file.key > file.keyinfo +echo file.key >> file.keyinfo +echo $(openssl rand -hex 16) >> file.keyinfo +ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags delete_segments \ + -hls_key_info_file file.keyinfo out.m3u8 +@end example + @item hls_flags single_file If this flag is set, the muxer will store all segments in a single MPEG-TS file, and will use byte ranges in the playlist. HLS playlists generated with @@ -493,7 +604,7 @@ MD5 testing format. This muxer computes and prints the MD5 hash of all the input audio and video frames. By default audio frames are converted to signed 16-bit raw audio and video frames to raw video before computing the -hash. +hash. Timestamps are ignored. The output of the muxer consists of a single line of the form: MD5=@var{MD5}, where @var{MD5} is a hexadecimal number representing @@ -611,6 +722,13 @@ point on IIS with this muxer. Example: ffmpeg -re @var{} -movflags isml+frag_keyframe -f ismv http://server/publishingpoint.isml/Streams(Encoder1) @end example +@subsection Audible AAX + +Audible AAX files are encrypted M4B files, and they can be decrypted by specifying a 4 byte activation secret. +@example +ffmpeg -activation_bytes 1CEB00DA -i test.aax -vn -c:a copy output.mp4 +@end example + @section mp3 The MP3 muxer writes a raw MP3 stream with the following optional features: @@ -703,6 +821,10 @@ Set a constant muxrate (default VBR). @item -pcr_period @var{numer} Override the default PCR retransmission time (default 20ms), ignored if variable muxrate is selected. +@item pat_period @var{number} +Maximal time in seconds between PAT/PMT tables. +@item sdt_period @var{number} +Maximal time in seconds between SDT tables. @item -pes_payload_size @var{number} Set minimum PES packet payload in bytes. @item -mpegts_flags @var{flags} @@ -754,6 +876,10 @@ Option mpegts_flags may take a set of such flags: Reemit PAT/PMT before writing the next packet. @item latm Use LATM packetization for AAC. +@item pat_pmt_at_frames +Reemit PAT and PMT at each video frame. +@item system_b +Conform to System B (DVB) instead of System A (ATSC). @end table @subsection Example @@ -770,6 +896,21 @@ ffmpeg -i file.mpg -c copy \ -y out.ts @end example +@section mxf, mxf_d10 + +MXF muxer. + +@subsection Options + +The muxer options are: + +@table @option +@item store_user_comments @var{bool} +Set if user comments should be stored if available or never. +IRT D-10 does not allow user comments. The default is thus to write them for +mxf but not for mxf_d10 +@end table + @section null Null muxer. @@ -908,13 +1049,6 @@ Allow caching (only affects M3U8 list files). Allow live-friendly file generation. @end table -@item segment_list_type @var{type} -Select the listing format. -@table @option -@item @var{flat} use a simple flat list of entries. -@item @var{hls} use a m3u8-like structure. -@end table - @item segment_list_size @var{size} Update the list file so that it contains at most @var{size} segments. If 0 the list file will contain all the segments. Default @@ -924,6 +1058,9 @@ value is 0. Prepend @var{prefix} to each entry. Useful to generate absolute paths. By default no prefix is applied. +@item segment_list_type @var{type} +Select the listing format. + The following values are recognized: @table @samp @item flat @@ -983,6 +1120,28 @@ to create files at 12:00 o'clock, 12:15, 12:30, etc. Default value is "0". +@item segment_clocktime_offset @var{duration} +Delay the segment splitting times with the specified duration when using +@option{segment_atclocktime}. + +For example with @option{segment_time} set to "900" and +@option{segment_clocktime_offset} set to "300" this makes it possible to +create files at 12:05, 12:20, 12:35, etc. + +Default value is "0". + +@item segment_clocktime_wrap_duration @var{duration} +Force the segmenter to only start a new segment if a packet reaches the muxer +within the specified duration after the segmenting clock time. This way you +can make the segmenter more resilient to backward local time jumps, such as +leap seconds or transition to standard time from daylight savings time. + +Assuming that the delay between the packets of your source is less than 0.5 +second you can detect a leap second by specifying 0.5 as the duration. + +Default is the maximum possible duration which means starting a new segment +regardless of the elapsed time since the last clock time. + @item segment_time_delta @var{delta} Specify the accuracy time when selecting the start time for a segment, expressed as a duration specification. Default value is "0". @@ -1172,7 +1331,8 @@ Several bitstream filters can be specified, separated by ",". @item select Select the streams that should be mapped to the slave output, specified by a stream specifier. If not specified, this defaults to -all the input streams. +all the input streams. You may use multiple stream specifiers +separated by commas (@code{,}) e.g.: @code{a:0,v} @end table @subsection Examples diff --git a/doc/platform.texi b/doc/platform.texi index 705a6800..f7ee4564 100644 --- a/doc/platform.texi +++ b/doc/platform.texi @@ -107,8 +107,13 @@ Notes: @itemize -@item Building natively using MSYS2 can be sped up by disabling implicit rules -in the Makefile by calling @code{make -r} instead of plain @code{make}. This +@item Building for the MSYS environment is discouraged, MSYS2 provides a full +MinGW-w64 environment through @file{mingw64_shell.bat} or +@file{mingw32_shell.bat} that should be used instead of the environment +provided by @file{msys2_shell.bat}. + +@item Building using MSYS2 can be sped up by disabling implicit rules in the +Makefile by calling @code{make -r} instead of plain @code{make}. This speed up is close to non-existent for normal one-off builds and is only noticeable when running make for a second time (for example during @code{make install}). @@ -122,6 +127,25 @@ libavformat) as DLLs. @end itemize +@subsection Native Windows compilation using MSYS2 + +The MSYS2 MinGW-w64 environment provides ready to use toolchains and dependencies +through @command{pacman}. + +Make sure to use @file{mingw64_shell.bat} or @file{mingw32_shell.bat} to have +the correct MinGW-w64 environment. The default install provides shortcuts to +them under @command{MinGW-w64 Win64 Shell} and @command{MinGW-w64 Win32 Shell}. + +@example +# normal msys2 packages +pacman -S make pkgconf diffutils + +# mingw-w64 packages and toolchains +pacman -S mingw-w64-x86_64-yasm mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL +@end example + +To target 32bit replace the @code{x86_64} with @code{i686} in the command above. + @section Microsoft Visual C++ or Intel C++ Compiler for Windows FFmpeg can be built with MSVC 2012 or earlier using a C99-to-C89 conversion utility @@ -175,12 +199,6 @@ Notes: @itemize -@item It is possible that coreutils' @code{link.exe} conflicts with MSVC's linker. -You can find out by running @code{which link} to see which @code{link.exe} you -are using. If it is located at @code{/bin/link.exe}, then you have the wrong one -in your @code{PATH}. Either move or remove that copy, or make sure MSVC's -@code{link.exe} takes precedence in your @code{PATH} over coreutils'. - @item If you wish to build with zlib support, you will have to grab a compatible zlib binary from somewhere, with an MSVC import lib, or if you wish to link statically, you can follow the instructions below to build a compatible @@ -296,7 +314,7 @@ These library packages are only available from @uref{http://sourceware.org/cygwinports/, Cygwin Ports}: @example -yasm, libSDL-devel, libfaac-devel, libaacplus-devel, libgsm-devel, libmp3lame-devel, +yasm, libSDL-devel, libfaac-devel, libgsm-devel, libmp3lame-devel, libschroedinger1.0-devel, speex-devel, libtheora-devel, libxvidcore-devel @end example diff --git a/doc/protocols.texi b/doc/protocols.texi index 453dbcf6..375d0428 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -1,3 +1,22 @@ +@chapter Protocol Options +@c man begin PROTOCOL OPTIONS + +The libavformat library provides some generic global options, which +can be set on all the protocols. In addition each protocol may support +so-called private options, which are specific for that component. + +The list of supported options follows: + +@table @option +@item protocol_whitelist @var{list} (@emph{input}) +Set a ","-separated list of allowed protocols. "ALL" matches all protocols. Protocols +prefixed by "-" are disabled. +All protocols are allowed by default but protocols used by an another +protocol (nested protocols) are restricted to a per protocol subset. +@end table + +@c man end PROTOCOL OPTIONS + @chapter Protocols @c man begin PROTOCOLS @@ -19,6 +38,18 @@ supported protocols. A description of the currently available protocols follows. +@section async + +Asynchronous data filling wrapper for input stream. + +Fill data in a background thread, to decouple I/O operation from demux thread. + +@example +async:@var{URL} +async:http://host/resource +async:cache:http://host/resource +@end example + @section bluray Read BluRay playlist. @@ -228,6 +259,9 @@ If set to 1 use chunked Transfer-Encoding for posts, default is 1. @item content_type Set a specific content type for the POST messages. +@item http_proxy +set HTTP proxy to tunnel through e.g. http://example.com:1234 + @item headers Set custom HTTP headers, can override built in default headers. The value must be a string encoding the headers. @@ -248,6 +282,16 @@ Set timeout in microseconds of socket I/O operations used by the underlying low operation. By default it is set to -1, which means that the timeout is not specified. +@item reconnect_at_eof +If set then eof is treated like an error and causes reconnection, this is useful +for live / endless streams. + +@item reconnect_streamed +If set then even streamed/non seekable streams will be reconnected on errors. + +@item reconnect_delay_max +Sets the maximum delay in seconds after which to give up reconnecting + @item mime_type Export the MIME type. @@ -292,6 +336,8 @@ autodetection in the future. If set to 1 enables experimental HTTP server. This can be used to send data when used as an output option, or read data from a client with HTTP POST when used as an input option. +If set to 2 enables experimental mutli-client HTTP server. This is not yet implemented +in ffmpeg.c or ffserver.c and thus must not be used as a command line option. @example # Server side (sending): ffmpeg -i somefile.ogg -c copy -listen 1 -f ogg http://@var{server}:@var{port} @@ -1120,6 +1166,12 @@ than this time interval, raise error. @item listen_timeout=@var{milliseconds} Set listen timeout, expressed in milliseconds. + +@item recv_buffer_size=@var{bytes} +Set receive buffer size, expressed bytes. + +@item send_buffer_size=@var{bytes} +Set send buffer size, expressed bytes. @end table The following example shows how to setup a listening TCP connection diff --git a/doc/resampler.texi b/doc/resampler.texi index f9eef03f..cb7d536c 100644 --- a/doc/resampler.texi +++ b/doc/resampler.texi @@ -66,8 +66,8 @@ Set rematrix volume. Default value is 1.0. @item rematrix_maxval Set maximum output value for rematrixing. -This can be used to prevent clipping vs. preventing volumn reduction -A value of 1.0 prevents cliping. +This can be used to prevent clipping vs. preventing volume reduction. +A value of 1.0 prevents clipping. @item flags, swr_flags Set flags used by the converter. Default value is 0. @@ -94,13 +94,13 @@ select triangular dither @item triangular_hp select triangular dither with high pass @item lipshitz -select lipshitz noise shaping dither +select Lipshitz noise shaping dither. @item shibata -select shibata noise shaping dither +select Shibata noise shaping dither. @item low_shibata -select low shibata noise shaping dither +select low Shibata noise shaping dither. @item high_shibata -select high shibata noise shaping dither +select high Shibata noise shaping dither. @item f_weighted select f-weighted noise shaping dither @item modified_e_weighted @@ -132,7 +132,7 @@ For swr only, set resampling phase shift, default value is 10, and must be in the interval [0,30]. @item linear_interp -Use Linear Interpolation if set to 1, default value is 0. +Use linear interpolation if set to 1, default value is 0. @item cutoff Set cutoff frequency (swr: 6dB point; soxr: 0dB point) ratio; must be a float @@ -214,13 +214,13 @@ It accepts the following values: @item cubic select cubic @item blackman_nuttall -select Blackman Nuttall Windowed Sinc +select Blackman Nuttall windowed sinc @item kaiser -select Kaiser Windowed Sinc +select Kaiser windowed sinc @end table @item kaiser_beta -For swr only, set Kaiser Window Beta value. Must be an integer in the +For swr only, set Kaiser window beta value. Must be a double float value in the interval [2,16], default value is 9. @item output_sample_bits diff --git a/doc/scaler.texi b/doc/scaler.texi index 23d63938..3e115cdd 100644 --- a/doc/scaler.texi +++ b/doc/scaler.texi @@ -46,7 +46,7 @@ Select Gaussian rescaling algorithm. Select sinc rescaling algorithm. @item lanczos -Select lanczos rescaling algorithm. +Select Lanczos rescaling algorithm. @item spline Select natural bicubic spline rescaling algorithm. @@ -91,6 +91,7 @@ Select source range. @item dst_range Select destination range. +@anchor{sws_params} @item param0, param1 Set scaling algorithm parameters. The specified values are specific of some scaling algorithms and ignored by others. The specified values @@ -122,6 +123,22 @@ a_dither). @end table +@item alphablend +Set the alpha blending to use when the input has alpha but the output does not. +Default value is @samp{none}. + +@table @samp +@item uniform_color +Blend onto a uniform background color + +@item checkerboard +Blend onto a checkerboard + +@item none +No blending + +@end table + @end table @c man end SCALER OPTIONS diff --git a/doc/texi2pod.pl b/doc/texi2pod.pl index e1ff6b46..9a9b34fc 100644 --- a/doc/texi2pod.pl +++ b/doc/texi2pod.pl @@ -384,7 +384,7 @@ sub postprocess # @* is also impossible in .pod; we discard it and any newline that # follows it. Similarly, our macro @gol must be discarded. - s/\@anchor{(?:[^\}]*)\}//g; + s/\@anchor\{(?:[^\}]*)\}//g; s/\(?\@xref\{(?:[^\}]*)\}(?:[^.<]|(?:<[^<>]*>))*\.\)?//g; s/\s+\(\@pxref\{(?:[^\}]*)\}\)//g; s/;\s+\@pxref\{(?:[^\}]*)\}//g; diff --git a/doc/utils.texi b/doc/utils.texi index 6517ac0a..7aea4606 100644 --- a/doc/utils.texi +++ b/doc/utils.texi @@ -238,6 +238,14 @@ The following abbreviations are recognized: 480x320 @item qhd 960x540 +@item 2kdci +2048x1080 +@item 4kdci +4096x2160 +@item uhd2160 +3840x2160 +@item uhd4320 +7680x4320 @end table @anchor{video rate syntax} @@ -861,7 +869,7 @@ Return 1 if @var{x} is lesser than or equal to @var{y}, 0 otherwise. Return the maximum between @var{x} and @var{y}. @item min(x, y) -Return the maximum between @var{x} and @var{y}. +Return the minimum between @var{x} and @var{y}. @item mod(x, y) Compute the remainder of division of @var{x} by @var{y}. diff --git a/doc/writing_filters.txt b/doc/writing_filters.txt index eb16d424..66ebb532 100644 --- a/doc/writing_filters.txt +++ b/doc/writing_filters.txt @@ -3,8 +3,8 @@ libavfilter. Foreword: just like everything else in FFmpeg, libavfilter is monolithic, which means that it is highly recommended that you submit your filters to the FFmpeg -development mailing-list and make sure it is applied. Otherwise, your filter is -likely to have a very short lifetime due to more a less regular internal API +development mailing-list and make sure that they are applied. Otherwise, your filters +are likely to have a very short lifetime due to more or less regular internal API changes, and a limited distribution, review, and testing. Bootstrap @@ -64,7 +64,7 @@ filter, so you can update the boilerplate with your credits. Doxy ---- -Next chunk is the Doxygen about the file. See http://ffmpeg.org/doxygen/trunk/. +Next chunk is the Doxygen about the file. See https://ffmpeg.org/doxygen/trunk/. Detail here what the filter is, does, and add some references if you feel like it. @@ -73,11 +73,11 @@ Context Skip the headers and scroll down to the definition of FoobarContext. This is your local state context. It is already filled with 0 when you get it so do not -worry about uninitialized read into this context. This is where you put every -"global" information you need, typically the variable storing the user options. +worry about uninitialized reads into this context. This is where you put all +"global" information that you need; typically the variables storing the user options. You'll notice the first field "const AVClass *class"; it's the only field you -need to keep assuming you have a context. There are some magic you don't care -about around this field, just let it be (in first position) for now. +need to keep assuming you have a context. There is some magic you don't need to +care about around this field, just let it be (in the first position) for now. Options ------- @@ -87,7 +87,7 @@ options. For example, -vf foobar=mode=colormix:high=0.4:low=0.1. Most options have the following pattern: name, description, offset, type, default value, minimum value, maximum value, flags - - name is the option name, keep it simple, lowercase + - name is the option name, keep it simple and lowercase - description are short, in lowercase, without period, and describe what they do, for example "set the foo of the bar" - offset is the offset of the field in your local context, see the OFFSET() @@ -99,7 +99,7 @@ have the following pattern: - min and max values define the range of available values, inclusive - flags are AVOption generic flags. See AV_OPT_FLAG_* definitions -In doubt, just look at the other AVOption definitions all around the codebase, +When in doubt, just look at the other AVOption definitions all around the codebase, there are tons of examples. Class @@ -146,14 +146,14 @@ we won't cover this here since vf_foobar is just a simple 1:1 filter. uninit() ~~~~~~~~ -Similarly, there is the uninit() callback, doing what the name suggest. Free +Similarly, there is the uninit() callback, doing what the name suggests. Free everything you allocated here. query_formats() ~~~~~~~~~~~~~~~ -This is following the init() and is used for the format negotiation, basically -where you say what pixel format(s) (gray, rgb 32, yuv 4:2:0, ...) you accept +This follows the init() and is used for the format negotiation. Basically +you specify here what pixel format(s) (gray, rgb 32, yuv 4:2:0, ...) you accept for your inputs, and what you can output. All pixel formats are defined in libavutil/pixfmt.h. If you don't change the pixel format between the input and the output, you just have to define a pixel formats array and call @@ -182,7 +182,7 @@ will update outlink->w and outlink->h. filter_frame() ~~~~~~~~~~~~~~ -This is the callback you are waiting from the beginning: it is where you +This is the callback you are waiting for from the beginning: it is where you process the received frames. Along with the frame, you get the input link from where the frame comes from. @@ -317,7 +317,7 @@ Adding timeline support feature to add. In the most simple case, you just have to add AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC to the AVFilter.flags. You can typically do this when your filter does not need to save the previous context frames, or -basically if your filter just alter whatever goes in and doesn't need +basically if your filter just alters whatever goes in and doesn't need previous/future information. See for instance commit 86cb986ce that adds timeline support to the fieldorder filter. diff --git a/ffmpeg.c b/ffmpeg.c index 384b92ca..a5ec3c38 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -32,14 +32,12 @@ #include #include -#if HAVE_ISATTY #if HAVE_IO_H #include #endif #if HAVE_UNISTD_H #include #endif -#endif #include "libavformat/avformat.h" #include "libavdevice/avdevice.h" @@ -49,6 +47,7 @@ #include "libavutil/parseutils.h" #include "libavutil/samplefmt.h" #include "libavutil/fifo.h" +#include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" #include "libavutil/mathematics.h" @@ -63,7 +62,6 @@ #include "libavcodec/mathops.h" #include "libavformat/os_support.h" -# include "libavfilter/avcodec.h" # include "libavfilter/avfilter.h" # include "libavfilter/buffersrc.h" # include "libavfilter/buffersink.h" @@ -79,6 +77,10 @@ #include #include #endif +#if HAVE_SETCONSOLECTRLHANDLER +#include +#endif + #if HAVE_SYS_SELECT_H #include @@ -132,8 +134,6 @@ AVIOContext *progress_avio = NULL; static uint8_t *subtitle_out; -#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass" - InputStream **input_streams = NULL; int nb_input_streams = 0; InputFile **input_files = NULL; @@ -169,8 +169,8 @@ static int sub2video_get_blank_frame(InputStream *ist) AVFrame *frame = ist->sub2video.frame; av_frame_unref(frame); - ist->sub2video.frame->width = ist->sub2video.w; - ist->sub2video.frame->height = ist->sub2video.h; + ist->sub2video.frame->width = ist->dec_ctx->width ? ist->dec_ctx->width : ist->sub2video.w; + ist->sub2video.frame->height = ist->dec_ctx->height ? ist->dec_ctx->height : ist->sub2video.h; ist->sub2video.frame->format = AV_PIX_FMT_RGB32; if ((ret = av_frame_get_buffer(frame, 32)) < 0) return ret; @@ -190,7 +190,9 @@ static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h, return; } if (r->x < 0 || r->x + r->w > w || r->y < 0 || r->y + r->h > h) { - av_log(NULL, AV_LOG_WARNING, "sub2video: rectangle overflowing\n"); + av_log(NULL, AV_LOG_WARNING, "sub2video: rectangle (%d %d %d %d) overflowing %d %d\n", + r->x, r->y, r->w, r->h, w, h + ); return; } @@ -222,7 +224,6 @@ static void sub2video_push_ref(InputStream *ist, int64_t pts) static void sub2video_update(InputStream *ist, AVSubtitle *sub) { - int w = ist->sub2video.w, h = ist->sub2video.h; AVFrame *frame = ist->sub2video.frame; int8_t *dst; int dst_linesize; @@ -250,7 +251,7 @@ static void sub2video_update(InputStream *ist, AVSubtitle *sub) dst = frame->data [0]; dst_linesize = frame->linesize[0]; for (i = 0; i < num_rects; i++) - sub2video_copy_rect(dst, dst_linesize, w, h, sub->rects[i]); + sub2video_copy_rect(dst, dst_linesize, frame->width, frame->height, sub->rects[i]); sub2video_push_ref(ist, pts); ist->sub2video.end_pts = end_pts; } @@ -291,7 +292,7 @@ static void sub2video_flush(InputStream *ist) if (ist->sub2video.end_pts < INT64_MAX) sub2video_update(ist, NULL); for (i = 0; i < ist->nb_filters; i++) - av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0); + av_buffersrc_add_frame(ist->filters[i]->filter, NULL); } /* end of sub2video hack */ @@ -313,6 +314,7 @@ void term_exit(void) static volatile int received_sigterm = 0; static volatile int received_nb_signals = 0; static volatile int transcode_init_done = 0; +static volatile int ffmpeg_exited = 0; static int main_return_code = 0; static void @@ -321,20 +323,52 @@ sigterm_handler(int sig) received_sigterm = sig; received_nb_signals++; term_exit_sigsafe(); - if(received_nb_signals > 3) + if(received_nb_signals > 3) { + write(2/*STDERR_FILENO*/, "Received > 3 system signals, hard exiting\n", + strlen("Received > 3 system signals, hard exiting\n")); + exit(123); + } } +#if HAVE_SETCONSOLECTRLHANDLER +static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) +{ + av_log(NULL, AV_LOG_DEBUG, "\nReceived windows signal %ld\n", fdwCtrlType); + + switch (fdwCtrlType) + { + case CTRL_C_EVENT: + case CTRL_BREAK_EVENT: + sigterm_handler(SIGINT); + return TRUE; + + case CTRL_CLOSE_EVENT: + case CTRL_LOGOFF_EVENT: + case CTRL_SHUTDOWN_EVENT: + sigterm_handler(SIGTERM); + /* Basically, with these 3 events, when we return from this method the + process is hard terminated, so stall as long as we need to + to try and let the main thread(s) clean up and gracefully terminate + (we have at most 5 seconds, but should be done far before that). */ + while (!ffmpeg_exited) { + Sleep(0); + } + return TRUE; + + default: + av_log(NULL, AV_LOG_ERROR, "Received unknown windows signal %ld\n", fdwCtrlType); + return FALSE; + } +} +#endif + void term_init(void) { #if HAVE_TERMIOS_H if(!run_as_daemon){ struct termios tty; - int istty = 1; -#if HAVE_ISATTY - istty = isatty(0) && isatty(2); -#endif - if (istty && tcgetattr (0, &tty) == 0) { + if (tcgetattr (0, &tty) == 0) { oldtty = tty; restore_tty = 1; @@ -358,6 +392,9 @@ void term_init(void) #ifdef SIGXCPU signal(SIGXCPU, sigterm_handler); #endif +#if HAVE_SETCONSOLECTRLHANDLER + SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE); +#endif } /* read a key without blocking */ @@ -391,10 +428,6 @@ static int read_key(void) is_pipe = !GetConsoleMode(input_handle, &dw); } - if (stdin->_cnt > 0) { - read(0, &ch, 1); - return ch; - } if (is_pipe) { /* When running under a GUI, you will end here. */ if (!PeekNamedPipe(input_handle, NULL, 0, NULL, &nchars, NULL)) { @@ -429,7 +462,7 @@ static void ffmpeg_cleanup(int ret) if (do_benchmark) { int maxrss = getmaxrss() / 1024; - printf("bench: maxrss=%ikB\n", maxrss); + av_log(NULL, AV_LOG_INFO, "bench: maxrss=%ikB\n", maxrss); } for (i = 0; i < nb_filtergraphs; i++) { @@ -494,6 +527,8 @@ static void ffmpeg_cleanup(int ret) av_freep(&ost->audio_channels_map); ost->audio_channels_mapped = 0; + av_dict_free(&ost->sws_dict); + avcodec_free_context(&ost->enc_ctx); av_freep(&output_streams[i]); @@ -521,8 +556,12 @@ static void ffmpeg_cleanup(int ret) av_freep(&input_streams[i]); } - if (vstats_file) - fclose(vstats_file); + if (vstats_file) { + if (fclose(vstats_file)) + av_log(NULL, AV_LOG_ERROR, + "Error closing vstats file, loss of information possible: %s\n", + av_err2str(AVERROR(errno))); + } av_freep(&vstats_filename); av_freep(&input_streams); @@ -535,12 +574,13 @@ static void ffmpeg_cleanup(int ret) avformat_network_deinit(); if (received_sigterm) { - av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n", + av_log(NULL, AV_LOG_INFO, "Exiting normally, received signal %d.\n", (int) received_sigterm); } else if (ret && transcode_init_done) { av_log(NULL, AV_LOG_INFO, "Conversion failed!\n"); } term_exit(); + ffmpeg_exited = 1; } void remove_avoptions(AVDictionary **a, AVDictionary *b) @@ -577,7 +617,7 @@ static void update_benchmark(const char *fmt, ...) va_start(va, fmt); vsnprintf(buf, sizeof(buf), fmt, va); va_end(va); - printf("bench: %8"PRIu64" %s \n", t - current_time, buf); + av_log(NULL, AV_LOG_INFO, "bench: %8"PRIu64" %s \n", t - current_time, buf); } current_time = t; } @@ -599,7 +639,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) int ret; if (!ost->st->codec->extradata_size && ost->enc_ctx->extradata_size) { - ost->st->codec->extradata = av_mallocz(ost->enc_ctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + ost->st->codec->extradata = av_mallocz(ost->enc_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (ost->st->codec->extradata) { memcpy(ost->st->codec->extradata, ost->enc_ctx->extradata, ost->enc_ctx->extradata_size); ost->st->codec->extradata_size = ost->enc_ctx->extradata_size; @@ -619,56 +659,40 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) */ if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) { if (ost->frame_number >= ost->max_frames) { - av_free_packet(pkt); + av_packet_unref(pkt); return; } ost->frame_number++; } + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { + int i; + uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, + NULL); + ost->quality = sd ? AV_RL32(sd) : -1; + ost->pict_type = sd ? sd[4] : AV_PICTURE_TYPE_NONE; + + for (i = 0; ierror); i++) { + if (sd && i < sd[5]) + ost->error[i] = AV_RL64(sd + 8 + 8*i); + else + ost->error[i] = -1; + } + + if (ost->frame_rate.num && ost->is_cfr) { + if (pkt->duration > 0) + av_log(NULL, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n"); + pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate), + ost->st->time_base); + } + } if (bsfc) av_packet_split_side_data(pkt); - while (bsfc) { - AVPacket new_pkt = *pkt; - AVDictionaryEntry *bsf_arg = av_dict_get(ost->bsf_args, - bsfc->filter->name, - NULL, 0); - int a = av_bitstream_filter_filter(bsfc, avctx, - bsf_arg ? bsf_arg->value : NULL, - &new_pkt.data, &new_pkt.size, - pkt->data, pkt->size, - pkt->flags & AV_PKT_FLAG_KEY); - if(a == 0 && new_pkt.data != pkt->data && new_pkt.destruct) { - uint8_t *t = av_malloc(new_pkt.size + FF_INPUT_BUFFER_PADDING_SIZE); //the new should be a subset of the old so cannot overflow - if(t) { - memcpy(t, new_pkt.data, new_pkt.size); - memset(t + new_pkt.size, 0, FF_INPUT_BUFFER_PADDING_SIZE); - new_pkt.data = t; - new_pkt.buf = NULL; - a = 1; - } else - a = AVERROR(ENOMEM); - } - if (a > 0) { - pkt->side_data = NULL; - pkt->side_data_elems = 0; - av_free_packet(pkt); - new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, - av_buffer_default_free, NULL, 0); - if (!new_pkt.buf) - exit_program(1); - } else if (a < 0) { - new_pkt = *pkt; - av_log(NULL, AV_LOG_ERROR, "Failed to open bitstream filter %s for stream %d with codec %s", - bsfc->filter->name, pkt->stream_index, - avctx->codec ? avctx->codec->name : "copy"); - print_error("", a); - if (exit_on_error) - exit_program(1); - } - *pkt = new_pkt; - - bsfc = bsfc->next; + if ((ret = av_apply_bitstream_filters(avctx, pkt, bsfc)) < 0) { + print_error("", ret); + if (exit_on_error) + exit_program(1); } if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { @@ -729,7 +753,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) main_return_code = 1; close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED); } - av_free_packet(pkt); + av_packet_unref(pkt); } static void close_output_stream(OutputStream *ost) @@ -929,11 +953,11 @@ static void do_video_out(AVFormatContext *s, ost->last_nb0_frames[1], ost->last_nb0_frames[2]); } else { - delta0 = sync_ipts - ost->sync_opts; + delta0 = sync_ipts - ost->sync_opts; // delta0 is the "drift" between the input frame (next_picture) and where it would fall in the output. delta = delta0 + duration; /* by default, we output a single frame */ - nb0_frames = 0; + nb0_frames = 0; // tracks the number of times the PREVIOUS frame should be duplicated, mostly for variable framerate (VFR) nb_frames = 1; format_video_sync = video_sync_method; @@ -952,25 +976,25 @@ static void do_video_out(AVFormatContext *s, format_video_sync = VSYNC_VSCFR; } } + ost->is_cfr = (format_video_sync == VSYNC_CFR || format_video_sync == VSYNC_VSCFR); if (delta0 < 0 && delta > 0 && format_video_sync != VSYNC_PASSTHROUGH && format_video_sync != VSYNC_DROP) { - double cor = FFMIN(-delta0, duration); if (delta0 < -0.6) { av_log(NULL, AV_LOG_WARNING, "Past duration %f too large\n", -delta0); } else - av_log(NULL, AV_LOG_DEBUG, "Cliping frame in rate conversion by %f\n", -delta0); - sync_ipts += cor; - duration -= cor; - delta0 += cor; + av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0); + sync_ipts = ost->sync_opts; + duration += delta0; + delta0 = 0; } switch (format_video_sync) { case VSYNC_VSCFR: - if (ost->frame_number == 0 && delta - duration >= 0.5) { - av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta - duration)); + if (ost->frame_number == 0 && delta0 >= 0.5) { + av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); delta = duration; delta0 = 0; ost->sync_opts = lrint(sync_ipts); @@ -1010,22 +1034,22 @@ static void do_video_out(AVFormatContext *s, sizeof(ost->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(ost->last_nb0_frames) - 1)); ost->last_nb0_frames[0] = nb0_frames; - if (nb0_frames == 0 && ost->last_droped) { + if (nb0_frames == 0 && ost->last_dropped) { nb_frames_drop++; av_log(NULL, AV_LOG_VERBOSE, "*** dropping frame %d from stream %d at ts %"PRId64"\n", ost->frame_number, ost->st->index, ost->last_frame->pts); } - if (nb_frames > (nb0_frames && ost->last_droped) + (nb_frames > nb0_frames)) { + if (nb_frames > (nb0_frames && ost->last_dropped) + (nb_frames > nb0_frames)) { if (nb_frames > dts_error_threshold * 30) { av_log(NULL, AV_LOG_ERROR, "%d frame duplication too large, skipping\n", nb_frames - 1); nb_frames_drop++; return; } - nb_frames_dup += nb_frames - (nb0_frames && ost->last_droped) - (nb_frames > nb0_frames); + nb_frames_dup += nb_frames - (nb0_frames && ost->last_dropped) - (nb_frames > nb0_frames); av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", nb_frames - 1); } - ost->last_droped = nb_frames == nb0_frames && next_picture; + ost->last_dropped = nb_frames == nb0_frames && next_picture; /* duplicates frame if needed */ for (i = 0; i < nb_frames; i++) { @@ -1051,6 +1075,7 @@ static void do_video_out(AVFormatContext *s, #endif return; +#if FF_API_LAVF_FMT_RAWPICTURE if (s->oformat->flags & AVFMT_RAWPICTURE && enc->codec->id == AV_CODEC_ID_RAWVIDEO) { /* raw pictures are written as AVPicture structure to @@ -1066,11 +1091,13 @@ static void do_video_out(AVFormatContext *s, pkt.flags |= AV_PKT_FLAG_KEY; write_frame(s, &pkt, ost); - } else { + } else +#endif + { int got_packet, forced_keyframe = 0; double pts_time; - if (enc->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) && + if (enc->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) && ost->top_field_first >= 0) in_picture->top_field_first = !!ost->top_field_first; @@ -1096,7 +1123,7 @@ static void do_video_out(AVFormatContext *s, ost->forced_keyframes_expr_const_values[FKF_T] = pts_time; res = av_expr_eval(ost->forced_keyframes_pexpr, ost->forced_keyframes_expr_const_values, NULL); - av_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n", + ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n", ost->forced_keyframes_expr_const_values[FKF_N], ost->forced_keyframes_expr_const_values[FKF_N_FORCED], ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N], @@ -1149,7 +1176,7 @@ static void do_video_out(AVFormatContext *s, av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &enc->time_base)); } - if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY)) + if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & AV_CODEC_CAP_DELAY)) pkt.pts = ost->sync_opts; av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base); @@ -1193,7 +1220,7 @@ static void do_video_out(AVFormatContext *s, static double psnr(double d) { - return -10.0 * log(d) / log(10.0); + return -10.0 * log10(d); } static void do_video_stats(OutputStream *ost, int frame_size) @@ -1214,9 +1241,11 @@ static void do_video_stats(OutputStream *ost, int frame_size) enc = ost->enc_ctx; if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { frame_number = ost->st->nb_frames; - fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, enc->coded_frame ? enc->coded_frame->quality / (float)FF_QP2LAMBDA : 0); - if (enc->coded_frame && (enc->flags&CODEC_FLAG_PSNR)) - fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0))); + fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, + ost->quality / (float)FF_QP2LAMBDA); + + if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR)) + fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width * enc->height * 255.0 * 255.0))); fprintf(vstats_file,"f_size= %6d ", frame_size); /* compute pts value */ @@ -1228,7 +1257,7 @@ static void do_video_stats(OutputStream *ost, int frame_size) avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0; fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate); - fprintf(vstats_file, "type= %c\n", enc->coded_frame ? av_get_picture_type_char(enc->coded_frame->pict_type) : 'I'); + fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type)); } } @@ -1326,7 +1355,7 @@ static int reap_filters(int flush) do_video_out(of->ctx, ost, filtered_frame, float_pts); break; case AVMEDIA_TYPE_AUDIO: - if (!(enc->codec->capabilities & CODEC_CAP_PARAM_CHANGE) && + if (!(enc->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE) && enc->channels != av_frame_get_channels(filtered_frame)) { av_log(NULL, AV_LOG_ERROR, "Audio filter graph output is not normalized and encoder does not support parameter changes\n"); @@ -1365,8 +1394,8 @@ static void print_final_stats(int64_t total_size) } extra_size += ost->enc_ctx->extradata_size; data_size += ost->data_size; - if ( (ost->enc_ctx->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2)) - != CODEC_FLAG_PASS1) + if ( (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2)) + != AV_CODEC_FLAG_PASS1) pass1_used = 0; } @@ -1473,10 +1502,13 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti AVCodecContext *enc; int frame_number, vid, i; double bitrate; - int64_t pts = INT64_MIN; + double speed; + int64_t pts = INT64_MIN + 1; static int64_t last_time = -1; static int qp_histogram[52]; int hours, mins, secs, us; + int ret; + float t; if (!print_stats && !is_last_report && !progress_avio) return; @@ -1491,6 +1523,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti last_time = cur_time; } + t = (cur_time-timer_start) / 1000000.0; + oc = output_files[0]->ctx; @@ -1505,15 +1539,16 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti float q = -1; ost = output_streams[i]; enc = ost->enc_ctx; - if (!ost->stream_copy && enc->coded_frame) - q = enc->coded_frame->quality / (float)FF_QP2LAMBDA; + if (!ost->stream_copy) + q = ost->quality / (float) FF_QP2LAMBDA; + if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q); av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n", ost->file_index, ost->index, q); } if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { - float fps, t = (cur_time-timer_start) / 1000000.0; + float fps; frame_number = ost->frame_number; fps = t > 1 ? frame_number / t : 0; @@ -1531,9 +1566,10 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti if (qp >= 0 && qp < FF_ARRAY_ELEMS(qp_histogram)) qp_histogram[qp]++; for (j = 0; j < 32; j++) - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log2(qp_histogram[j] + 1))); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", av_log2(qp_histogram[j] + 1)); } - if ((enc->flags&CODEC_FLAG_PSNR) && (enc->coded_frame || is_last_report)) { + + if ((enc->flags & AV_CODEC_FLAG_PSNR) && (ost->pict_type != AV_PICTURE_TYPE_NONE || is_last_report)) { int j; double error, error_sum = 0; double scale, scale_sum = 0; @@ -1545,7 +1581,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti error = enc->error[j]; scale = enc->width * enc->height * 255.0 * 255.0 * frame_number; } else { - error = enc->coded_frame->error[j]; + error = ost->error[j]; scale = enc->width * enc->height * 255.0 * 255.0; } if (j) @@ -1569,7 +1605,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti pts = FFMAX(pts, av_rescale_q(av_stream_get_end_pts(ost->st), ost->st->time_base, AV_TIME_BASE_Q)); if (is_last_report) - nb_frames_drop += ost->last_droped; + nb_frames_drop += ost->last_dropped; } secs = FFABS(pts) / AV_TIME_BASE; @@ -1580,6 +1616,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti mins %= 60; bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1; + speed = t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1; if (total_size < 0) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "size=N/A time="); @@ -1611,6 +1648,14 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti av_bprintf(&buf_script, "dup_frames=%d\n", nb_frames_dup); av_bprintf(&buf_script, "drop_frames=%d\n", nb_frames_drop); + if (speed < 0) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf)," speed=N/A"); + av_bprintf(&buf_script, "speed=N/A\n"); + } else { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf)," speed=%4.3gx", speed); + av_bprintf(&buf_script, "speed=%4.3gx\n", speed); + } + if (print_stats || is_last_report) { const char end = is_last_report ? '\n' : '\r'; if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) { @@ -1629,7 +1674,9 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti avio_flush(progress_avio); av_bprint_finalize(&buf_script, NULL); if (is_last_report) { - avio_closep(&progress_avio); + if ((ret = avio_closep(&progress_avio)) < 0) + av_log(NULL, AV_LOG_ERROR, + "Error closing progress log, loss of information possible: %s\n", av_err2str(ret)); } } @@ -1652,8 +1699,10 @@ static void flush_encoders(void) if (enc->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1) continue; +#if FF_API_LAVF_FMT_RAWPICTURE if (enc->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == AV_CODEC_ID_RAWVIDEO) continue; +#endif for (;;) { int (*encode)(AVCodecContext*, AVPacket*, const AVFrame*, int*) = NULL; @@ -1662,11 +1711,11 @@ static void flush_encoders(void) switch (enc->codec_type) { case AVMEDIA_TYPE_AUDIO: encode = avcodec_encode_audio2; - desc = "Audio"; + desc = "audio"; break; case AVMEDIA_TYPE_VIDEO: encode = avcodec_encode_video2; - desc = "Video"; + desc = "video"; break; default: stop_encoding = 1; @@ -1682,9 +1731,11 @@ static void flush_encoders(void) update_benchmark(NULL); ret = encode(enc, &pkt, NULL, &got_packet); - update_benchmark("flush %s %d.%d", desc, ost->file_index, ost->index); + update_benchmark("flush_%s %d.%d", desc, ost->file_index, ost->index); if (ret < 0) { - av_log(NULL, AV_LOG_FATAL, "%s encoding failed\n", desc); + av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n", + desc, + av_err2str(ret)); exit_program(1); } if (ost->logfile && enc->stats_out) { @@ -1695,7 +1746,7 @@ static void flush_encoders(void) break; } if (ost->finished & MUXER_FINISHED) { - av_free_packet(&pkt); + av_packet_unref(&pkt); continue; } av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base); @@ -1738,7 +1789,6 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p InputFile *f = input_files [ist->file_index]; int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; int64_t ost_tb_start_time = av_rescale_q(start_time, AV_TIME_BASE_Q, ost->st->time_base); - int64_t ist_tb_start_time = av_rescale_q(start_time, AV_TIME_BASE_Q, ist->st->time_base); AVPicture pict; AVPacket opkt; @@ -1748,13 +1798,13 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p !ost->copy_initial_nonkeyframes) return; - if (pkt->pts == AV_NOPTS_VALUE) { - if (!ost->frame_number && ist->pts < start_time && - !ost->copy_prior_start) - return; - } else { - if (!ost->frame_number && pkt->pts < ist_tb_start_time && - !ost->copy_prior_start) + if (!ost->frame_number && !ost->copy_prior_start) { + int64_t comp_start = start_time; + if (copy_ts && f->start_time != AV_NOPTS_VALUE) + comp_start = FFMAX(start_time, f->start_time + f->ts_offset); + if (pkt->pts == AV_NOPTS_VALUE ? + ist->pts < comp_start : + pkt->pts < av_rescale_q(comp_start, AV_TIME_BASE_Q, ist->st->time_base)) return; } @@ -1766,7 +1816,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p if (f->recording_time != INT64_MAX) { start_time = f->ctx->start_time; - if (f->start_time != AV_NOPTS_VALUE) + if (f->start_time != AV_NOPTS_VALUE && copy_ts) start_time += f->start_time; if (ist->pts >= f->recording_time + start_time) { close_output_stream(ost); @@ -1800,17 +1850,22 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base); opkt.flags = pkt->flags; - // FIXME remove the following 2 lines they shall be replaced by the bitstream filters - if ( ost->enc_ctx->codec_id != AV_CODEC_ID_H264 - && ost->enc_ctx->codec_id != AV_CODEC_ID_MPEG1VIDEO - && ost->enc_ctx->codec_id != AV_CODEC_ID_MPEG2VIDEO - && ost->enc_ctx->codec_id != AV_CODEC_ID_VC1 + if ( ost->st->codec->codec_id != AV_CODEC_ID_H264 + && ost->st->codec->codec_id != AV_CODEC_ID_MPEG1VIDEO + && ost->st->codec->codec_id != AV_CODEC_ID_MPEG2VIDEO + && ost->st->codec->codec_id != AV_CODEC_ID_VC1 ) { - if (av_parser_change(ost->parser, ost->st->codec, + int ret = av_parser_change(ost->parser, ost->st->codec, &opkt.data, &opkt.size, pkt->data, pkt->size, - pkt->flags & AV_PKT_FLAG_KEY)) { + pkt->flags & AV_PKT_FLAG_KEY); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "av_parser_change failed: %s\n", + av_err2str(ret)); + exit_program(1); + } + if (ret) { opkt.buf = av_buffer_create(opkt.data, opkt.size, av_buffer_default_free, NULL, 0); if (!opkt.buf) exit_program(1); @@ -1821,13 +1876,22 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p } av_copy_packet_side_data(&opkt, pkt); - if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (of->ctx->oformat->flags & AVFMT_RAWPICTURE)) { +#if FF_API_LAVF_FMT_RAWPICTURE + if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && + ost->st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && + (of->ctx->oformat->flags & AVFMT_RAWPICTURE)) { /* store AVPicture in AVPacket, as expected by the output format */ - avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height); + int ret = avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "avpicture_fill failed: %s\n", + av_err2str(ret)); + exit_program(1); + } opkt.data = (uint8_t *)&pict; opkt.size = sizeof(AVPicture); opkt.flags |= AV_PKT_FLAG_KEY; } +#endif write_frame(of->ctx, &opkt, ost); } @@ -1852,6 +1916,22 @@ int guess_input_channel_layout(InputStream *ist) return 1; } +static void check_decode_result(InputStream *ist, int *got_output, int ret) +{ + if (*got_output || ret<0) + decode_error_stat[ret<0] ++; + + if (ret < 0 && exit_on_error) + exit_program(1); + + if (exit_on_error && *got_output && ist) { + if (av_frame_get_decode_error_flags(ist->decoded_frame) || (ist->decoded_frame->flags & AV_FRAME_FLAG_CORRUPT)) { + av_log(NULL, AV_LOG_FATAL, "%s: corrupt decoded frame in stream %d\n", input_files[ist->file_index]->ctx->filename, ist->st->index); + exit_program(1); + } + } +} + static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) { AVFrame *decoded_frame, *f; @@ -1874,23 +1954,10 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) ret = AVERROR_INVALIDDATA; } - if (*got_output || ret<0) - decode_error_stat[ret<0] ++; - - if (ret < 0 && exit_on_error) - exit_program(1); + check_decode_result(ist, got_output, ret); - if (!*got_output || ret < 0) { - if (!pkt->size) { - for (i = 0; i < ist->nb_filters; i++) -#if 1 - av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0); -#else - av_buffersrc_add_frame(ist->filters[i]->filter, NULL); -#endif - } + if (!*got_output || ret < 0) return ret; - } ist->samples_decoded += decoded_frame->nb_samples; ist->frames_decoded++; @@ -1967,6 +2034,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) decoded_frame->pts = av_rescale_delta(decoded_frame_tb, decoded_frame->pts, (AVRational){1, avctx->sample_rate}, decoded_frame->nb_samples, &ist->filter_in_rescale_delta_last, (AVRational){1, avctx->sample_rate}); + ist->nb_samples = decoded_frame->nb_samples; for (i = 0; i < ist->nb_filters; i++) { if (i < ist->nb_filters - 1) { f = ist->filter_frame; @@ -2014,19 +2082,16 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) if (ist->dec_ctx->codec_id == AV_CODEC_ID_H264) { ist->st->codec->has_b_frames = ist->dec_ctx->has_b_frames; } else - av_log_ask_for_sample( - ist->dec_ctx, - "has_b_frames is larger in decoder than demuxer %d > %d ", - ist->dec_ctx->has_b_frames, - ist->st->codec->has_b_frames - ); + av_log(ist->dec_ctx, AV_LOG_WARNING, + "has_b_frames is larger in decoder than demuxer %d > %d.\n" + "If you want to help, upload a sample " + "of this file to ftp://upload.ffmpeg.org/incoming/ " + "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)", + ist->dec_ctx->has_b_frames, + ist->st->codec->has_b_frames); } - if (*got_output || ret<0) - decode_error_stat[ret<0] ++; - - if (ret < 0 && exit_on_error) - exit_program(1); + check_decode_result(ist, got_output, ret); if (*got_output && ret >= 0) { if (ist->dec_ctx->width != decoded_frame->width || @@ -2042,17 +2107,8 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) } } - if (!*got_output || ret < 0) { - if (!pkt->size) { - for (i = 0; i < ist->nb_filters; i++) -#if 1 - av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0); -#else - av_buffersrc_add_frame(ist->filters[i]->filter, NULL); -#endif - } + if (!*got_output || ret < 0) return ret; - } if(ist->top_field_first>=0) decoded_frame->top_field_first = ist->top_field_first; @@ -2143,11 +2199,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) int i, ret = avcodec_decode_subtitle2(ist->dec_ctx, &subtitle, got_output, pkt); - if (*got_output || ret<0) - decode_error_stat[ret<0] ++; - - if (ret < 0 && exit_on_error) - exit_program(1); + check_decode_result(NULL, got_output, ret); if (ret < 0 || !*got_output) { if (!pkt->size) @@ -2200,8 +2252,19 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) return ret; } +static int send_filter_eof(InputStream *ist) +{ + int i, ret; + for (i = 0; i < ist->nb_filters; i++) { + ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL); + if (ret < 0) + return ret; + } + return 0; +} + /* pkt = NULL means EOF (needed to flush decoder buffers) */ -static int process_input_packet(InputStream *ist, const AVPacket *pkt) +static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof) { int ret = 0, i; int got_output = 0; @@ -2247,7 +2310,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt) ist->dts = ist->next_dts; if (avpkt.size && avpkt.size != pkt->size && - !(ist->dec->capabilities & CODEC_CAP_SUBFRAMES)) { + !(ist->dec->capabilities & AV_CODEC_CAP_SUBFRAMES)) { av_log(NULL, ist->showed_multi_packet_warning ? AV_LOG_VERBOSE : AV_LOG_WARNING, "Multiple frames in a packet from stream %d\n", pkt->stream_index); ist->showed_multi_packet_warning = 1; @@ -2284,8 +2347,13 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt) return -1; } - if (ret < 0) - return ret; + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n", + ist->file_index, ist->st->index, av_err2str(ret)); + if (exit_on_error) + exit_program(1); + break; + } avpkt.dts= avpkt.pts= AV_NOPTS_VALUE; @@ -2304,6 +2372,16 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt) break; } + /* after flushing, send an EOF on all the filter inputs attached to the stream */ + /* except when looping we need to flush but not to send an EOF */ + if (!pkt && ist->decoding_needed && !got_output && !no_eof) { + int ret = send_filter_eof(ist); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n"); + exit_program(1); + } + } + /* handle stream copy */ if (!ist->decoding_needed) { ist->dts = ist->next_dts; @@ -2360,6 +2438,9 @@ static void print_sdp(void) } } + if (!j) + goto fail; + av_sdp_create(avc, j, sdp, sizeof(sdp)); if (!sdp_filename) { @@ -2375,6 +2456,7 @@ static void print_sdp(void) } } +fail: av_freep(&avc); } @@ -2491,8 +2573,98 @@ static InputStream *get_input_stream(OutputStream *ost) static int compare_int64(const void *a, const void *b) { - int64_t va = *(int64_t *)a, vb = *(int64_t *)b; - return va < vb ? -1 : va > vb ? +1 : 0; + return FFDIFFSIGN(*(const int64_t *)a, *(const int64_t *)b); +} + +static int init_output_stream(OutputStream *ost, char *error, int error_len) +{ + int ret = 0; + + if (ost->encoding_needed) { + AVCodec *codec = ost->enc; + AVCodecContext *dec = NULL; + InputStream *ist; + + if ((ist = get_input_stream(ost))) + dec = ist->dec_ctx; + if (dec && dec->subtitle_header) { + /* ASS code assumes this buffer is null terminated so add extra byte. */ + ost->enc_ctx->subtitle_header = av_mallocz(dec->subtitle_header_size + 1); + if (!ost->enc_ctx->subtitle_header) + return AVERROR(ENOMEM); + memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); + ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size; + } + if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0)) + av_dict_set(&ost->encoder_opts, "threads", "auto", 0); + if (ost->enc->type == AVMEDIA_TYPE_AUDIO && + !codec->defaults && + !av_dict_get(ost->encoder_opts, "b", NULL, 0) && + !av_dict_get(ost->encoder_opts, "ab", NULL, 0)) + av_dict_set(&ost->encoder_opts, "b", "128000", 0); + + if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) { + if (ret == AVERROR_EXPERIMENTAL) + abort_codec_experimental(codec, 1); + snprintf(error, error_len, + "Error while opening encoder for output stream #%d:%d - " + "maybe incorrect parameters such as bit_rate, rate, width or height", + ost->file_index, ost->index); + return ret; + } + if (ost->enc->type == AVMEDIA_TYPE_AUDIO && + !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) + av_buffersink_set_frame_size(ost->filter->filter, + ost->enc_ctx->frame_size); + assert_avoptions(ost->encoder_opts); + if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000) + av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." + " It takes bits/s as argument, not kbits/s\n"); + + ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, + "Error initializing the output stream codec context.\n"); + exit_program(1); + } + + if (ost->enc_ctx->nb_coded_side_data) { + int i; + + ost->st->side_data = av_realloc_array(NULL, ost->enc_ctx->nb_coded_side_data, + sizeof(*ost->st->side_data)); + if (!ost->st->side_data) + return AVERROR(ENOMEM); + + for (i = 0; i < ost->enc_ctx->nb_coded_side_data; i++) { + const AVPacketSideData *sd_src = &ost->enc_ctx->coded_side_data[i]; + AVPacketSideData *sd_dst = &ost->st->side_data[i]; + + sd_dst->data = av_malloc(sd_src->size); + if (!sd_dst->data) + return AVERROR(ENOMEM); + memcpy(sd_dst->data, sd_src->data, sd_src->size); + sd_dst->size = sd_src->size; + sd_dst->type = sd_src->type; + ost->st->nb_side_data++; + } + } + + // copy timebase while removing common factors + ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1}); + ost->st->codec->codec= ost->enc_ctx->codec; + } else { + ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, + "Error setting up codec context options.\n"); + return ret; + } + // copy timebase while removing common factors + ost->st->time_base = av_add_q(ost->st->codec->time_base, (AVRational){0, 1}); + } + + return ret; } static void parse_forced_key_frames(char *kf, OutputStream *ost, @@ -2605,7 +2777,7 @@ static void set_encoder_id(OutputFile *of, OutputStream *ost) if (!encoder_string) exit_program(1); - if (!(format_flags & AVFMT_FLAG_BITEXACT) && !(codec_flags & CODEC_FLAG_BITEXACT)) + if (!(format_flags & AVFMT_FLAG_BITEXACT) && !(codec_flags & AV_CODEC_FLAG_BITEXACT)) av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len); else av_strlcpy(encoder_string, "Lavc ", encoder_string_len); @@ -2646,21 +2818,6 @@ static int transcode_init(void) input_streams[j + ifile->ist_index]->start = av_gettime_relative(); } - /* output stream init */ - for (i = 0; i < nb_output_files; i++) { - oc = output_files[i]->ctx; - if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) { - av_dump_format(oc, i, oc->filename, 1); - av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", i); - return AVERROR(EINVAL); - } - } - - /* init complex filtergraphs */ - for (i = 0; i < nb_filtergraphs; i++) - if ((ret = avfilter_graph_config(filtergraphs[i]->graph, NULL)) < 0) - return ret; - /* for each output stream, we compute the right encoding parameters */ for (i = 0; i < nb_output_streams; i++) { AVCodecContext *enc_ctx; @@ -2697,7 +2854,7 @@ static int transcode_init(void) av_assert0(ist && !ost->filter); - extra_size = (uint64_t)dec_ctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; + extra_size = (uint64_t)dec_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) { return AVERROR(EINVAL); @@ -2772,7 +2929,7 @@ static int transcode_init(void) enc_ctx->time_base = dec_ctx->time_base; } - if (ist && !ost->frame_rate.num) + if (!ost->frame_rate.num) ost->frame_rate = ist->framerate; if(ost->frame_rate.num) enc_ctx->time_base = av_inv_q(ost->frame_rate); @@ -2819,6 +2976,7 @@ static int transcode_init(void) enc_ctx->audio_service_type = dec_ctx->audio_service_type; enc_ctx->block_align = dec_ctx->block_align; enc_ctx->initial_padding = dec_ctx->delay; + enc_ctx->profile = dec_ctx->profile; #if FF_API_AUDIOENC_DELAY enc_ctx->delay = dec_ctx->delay; #endif @@ -2869,12 +3027,13 @@ static int transcode_init(void) goto dump_format; } - if (ist) - ist->decoding_needed |= DECODING_FOR_OST; - ost->encoding_needed = 1; - set_encoder_id(output_files[ost->file_index], ost); +#if CONFIG_LIBMFX + if (qsv_transcode_init(ost)) + exit_program(1); +#endif + if (!ost->filter && (enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO || enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO)) { @@ -3001,39 +3160,6 @@ static int transcode_init(void) abort(); break; } - /* two pass mode */ - if (enc_ctx->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2)) { - char logfilename[1024]; - FILE *f; - - snprintf(logfilename, sizeof(logfilename), "%s-%d.log", - ost->logfile_prefix ? ost->logfile_prefix : - DEFAULT_PASS_LOGFILENAME_PREFIX, - i); - if (!strcmp(ost->enc->name, "libx264")) { - av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE); - } else { - if (enc_ctx->flags & CODEC_FLAG_PASS2) { - char *logbuffer; - size_t logbuffer_size; - if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { - av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n", - logfilename); - exit_program(1); - } - enc_ctx->stats_in = logbuffer; - } - if (enc_ctx->flags & CODEC_FLAG_PASS1) { - f = av_fopen_utf8(logfilename, "wb"); - if (!f) { - av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n", - logfilename, strerror(errno)); - exit_program(1); - } - ost->logfile = f; - } - } - } } if (ost->disposition) { @@ -3070,63 +3196,9 @@ static int transcode_init(void) /* open each encoder */ for (i = 0; i < nb_output_streams; i++) { - ost = output_streams[i]; - if (ost->encoding_needed) { - AVCodec *codec = ost->enc; - AVCodecContext *dec = NULL; - - if ((ist = get_input_stream(ost))) - dec = ist->dec_ctx; - if (dec && dec->subtitle_header) { - /* ASS code assumes this buffer is null terminated so add extra byte. */ - ost->enc_ctx->subtitle_header = av_mallocz(dec->subtitle_header_size + 1); - if (!ost->enc_ctx->subtitle_header) { - ret = AVERROR(ENOMEM); - goto dump_format; - } - memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); - ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size; - } - if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0)) - av_dict_set(&ost->encoder_opts, "threads", "auto", 0); - av_dict_set(&ost->encoder_opts, "side_data_only_packets", "1", 0); - - if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) { - if (ret == AVERROR_EXPERIMENTAL) - abort_codec_experimental(codec, 1); - snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height", - ost->file_index, ost->index); - goto dump_format; - } - if (ost->enc->type == AVMEDIA_TYPE_AUDIO && - !(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) - av_buffersink_set_frame_size(ost->filter->filter, - ost->enc_ctx->frame_size); - assert_avoptions(ost->encoder_opts); - if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000) - av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." - " It takes bits/s as argument, not kbits/s\n"); - - ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); - if (ret < 0) { - av_log(NULL, AV_LOG_FATAL, - "Error initializing the output stream codec context.\n"); - exit_program(1); - } - - // copy timebase while removing common factors - ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1}); - ost->st->codec->codec= ost->enc_ctx->codec; - } else { - ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts); - if (ret < 0) { - av_log(NULL, AV_LOG_FATAL, - "Error setting up codec context options.\n"); - return ret; - } - // copy timebase while removing common factors - ost->st->time_base = av_add_q(ost->st->codec->time_base, (AVRational){0, 1}); - } + ret = init_output_stream(output_streams[i], error, sizeof(error)); + if (ret < 0) + goto dump_format; } /* init input streams */ @@ -3316,8 +3388,12 @@ static OutputStream *choose_output(void) for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; - int64_t opts = av_rescale_q(ost->st->cur_dts, ost->st->time_base, + int64_t opts = ost->st->cur_dts == AV_NOPTS_VALUE ? INT64_MIN : + av_rescale_q(ost->st->cur_dts, ost->st->time_base, AV_TIME_BASE_Q); + if (ost->st->cur_dts == AV_NOPTS_VALUE) + av_log(NULL, AV_LOG_DEBUG, "cur_dts is invalid (this is harmless if it occurs once at the start per stream)\n"); + if (!ost->finished && opts < opts_min) { opts_min = opts; ost_min = ost->unavailable ? NULL : ost; @@ -3326,6 +3402,18 @@ static OutputStream *choose_output(void) return ost_min; } +static void set_tty_echo(int on) +{ +#if HAVE_TERMIOS_H + struct termios tty; + if (tcgetattr(0, &tty) == 0) { + if (on) tty.c_lflag |= ECHO; + else tty.c_lflag &= ~ECHO; + tcsetattr(0, TCSANOW, &tty); + } +#endif +} + static int check_keyboard_interaction(int64_t cur_time) { int i, ret, key; @@ -3358,10 +3446,13 @@ static int check_keyboard_interaction(int64_t cur_time) int k, n = 0; fprintf(stderr, "\nEnter command: |all