History

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.

Stefano Sabatini committed 14 years ago

Commit 8b03cd31 parent bd6240e3 files · +36 −1Browse files

Unified · Split

3 files
  1. doc/indevs.texi +6 −0
  2. libavdevice/lavfi.c +29 −0
  3. libavfilter/version.h +1 −1
doc/indevs.texi+6−0
@@ -320,6 +320,12 @@ label, but all the others need to be specified explicitly. · 319 unmodified lines
320 320
321If not specified defaults to the filename specified for the input321If not specified defaults to the filename specified for the input
322device.322device.
323
324@item graph_file
325Set the filename of the filtergraph to be read and sent to the other
326filters. Syntax of the filtergraph is the same as the one specified by
327the option @var{graph}.
328
323@end table329@end table
324 330
325@subsection Examples331@subsection Examples
libavdevice/lavfi.c+29−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
28#include "float.h" /* DBL_MIN, DBL_MAX */28#include "float.h" /* DBL_MIN, DBL_MAX */
29 29
30#include "libavutil/bprint.h"30#include "libavutil/bprint.h"
31#include "libavutil/file.h"
31#include "libavutil/log.h"32#include "libavutil/log.h"
32#include "libavutil/mem.h"33#include "libavutil/mem.h"
33#include "libavutil/opt.h"34#include "libavutil/opt.h"
@@ -43,6 +44,7 @@ · 9 unmodified lines
43typedef struct {44typedef struct {
44 AVClass *class; ///< class for private options45 AVClass *class; ///< class for private options
45 char *graph_str;46 char *graph_str;
47 char *graph_filename;
46 char *dump_graph;48 char *dump_graph;
47 AVFilterGraph *graph;49 AVFilterGraph *graph;
48 AVFilterContext **sinks;50 AVFilterContext **sinks;
@@ -104,6 +106,32 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) · 55 unmodified lines
104 buffersink = avfilter_get_by_name("ffbuffersink");106 buffersink = avfilter_get_by_name("ffbuffersink");
105 abuffersink = avfilter_get_by_name("ffabuffersink");107 abuffersink = avfilter_get_by_name("ffabuffersink");
106 108
109 if (lavfi->graph_filename && lavfi->graph_str) {
110 av_log(avctx, AV_LOG_ERROR,
111 "Only one of the graph or graph_file options must be specified\n");
112 return AVERROR(EINVAL);
113 }
114
115 if (lavfi->graph_filename) {
116 uint8_t *file_buf, *graph_buf;
117 size_t file_bufsize;
118 ret = av_file_map(lavfi->graph_filename,
119 &file_buf, &file_bufsize, 0, avctx);
120 if (ret < 0)
121 return ret;
122
123 /* create a 0-terminated string based on the read file */
124 graph_buf = av_malloc(file_bufsize + 1);
125 if (!graph_buf) {
126 av_file_unmap(file_buf, file_bufsize);
127 return AVERROR(ENOMEM);
128 }
129 memcpy(graph_buf, file_buf, file_bufsize);
130 graph_buf[file_bufsize] = 0;
131 av_file_unmap(file_buf, file_bufsize);
132 lavfi->graph_str = graph_buf;
133 }
134
107 if (!lavfi->graph_str)135 if (!lavfi->graph_str)
108 lavfi->graph_str = av_strdup(avctx->filename);136 lavfi->graph_str = av_strdup(avctx->filename);
109 137
@@ -376,6 +404,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) · 266 unmodified lines
376 404
377static const AVOption options[] = {405static const AVOption options[] = {
378 { "graph", "set libavfilter graph", OFFSET(graph_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },406 { "graph", "set libavfilter graph", OFFSET(graph_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
407 { "graph_file","set libavfilter graph filename", OFFSET(graph_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC},
379 { "dumpgraph", "dump graph to stderr", OFFSET(dump_graph), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },408 { "dumpgraph", "dump graph to stderr", OFFSET(dump_graph), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
380 { NULL },409 { NULL },
381};410};
libavfilter/version.h+1−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
30 30
31#define LIBAVFILTER_VERSION_MAJOR 331#define LIBAVFILTER_VERSION_MAJOR 3
32#define LIBAVFILTER_VERSION_MINOR 2032#define LIBAVFILTER_VERSION_MINOR 20
33#define LIBAVFILTER_VERSION_MICRO 10433#define LIBAVFILTER_VERSION_MICRO 105
34 34
35#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \35#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
36 LIBAVFILTER_VERSION_MINOR, \36 LIBAVFILTER_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t