www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - MP4 Library

reply Ron Tarrant <rontarrant gmail.com> writes:
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.
Aug 19
next sibling parent reply Jordan Wilson <wilsonjord gmail.com> writes:
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.
dcv might be something you are interested in looking at. I've used dmagick + process pipes to `ffmpeg` myself, and found it pretty straightforward (dmagick might be heavy for your use, if it's just simply image loading there'll be more lightweight libs available I imagine). Jordan
Aug 19
next sibling parent Ron Tarrant <rontarrant gmail.com> writes:
On Tuesday, 20 August 2024 at 03:32:03 UTC, Jordan Wilson wrote:

 dcv might be something you are interested in looking at.
 I've used dmagick + process pipes to `ffmpeg` myself
Thanks, Jordan. I'll check those out.
Aug 20
prev sibling parent Elias Batek <desisma heidel.beer> writes:
On Tuesday, 20 August 2024 at 03:32:03 UTC, Jordan Wilson wrote:
 process pipes to `ffmpeg`
By the way, there’s a wrapper for this exact purpose in arsd: https://github.com/adamdruppe/arsd/blob/master/pixmaprecorder.d
Aug 21
prev sibling next sibling parent reply IchorDev <zxinsworld gmail.com> writes:
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.
If you know how to use ffmpeg as a library then there’s very good bindings in the form of [ffmpeg-d](https://code.dlang.org/packages/ffmpeg-d). If you have never used ffmpeg as a library then I’ll send you a warning: the API is confusing, the documentation is vague, and every example you can find online will use deprecated/removed functionality somewhere. Other than that, the existing options for encoding videos in D are pretty sparse. I would love to write some bindings to try and help the situation, but I’m not sure what libraries would be good. Are there any C/C++ libraries that developers prefer for video encoding, decoding, and manipulation?
Aug 22
next sibling parent Paolo Invernizzi <paolo.invernizzi gmail.com> writes:
On Thursday, 22 August 2024 at 14:01:50 UTC, IchorDev wrote:
 On Monday, 19 August 2024 at 18:18:57 UTC, Ron Tarrant wrote:
 [...]
If you know how to use ffmpeg as a library then there’s very good bindings in the form of [ffmpeg-d](https://code.dlang.org/packages/ffmpeg-d). If you have never used ffmpeg as a library then I’ll send you a warning: the API is confusing, the documentation is vague, and every example you can find online will use deprecated/removed functionality somewhere. Other than that, the existing options for encoding videos in D are pretty sparse. I would love to write some bindings to try and help the situation, but I’m not sure what libraries would be good. Are there any C/C++ libraries that developers prefer for video encoding, decoding, and manipulation?
Just to add that importC works pretty fine against ffmpeg, and it's a big plus as ffmpeg API is pretty fluid from release to release.
Aug 26
prev sibling parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Thursday, 22 August 2024 at 14:01:50 UTC, IchorDev wrote:
 On Monday, 19 August 2024 at 18:18:57 UTC, Ron Tarrant wrote:
 If you
have never used ffmpeg as a library then I’ll send you a warning: the API is confusing, the documentation is vague, and every example you can find online will use deprecated/removed functionality somewhere.
LOL! That's very comforting. :)
 Other than that, the existing options for encoding videos in D 
 are pretty sparse. I would love to write some bindings to try 
 and help the situation, but I’m not sure what libraries would 
 be good. Are there any C/C++ libraries that developers prefer 
 for video encoding, decoding, and manipulation?
I saw an initial stab at creating OpenCV bindings, but it hasn't been touched in years. Perhaps that might be of interest?
Sep 11
next sibling parent Paolo Invernizzi <paolo.invernizzi gmail.com> writes:
On Wednesday, 11 September 2024 at 07:26:32 UTC, Ron Tarrant 
wrote:
 On Thursday, 22 August 2024 at 14:01:50 UTC, IchorDev wrote:
 On Monday, 19 August 2024 at 18:18:57 UTC, Ron Tarrant wrote:
 Are there any C/C++ libraries that developers prefer for video 
 encoding, decoding, and manipulation?
I saw an initial stab at creating OpenCV bindings, but it hasn't been touched in years. Perhaps that might be of interest?
I suggest to go directly for ffmpeg usage, importC is pretty usable with that. It's pretty low level, but it's the common engine for a bazar of external tools. /P
Sep 11
prev sibling parent IchorDev <zxinsworld gmail.com> writes:
On Wednesday, 11 September 2024 at 07:26:32 UTC, Ron Tarrant 
wrote:
 On Thursday, 22 August 2024 at 14:01:50 UTC, IchorDev wrote:

 LOL! That's very comforting. :)
Yes, rest assured: it sucks!
 I saw an initial stab at creating OpenCV bindings, but it 
 hasn't been touched in years. Perhaps that might be of interest?
Do people like OpenCV? I don't hear about it much. Also, were these bindings to the C or C++ API?
Sep 20
prev sibling parent reply Andrea Fontana <nospam example.org> writes:
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
Sep 11
parent Guillaume Piolat <guillaume.piolat gmail.com> writes:
On Wednesday, 11 September 2024 at 16:23:16 UTC, Andrea Fontana 
wrote:
 ```
 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
If you want to create a .y4m file without ffmpeg, here is old code (probably doesn't really build anymore): - https://github.com/p0nce/y4m-d let's you create a .y4m - https://github.com/p0nce/y4m-tools for manipulating such files - in particular, creating a YUV frame necessitate conversion from sRGB such as in https://github.com/p0nce/y4m-tools/blob/master/shader-capture/source/app.d#L359
Sep 11