[FFmpeg-devel] [PATCH] doc/examples/muxing: code rewrite with improved readability and fixed issues

Paolo Prete p4olo_prete at yahoo.it
Sat Jun 18 15:06:26 EEST 2022


Please review this. It's a code rewrite of doc/examples/muxing.c which improves readability and fixes issues.
More specifically:
*) Original functions of muxing.c have generic/unclear/ambiguous names and they don't group logically relatedblocks of code: this makes the code hard to read.See for example open_audio/video() and add_stream(), which mix initialization of the encoders' and muxers' stuff.A redundant structure with an ambiguous name ("struct OutputStream"), which is not part of API, is widely used too.The patch uses functions with clearer names and with blocks of code strictly logically related, such as: init_encoder(), init_avframe(), init_muxer(), convert_frame(), encode_frame(), mux_encoded_pkt()...
*) Errors are not always properly managed: in some cases they are not propagated to the main() function and a call to exit(1) is forced, causing memory leaks. This has been fixed as well.
*) The program doesn't work for some extensions (try for example: m4v or mjpeg). In addition, it gives weird results when the filename doesn't have an extension.This has been fixed by checking the filename and supporting a fixed set of extensions.
*) The program claims to output raw images by using '%%d' in the filename, but it actually doesn't. This has been fixed as well.
*) Input parameters such as width, height, sample_rate and ch_layout are now exposed at the level of the main() function and they are much easier to customize.
*) fprintf() has been replaced with av_log()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-doc-examples-muxing-code-rewrite-with-improved-reada.patch
Type: text/x-patch
Size: 40181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20220618/93d26d6a/attachment.bin>


More information about the ffmpeg-devel mailing list