Enhance Avisynth video workflow and metadata tools

This commit is contained in:
ajp_anton
2026-07-30 03:20:19 +00:00
parent d60ce51b14
commit 100cad1cb5
26 changed files with 2350 additions and 1161 deletions
+51 -2
View File
@@ -36,6 +36,7 @@ static AVS_Library* avs_library = NULL;
#define avs_is_yv16 avs_library->avs_is_yv16
#define avs_is_yv24 avs_library->avs_is_yv24
#define avs_prop_get_int avs_library->avs_prop_get_int
#define avs_prop_get_float avs_library->avs_prop_get_float
#define avs_release_clip avs_library->avs_release_clip
#define avs_release_value avs_library->avs_release_value
#define avs_release_video_frame avs_library->avs_release_video_frame
@@ -217,6 +218,7 @@ static int require_frame_property_api(FILE* log) {
if (
avs_get_frame_props_ro
&& avs_prop_get_int
&& avs_prop_get_float
) {
return 1;
}
@@ -322,6 +324,13 @@ static int read_int_frame_prop(
int64_t* value_out
);
static int read_float_frame_prop(
AVS_ScriptEnvironment* env,
const AVS_VideoFrame* frame,
const char* name,
double* value_out
);
static int write_wav(AVS_Clip* clip, const AVS_VideoInfo* vi) {
if (!avs_has_audio(vi)) {
fprintf(stderr, "script has no audio\n");
@@ -463,6 +472,29 @@ static int read_int_frame_prop(
return 1;
}
static int read_float_frame_prop(
AVS_ScriptEnvironment* env,
const AVS_VideoFrame* frame,
const char* name,
double* value_out
) {
const AVS_Map* props = avs_get_frame_props_ro(env, frame);
if (!props) {
return 0;
}
int error = AVS_GETPROPERROR_SUCCESS;
double value = avs_prop_get_float(env, props, name, 0, &error);
if (error == AVS_GETPROPERROR_UNSET || error == AVS_GETPROPERROR_INDEX) {
return 0;
}
if (error != AVS_GETPROPERROR_SUCCESS) {
return -1;
}
*value_out = value;
return 1;
}
static int write_validation_row(
FILE* csv,
AVS_ScriptEnvironment* env,
@@ -473,11 +505,21 @@ static int write_validation_row(
int64_t source_frame = 0;
int64_t drop_frame = 0;
int64_t matrix = 0;
int64_t primaries = 0;
int64_t transfer = 0;
int64_t color_range = 0;
double absolute_timestretch = 0.0;
int source_id_status = read_int_frame_prop(env, frame, "mbt_source_id", &source_id);
int source_frame_status = read_int_frame_prop(env, frame, "mbt_source_frame", &source_frame);
int drop_frame_status = read_int_frame_prop(env, frame, "mbt_drop_frame", &drop_frame);
int matrix_status = read_int_frame_prop(env, frame, "_Matrix", &matrix);
if (source_id_status < 0 || source_frame_status < 0 || drop_frame_status < 0 || matrix_status < 0) {
int primaries_status = read_int_frame_prop(env, frame, "_Primaries", &primaries);
int transfer_status = read_int_frame_prop(env, frame, "_Transfer", &transfer);
int color_range_status = read_int_frame_prop(env, frame, "_ColorRange", &color_range);
int absolute_timestretch_status = read_float_frame_prop(
env, frame, "mbt_absolute_timestretch", &absolute_timestretch
);
if (source_id_status < 0 || source_frame_status < 0 || drop_frame_status < 0 || matrix_status < 0 || primaries_status < 0 || transfer_status < 0 || color_range_status < 0 || absolute_timestretch_status < 0) {
fprintf(stderr, "failed to read media-batch-tools frame properties at frame %d\n", output_frame);
return 12;
}
@@ -494,6 +536,13 @@ static int write_validation_row(
if (matrix_status > 0) {
fprintf(csv, "%lld", (long long)matrix);
}
fprintf(csv, ",%lld,%lld,%lld,",
primaries_status > 0 ? (long long)primaries : 0LL,
transfer_status > 0 ? (long long)transfer : 0LL,
color_range_status > 0 ? (long long)color_range : 0LL);
if (absolute_timestretch_status > 0) {
fprintf(csv, "%.17g", absolute_timestretch);
}
fputc('\n', csv);
return 0;
}
@@ -546,7 +595,7 @@ static int render_clip(
fprintf(stderr, "failed to open validation CSV for writing: %s\n", validation_csv_path);
return 11;
}
fputs("output_frame,source_id,source_frame,drop_frame,matrix\n", validation_csv);
fputs("output_frame,source_id,source_frame,drop_frame,matrix,primaries,transfer,color_range,absolute_timestretch\n", validation_csv);
fflush(validation_csv);
}
}
Binary file not shown.
Binary file not shown.