je ne comprends rien a MovieStatus() et MovieLength
je cherche a pouvoir avancer et reculer a l'image prêt mais surtout connaitre a quel position en temps je suis rendu...
MovieStatus est sensé renvoyer est le numéro de la trame en cours d'affichage.
MovieLength est sensé renvoyer la longueur de la vidéo en nombre de trames.
mais Movie Status est >MovieLength
quelqu'un a compris comment ça marche ?
comment transformé MovieStatus en temps et MovieLength en temps et comment transformé un temps pour MovieSeek ?
J'essaye de faire un outil qui permet de prendre des photos a partir de film GoPro. Et de façon que la photo ai la bonne heure de création en fonction de la date de debut du film et du temps écoulé dans le film.
Freak a fournit un code pour faire la copie d'ecran.
Voici mon code.
Si quelqu'un a une idée,une explication, je suis preneur. Merci
Code : Tout sélectionner
UseJPEGImageEncoder()
;Source : http://www.forums.purebasic.com/english/viewtopic.php?f=12&t=9384&hilit=MovieSeek&sid=35210c834fc99808364128cad84e2228
;coded by Freak
;Updated by dige
;Updated by ozzie
;
; ---------------------------------------------------------------------
;
; CaptureFrame(#Movie, #Image, #Memory)
;
; Copies the current frame of the #Movie to the #Image.
; The movie must pe paused when calling this, otherwise it will fail.
; The #Image should be the same size as the movie (MovieWidth(), MovieHeight())
;
; ---------------------------------------------------------------------
Structure PB_StructureMovie
Movie.IGraphBuilder
MediaControl.IMediaControl
MediaEvent.IMediaEventEx
Window.IVideoWindow
Audio.IBasicAudio
Video.IBasicVideo
MediaSeeking.IMediaSeeking
state.l
EndStructure
Procedure.l CaptureFrame(MovieNumber, ImageNumber)
Protected *Movie.PB_StructureMovie, *Video.IBasicVideo, *Window.IVideoWindow
Protected *ImageData.BITMAPINFOHEADER, DataSize, Parent, Result
Protected hBmp, w, h, hdc
Protected bmi.BITMAPINFO
*Movie = IsMovie(MovieNumber)
*Window = *Movie\Window
*Video = *Movie\Video
Result = 0
If *Video\GetCurrentImage(@DataSize, 0) = #S_OK
*ImageData = AllocateMemory(DataSize)
If *ImageData
If *Video\GetCurrentImage(@DataSize, *ImageData) = #S_OK
If IsImage( ImageNumber )
hBmp = ImageID( ImageNumber )
w = ImageWidth(ImageNumber)
h = ImageHeight(ImageNumber)
bmi.BITMAPINFO
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = w
bmi\bmiHeader\biHeight = h
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = ImageDepth(ImageNumber)
bmi\bmiHeader\biBitCount = 32
bmi\bmiHeader\biCompression = #BI_RGB
hdc = StartDrawing(ImageOutput(ImageNumber))
If hdc
SetDIBits_( hdc, hBmp, 0, h, *ImageData, @bmi, #DIB_RGB_COLORS)
StopDrawing()
EndIf
EndIf
EndIf
FreeMemory(*ImageData)
EndIf
EndIf
*Window\get_Owner(@Parent)
RedrawWindow_(Parent,0,0,#RDW_INVALIDATE)
ProcedureReturn Result
EndProcedure
; ---------------------------------------------------------------------
; Code example:
; ---------------------------------------------------------------------
#Movie = 0
#Image = 0
#Window = 0
Enumeration
#Gadget_Capture
#Gadget_Play
#Gadget_Frame
#Gadget_Pause
EndEnumeration
If InitMovie()
FileName$ = OpenFileRequester("Choose Movie","","Movie Files|*.mpg;*.avi;*.mpeg|All Files|*.*", 0)
date.i=GetFileDate(FileName$, #PB_Date_Created)
If LoadMovie(#Movie, FileName$)
Debug MovieInfo(#Movie, 0)
Width = MovieWidth(#Movie)
Height = MovieHeight(#Movie)
CreateImage(#Image, Width , Height)
If OpenWindow(#Window, 0, 0, 800 , 600, "Frame Capture", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
ButtonGadget(#Gadget_Play, 0, 0, 100, 25, "play")
ButtonGadget(#Gadget_Pause, 100, 0, 100, 25, "pause")
StringGadget(#Gadget_Frame, 200,0,100,25,"")
ButtonGadget(#Gadget_Capture, 300, 0, 100, 25, "Capture")
ResizeMovie(#Movie,0,50,WindowWidth(#Window) ,Height*WindowWidth(#Window)/Width)
PlayMovie(#Movie, WindowID(#Window))
time=ElapsedMilliseconds()
SmartWindowRefresh(#Window, #True)
AddWindowTimer(#Window,0,1000)
HideWindow(#Window, 0)
Repeat
Event = WindowEvent()
If Event = #PB_Event_Timer
Debug "movie "+Str(MovieStatus(#Movie)/1000)+" "+Str(MovieLength(#Movie))
Debug "time "+Str(ElapsedMilliseconds()-time)
EndIf
If Event = #PB_Event_Gadget
Select EventGadget()
Case #Gadget_Capture
resume.b=#False
If MovieStatus(#Movie)>0
SetGadgetText(#Gadget_Frame,Str(MovieStatus(#Movie)))
pos.l=MovieStatus(#Movie)
PauseMovie(#Movie)
resume.b=#True
EndIf
If MovieStatus(#Movie)=-1
CaptureFrame(#Movie, #Image)
newDate=AddDate(date,#PB_Date_Second,pos)
name.s=FormatDate("%yyyy-%mm-%dd %hhh%iim%sss",newDate)+" "+GetFilePart(FileName$,#PB_FileSystem_NoExtension)+".jpg"
SaveImage(#Image,name,#PB_ImagePlugin_JPEG)
SetFileDate(name,#PB_Date_Created,newDate)
EndIf
If resume=#True
ResumeMovie(#Movie)
EndIf
Case #Gadget_Pause
If MovieStatus(#Movie)>0
pos.l=MovieStatus(#Movie) ;renvoie la position dans le film en seconde
SetGadgetText(#Gadget_Frame,Str(MovieStatus(#Movie)))
PauseMovie(#Movie)
EndIf
Case #Gadget_Play
If MovieStatus(#Movie)<=0
MovieSeek(#Movie,ValD(GetGadgetText(#Gadget_Frame)))
ResumeMovie(#Movie)
EndIf
Case #Gadget_Frame
If MovieStatus(#Movie)<=0
MovieSeek(#Movie,ValD(GetGadgetText(#Gadget_Frame)))
ResumeMovie(#Movie)
PauseMovie(#Movie)
EndIf
EndSelect
EndIf
If Event = 0
Delay(1)
EndIf
Until event = #PB_Event_CloseWindow
EndIf
EndIf
EndIf
End