[Lazarus] PasLibVLC based video player does not run on Linux...

Bo Berglund bo.berglund at gmail.com
Tue Nov 21 19:29:58 CET 2023


On Tue, 21 Nov 2023 18:05:22 +0100 (CET), Michael Van Canneyt via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>
>
>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.

>>
>> 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;


>>
>> 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



More information about the lazarus mailing list