Skip to content

Commit

Permalink
Add avfilter link (#935)
Browse files Browse the repository at this point in the history
The avfilter link can do anything the avfilter filter can do.

Additionally, the link properly handles the adeclick filter by
providing future frames to overcome the delay required by that
avfilter.

In the future, more avfilter types can be optimized with future
frames if they also require a delay.
  • Loading branch information
bmatherly committed Aug 13, 2023
1 parent 5f9200e commit 310e220
Show file tree
Hide file tree
Showing 3 changed files with 1,128 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/modules/avformat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if(TARGET PkgConfig::libavcodec)
endif()

if(TARGET PkgConfig::libavfilter)
target_sources(mltavformat PRIVATE filter_avfilter.c link_avdeinterlace.c)
target_sources(mltavformat PRIVATE filter_avfilter.c link_avdeinterlace.c link_avfilter.c)
target_link_libraries(mltavformat PRIVATE PkgConfig::libavfilter)
target_compile_definitions(mltavformat PRIVATE AVFILTER)
endif()
Expand Down
12 changes: 11 additions & 1 deletion src/modules/avformat/factory.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extern mlt_filter filter_swscale_init(mlt_profile profile, char *arg);
extern mlt_producer producer_avformat_init(mlt_profile profile, const char *service, char *file);
extern mlt_filter filter_avfilter_init(mlt_profile, mlt_service_type, const char *, char *);
extern mlt_link link_avdeinterlace_init(mlt_profile, mlt_service_type, const char *, char *);
extern mlt_link link_avfilter_init(mlt_profile, mlt_service_type, const char *, char *);
extern mlt_link link_swresample_init(mlt_profile profile, mlt_service_type, const char *, char *);

// ffmpeg Header files
Expand Down Expand Up @@ -345,7 +346,11 @@ static mlt_properties avfilter_metadata(mlt_service_type type, const char *id, v
"numeric properties have type string because they accept an expression (see FFmpeg "
"documentation) even though they evaluate to a numeric value.");
mlt_properties_set(metadata, "creator", "libavfilter maintainers");
mlt_properties_set(metadata, "type", "filter");
if (type == mlt_service_filter_type) {
mlt_properties_set(metadata, "type", "filter");
} else {
mlt_properties_set(metadata, "type", "link");
}

mlt_properties tags = mlt_properties_new();
mlt_properties_set_data(metadata, "tags", tags, 0, (mlt_destructor) mlt_properties_close, NULL);
Expand Down Expand Up @@ -506,6 +511,11 @@ MLT_REPOSITORY
service_name,
avfilter_metadata,
(void *) f->name);
MLT_REGISTER(mlt_service_link_type, service_name, link_avfilter_init);
MLT_REGISTER_METADATA(mlt_service_link_type,
service_name,
avfilter_metadata,
(void *) f->name);
}
}
mlt_properties_close(blacklist);
Expand Down
Loading

0 comments on commit 310e220

Please sign in to comment.