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.
Showing the changes to libavfilter (2 of 3 files). Show all
Unified · Split
| @@ -32,7 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "version_major.h" |
| 33 | 33 | |
| 34 | 34 | #define LIBAVFILTER_VERSION_MINOR 14 |
| 35 | −#define LIBAVFILTER_VERSION_MICRO 101 | |
| 35 | +#define LIBAVFILTER_VERSION_MICRO 102 | |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | * filter for showing textual video frame information |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | +#include <ctype.h> | |
| 25 | 26 | #include <inttypes.h> |
| 26 | 27 | |
| 27 | 28 | #include "libavutil/bswap.h" |
| @@ -52,6 +53,7 @@ · 24 unmodified lines | ||
| 52 | 53 | typedef struct ShowInfoContext { |
| 53 | 54 | const AVClass *class; |
| 54 | 55 | int calculate_checksums; |
| 56 | + int udu_sei_as_ascii; | |
| 55 | 57 | } ShowInfoContext; |
| 56 | 58 | |
| 57 | 59 | #define OFFSET(x) offsetof(ShowInfoContext, x) |
| @@ -59,6 +61,8 @@ typedef struct ShowInfoContext { · 1 unmodified line | ||
| 59 | 61 | |
| 60 | 62 | static const AVOption showinfo_options[] = { |
| 61 | 63 | { "checksum", "calculate checksums", OFFSET(calculate_checksums), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, VF }, |
| 64 | + { "udu_sei_as_ascii", "try to print user data unregistered SEI as ascii character when possible", | |
| 65 | + OFFSET(udu_sei_as_ascii), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VF }, | |
| 62 | 66 | { NULL } |
| 63 | 67 | }; |
| 64 | 68 | |
| @@ -418,6 +422,7 @@ static void dump_video_enc_params(AVFilterContext *ctx, const AVFrameSideData *s · 353 unmodified lines | ||
| 418 | 422 | static void dump_sei_unregistered_metadata(AVFilterContext *ctx, const AVFrameSideData *sd) |
| 419 | 423 | { |
| 420 | 424 | const uint8_t *user_data = sd->data; |
| 425 | + ShowInfoContext *s = ctx->priv; | |
| 421 | 426 | |
| 422 | 427 | if (sd->size < AV_UUID_LEN) { |
| 423 | 428 | av_log(ctx, AV_LOG_ERROR, "invalid data(%"SIZE_SPECIFIER" < " |
| @@ -428,8 +433,13 @@ static void dump_sei_unregistered_metadata(AVFilterContext *ctx, const AVFrameSi · 4 unmodified lines | ||
| 428 | 433 | av_log(ctx, AV_LOG_INFO, "UUID=" AV_PRI_UUID "\n", AV_UUID_ARG(user_data)); |
| 429 | 434 | |
| 430 | 435 | av_log(ctx, AV_LOG_INFO, "User Data="); |
| 431 | − for (size_t i = 16; i < sd->size; i++) | |
| 432 | − av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]); | |
| 436 | + for (size_t i = 16; i < sd->size; i++) { | |
| 437 | + const char *format = "%02x"; | |
| 438 | + | |
| 439 | + if (s->udu_sei_as_ascii) | |
| 440 | + format = isprint(user_data[i]) ? "%c" : "\\x%02x"; | |
| 441 | + av_log(ctx, AV_LOG_INFO, format, user_data[i]); | |
| 442 | + } | |
| 433 | 443 | av_log(ctx, AV_LOG_INFO, "\n"); |
| 434 | 444 | } |
| 435 | 445 | |