[FFmpeg-devel] [RFC][WIP][PATCH] avfilter: add luascript filter

Stefano Sabatini stefasab at gmail.com
Sat Feb 13 18:36:09 CET 2016


On date Thursday 2016-02-04 19:40:18 +0100, Paul B Mahol encoded:
> On 2/2/16, Paul B Mahol <onemda at gmail.com> wrote:
> > Hi,
> >
> > patch attached.
> >
> 
> Much more useful version attached.
> 
> Simple demo demonstrating functionality currently missing in lavfi:

I toyed with this idea three years ago, and I'll show you my (crappy)
POC patch which assumes a different design (resuming: I wanted to
implement a lua function to filter the media buffer, and possibly add
other hooks to call during configuration).

Sample lua script file:

frame = 0

function init()
         print "hello world!"
         print(l_sin(239))
end

function filter_frame()
         print(string.format('frame number %d', frame))
         frame = frame + 1
end

I gave up because I realized that with that approach I also needed to
script most FFmpeg functions, that is I needed to script FFmpeg as a
whole, which hugely extended the scope of the task.

> 
> lavfi.log(0, "Lavfi script example", lavfi.script_name, lavfi.frame_count(0));
> if (lavfi.frame_count(0) >= 50) then
>     lavfi.filter({"aa"}, "vflip", nil, {"a"})
>     lavfi.filter({"bb"}, "hflip", nil, {"b"})
> else
>     lavfi.filter({"aa"}, "negate", nil, {"a"})
>     lavfi.filter({"bb"}, "vflip",  nil, {"b"})
> end
> 
> lavfi.filter({"a", "b"}, "hstack", "2", {"out0"});

Can you shortly give a description of how this code interface with lua?
(alternatively write docs, assuming you plan to land a committable version)

> From a84f155924b2235162d690664c97b55477d0a4c2 Mon Sep 17 00:00:00 2001
> From: Paul B Mahol <onemda at gmail.com>
> Date: Tue, 2 Feb 2016 10:09:50 +0100
> Subject: [PATCH] avfilter: add luascript filter
> 
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  configure                   |   4 +
>  libavfilter/Makefile        |   1 +
>  libavfilter/allfilters.c    |   1 +
>  libavfilter/src_luascript.c | 793 ++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 799 insertions(+)
>  create mode 100644 libavfilter/src_luascript.c

[...]
-- 
FFmpeg = Free and Frightening Maxi Portentous Evangelical Glue
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavfi-add-lua-filter.patch
Type: text/x-diff
Size: 11380 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160213/8774b3a6/attachment.patch>


More information about the ffmpeg-devel mailing list