ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to get Video Length/Frame nr via DShowParams?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

DVi

Turkey
6 Posts

Posted - May 07 2016 :  16:59:24  Show Profile  Reply
Hi,
I'm trying to make a vide playing ability for my little program and trying some of components about it.. I found ImageEn via search engine and using as trial mode in Delphi XE8..
I need open a video file (mp4, avi or mpeg2 files) and standard video controls such as play, stop, pause, step forward, step backward, rewind...
I had managed to load, play and stop file like:

// Load video
   with Pic1.IO.DShowParams do begin
      if State = gsRunning then begin
         Stop;
         Disconnect;
      end;

      FileInput := LoadPic.FileName;
      TotalFrameCount := Pic1.IO.OpenMediaFile(LoadPic.FileName);
      EnableSampleGrabber := true;
      RenderAudio := true;
      Connect;
      Position := 0;
      Pause; // This shows first frame
   end;

// Play video button (speedbutton)
   if Playing then
      Pic1.IO.DShowParams.Pause
   else
      Pic1.IO.DShowParams.Run;

   Playing := (Pic1.IO.DShowParams.State = gsRunning);

// Step forward-backward by Frm variable(!!!)
   Pic1.IO.DShowParams.Position := Frm;

The problem is: I couldn't get active Frame count and compare with TotalFrameCount.. I can take
Pic1.IO.DShowParams.Position
but i think it gives as miliseconds and Framecount is not suitable for comparing and forwarding that value..

So, I couldn't show/change the playing time value..
I checked Demos/Display/VideoPlayer but there's no any slider or any time display.. Other examples are using Camera input and not suitable for my video file example..

Could anyone help me how to get Total Length (time) and change active frame by a slider? A complete example would be great..
Thanks..


Dany Vitaes

xequte

39053 Posts

Posted - May 08 2016 :  01:53:34  Show Profile  Reply
Hi

You can set IO.DShowParams.TimeFormat to specify what values are used for time (such as frame).

http://www.imageen.com/help/TIEDirectShow.TimeFormat.html

Also, the total time is give by IO.DShowParams.Duration.


See the TIEDirectShow documentation for other properties and methods such as Step:

http://www.imageen.com/help/TIEDirectShow.html




Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

DVi

Turkey
6 Posts

Posted - May 09 2016 :  17:01:06  Show Profile  Reply
Thank you very much for your Reply..
I tried

Pic1.IO.DShowParams.TimeFormat := tfFrame;
[/Code]
and get current Frame and Total Frames with DShowParams.Position and .Duration values.
But, if I try to show these values in 2 labels caption in the form, video playing is getting lagged and it is not playing well (starting to jump frames)..
I think I made a mistake somewhere but I couldn't find it :(
I also tried to put a Timer on the form and get DShowParams.Position value and write in a label.caption but video lag is still remains..
Is it possible to show me actual example which is used for playing a video and frames of current/total are being able to shown in the form?

Dany Vitaes
Go to Top of Page

xequte

39053 Posts

Posted - May 09 2016 :  23:52:00  Show Profile  Reply
Hi Dany

Ensure you do not set DShowParams.TimeFormat too frequently as it will cause lagging.

Here is an updated demo...

attach/xequte/201659235155_VideoPlayer.zip
3.41 KB

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

DVi

Turkey
6 Posts

Posted - May 10 2016 :  13:57:03  Show Profile  Reply
Dear Nigel,
I tried your example, it's great, but if I add a Trackbar to move position of video, playing is very poor! I attached my modified sources.

I think my trackbar was the problem, but is there any way to use pointer to change video position? If there is no trackbar, playing is very nice..

I also try to put a Timer and check trackbar position, it is better than ImageEnView1DrawCanvas method but still laggy :(

attach/DVi/2016510135159_VideoPlayer_with_TrackBar.zip
1696.17 KB

I think I have to find different component or way to achieve this..

I'll add beginning and end surveys before & after the video and there are questions about that video. So, he/she should be replay video parts before the end survey.

Dany Vitaes
Go to Top of Page

xequte

39053 Posts

Posted - May 12 2016 :  00:43:55  Show Profile  Reply
Hi Dany

When you set:

TrackBar.Position := ImageEnView1.IO.DShowParams.Position;

It will call the event TrackBarChange(); thereby setting the position.

You need to have a private form variable to know if it is the user changing the trackbar, i.e.

procedure Tfmain.Timer1Timer(Sender: TObject);
begin
  fInternalChange := True;
  TrackBar.Position := ImageEnView1.IO.DShowParams.Position;
  Timer1.Enabled := True;
  fInternalChange := False;
end;

procedure Tfmain.TrackBarChange(Sender: TObject);
begin
  if not fInternalChange then
   ImageEnView1.IO.DShowParams.Position := TrackBar.Position;
end;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

DVi

Turkey
6 Posts

Posted - May 17 2016 :  16:08:02  Show Profile  Reply
Thank you for your style,
maybe other results I don't know but still lagging..
So I'd shown position only and won't use a trackbar :)
Many thanks for your help..

Dany Vitaes
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: