I created a video editing tool back in 2018 or so in order to help pinpointing
cut points for editing mp4 videos.

At the time I did not find anything useful other than PasLibVLC, which I have
been using since then on Windows. It works OK for what I need but I have to
install the custom package into the IDE every time I make a new Lazarus
installation. Until now I have only been on Windows with this application.

A few days ago I wanted to build the application on a Linux system, but even
though it compiled after I removed some Windows-only experimental functions it
did not actually display the video, nothing at all shows up....

So I have been looking around for a solution and yesterday I found what is right
under my nose:

Lazarus contains LibVLC as a standard package available to be installed in the
GUI using Package/Install-remove packages! No download needed from external
sources!

Really very neat and simple to get going and to rely upon going forward!

Anyway, I have been experimenting with the example inside the package code and
also read Michael's document "Displaying video files using Free Pascal and
Lazarus".

I think I can switch out PasLibVLC and replace it with the LclVLC player instead
but I need some help in implementation.

There are some functions I would like to get hints on how to implement:

1) Progressbar update
---------------------
It is decribed how to make a progressbar show the current position of the video
playback. That is event driven AFAICT. And it is shown in the doc...

However, I don't understand what is going on in the pdf doc regarding getting
the actual position shown by the position of the progressbar.

I have tried to get the info from the player like this, but it won't work at
all, it looks like the DoPositionChanged() event code does not get called..
This is what I have done:

procedure TfrmMainVlc.FormCreate(Sender: TObject);
begin
  FPlayer:=TLCLVLCPlayer.Create(Self);
  FPlayer.ParentWindow:=PVideo;
  FPlayer.OnPositionChanged:=@DoPositionChanged; //Set event handler
  FVideoFile := ReadIniString('Files', 'LastVideo', ''); //Get last video name
  FEVideo.FileName := FVideoFile;
  tbVolume.Position := ReadIniInt('Settings', 'Volume', 10); //Get last volume
end;

procedure TfrmMainVlc.DoPositionChanged(Sender: TObject; const APos: Double);
var
  nCurrPos: int64;
begin
  //Just print the position to screen as first test
  nCurrPos := Round(APos); //Position in ms
  stxPos.Caption := IntToStr(nCurrPos); //Show position in StaticText box
end;

Nothing at all happens when I play the video, the event function is not called.

2) Reposition video via progressbar
-----------------------------------
I also need the reverse, i.e. when I click the progressbar I want the video to
be repositioned to the place I clicked.
And this I have solved using this piece of code (note: I have set the
progressbar max value to 1000 to get better resolution:

//Mouse up on progressbar should reposition the video to the clicked pos
procedure TfrmMainVlc.pgbVideoposMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  VidPos,
  Duration: int64;
begin
  Duration := FPlayer.VideoLength div 1000;
  VidPos := Round(X / pgbVideopos.Width * pgbVideopos.Max * Duration / 1000);
  FPlayer.VideoPosition := Round(VidPos * 1000);
end;

3) Increase/decrease playback speed?
------------------------------------
Is it possible to adjust the playback speed (I can do this with PasLibVLC)?
Then how can it be done, say to enter a percentage between 50 and 200 in a box
and then tell the player to use that setting.

4) Lipsync adjust
-----------------
Is it possible to shift the audio forward/backward relative to the image in
order to adjust lip sync? I can do this with PasLibVLC, but how can it be done
here?

Grateful for any suggestions on how to get this to work!


-- 
Bo Berglund
Developer in Sweden

-- 
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to