Go to file
Kevin Mark 3385989b98 libavfilter/scale2ref: Add constants for the primary input
Variables pertaining to the main video are now available when
using the scale2ref filter. This allows, as an example, scaling a
video with another as a reference point while maintaining the
original aspect ratio of the primary/non-reference video.

Consider the following graph: scale2ref=iw/6:-1 [main][ref]
This will scale [main] to 1/6 the width of [ref] while maintaining
the aspect ratio. This works well when the AR of [ref] is equal to
the AR of [main] only. What the above filter really does is
maintain the AR of [ref] when scaling [main]. So in all non-same-AR
situations [main] will appear stretched or compressed to conform to
the same AR of the reference video. Without doing this calculation
externally there is no way to scale in reference to another input
while maintaining AR in libavfilter.

To make this possible, we introduce eight new constants to be used
in the w and h expressions only in the scale2ref filter:

 * main_w/main_h: width/height of the main input video
 * main_a: aspect ratio of the main input video
 * main_sar: sample aspect ratio of the main input video
 * main_dar: display aspect ratio of the main input video
 * main_hsub/main_vsub: horiz/vert chroma subsample vals of main
 * mdar: a shorthand alias of main_dar

Of course, not all of these constants are needed for maintaining the
AR, but adding additional constants in line of what is available for
in/out allows for other scaling possibilities I have not imagined.

So to now scale a video to 1/6 the size of another video using the
width and maintaining its own aspect ratio you can do this:

scale2ref=iw/6:ow/mdar [main][ref]

This is ideal for picture-in-picture configurations where you could
have a square or 4:3 video overlaid on a corner of a larger 16:9
feed all while keeping the scaled video in the corner at its correct
aspect ratio and always the same size relative to the larger video.

I've tried to re-use as much code as possible. I could not find a way
to avoid duplication of the var_names array. It must now be kept in
sync with the other (the normal one and the scale2ref one) for
everything to work which does not seem ideal. For every new variable
introduced/removed into/from the normal scale filter one must be
added/removed to/from the scale2ref version. Suggestions on how to
avoid var_names duplication are welcome.

var_values has been increased to always be large enough for the
additional scale2ref variables. I do not forsee this being a problem
as the names variable will always be the correct size. From my
understanding of av_expr_parse_and_eval it will stop processing
variables when it runs out of names even though there may be
additional (potentially uninitialized) entries in the values array.
The ideal solution here would be using a variable-length array but
that is unsupported in C90.

This patch does not remove any functionality and is strictly a
feature patch. There are no API changes. Behavior does not change for
any previously valid inputs.

The applicable documentation has also been updated.

Signed-off-by: Kevin Mark <kmark937@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-06-01 22:56:08 +02:00
compat compat/cuda: make cuvidGetDecoderCaps optional 2017-06-01 12:39:06 +02:00
doc libavfilter/scale2ref: Add constants for the primary input 2017-06-01 22:56:08 +02:00
ffbuild build: remove --enable-raise-major configure option 2017-05-17 22:52:59 -03:00
libavcodec avcodec/asvdec: Use rounded up dimenensions in input size check 2017-06-01 22:20:16 +02:00
libavdevice Use AVOnce as a static variable consistently 2017-05-22 12:36:32 +02:00
libavfilter libavfilter/scale2ref: Add constants for the primary input 2017-06-01 22:56:08 +02:00
libavformat avformat/tls_schannel: log unknown error codes 2017-05-31 12:07:43 +02:00
libavresample Merge commit '92db5083077a8b0f8e1050507671b456fd155125' 2017-05-04 19:59:30 -03:00
libavutil avutil/pixfmt: remove superfluous define 2017-06-01 01:18:49 -03:00
libpostproc Merge commit '92db5083077a8b0f8e1050507671b456fd155125' 2017-05-04 19:59:30 -03:00
libswresample Merge commit '92db5083077a8b0f8e1050507671b456fd155125' 2017-05-04 19:59:30 -03:00
libswscale Merge commit '92db5083077a8b0f8e1050507671b456fd155125' 2017-05-04 19:59:30 -03:00
presets
tests checkasm: add _fixed suffix to fixed_dsp tests 2017-06-01 13:12:20 -03:00
tools tools/target_dec_fuzzer: Move the hwaccel check outside the initialization if 2017-05-29 03:40:47 +02:00
.gitattributes
.gitignore build: add support for building .cu files via nvcc 2017-05-15 11:46:50 +02:00
.travis.yml
Changelog avfilter: add audio surround upmixer 2017-06-01 21:25:36 +02:00
cmdutils_opencl.c cmdutils_opencl: Fix read of uinitialized cl_mem 2017-05-11 13:02:12 +02:00
cmdutils.c avformat, ffmpeg: deprecate old rotation API 2017-03-27 13:20:27 +02:00
cmdutils.h Merge commit '122de16dd8108a59a55d30543c9f28b5f61b02d1' 2017-05-05 14:04:30 +02:00
configure configure: libnpp does not need to link libcuda 2017-06-01 11:36:13 +02:00
CONTRIBUTING.md
COPYING.GPLv2
COPYING.GPLv3
COPYING.LGPLv2.1
COPYING.LGPLv3
CREDITS
ffmpeg_cuvid.c
ffmpeg_dxva2.c
ffmpeg_filter.c ffmpeg: check for unconnected outputs 2017-05-05 00:15:15 +02:00
ffmpeg_opt.c ffmpeg: remove bsf extradata propagation hack 2017-05-24 20:28:00 -03:00
ffmpeg_qsv.c
ffmpeg_vaapi.c
ffmpeg_vdpau.c
ffmpeg_videotoolbox.c ffmpeg_videotoolbox: fix usage of av_get_codec_tag_string() 2017-03-29 14:49:29 +02:00
ffmpeg.c ffmpeg: remove bsf extradata propagation hack 2017-05-24 20:28:00 -03:00
ffmpeg.h ffmpeg: remove bsf extradata propagation hack 2017-05-24 20:28:00 -03:00
ffplay.c Merge commit '122de16dd8108a59a55d30543c9f28b5f61b02d1' 2017-05-05 14:04:30 +02:00
ffprobe.c ffprobe: Print AVContentLightMetadata side data contents 2017-06-01 15:07:16 -04:00
ffserver_config.c
ffserver_config.h
ffserver.c Merge commit '122de16dd8108a59a55d30543c9f28b5f61b02d1' 2017-05-05 14:04:30 +02:00
INSTALL.md
LICENSE.md Merge commit '4fef648d10bf3bcfd4b8fa5755c1128966a2427c' 2017-03-15 22:07:47 +01:00
MAINTAINERS lavc: remove libschroedinger encoding and decoding wrappers 2017-05-29 20:15:58 +01:00
Makefile build: remove --enable-raise-major configure option 2017-05-17 22:52:59 -03:00
README.md
RELEASE Bump minor versions for master after release/3.3 branchpoint 2017-03-31 13:21:06 +02:00

FFmpeg README

FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata.

Libraries

  • libavcodec provides implementation of a wider range of codecs.
  • libavformat implements streaming protocols, container formats and basic I/O access.
  • libavutil includes hashers, decompressors and miscellaneous utility functions.
  • libavfilter provides a mean to alter decoded Audio and Video through chain of filters.
  • libavdevice provides an abstraction to access capture and playback devices.
  • libswresample implements audio mixing and resampling routines.
  • libswscale implements color conversion and scaling routines.

Tools

  • ffmpeg is a command line toolbox to manipulate, convert and stream multimedia content.
  • ffplay is a minimalistic multimedia player.
  • ffprobe is a simple analysis tool to inspect multimedia content.
  • ffserver is a multimedia streaming server for live broadcasts.
  • Additional small tools such as aviocat, ismindex and qt-faststart.

Documentation

The offline documentation is available in the doc/ directory.

The online documentation is available in the main website and in the wiki.

Examples

Coding examples are available in the doc/examples directory.

License

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 and will be ignored.