Recent

Author Topic: Moving project from Windows to Linux, advice needed...  (Read 875 times)

BosseB

  • Sr. Member
  • ****
  • Posts: 455
Moving project from Windows to Linux, advice needed...
« on: November 17, 2023, 10:58:45 am »
Some years back I have written a Video editor utility using Lazarus/Fpc on Windows 64 bit. It is in daily use and works fine on Windows.

Now I want to build it on a RaspberryPi4B with the latest 64 bit Pi-OS.

So I have installed fpc using apt and checked out and built Lazarus 3.0.RC2 from sources to have the most recent stuff on the Rpi4B.

I also installed all the needed custom packages into Lazarus for this project and that succeeded.

Then:

When I load the project and execute a quick compile I find a bunch of compatibility problems some of which can be solved using this in uses:
Code: Pascal  [Select][+][-]
  1.   LCLIntf,
  2.   LCLType,
  3.   {$IFDEF WINDOWS}
  4.     Windows,
  5.   {$ENDIF}
  6.  
But it is not enough, I still get not found errors on these identifiers:
Code: Pascal  [Select][+][-]
  1. FindWindow
  2. GetWindow
  3. GW_HWNDNEXT
  4. GetWindowText
  5.  
This is as far as I have gotten now and it seems like it is all about Windows handling code. There may be more once I can get this sorted because right now the Quick Compile stops at this unit (a utils.pas unit).
Any suggestions, please?
« Last Edit: November 17, 2023, 11:00:44 am by BosseB »
--
Bo Berglund
Sweden

myisjwj

  • Jr. Member
  • **
  • Posts: 56
Re: Moving project from Windows to Linux, advice needed...
« Reply #1 on: November 21, 2023, 03:16:18 am »
Code: Pascal  [Select][+][-]
  1. uses
  2.   Xlib;
  3.  
  4. var
  5.   display: PDisplay;
  6.   rootWindow: TWindow;
  7.   windowList: PPWindow;
  8.   numberOfWindows: Integer;
  9.   i: Integer;
  10.   windowName: PChar;
  11.  
  12. begin
  13.   display := XOpenDisplay(nil);
  14.   if display = nil then
  15.   begin
  16.     // donot open
  17.     Exit;
  18.   end;
  19.  
  20.   rootWindow := DefaultRootWindow(display);
  21.   XQueryTree(display, rootWindow, @rootWindow, @rootWindow, @windowList, @numberOfWindows);
  22.  
  23.   for i := 0 to numberOfWindows - 1 do
  24.   begin
  25.     if XFetchName(display, windowList[i], @windowName) <> 0 then
  26.     begin
  27.       WriteLn('winH: ', windowList[i]);
  28.       WriteLn('winText: ', windowName);
  29.       XFree(windowName);
  30.     end;
  31.   end;
  32.  
  33.   XFree(windowList);
  34.   XCloseDisplay(display);
  35. end.

BosseB

  • Sr. Member
  • ****
  • Posts: 455
Re: Moving project from Windows to Linux, advice needed...
« Reply #2 on: November 21, 2023, 08:02:28 am »
I don't know what to do about the code you posted above, but:

I have gotten a lot further by removing all Windows specific functions, which were there only as tests in the first place. Used ifdef to take them out on Unix.

The application is a video player with tools to accurately pinpoint cut points to edit the video (mp4) using ffmpeg in the end.

It uses PasLibVlc to play the video in a panel and controls to jump around in the video etc.

So after I ifdef-ed away all the Windows stuff the application builds on the Pi-OS 64 bit target and can be started, but it does not work (no exceptions or such, just does not do its main thing). The video playback panel is empty.

I now believe that the problem is in the use of the video player from package PasLibVlc.

Does this package actually work on Linux or is it dependent on something being available on the target system (apart from VLC of course, PasLibVlc does its thing via calls to the VLC library).

On this system VLC is installed and runs fine, I can play the videos using VLC itself but my application, which uses PasLibVlc cannot open any video, the player object seems not even to initialize.
It should paint the playback part black on startup but does not so it seems it cannot start.

I am not versed in the deep-down things in Lazarus/Fpc so I don't know how this can be debugged...

I *have* enabled cthreads in the project file as the first command there, since this the VLC stuff probably is thread based. Still no joy.

My system runs the X11 window manager if that matters (no Wayland used).

Is there some property or such to use in order to let the PasLibVlc package know how to find the VLC library?
« Last Edit: November 21, 2023, 08:05:06 am by BosseB »
--
Bo Berglund
Sweden

jamie

  • Hero Member
  • *****
  • Posts: 5854
Re: Moving project from Windows to Linux, advice needed...
« Reply #3 on: November 21, 2023, 11:22:13 pm »
Did you include the LCLTinf and LCLType ?

Also you may want to included the "Types" unit.
The only true wisdom is knowing you know nothing

BosseB

  • Sr. Member
  • ****
  • Posts: 455
Re: Moving project from Windows to Linux, advice needed...
« Reply #4 on: November 21, 2023, 11:57:44 pm »
Did you include the LCLTinf and LCLType ?

Also you may want to included the "Types" unit.
Do difference at all...
I assume you meant LCLintf...

I am on two tracks now:
1) Getting PasLibVLC working on Linux, so far no success.
2) Switching to LclVlc, which is part of the Lazarus distro.

1) Is going to be OK as soon as whatever it is that blocks it from showing the player on my Linux platforms is removed. But how???

2) Means making a lot of changes to the sources and also to somehow figure out how two functions in LclVLC can be accessed. They are now hidden as private class methods and I have no idea on how to fix that. But this component actually works on Linux and displays the video properly.
--
Bo Berglund
Sweden

Curt Carpenter

  • Sr. Member
  • ****
  • Posts: 342
Re: Moving project from Windows to Linux, advice needed...
« Reply #5 on: November 22, 2023, 04:29:44 am »
FWIW (not much) I banged away on PasLibVLC and LclVlc for about a week last year and finally gave up -- but I'm strictly a hobbiest.  If you find the key to making either work on linux, I will be appreciative.

BosseB

  • Sr. Member
  • ****
  • Posts: 455
Re: Moving project from Windows to Linux, advice needed...
« Reply #6 on: November 22, 2023, 08:14:59 am »
FWIW (not much) I banged away on PasLibVLC and LclVlc for about a week last year and finally gave up -- but I'm strictly a hobbiest.  If you find the key to making either work on linux, I will be appreciative.
To install LclVlc to the Lazarus palette on Linux this is what you do:

If lazVlc is not installed in Lazarus then it can be found here (OLPM is no longer used):

- Package/Install_Uninstall_Packages
- In the search box on top type in vlc and you will see "lazvlc 1.0" as a available.
- Select it and hit the Install button below the list.
- Then hit button "Save and rebuild IDE"

And there is a useful document describing how to use LclVlc too:
http://www.freepascal.org/~michael/articles/lazvlc/lazvlc.pdf

Finally: in the package source there is a simple example program that can be used as a starting point.

This package works but it is missing two functions that I use from PasLibVLC:
- Command to run video slower or faster than normal speed
- Property to adjust audio delay to get rid of lipsync problems

Both of these are implemented inside LclVlc but hidden from the user by having them private and I don't know how to change that.
And I use these in my own application because in PaslibVlc they are public.
--
Bo Berglund
Sweden

 

TinyPortal © 2005-2018