Recent

Author Topic: Failed to port application using PasLibVLC to Linux  (Read 4819 times)

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Failed to port application using PasLibVLC to Linux
« on: November 18, 2023, 10:41:52 am »
I have written a video player application on Windows 7/10 which is based on PasLibVLC for the video handling.

The application is used to navigate an mp4 video to find accurate cut points for editing, which is then actually done using ffmpeg outside of the application.

The PasLibVLC package is supposed to be multi-platform so I have tried to port it over to a Raspberry Pi4B running Linux Pi-OS 64 bit bookworm (the latest Debian based).

After I removed some non-needed experimental functions for Windows from the application it did build on the Linux target using Lazarus 3.0.RC2 and Fpc 3.2.2

But when I start it then the main video window (filling most of the application) is missing even though there are no errors when building it...

So where do I start looking for what has happened?

VLC 3.0.20 is installed on the target system by default, could it be a problem for PasLibVLC to find the VLC libraries and if so how is that fixed?
Some extra packages for VLC to install?

(I used PasLibVLC on Windows since it was so easy back when I started the project in 2019 and it has worked well in several Windows installations).
--
Bo Berglund
Sweden

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Failed to port application using PasLibVLC to Linux
« Reply #1 on: November 18, 2023, 03:39:19 pm »
No feedback here about PasLibVlc usage on Linux so I have started looking elsewhere...

Luckily I have found a package available within Lazarus sources itself named LazVLC for interfacing with the VLC video engine. As with PasLibVlc the VLC 3.x application must be installed on the target machine.

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"

Now the IDE is rebuilt and when it comes back up there will be a new tab on the component palette named Multimedia where the new components are shown (there are 2).

I have tested the sample program that is part of the package (look in the Lazarus sources in components/vlc/example) and it can play my video examples fine. But it is a really minimal example so one has to do a lot more to make it useful.

But hopefully I can cut away PasLibVlc and keep everything else.

There are a number of functions for which I need to find the corresponding ones in the lazVLC components, but hopefully it is possible in which case I can throw out PasLibVlc altogether.
For example I have buttons to jump a certain fixed time forward and backward during playback and I need to read off the exact time the video playback is positioned at.
I also have functionality to speed up/down playback of the video, also needed.
Play/Pause/Resume/End are easily available and the bare bones example have these.

But I need a bit more..

Posting this for future reference in case someone else has the same problem...
--
Bo Berglund
Sweden

paweld

  • Hero Member
  • *****
  • Posts: 1516
Re: Failed to port application using PasLibVLC to Linux
« Reply #2 on: December 25, 2023, 10:49:11 am »
Hi BosseB,
I saw your post earlier, but didn't have time to check it out. Certainly PasLibVlc works under Linux, but it actually didn't work on RaspberryPi. Here's a revised version that works on RaspberryPi 32 and 64 bit: https://github.com/paweld/PasLibVlc
« Last Edit: December 25, 2023, 10:59:44 am by paweld »
Best regards / Pozdrawiam
paweld

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Failed to port application using PasLibVLC to Linux
« Reply #3 on: December 25, 2023, 03:49:19 pm »
Hi BosseB,
I saw your post earlier, but didn't have time to check it out. Certainly PasLibVlc works under Linux, but it actually didn't work on RaspberryPi. Here's a revised version that works on RaspberryPi 32 and 64 bit: https://github.com/paweld/PasLibVlc
I have now retrieved the 3.0.7 sources from the GitHub location you showed using the 3.0.7 zip file .
When I diff the Lazarus//Makefile against the 3.0.6 version I get a massive number of differences which consists of Path setting diffs.
This is the first of these lines, many more follow:
Code: Pascal  [Select][+][-]
  1. 3-0-6 #1043: override COMPILER_UNITDIR+=../source ../source.vcl ../../../packager/units/$(CPU_TARGET)-$(OS_TARGET) ../../lazutils/lib/$(CPU_TARGET)-$(OS_TARGET) ../../../lcl/units/$(CPU_TARGET)-$(OS_TARGET) ../../../lcl/units/$(CPU_TARGET)-$(OS_TARGET)/$(LCL_PLATFORM) .
  2.  
  3. 3.0.7 #1043: override COMPILER_UNITDIR+=../source ../source.vcl C:/lazarus/packager/units/$(CPU_TARGET)-$(OS_TARGET) C:/lazarus/components/lazutils/lib/$(CPU_TARGET)-$(OS_TARGET) C:/lazarus/lcl/units/$(CPU_TARGET)-$(OS_TARGET) C:/lazarus/lcl/units/$(CPU_TARGET)-$(OS_TARGET)/$(LCL_PLATFORM) .
  4.  

Notice the existence of an absolute path on a Windows system using C:/lazarus notation!
Example:
Code: Pascal  [Select][+][-]
  1. C:/lazarus/packager/units/

I don't want to experiment with my installations potentially making them break.
So how can I retrieve files which will work for Linux?

Or does the Linux install not use the Makefile?
The other files seem to be OK.
--
Bo Berglund
Sweden

paweld

  • Hero Member
  • *****
  • Posts: 1516
Re: Failed to port application using PasLibVLC to Linux
« Reply #4 on: December 25, 2023, 04:07:29 pm »
The link you downloaded is the latest official version, which also does not work with the raspberry pi.
If you want a version that works properly on the raspberry pi you need to download from this link (Code > Download ZIP): https://codeload.github.com/paweld/PasLibVlc/zip/refs/heads/master
As for the changes between version 3.0.6 and 3.0.7, I haven't checked what the changes were. While for sure the version from github works properly under Windows 10 x64, Debian 12 x64 with XFCE and RPi 5 with Raspberry Pi OS Bookworm 64 bit
Best regards / Pozdrawiam
paweld

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Failed to port application using PasLibVLC to Linux
« Reply #5 on: December 27, 2023, 12:20:15 am »
The link you downloaded is the latest official version, which also does not work with the raspberry pi.
If you want a version that works properly on the raspberry pi you need to download from this link (Code > Download ZIP): https://codeload.github.com/paweld/PasLibVlc/zip/refs/heads/master
As for the changes between version 3.0.6 and 3.0.7, I haven't checked what the changes were. While for sure the version from github works properly under Windows 10 x64, Debian 12 x64 with XFCE and RPi 5 with Raspberry Pi OS Bookworm 64 bit
I downloaded the 3.0.7 zipfile and copied over the relevant files (dirs Lazarus, source and source.vcl and the 4 files in the root to my RPi5B installation's copy of PasLibVlc. THus overwriting the files thta I had retrieved from our own SVN server. I have saved the PasLibVlc 3.0.6 Lazarus item there to help in using it with Lazarus on various platforms.

Then I rebuilt my Lazarus 3.0.0 from the sources and launched Lazarus.
Now when I load the VideoPlayer project it can be built and when I start the executable it appears as it should on screen.
So it seems to actually work, but my only way of communicating right now is via VNC remote desktop and that does not work well with the video stuff....
I need to find myself a hardware monitor and some way to get sound off of the RPi5B too (it no longer has a headphone audio plug so I cannot attach my headphones...
--
Bo Berglund
Sweden

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 688
Re: Failed to port application using PasLibVLC to Linux
« Reply #6 on: December 27, 2023, 05:30:41 pm »
It's always something isn't it? 

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Failed to port application using PasLibVLC to Linux
« Reply #7 on: December 27, 2023, 07:34:16 pm »
It's always something isn't it?
I think it is called Murphy's Law... 8-)

The fact that the RPi5B is missing audio output was not something I had expected, and I am not alone it seems because I have now seen several threads on the Raspberry forums asking about RPi5 audio...

And I have ordered a USB-A connected audio interface device from Amazon too so when that arrives I can at least listen to the sound while debugging.

By the way, interfacing via VNC to an Ubuntu Mint 20 laptop brings up the video without the slowness and audio is heard through the laptop's built-in speakers.
This is when playing using VLC on the Mint machine.

So the RPi5B is still not a powerhouse..
« Last Edit: December 27, 2023, 07:37:29 pm by BosseB »
--
Bo Berglund
Sweden

paweld

  • Hero Member
  • *****
  • Posts: 1516
Re: Failed to port application using PasLibVLC to Linux
« Reply #8 on: December 27, 2023, 08:04:50 pm »
As I wrote, in order for the component to work properly on the RPi you need to download the version with the fixes applied from this link: https://codeload.github.com/paweld/PasLibVlc/zip/refs/heads/master
Best regards / Pozdrawiam
paweld

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Failed to port application using PasLibVLC to Linux
« Reply #9 on: December 27, 2023, 11:05:14 pm »
As I wrote, in order for the component to work properly on the RPi you need to download the version with the fixes applied from this link: https://codeload.github.com/paweld/PasLibVlc/zip/refs/heads/master
And I have done so whereupon the PasLibVlc started working on the RPi platform! I believe I have said so.
So the PasLibVlc code 3.0.7 seems to work well at least using the zip package.

What is the problem here is shown when using VLC by itself to play a locally stored video file (which is what my application in the end does).
This does not work via VNC to my Win10 laptop because the video is not smoothly played then.
THis has nothing to do with PasLibVlc since the VLC video player is used.

Same test on the Ubuntu Mint laptop also playing on VLC player via VNC works just fine.
I will move my player code over to that computer and test how it behaves with the new PasLibVlc, probably tomorrow.
--
Bo Berglund
Sweden

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Failed to port application using PasLibVLC to Linux
« Reply #10 on: December 28, 2023, 01:07:53 am »
Quote
Same test on the Ubuntu Mint laptop also playing on VLC player via VNC works just fine.
I will move my player code over to that computer and test how it behaves with the new PasLibVlc, probably tomorrow.

So I had a look right away and did this on the Ubuntu Mint 20 machine:
- Using Lazarus 2.2.4 I updated PasLibVlc from 3.0.6 to 3.0.7 using the files as discussed above
- Checked out the VideoPlayer sources to my projects dir from my SVN server
- Opened the project inside Lazarus and edited out Windows specific stuff using IFDEF's
- After this the project built without errors.

Then I started it outside of Lazarus by executing the compiled binary in a Terminal window which caused the application to appear in the desktop.
I used the function to open a video file and it worked fine, the video played as it should!

No problems viewing it via VNC remote desktop either.

So after testinga few functions I closed the application and had a look at the command window again.
This now contained a number of lines of text output while I was using the application:

Code: [Select]
$ ./VideoPlayer
Warning: option --overlay no longer exists.
Warning: option --overlay no longer exists.
libdvdnav: Using dvdnav version 6.0.1
libdvdread: Encrypted DVD support unavailable.
************************************************
**                                            **
**  No css library available. See             **
**  /usr/share/doc/libdvdread4/README.css     **
**  for more information.                     **
**                                            **
************************************************
libdvdread: Couldn't find device name.
libdvdread:DVDOpenFilePath:findDVDFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFilePath:findDVDFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
../include/vlc_xlib.h:46:vlc_xlib_init: Xlib not initialized for threads.
This process is probably using LibVLC incorrectly.
Pass "--no-xlib" to libvlc_new() to fix this.
--- repeats the 3 lines above 17 times ---

Concerning thread usage I have this in my lpr project file:

Code: Pascal  [Select][+][-]
  1. program VideoPlayer;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}
  7.   cthreads,
  8.   {$ENDIF}
  9.   Interfaces, // this includes the LCL widgetset
  10.   Forms, FormMain, PasLibVlcPlayer, formPasswd, formeditcuts, formfindwindow
  11.   { you can add units after this };
  12.  
  13. {$R *.res}
  14.  
  15. begin
  16.   RequireDerivedFormResource:=True;
  17.   Application.Scaled:=True;
  18.   Application.Initialize;
  19.   Application.CreateForm(TfrmMain, frmMain);
  20.   Application.Run;
  21. end.
  22.  

So cthreads is at least in the project uses clause...
--
Bo Berglund
Sweden

Josh

  • Hero Member
  • *****
  • Posts: 1428
Re: Failed to port application using PasLibVLC to Linux
« Reply #11 on: December 28, 2023, 01:32:46 am »
prob nothing to dowith it,but i use the cmem;memory manager with cthreads

{$IFDEF UNIX}
  cmem,  cthreads,
  {$ENDIF}
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

paweld

  • Hero Member
  • *****
  • Posts: 1516
Re: Failed to port application using PasLibVLC to Linux
« Reply #12 on: December 28, 2023, 11:49:48 am »
Quote from: BosseB
I believe I have said so.
Hi BosseB,
Sorry, but my English is not good and I apparently misunderstood your comment.
Best regards / Pozdrawiam
paweld

BosseB

  • Sr. Member
  • ****
  • Posts: 484
Re: Failed to port application using PasLibVLC to Linux
« Reply #13 on: December 28, 2023, 04:26:12 pm »
Hi BosseB,
Sorry, but my English is not good and I apparently misunderstood your comment.
No probs! :)

But what do you make of the command window printouts complaining about:

Code: Pascal  [Select][+][-]
  1. ../include/vlc_xlib.h:46:vlc_xlib_init: Xlib not initialized for threads.
  2. This process is probably using LibVLC incorrectly.
  3. Pass "--no-xlib" to libvlc_new() to fix this.

It seems like I am not getting the events for video progress etc, possibly because of some error in initializing the threading system...
I have no idea on how to do what it suggests...

Is there some test I can do in order to pinpoint the problem?
« Last Edit: December 28, 2023, 04:28:52 pm by BosseB »
--
Bo Berglund
Sweden

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: Failed to port application using PasLibVLC to Linux
« Reply #14 on: December 28, 2023, 04:37:40 pm »
Code: Pascal  [Select][+][-]
  1. ../include/vlc_xlib.h:46:vlc_xlib_init: Xlib not initialized for threads.
  2. This process is probably using LibVLC incorrectly.
  3. Pass "--no-xlib" to libvlc_new() to fix this.

It seems like I am not getting the events for video progress etc, possibly because of some error in initializing the threading system...
I have no idea on how to do what it suggests...
There is literally a libvcl_new external variable (in unit paslibvlcunit) that points to the linked library an which you can use to provide the commandline arguments.

Most of the class implementations are full of these calls to libvcl_new but I assume that none actually passes the option --no-xlib (as suggested by the error message).

Code: Pascal  [Select][+][-]
  1. (**
  2.  * Create and initialize a libvlc instance.
  3.  * This functions accept a list of "command line" arguments similar to the
  4.  * main(). These arguments affect the LibVLC instance default configuration.
  5.  *
  6.  * LibVLC may create threads. Therefore, any thread-unsafe process
  7.  * initialization must be performed before calling libvlc_new(). In particular
  8.  * and where applicable:
  9.  * - setlocale() and textdomain(),
  10.  * - setenv(), unsetenv() and putenv(),
  11.  * - with the X11 display system, XInitThreads()
  12.  *   (see also libvlc_media_player_set_xwindow()) and
  13.  * - on Microsoft Windows, SetErrorMode().
  14.  * - sigprocmask() shall never be invoked; pthread_sigmask() can be used.
  15.  *
  16.  * On POSIX systems, the SIGCHLD signal MUST be ignored, i.e. the
  17.  * signal handler must set to SIG_DFL or a function pointer, not SIG_IGN.
  18.  * Also while LibVLC is active, the wait() function shall not be called, and
  19.  * any call to waitpid() shall use a strictly positive value for the first
  20.  * parameter (i.e. the PID). Failure to follow those rules may lead to a
  21.  * deadlock or a busy loop.
  22.  * Also on POSIX systems, it is recommended that the SIGPIPE signal be blocked,
  23.  * even if it is not, in principles, necessary, e.g.:
  24.  
  25.    sigset_t set;
  26.  
  27.    signal(SIGCHLD, SIG_DFL);
  28.    sigemptyset(&set);
  29.    sigaddset(&set, SIGPIPE);
  30.    pthread_sigmask(SIG_BLOCK, &set, NULL);
  31.  
  32.  *
  33.  * On Microsoft Windows Vista/2008, the process error mode
  34.  * SEM_FAILCRITICALERRORS flag MUST be set before using LibVLC.
  35.  * On later versions, that is optional and unnecessary.
  36.  * Also on Microsoft Windows (Vista and any later version), setting the default
  37.  * DLL directories to SYSTEM32 exclusively is strongly recommended for
  38.  * security reasons:
  39.  
  40.    SetErrorMode(SEM_FAILCRITICALERRORS);
  41.    SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32);
  42.  
  43.  *
  44.  * Arguments are meant to be passed from the command line to LibVLC, just like
  45.  * VLC media player does. The list of valid arguments depends on the LibVLC
  46.  * version, the operating system and platform, and set of available LibVLC
  47.  * plugins. Invalid or unsupported arguments will cause the function to fail
  48.  * (i.e. return NULL). Also, some arguments may alter the behaviour or
  49.  * otherwise interfere with other LibVLC functions.
  50.  *
  51.  * There is absolutely no warranty or promise of forward, backward and
  52.  * cross-platform compatibility with regards to libvlc_new() arguments.
  53.  * We recommend that you do not use them, other than when debugging.
  54.  *
  55.  * param  argc the number of arguments (should be 0)
  56.  * param  argv list of arguments (should be NULL)
  57.  * return the libvlc instance or NULL in case of error
  58.  *)
  59. var
  60.   libvlc_new : function(
  61.     argc : Integer;
  62.     args : PPAnsiChar
  63.   ) : libvlc_instance_t_ptr; cdecl;
  64.  
« Last Edit: December 28, 2023, 04:40:28 pm by TRon »
Today is tomorrow's yesterday.

 

TinyPortal © 2005-2018