MP4 Library

Andrea Fontana nospam at example.org
Wed Sep 11 16:23:16 UTC 2024


On Monday, 19 August 2024 at 18:18:57 UTC, Ron Tarrant wrote:
> Hi all,
> Anyone know of a library similar to OpenCV that can be used 
> from D to create MP4 files from a series of images? I think I 
> came across some mention of OpenCV bindings, but I can't find 
> it now.
>
> Any help would be most welcome and appreciated. Thanks.

```
import std;

void main()
{

    // A mp4 1fps (-r 1) with standard settings
    auto pp = pipeShell("ffmpeg -y -r 1 -f png_pipe -c:v png -i - 
-c:v libx264 -crf 24 test.mp4", Redirect.all);

    // Feed frames from stdin
    pp.stdin.rawWrite(std.file.read("/path/to/your/frame1.png"));
    pp.stdin.rawWrite(std.file.read("/path/to/your/frame2.png"));
    pp.stdin.rawWrite(std.file.read("/path/to/your/frame3.png"));

    // Flush & close stdin
    pp.stdin.flush();
    pp.stdin.close();

    // Wait for ffmpeg to finish the job
    pp.pid.wait();
}
```

Andrea


More information about the Digitalmars-d mailing list