avfilter/vf_showinfo: add udu_sei_as_ascii option
Some encoders (e.g., libx264) dump encoder configuration as user data unregistered SEI message. This option try to print it as ascii character when possible. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
parent
fb54c89a0d
commit
56ca0f2918
@ -21796,6 +21796,10 @@ This filter supports the following options:
|
|||||||
@table @option
|
@table @option
|
||||||
@item checksum
|
@item checksum
|
||||||
Calculate checksums of each plane. By default enabled.
|
Calculate checksums of each plane. By default enabled.
|
||||||
|
|
||||||
|
@item udu_sei_as_ascii
|
||||||
|
Try to print user data unregistered SEI as ascii character when possible,
|
||||||
|
in hex format otherwise.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
The shown line contains a sequence of key/value pairs of the form
|
The shown line contains a sequence of key/value pairs of the form
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "version_major.h"
|
#include "version_major.h"
|
||||||
|
|
||||||
#define LIBAVFILTER_VERSION_MINOR 14
|
#define LIBAVFILTER_VERSION_MINOR 14
|
||||||
#define LIBAVFILTER_VERSION_MICRO 101
|
#define LIBAVFILTER_VERSION_MICRO 102
|
||||||
|
|
||||||
|
|
||||||
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
|
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
* filter for showing textual video frame information
|
* filter for showing textual video frame information
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "libavutil/bswap.h"
|
#include "libavutil/bswap.h"
|
||||||
@ -52,6 +53,7 @@
|
|||||||
typedef struct ShowInfoContext {
|
typedef struct ShowInfoContext {
|
||||||
const AVClass *class;
|
const AVClass *class;
|
||||||
int calculate_checksums;
|
int calculate_checksums;
|
||||||
|
int udu_sei_as_ascii;
|
||||||
} ShowInfoContext;
|
} ShowInfoContext;
|
||||||
|
|
||||||
#define OFFSET(x) offsetof(ShowInfoContext, x)
|
#define OFFSET(x) offsetof(ShowInfoContext, x)
|
||||||
@ -59,6 +61,8 @@ typedef struct ShowInfoContext {
|
|||||||
|
|
||||||
static const AVOption showinfo_options[] = {
|
static const AVOption showinfo_options[] = {
|
||||||
{ "checksum", "calculate checksums", OFFSET(calculate_checksums), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, VF },
|
{ "checksum", "calculate checksums", OFFSET(calculate_checksums), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, VF },
|
||||||
|
{ "udu_sei_as_ascii", "try to print user data unregistered SEI as ascii character when possible",
|
||||||
|
OFFSET(udu_sei_as_ascii), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VF },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -418,6 +422,7 @@ static void dump_video_enc_params(AVFilterContext *ctx, const AVFrameSideData *s
|
|||||||
static void dump_sei_unregistered_metadata(AVFilterContext *ctx, const AVFrameSideData *sd)
|
static void dump_sei_unregistered_metadata(AVFilterContext *ctx, const AVFrameSideData *sd)
|
||||||
{
|
{
|
||||||
const uint8_t *user_data = sd->data;
|
const uint8_t *user_data = sd->data;
|
||||||
|
ShowInfoContext *s = ctx->priv;
|
||||||
|
|
||||||
if (sd->size < AV_UUID_LEN) {
|
if (sd->size < AV_UUID_LEN) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "invalid data(%"SIZE_SPECIFIER" < "
|
av_log(ctx, AV_LOG_ERROR, "invalid data(%"SIZE_SPECIFIER" < "
|
||||||
@ -428,8 +433,13 @@ static void dump_sei_unregistered_metadata(AVFilterContext *ctx, const AVFrameSi
|
|||||||
av_log(ctx, AV_LOG_INFO, "UUID=" AV_PRI_UUID "\n", AV_UUID_ARG(user_data));
|
av_log(ctx, AV_LOG_INFO, "UUID=" AV_PRI_UUID "\n", AV_UUID_ARG(user_data));
|
||||||
|
|
||||||
av_log(ctx, AV_LOG_INFO, "User Data=");
|
av_log(ctx, AV_LOG_INFO, "User Data=");
|
||||||
for (size_t i = 16; i < sd->size; i++)
|
for (size_t i = 16; i < sd->size; i++) {
|
||||||
av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
|
const char *format = "%02x";
|
||||||
|
|
||||||
|
if (s->udu_sei_as_ascii)
|
||||||
|
format = isprint(user_data[i]) ? "%c" : "\\x%02x";
|
||||||
|
av_log(ctx, AV_LOG_INFO, format, user_data[i]);
|
||||||
|
}
|
||||||
av_log(ctx, AV_LOG_INFO, "\n");
|
av_log(ctx, AV_LOG_INFO, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user