Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2023-11

PasLibVLC based video player does not run on Linux...

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

As I have written in other posts I am trying to port a video application from Windows to Linux, specifically on Raspberry Pi4B with either bullseye or bookworm operating systems.

The application runs very well on Windows and is based on PasLibVLC found here: https://prog.olsztyn.pl/paslibvlc/

But I am not able to make it show videos on Linux..

So as a test I have now reverted to a demo application on this website in order to minimize the possible problems:
http://lazplanet.blogspot.com/2018/01/how-to-make-simple-video-player-in.html

When I follow these instructions to create a test application on the RPi4B it builds but when executed the video window does not appear and no video can be played. Instead of a black player waiting for rthe file to play, there is a gray background just like the player was not I copy the sources from RPi4B to my Windows10 PC and open the project in Lazarus there (same version 2.2.6) it builds fine, and in this case it also displays the video as expected. No problems sources.

So something is not working in the Linux environment and I don't understand what. And whatever it is it does not generate any errors during compile/build on Linux.

I *have* enabled the threading system in the project file by putting cthreads into the uses clause as first item so it is not a thread initializatiuon problem:

  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}

Now I am wondering if it perhaps cannot find the VLC *libraries* that are supposed to be available on a system with VLC installed. But I do not know how thatr is supposed to work and I don't understand the code either.

All my Linux systems (with a GUI) can run VLC OK and display mp4 videos just fine with the VLC player application.

But only on Windows10 is it working when using PasLibVlc in the test application.

Any ideas?

Bo Berglund Developer in Sweden

Reply by email

Michael Van Canneyt
to Bo Berglund
Bo Berglund wrote 25 lines
As I have written in other posts I am trying to port a video application from Windows to Linux, specifically on Raspberry Pi4B with either bullseye or bookworm operating systems. The application runs very well on Windows and is based on PasLibVLC found here: https://prog.olsztyn.pl/paslibvlc/ But I am not able to make it show videos on Linux.. So as a test I have now reverted to a demo application on this website in order to minimize the possible problems: http://lazplanet.blogspot.com/2018/01/how-to-make-simple-video-player-in.html When I follow these instructions to create a test application on the RPi4B it builds but when executed the video window does not appear and no video can be played. Instead of a black player waiting for rthe file to play, there is a gray background just like the player was not created at all. If I copy the sources from RPi4B to my Windows10 PC and open the project in Lazarus there (same version 2.2.6) it builds fine, and in this case it also displays the video as expected. No problems sources. So something is not working in the Linux environment and I don't understand what. And whatever it is it does not generate any errors during compile/build on Linux.

I developed it on linux, so at least then it worked.

Show quoted text 13 lines
I *have* enabled the threading system in the project file by putting cthreads into the uses clause as first item so it is not a thread initializatiuon problem: {$IFDEF UNIX} cthreads, {$ENDIF} Now I am wondering if it perhaps cannot find the VLC *libraries* that are supposed to be available on a system with VLC installed. But I do not know how thatr is supposed to work and I don't understand the code either.

Make sure you have libvlc-dev installed on the rpi.

This should install a symlink libvlc.so somewhere below /usr/lib

Michael.

Reply by email

Bo Berglund
to Michael Van Canneyt
Michael Van Canneyt wrote 29 lines
On Tue, 21 Nov 2023, Bo Berglund via lazarus wrote: > As I have written in other posts I am trying to port a video application from > Windows to Linux, specifically on Raspberry Pi4B with either bullseye or > bookworm operating systems. > > The application runs very well on Windows and is based on PasLibVLC found here: > https://prog.olsztyn.pl/paslibvlc/ > > But I am not able to make it show videos on Linux.. > > So as a test I have now reverted to a demo application on this website in order > to minimize the possible problems: > http://lazplanet.blogspot.com/2018/01/how-to-make-simple-video-player-in.html > > When I follow these instructions to create a test application on the RPi4B it > builds but when executed the video window does not appear and no video can be > played. Instead of a black player waiting for rthe file to play, there is a gray > background just like the player was not created at all. > > If I copy the sources from RPi4B to my Windows10 PC and open the project in > Lazarus there (same version 2.2.6) it builds fine, and in this case it also > displays the video as expected. No problems sources. > > So something is not working in the Linux environment and I don't understand > what. And whatever it is it does not generate any errors during compile/build on > Linux.

Thanks for responding! Much appreciated.

I developed it on linux, so at least then it worked.

Do you mean lclVlc or PasLibVlc?

I saw your name concerning the lclVlc package and the pdf documentation but another name (Robert Jedrzejczyk) is mentioned in the sources for PasLibVlc...

I have tried replacing PasLibVlc with LclVlc shipped with Lazarus but I am missing a couple of items that I use during playback (varying play speed and audio shift for lipsync), which PasLibVlc does expose.

And there is a curious animation of my progressbar when the video is jumped to a new position so the playing moves instantly but the progressbar is slowly reaching the actual position in about a second or so.

This is mostly an appearance problem when I jump with the location buttons I have in my main application, but still looks strange.

This is done now in a small test application where I am testing all the VLC calls used in the actual application I am porting but using LclVLC instead of PasLibVlc.

When done there I will do the surgery on the main application itself.

Show quoted text 15 lines
> > I *have* enabled the threading system in the project file by putting cthreads > into the uses clause as first item so it is not a thread initializatiuon > problem: > > {$IFDEF UNIX} > cthreads, > {$ENDIF} > > > Now I am wondering if it perhaps cannot find the VLC *libraries* that are > supposed to be available on a system with VLC installed. But I do not know how > thatr is supposed to work and I don't understand the code either.

On the newest RPi4 running bookworm 64 bit:

$ apt policy libvlc-dev
libvlc-dev:
Installed: 1:3.0.20-0+rpt1+deb12u1
Candidate: 1:3.0.20-0+rpt1+deb12u1
Version table:
*** 1:3.0.20-0+rpt1+deb12u1 500
500 http://archive.raspberrypi.com/debian bookworm/main arm64 Packages 100 /var/lib/dpkg/status
3.0.20-0+deb12u1 500
500 http://deb.debian.org/debian-security bookworm-security/main arm64 Packages
3.0.18-2 500
500 http://deb.debian.org/debian bookworm/main arm64 Packages

And on the other running bullseye 32 bit:

$ apt policy libvlc-dev
libvlc-dev:
Installed: 1:3.0.20-0+rpt1+deb11u1
Candidate: 1:3.0.20-0+rpt1+deb11u1
Version table:
*** 1:3.0.20-0+rpt1+deb11u1 500
500 http://archive.raspberrypi.org/debian bullseye/main armhf Packages 100 /var/lib/dpkg/status
3.0.20-0+deb11u1+rpi1 500
500 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages

$ find /usr/lib -name libvlc.so
/usr/lib/arm-linux-gnueabihf/libvlc.so
Make sure you have libvlc-dev installed on the rpi. This should install a symlink libvlc.so somewhere below /usr/lib

On the bullseye system:

$ find /usr/lib -name libvlc.so
/usr/lib/arm-linux-gnueabihf/libvlc.so

On the bookworm 64 system:

$ find /usr/lib -name libvlc.so
/usr/lib/aarch64-linux-gnu/libvlc.so

Are these locations that will let the application (or Lazaur/Fpc) find the libraries?

What are the requirements for the executable's environment for it to find the libvlc files?

And is it necessary for them to be there for the building process only or for the end user's execution too?

Bo Berglund Developer in Sweden

Reply by email

Michael Van Canneyt
to Bo Berglund
Bo Berglund wrote 10 lines
>> >> So something is not working in the Linux environment and I don't understand >> what. And whatever it is it does not generate any errors during compile/build on >> Linux. Thanks for responding! Much appreciated. > I developed it on linux, so at least then it worked. Do you mean lclVlc or PasLibVlc?

lclVlc

I saw your name concerning the lclVlc package and the pdf documentation but another name (Robert Jedrzejczyk) is mentioned in the sources for PasLibVlc...

Where did you find paslibvlc ?

The one I maintain is part of FPC and is in fpc/packages/libvlc.

I have tried replacing PasLibVlc with LclVlc shipped with Lazarus but I am missing a couple of items that I use during playback (varying play speed and audio shift for lipsync), which PasLibVlc does expose.

It should not be difficult to add those properties to lclvlc

What are the requirements for the executable's environment for it to find the libvlc files?

Notmally nothing.

And is it necessary for them to be there for the building process only or for the end user's execution too?

libvlc is loaded dynamically, you can specify the name. I can't comment on PasLibVlc.

Michael.

Reply by email

Bo Berglund
to Michael Van Canneyt
Michael Van Canneyt wrote 5 lines
On Tue, 21 Nov 2023, Bo Berglund via lazarus wrote: Where did you find paslibvlc ?

I found it here years ago:

https://prog.olsztyn.pl/paslibvlc/

And the first commit to my video tool in svn using it was done in May 2019...

The one I maintain is part of FPC and is in fpc/packages/libvlc.

Yes and a few days ago I found it to be a part of fpc/lazarus and that made me try to see if I could find all the stuff I have used in paslibvlc also here so I could just exchange the player and modify the calls.

Makes much more sense to use a package that is in effect maintained than one that is stale on the net.

Show quoted text 6 lines
> > I have tried replacing PasLibVlc with LclVlc shipped with Lazarus but I am > missing a couple of items that I use during playback (varying play speed and > audio shift for lipsync), which PasLibVlc does expose. It should not be difficult to add those properties to lclvlc

If one knows how it is done internally I guess it is doable but for me not... But I can trace what I use backwards into PasLibVlc and see where it finally ends up. So:

--------- Delay audio ------------------------
I call the audio delay like this:

procedure TfrmMain.btnShiftAudioClick(Sender: TObject);
//For testing purposes, delay audio by value from speAudio
var
  SyncCmd: string;
begin
  vlcPlayer.SetAudioDelay(speAudio.Value * 1000);
end;

which calls this inside PasLibVlc:

procedure TPasLibVlcPlayer.SetAudioDelay(delay: Int64);
begin
  if not Assigned(p_mi) then exit;
  libvlc_audio_set_delay(p_mi, delay);
end;

and this is where it ends up:

(**
* Set current audio delay. The audio delay will be reset to zero each time the media changes.
*
* param p_mi media player
* param i_delay the audio delay (microseconds)
* return 0 on success, -1 on error
* version LibVLC 1.1.1 or later
*)
var
libvlc_audio_set_delay : function(

    p_mi    : libvlc_media_player_t_ptr;
    i_delay : Int64
  ) : Integer; cdecl;

------------- Set video speed ----------------------- To set the speed this is what I use in my code:

procedure TfrmMain.btnFFClick(Sender: TObject);
begin
  vlcPlayer.SetPlayRate(speSpeed.Value);
end;

It goes here:

procedure TPasLibVlcPlayer.SetPlayRate(rate: Integer);
begin
  if (p_mi = NIL) then exit;
  if (rate < 1) then exit;
  if (rate > 1000) then exit;
  libvlc_media_player_set_rate(p_mi, rate / 100);
end;

And it winds up here:

(**
* Set movie play rate
*
* param p_mi the Media Player
* param rate movie play rate to set
* return -1 if an error was detected, 0 otherwise (but even then, it might
* not actually work depending on the underlying media protocol) *)

var
  libvlc_media_player_set_rate : function(
    p_mi : libvlc_media_player_t_ptr;
    rate : Single // float
  ) : Integer; cdecl;
Show quoted text 11 lines
> > What are the requirements for the executable's environment for it to find the > libvlc files? Notmally nothing. > > And is it necessary for them to be there for the building process only or for > the end user's execution too? libvlc is loaded dynamically, you can specify the name.

Well, for lclvlc there are no problems because it finds the lib on the platforms I have tested it. Both RPi4 versions (32 and 64 bit) and Windows10.

Michael.

Thanks again!

Nice to communicate with someone "in the know" for once!

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote 34 lines
------------- Set video speed ----------------------- To set the speed this is what I use in my code: procedure TfrmMain.btnFFClick(Sender: TObject); begin vlcPlayer.SetPlayRate(speSpeed.Value); end; It goes here: procedure TPasLibVlcPlayer.SetPlayRate(rate: Integer); begin if (p_mi = NIL) then exit; if (rate < 1) then exit; if (rate > 1000) then exit; libvlc_media_player_set_rate(p_mi, rate / 100); end; And it winds up here: (** * Set movie play rate * * param p_mi the Media Player * param rate movie play rate to set * return -1 if an error was detected, 0 otherwise (but even then, it might * not actually work depending on the underlying media protocol) *) var libvlc_media_player_set_rate : function( p_mi : libvlc_media_player_t_ptr; rate : Single // float ) : Integer; cdecl;

Now I have searched in the test application tha uses the Lazarus lclvlc package and found this hidden inside the vlc.pp unit

procedure TCustomVLCMediaPlayer.SetPlayRate(Avalue : Integer);
begin
  if Assigned(FInstance) then
    begin
    if (Avalue< 1) then
       AValue:=1
    else if (AValue>1000) then
      AValue:=1000;
    libvlc_media_player_set_rate(FInstance,AValue/100);
    end;
end;

So there is such a function inside but how can I use it in my top level code? I tried like this:

procedure TfrmMainVlc.btnSpeedClick(Sender: TObject);
var
  VideoSpeed: integer;
begin
  VideoSpeed := speVideoSpeed.Value;
  Fplayer.SetPlayRate(VideoSpeed);
end;

But it generates an error:
"identifier idents no member "SetPlayRate"

So I tried to trace it further and found it in unit vlc:

  TCustomVLCMediaPlayer = Class(TComponent)
  private
   ...
   procedure SetPlayRate(AValue: Integer);
   ...

So how can I get to use this function? I.e. how to publish it (it is private now)?

If I trace it down to implementation it looks like this:

procedure TCustomVLCMediaPlayer.SetPlayRate(Avalue : Integer);
begin
  if Assigned(FInstance) then
    begin
    if (Avalue< 1) then
       AValue:=1
    else if (AValue>1000) then
      AValue:=1000;
    libvlc_media_player_set_rate(FInstance,AValue/100);
    end;
end;

So all is there but not accessible for me...

Bo Berglund Developer in Sweden

Reply by email

Werner Pamler
to Bo Berglund
Bo Berglund wrote 93 lines
On Tue, 21 Nov 2023 19:29:58 +0100, Bo Berglund via lazarus wrote: > ------------- Set video speed ----------------------- > To set the speed this is what I use in my code: > > procedure TfrmMain.btnFFClick(Sender: TObject); > begin > vlcPlayer.SetPlayRate(speSpeed.Value); > end; > > It goes here: > > procedure TPasLibVlcPlayer.SetPlayRate(rate: Integer); > begin > if (p_mi = NIL) then exit; > if (rate < 1) then exit; > if (rate > 1000) then exit; > libvlc_media_player_set_rate(p_mi, rate / 100); > end; > > And it winds up here: > > (** > * Set movie play rate > * > * param p_mi the Media Player > * param rate movie play rate to set > * return -1 if an error was detected, 0 otherwise (but even then, it might > * not actually work depending on the underlying media protocol) > *) > > var > libvlc_media_player_set_rate : function( > p_mi : libvlc_media_player_t_ptr; > rate : Single // float > ) : Integer; cdecl; Now I have searched in the test application tha uses the Lazarus lclvlc package and found this hidden inside the vlc.pp unit procedure TCustomVLCMediaPlayer.SetPlayRate(Avalue : Integer); begin if Assigned(FInstance) then begin if (Avalue< 1) then AValue:=1 else if (AValue>1000) then AValue:=1000; libvlc_media_player_set_rate(FInstance,AValue/100); end; end; So there is such a function inside but how can I use it in my top level code? I tried like this: procedure TfrmMainVlc.btnSpeedClick(Sender: TObject); var VideoSpeed: integer; begin VideoSpeed := speVideoSpeed.Value; Fplayer.SetPlayRate(VideoSpeed); end; But it generates an error: "identifier idents no member "SetPlayRate" So I tried to trace it further and found it in unit vlc: TCustomVLCMediaPlayer = Class(TComponent) private ... procedure SetPlayRate(AValue: Integer); ... So how can I get to use this function? I.e. how to publish it (it is private now)? If I trace it down to implementation it looks like this: procedure TCustomVLCMediaPlayer.SetPlayRate(Avalue : Integer); begin if Assigned(FInstance) then begin if (Avalue< 1) then AValue:=1 else if (AValue>1000) then AValue:=1000; libvlc_media_player_set_rate(FInstance,AValue/100); end; end; So all is there but not accessible for me...

Private methods GetSomething and SetSomething usually are getters and setter for a property "Something". I can see that the methods GetPlayRate and SetPlayRate do exist, but a property "PlayRate" has not been defined. Just forgotten? Post a feature request to the fpc bugtracker to create this property.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20231122/dc6c598e/attachment-0001.htm>

Reply by email