lavd/lavfi: add graph_file option
Allow to specify a filename where to put the filtergraph description. This is useful to override limitations or glitches of particular shell environments, and allows a level of indirection for specifying filtergraphs.
This commit is contained in:
parent
bd6240e7e9
commit
8b03cd3cd7
@ -320,6 +320,12 @@ label, but all the others need to be specified explicitly.
|
|||||||
|
|
||||||
If not specified defaults to the filename specified for the input
|
If not specified defaults to the filename specified for the input
|
||||||
device.
|
device.
|
||||||
|
|
||||||
|
@item graph_file
|
||||||
|
Set the filename of the filtergraph to be read and sent to the other
|
||||||
|
filters. Syntax of the filtergraph is the same as the one specified by
|
||||||
|
the option @var{graph}.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@subsection Examples
|
@subsection Examples
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "float.h" /* DBL_MIN, DBL_MAX */
|
#include "float.h" /* DBL_MIN, DBL_MAX */
|
||||||
|
|
||||||
#include "libavutil/bprint.h"
|
#include "libavutil/bprint.h"
|
||||||
|
#include "libavutil/file.h"
|
||||||
#include "libavutil/log.h"
|
#include "libavutil/log.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
@ -43,6 +44,7 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
AVClass *class; ///< class for private options
|
AVClass *class; ///< class for private options
|
||||||
char *graph_str;
|
char *graph_str;
|
||||||
|
char *graph_filename;
|
||||||
char *dump_graph;
|
char *dump_graph;
|
||||||
AVFilterGraph *graph;
|
AVFilterGraph *graph;
|
||||||
AVFilterContext **sinks;
|
AVFilterContext **sinks;
|
||||||
@ -104,6 +106,32 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
|
|||||||
buffersink = avfilter_get_by_name("ffbuffersink");
|
buffersink = avfilter_get_by_name("ffbuffersink");
|
||||||
abuffersink = avfilter_get_by_name("ffabuffersink");
|
abuffersink = avfilter_get_by_name("ffabuffersink");
|
||||||
|
|
||||||
|
if (lavfi->graph_filename && lavfi->graph_str) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
|
"Only one of the graph or graph_file options must be specified\n");
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lavfi->graph_filename) {
|
||||||
|
uint8_t *file_buf, *graph_buf;
|
||||||
|
size_t file_bufsize;
|
||||||
|
ret = av_file_map(lavfi->graph_filename,
|
||||||
|
&file_buf, &file_bufsize, 0, avctx);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/* create a 0-terminated string based on the read file */
|
||||||
|
graph_buf = av_malloc(file_bufsize + 1);
|
||||||
|
if (!graph_buf) {
|
||||||
|
av_file_unmap(file_buf, file_bufsize);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
memcpy(graph_buf, file_buf, file_bufsize);
|
||||||
|
graph_buf[file_bufsize] = 0;
|
||||||
|
av_file_unmap(file_buf, file_bufsize);
|
||||||
|
lavfi->graph_str = graph_buf;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lavfi->graph_str)
|
if (!lavfi->graph_str)
|
||||||
lavfi->graph_str = av_strdup(avctx->filename);
|
lavfi->graph_str = av_strdup(avctx->filename);
|
||||||
|
|
||||||
@ -376,6 +404,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
|
|||||||
|
|
||||||
static const AVOption options[] = {
|
static const AVOption options[] = {
|
||||||
{ "graph", "set libavfilter graph", OFFSET(graph_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
|
{ "graph", "set libavfilter graph", OFFSET(graph_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
|
||||||
|
{ "graph_file","set libavfilter graph filename", OFFSET(graph_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC},
|
||||||
{ "dumpgraph", "dump graph to stderr", OFFSET(dump_graph), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
|
{ "dumpgraph", "dump graph to stderr", OFFSET(dump_graph), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#define LIBAVFILTER_VERSION_MAJOR 3
|
#define LIBAVFILTER_VERSION_MAJOR 3
|
||||||
#define LIBAVFILTER_VERSION_MINOR 20
|
#define LIBAVFILTER_VERSION_MINOR 20
|
||||||
#define LIBAVFILTER_VERSION_MICRO 104
|
#define LIBAVFILTER_VERSION_MICRO 105
|
||||||
|
|
||||||
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
|
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
|
||||||
LIBAVFILTER_VERSION_MINOR, \
|
LIBAVFILTER_VERSION_MINOR, \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user