We help IT Professionals succeed at work.

Delphi my timecode doesnt sync up properly

AivsCoder
AivsCoder asked
on
Medium Priority
402 Views
Last Modified: 2012-05-11
Hello,

I have a program which displays video and allows me to seek to a word in the video. In record mode, I have a timer running. When I type a word and hit enter, my program will note how many seconds has since elapsed and store the word and the seconds elapsed into a VirtualStringTree.

In playback mode, it is seeks to the right frames for up to roughyl 5-6 times then all of a sudden is out of sync by a few seconds which is driving me nuts.

I am using the TMPlayer since it was available for free.
http://www.felix-colibri.com/papers/graphic/delphi_video_player/delphi_video_player.html#tmplayer_video_player
My code basically retrieve the timing for the word I clicked on and seeks to that position.
Then seeks 4 seconds before the word so that I actually hear the word.

I tried with seconds, then felt that if I change to milliseconds, I might be able to sync it better but I dont think it may any difference.
Anyone can help
var
Data    : PNodeData;
s       : String;
distancetotravel : double;
begin
if KeyLoggerAudioTiming.FocusedNode=nil then //no selected node
exit;
Data := KeyLoggerAudioTiming.GetNodeData(KeyLoggerAudioTiming.FocusedNode);

// Go forward

if milliseconds < StrToInt(Data.DictionaryWord) then
begin
MultimediaTimer1.Enabled := false;
  distancetotravel := (StrToFloat(Data.DictionaryWord) - milliseconds) / 250;

  MPlayer1.SendSeek(distancetotravel-4, false);

  milliseconds := StrToInt(Data.DictionaryWord)-4000;
  MultimediaTimer1.Enabled := true;
end;

// go backwards
if milliseconds > StrToInt(Data.DictionaryWord) then
begin
MultimediaTimer1.Enabled := false;
  distancetotravel := (milliseconds - StrToInt(Data.DictionaryWord)) / 1000;
  MPlayer1.SendSeek(-distancetotravel-4, false);
  milliseconds := StrToInt(Data.DictionaryWord)-4000;
MultimediaTimer1.Enabled := true;
end;
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Ferruccio AccalaiCEO and Co-founder
CERTIFIED EXPERT

Commented:
Just a guess but could be it a difference in these divisions by case?

// Go forward
if milliseconds < StrToInt(Data.DictionaryWord) then
begin
MultimediaTimer1.Enabled := false;
  distancetotravel := (StrToFloat(Data.DictionaryWord) - milliseconds) / 250; //why by 250????

// go backwards
if milliseconds > StrToInt(Data.DictionaryWord) then
begin
MultimediaTimer1.Enabled := false;
  distancetotravel := (milliseconds - StrToInt(Data.DictionaryWord)) / 1000;
Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT

Commented:

Why don't you make the times to be relative to the start time of the video

Author

Commented:
Code example would have been nice. Thanks anyways
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.