ffmpeg/doc/examples
Jiasheng Jiang 013d39a06c
examples: Add check and replace av_free() to avoid potential memory errors
Add check for the return value of av_packet_alloc() to avoid potential NULL pointer dereference.
Moreover, replace redundant av_free() with fprintf().

Fixes: 9a38184a14 ("examples/decode_audio: allocate the packet dynamically")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c64cff64a2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-30 21:38:19 +01:00
..
.gitignore examples/avio_dir_cmd: drop support for move/delete operations 2020-03-16 09:23:37 +01:00
avio_list_dir.c examples/avio_dir_cmd: drop support for move/delete operations 2020-03-16 09:23:37 +01:00
avio_reading.c examples: Add av_freep to avoid potential memory leak 2025-11-30 21:38:17 +01:00
decode_audio.c examples: Add check and replace av_free() to avoid potential memory errors 2025-11-30 21:38:19 +01:00
decode_video.c doc/examples: Always open files as "binary", not "text". 2020-08-25 18:54:50 +02:00
demuxing_decoding.c doc/examples/demux_decode: Simplify loop 2024-06-15 23:32:45 +02:00
encode_audio.c examples: Don't call deprecated functions which don't do anything 2018-02-09 21:38:42 +00:00
encode_video.c Stop hardcoding align=32 in av_frame_get_buffer() calls. 2020-05-22 14:38:57 +02:00
extract_mvs.c examples: Don't call deprecated functions which don't do anything 2018-02-09 21:38:42 +00:00
filter_audio.c lav*,tests: remove several register_all calls 2018-04-02 03:26:22 +01:00
filtering_audio.c doc/examples/filtering_audio: Remove setting deprecated refcounted_frames 2018-04-22 15:39:22 +08:00
filtering_video.c examples/filtering_video: fix memory leak 2018-05-16 00:39:52 +02:00
http_multiclient.c examples: Don't call deprecated functions which don't do anything 2018-02-09 21:38:42 +00:00
hw_decode.c doc/examples: Always open files as "binary", not "text". 2020-08-25 18:54:50 +02:00
Makefile examples/avio_dir_cmd: drop support for move/delete operations 2020-03-16 09:23:37 +01:00
Makefile.example examples/avio_dir_cmd: drop support for move/delete operations 2020-03-16 09:23:37 +01:00
metadata.c doc/examples/metadata: fix the example can't dump FLV metadata 2019-04-07 10:18:42 +08:00
muxing.c doc/examples/mux: remove nop 2024-07-21 21:43:30 +02:00
qsvdec.c examples: Don't call deprecated functions which don't do anything 2018-02-09 21:38:42 +00:00
README doc/examples/README: fix typo 2013-12-02 14:35:39 +01:00
remuxing.c examples: Don't call deprecated functions which don't do anything 2018-02-09 21:38:42 +00:00
resampling_audio.c doc/examples: remove unneeded NULL checks 2014-09-14 16:45:50 +02:00
scaling_video.c doc/examples: remove unneeded NULL checks 2014-09-14 16:45:50 +02:00
transcode_aac.c doc/examples/transcode_aac: use av_packet_alloc() to allocate packets 2021-03-17 15:19:37 -03:00
transcoding.c doc/examples/transcoding: use av_packet_alloc() to allocate packets 2021-03-17 15:19:37 -03:00
vaapi_encode.c doc/examples/vaapi_encode: Try to check fwrite() for failure 2024-07-21 21:39:09 +02:00
vaapi_transcode.c doc/examples/vaapi_transcode: Simplify loop 2024-06-15 23:32:42 +02:00

FFmpeg examples README
----------------------

Both following use cases rely on pkg-config and make, thus make sure
that you have them installed and working on your system.


Method 1: build the installed examples in a generic read/write user directory

Copy to a read/write user directory and just use "make", it will link
to the libraries on your system, assuming the PKG_CONFIG_PATH is
correctly configured.

Method 2: build the examples in-tree

Assuming you are in the source FFmpeg checkout directory, you need to build
FFmpeg (no need to make install in any prefix). Then just run "make examples".
This will build the examples using the FFmpeg build system. You can clean those
examples using "make examplesclean"

If you want to try the dedicated Makefile examples (to emulate the first
method), go into doc/examples and run a command such as
PKG_CONFIG_PATH=pc-uninstalled make.