Recent

Author Topic: Get video file resolution  (Read 1762 times)

CodeSculptor

  • New Member
  • *
  • Posts: 10
Get video file resolution
« on: November 27, 2020, 10:39:20 am »
In Windows (7+, like 10) when you get file-properties for an AVI or MPG and such, you can see the frame-height, frame-width.

Is there a way to get that via Lazarus?

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: Get video file resolution
« Reply #1 on: November 27, 2020, 12:54:03 pm »
hello,
with the mediainfo dll and the delphi wrapper included in the zip download you can retrieve all media infos from a media file. See Attachment.
Friendly J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

CodeSculptor

  • New Member
  • *
  • Posts: 10
Re: Get video file resolution
« Reply #2 on: November 27, 2020, 04:08:01 pm »
There's a few problems in that. 
(1) The DLL wrapper relies on Wintypes and WinProcs.
So it breaks under Lazarus.

(2) Setting the Mode to Delphi didn't help, and even setting the type to win32 (to use Windows instead) produces "can't assign values to an address" errors for each MI_GetProcAddress( call in the DLL wrapper -- which is the entire DLL wrapper purpose.

Has anyone actually gotten the MediaInfoDLL wrapper to work for lazarus? I see the same sample image snapped for each.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: Get video file resolution
« Reply #3 on: November 28, 2020, 01:18:00 am »
hello,
here is in attachment a small project to read media infos from media files. When you click on the button you can choose the file to
read.
the file MediaInfoDll.pas (delphi wrapper) has been converted to Lazarus (only windows)  with {$mode objfpc} header.
You must put the mediainfo.dll  in the project folder or in a system path.
If someone want to convert the wrapper unit to linux , i think it is possible.
Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Get video file resolution
« Reply #4 on: November 28, 2020, 02:09:17 am »
Hi!

The Linux counterpart is MediaInfo from MediaArena:

https://mediaarea.net/de/MediaInfo/Download/Source


Winni

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: Get video file resolution
« Reply #5 on: November 29, 2020, 02:12:43 am »
hello,
the file MediaInfoDll.pas (delphi wrapper) has been converted to Lazarus (only windows)  with {$mode objfpc} header.
You must put the mediainfo.dll  in the project folder or in a system path.
If someone want to convert the wrapper unit to linux , i think it is possible.
on Centos 8 with libmediainfo package installed the MediaInfoDll.pas  works. You need only change the path of the library and use the A version (Ansi) of the functions in your project  :
example :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   HandleMI: Cardinal;
  4.   To_Display: String;
  5.   CR: String;
  6.   filename: string;
  7.  
  8. begin
  9.   CR:=Chr(13) + Chr(10);
  10.   if (MediaInfoDLL_Load('libmediainfo.so.0')=false) then
  11.   begin
  12.       Memo1.Text := 'Error while loading MediaInfo.dll';
  13.       exit;
  14.   end;
  15.   if OpenDialog1.Execute then
  16.     begin
  17.       filename := OpenDialog1.Filename;
  18.  
  19.       HandleMI := MediaInfoA_New();
  20.       To_Display := 'Open' + CR;
  21.       To_Display := To_Display + format('%d', [MediaInfoA_Open(HandleMI, PChar(filename))]);
  22.  
  23.       To_Display := To_Display + CR + CR + 'Inform with Complete=false' + CR;
  24.       MediaInfoA_Option (0, 'Complete', '');
  25.       To_Display := To_Display + MediaInfoA_Inform(HandleMI, 0);
  26.  
  27.       To_Display := To_Display + CR + CR + 'Inform with Complete=true' + CR;
  28.       MediaInfoA_Option (0, 'Complete', '1');
  29.       To_Display := To_Display + MediaInfoA_Inform(HandleMI, 0);
  30.  
  31.       To_Display := To_Display + CR + CR + 'Custom Inform' + CR;
  32.       MediaInfoA_Option (0, 'Inform', 'General;Example : FileSize=%FileSize%');
  33.       To_Display := To_Display + MediaInfoA_Inform(HandleMI, 0);
  34.  
  35.       To_Display := To_Display + CR + CR + 'Close' + CR;
  36.       MediaInfoA_Close(HandleMI);
  37.  
  38.       Memo1.Text := To_Display;
  39.  
  40.     end;
  41.  
  42.  
  43. end;  

Result in attachment :  Centos 8.1  - Lazarus 2.0.10 - Fpc 3.2  - libmediainfo 20.0.8 

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

 

TinyPortal © 2005-2018