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

Paul B Mahol onemda at gmail.com
Sat Feb 13 20:35:08 CET 2016


On 2/13/16, Stefano Sabatini <stefasab at gmail.com> wrote:
> 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)

It just recreates different filtergraph depending on what lua executes,
pretty dumb really.


More information about the ffmpeg-devel mailing list