Encoding of video using built in Windows functionality (Media Foundation)? - delphi

I've been investigating various method of exporting video from my FMX application, in particular mp4 using the h.264 codec. One method is to use FFmpeg with the FFVCL components. The down side of this is that including FFmpeg dlls with my application increases the download size. The other problem is the licensing issue of using the libx264 encoder. There is a free to use libopenh264 encoder but isn't as good as it only supports the Baseline profile.
However, Windows has video encoding built in which includes the full h.264 with High profile (mfh264enc.dll). This seems like the ideal solution for high quality video export while minimising the size of my application and avoiding licensing problems. The following page gives information on the video encoding interface in Windows.
https://learn.microsoft.com/en-us/windows/win32/medfound/overview-of-encoding-in-media-foundation
My question is how can I call this from Delphi to export video from a sequence of images stored in TBitmap? My application is FMX but initially only for Windows. Has anyone already created a Delphi interface for video encoding using the built in Windows dlls? I don't have much experience with calling dlls from Delphi. How much work would it be to create an interface myself?

Related

Determining video file properties using DSpack and Delphi7

I would like to determine various properties from a video file (eg MP4) such as the length of the video etc but I have no experience of working with multimedia Can anyone help
Thanks
MIke
You don't need to use DSPack for this task.
Use the dll version of the MediaInfo library (the download comes with a Pascal demo and Google/Bing/Yahoo!/whatever come for more). Plus, you don't rely on the installed codecs of a machine as MediaInfo is independent.

delphi webcam capture : why does it not work on laptop?

I have tried many webcam components for delphi XE (Tcamera, TJVAviCapture, sources codes I found...) Mostly of them work on my desktop computers, but does not work on my maptop (tested with 2 laptops).
They open this source video window, and then webcam panel.
Some of them work in DELPHI IDE but not in .exe generated by delphi !
Does someone know a reliable component (or a snippet) that simply display the webcam on any laptop or dektop without showing that video source window ?
Regards
I've been using the Mitov Video Library for several years to do this sort of thing and am very happy with it. It's run my webcam application on many hundreds laptops and desktops all over the world without any problems. Free for non-commercial use. Regularly updated. Good support. Source code available.
http://www.mitov.com/screenshots/videolab

Library or component for creating video files (AVI, etc.) with Delphi 6 (C/C++ OK too)?

I have a stream of JPEG frames and accompanying audio buffers that I want to write to a video file. If possible, I'd like to let the user choose their format from the available Windows codecs if the library/component supports the use of those. If not, then if it can create something popular like AVI, WMV, or MOV format files then that would be fine. Does anyone know of a good library or component compatible with Delphi 6 that can do this? If not, a C/C++ sample would work too.
For AVI you may want to check if you have access to the AVIFile APIs from Delphi. This question suggests it is possible.
For WMV look for DirectShow access.
For MOV you can use the free Quicktime SDK.
It appears the JEDI site might have some API bindings that you can use.

How to display a thumb image or first frame from a MP4 file using Delphi 7

I need to display a thumbnail preview of a folder full of MP4 files.
So, is there a Delphi 7 component which extract a thumbnail image from MP4 files (if MP4 does contain a thumbnail image), or is there a Delphi 7 component which can extract the 1st frame from a MP4 file ?
I need to extract it so I can save it to a .jpg or .png file (to be used again later on).
Any ideas, Thanks.
Delphi's video processing capabilities are really limited. But it does include a simple activeX/OLE media player. So one option is to use the media player component to open the MP4 file, then snapshot the BMP surface. Then resize and save that BMP. But... that requires that your user has all the neccessary MP4 demuxers and decoders for windows media player to play the whole MP4 file, which they might not have installed yet. And you might run into anamorphic aspect ratios in your video image.
Another option is to use the wonderful free and open source ffmpeg.org project. It can open and re-save literally thousands of audio/video/image files using 1 small EXE. Your delphi program could just pop out a ffmpeg.exe commandline that extracts a single frame from any point in the movie and then ffmpeg can resize and save to jpg. All you'd have to do is wait for the JPG to write.
If you don't want to go the commandline route, and don't mind paying for a component, you could buy FFVCL from www.delphiffmpeg.com. It's a VCL wrapper for ffmpeg. I've never used it myself, but it supposedly can do anything a ffmpeg.exe commandline can do, but instead within the Delphi IDE from a VCL wrapper.
There's also free Pascal headers, to use ffmpeg in delphi from it's C APIs and DLLs if you're adventuresome. www.iversenit.dk/dev/ffmpeg-headers

Where can I find a free/opensource Delphi multimedia component?

I was in a project where I must be able to play almost audio/video files (format).
The requirements:
Video:
.dat (vcd & svcd)
.vob (dvd)
.rmvb (real media)
.mp4 (mpeg4/x264/h264)
.wmv/.asf (windows media)
.avi (xvid/divx/mpeg2,etc...)
.mkv (matroska, optional)
Audio:
.mp3 (you probably know this)
.ogg (vorbis)
.wma (windows media)
.wav (wave)
I already have all of the above codecs installed and working perfect on my system (tried it with WMP 10, Media Player Classic Home Cinema, VLC & Zoom Player).
And I have already tried the basic TMediaPlayer but can't work on other beside .avi for video, then i grab DSPack but it can't play .avi (xvid/divx) nor .mkv, i grab VLC but it's only gave me more headache because it was only ActiveX wrapper (no pure vcl component).
Can someone suggest another component? Free or open source would be preferred.
Edit:
I already solve issue with DSPack, it looks like I have to use always FDDShow for video playing using DSPack.
You can import the WMP 10 ActiveX control (Component->Import Component menu item), and then embed WMP into your application.
Since it's part of the operating system, can't get any more free than that; if you can run your Delphi app, the OS is there. :-)
DSPack was going to be my suggestion. I'm not sure what problems you had with DivX - I've used the free DivX codec with a DSPack-based program for years. FFDShow looks like a promising solution, too, although I've experienced problems with the quality of playback (tearing, low frame rates, instability when playing for a long periond, etc.) for some types of files. The video hardware and drivers are also very important, and unless you're supplying the complete hardware, software and image package, the users of your program may run into different problems in terms of the subjective acceptability (to them) of the playback. Keep that in mind - codec versions are important, driver versions are crucial, and some hardware just doesn't work right, no matter what the manufacturer says.

Resources