Seite 1 von 1

Video in MEMORY

Verfasst: 09.04.2022 13:27
von Velindos
Hallo Leute,

will ein Vorspan laden und diesen per Btn-Druck abspielen!

Nun das Movie kann ich mit LoadMovie() ja gegeben.

Möchte Ihn jedoch öfter im Programm abspielen und Ihn daher speichern wie folgt...

DataSection
HELP_Movie:
IncludeBinary "D:\[Pure@API]\[VIDEO]\Schneewechte.mp4": Data.s 0
EndDataSection

Wie kann ich dann das Movie abspielen?
PlayMovie(PeekS(?HELP_Movie,-1,#PB_Ascii), WindowID(0))
geht es nicht!

Jemand eine IDEE?

Gruss ... Velindos

Re: Video in MEMORY

Verfasst: 09.04.2022 14:37
von dige
PlayVideoFromRAM (),as dem Forum von 2016 ... hoffe es läuft noch ;-)

Code: Alles auswählen

; http://www.purebasic.fr/english/viewtopic.php?f=12&t=65366

;Don't forget, the wav is already loaded in memory (ReadData()).
Global *mm_Data, mm_size.l, mm_4.l, mm_opn
; Declare P_mm_IO(*lpM.MMIOINFO,mesg.l,param1.l,param2.l)

Procedure P_mm_IO(*lpM.MMIOINFO,mesg.l,lParam1.l,lParam2.l)
  Select mesg
  Case #MMIOM_OPEN
    If mm_opn=1: ProcedureReturn 0: EndIf
    mm_opn=1
    *lpM\lDiskOffset = 0:ProcedureReturn 0
  Case #MMIOM_CLOSE: ProcedureReturn 0
  Case #MMIOM_READ
    ; CallDebugger
    ; Debug *mm_Data+*lpM\lDiskOffset
    ; Debug lParam1
    ; Debug lParam2
    
    CopyMemory(*mm_Data+*lpM\lDiskOffset,lParam1, lParam2)
    *lpM\lDiskOffset + lParam2;
    ProcedureReturn lParam2
  Case #MMIOM_SEEK
    Select lParam2
    Case #SEEK_SET
    *lpM\lDiskOffset = lParam1
    Case #SEEK_CUR
    *lpM\lDiskOffset + lParam1
    Case #SEEK_END
    *lpM\lDiskOffset = fileSize - 1 - lParam1;
    EndSelect
    ProcedureReturn *lpM\lDiskOffset;
  Default
    ProcedureReturn -1
  EndSelect
  ProcedureReturn
EndProcedure

Procedure PlayVideoFromRam (*mem, hw1, memsize = #PB_Ignore)
  
  *generic_bank=AllocateMemory(4096)
  
  *mm_Data = *mem
  
  If  memsize = #PB_Ignore
    mm_size  =  MemorySize(*mm_Data)
  EndIf
  
  ; OpenFile(0, "J:\_temp\decoded.mov")
  ; WriteData(0, *mm_Data, mm_size)
  ; CloseFile(0)
  
  mm_4.l=mmioStringToFOURCC_("MOV",#MMIO_TOUPPER)
  ;could be anything other than "ABC", but not more than 3.
  mm_opn=0
  ;Now the private IOroutine is being loaded:
  mmioInstallIOProc_(mm_4,@P_mm_IO(),#MMIO_INSTALLPROC)
  ;Now an almost normal mci open command: but note the 'filename':
  ;..it's the extension "ABC+" which makes mci to use your private
  ;..routine P_mm_IO() for IO with wav at memory address *mm_Data:
  
  uu.l=mciSendString_("open film.ABC+ type AVIVideo alias test",0,0,0)
  
  uu.l=mciSendString_("window test handle " + Str(hw1),0,0,0) ; Put Film in Purebasic Windows
  ;uu.l=mciSendString_("put test destination at 0 0 "+Str(width/2)+" "+Str(height/2),0,0,0) ; show the film in a Part of the Windows
  
  ;from here on, you do mci commands (play [from], pause, status,..) as usual!
  ;...
  ;...
  ;when finished, close this way:
  
  mciSendString_("play test",0,0,0)
  ;mciSendString_("play test fullscreen",0,0,0) ; <- fullscreenmode
  
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_CloseWindow  ; If the user has pressed on the close button
      Quit = 1
    EndIf
  Until Quit = 1
  
  mciSendString_("close test",0,0,0)
  mmioInstallIOProc_(mm_4,#Null,#MMIO_REMOVEPROC)
  FreeMemory (*generic_bank)  
  
  
  
EndProcedure


OpenWindow(0, 0, 0, 800, 600, "PlayVideoFromRAM", #PB_Window_SystemMenu)
file.s = "J:\_temp\030712_45.AVI"
If OpenFile(0, file)
  *mem = AllocateMemory(Lof(0))
  ReadData(0, *mem, Lof(0))
  CloseFile(0)
EndIf

PlayVideoFromRam(*mem, WindowID(0)) 
; jaPBe Version=3.13.4.880
; Build=0
; FirstLine=48
; CursorPosition=92
; ExecutableFormat=Windows
; DontSaveDeclare
; EOF

Re: Video in MEMORY

Verfasst: 10.04.2022 12:17
von Velindos
Hallo Dige!
Danke für den Tip!

Hier mal als Bleistift!

Code: Alles auswählen

; ------------------------------------------------------------
; http://www.purebasic.fr/english/viewtopic.php?f=12&t=65366
Global *mem
; ------------------------------------------------------------
;Don't forget, the wav is already loaded in memory (ReadData()).
Global *mm_Data, mm_size.l, mm_4.l, mm_opn
; Declare P_mm_IO(*lpM.MMIOINFO,mesg.l,param1.l,param2.l)
;
; ------------------------------------------------------------
;
;   PureBasic - Movie example file
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;
Procedure P_mm_IO(*lpM.MMIOINFO,mesg.l,lParam1.l,lParam2.l)
  Select mesg
    Case #MMIOM_OPEN
      If mm_opn=1: ProcedureReturn 0: EndIf
      mm_opn=1
      *lpM\lDiskOffset = 0:ProcedureReturn 0
    Case #MMIOM_CLOSE: ProcedureReturn 0
    Case #MMIOM_READ
      ; CallDebugger
      ; Debug *mm_Data+*lpM\lDiskOffset
      ; Debug lParam1
      ; Debug lParam2
      
      CopyMemory(*mm_Data+*lpM\lDiskOffset,lParam1, lParam2)
      *lpM\lDiskOffset + lParam2;
      ProcedureReturn lParam2
    Case #MMIOM_SEEK
      Select lParam2
        Case #SEEK_SET
          *lpM\lDiskOffset = lParam1
        Case #SEEK_CUR
          *lpM\lDiskOffset + lParam1
        Case #SEEK_END
          *lpM\lDiskOffset = fileSize - 1 - lParam1;
      EndSelect
      ProcedureReturn *lpM\lDiskOffset;
    Default
      ProcedureReturn -1
  EndSelect
  ProcedureReturn
EndProcedure
; ------------------------------------------------------------
Procedure PlayVideoFromRam (*mem, hw1, memsize = #PB_Ignore)
  
  *generic_bank=AllocateMemory(4096)
  
  *mm_Data = *mem
  
  If  memsize = #PB_Ignore
    mm_size  =  MemorySize(*mm_Data)
    ; mm_size =  ?ExitProc - ?Inc
  EndIf
  
  ; OpenFile(0, "J:\_temp\decoded.mov")
  ; WriteData(0, *mm_Data, mm_size)
  ; CloseFile(0)
  
  mm_4.l=mmioStringToFOURCC_("MOV",#MMIO_TOUPPER)
  ;could be anything other than "ABC", but not more than 3.
  mm_opn=0
  ;Now the private IOroutine is being loaded:
  mmioInstallIOProc_(mm_4,@P_mm_IO(),#MMIO_INSTALLPROC)
  ;Now an almost normal mci open command: but note the 'filename':
  ;..it's the extension "ABC+" which makes mci to use your private
  ;..routine P_mm_IO() for IO with wav at memory address *mm_Data:
  
  uu.l=mciSendString_("open film.ABC+ type AVIVideo alias test",0,0,0)
  
  uu.l=mciSendString_("window test handle " + Str(hw1),0,0,0) ; Put Film in Purebasic Windows
                                                              ;uu.l=mciSendString_("put test destination at 0 0 "+Str(width/2)+" "+Str(height/2),0,0,0) ; show the film in a Part of the Windows
  
  ;from here on, you do mci commands (play [from], pause, status,..) as usual!
  ;...
  ;...
  ;when finished, close this way:
  
  mciSendString_("play test",0,0,0)
  ;mciSendString_("play test fullscreen",0,0,0) ; <- fullscreenmode
  
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_CloseWindow  ; If the user has pressed on the close button
      Quit = 1
    EndIf
  Until Quit = 1
  
  mciSendString_("close test",0,0,0)
  mmioInstallIOProc_(mm_4,#Null,#MMIO_REMOVEPROC)
  FreeMemory (*generic_bank)  
  
  
  
EndProcedure
; ------------------------------------------------------------
If InitMovie() = 0
  MessageRequester("Error", "Can't initialize movie playback !", 0) 
  End
EndIf
; ------------------------------------------------------------
; MovieName$ = OpenFileRequester("Choose the movie to play", "", "Movie files|*.avi;*.mpg|All Files|*.*", 0)
MovieName$ = "D:\Eigene Videos\Hier sind meine Videos\Ahsampo\VID_20210526_162108 - Kopie.mp4"
; ------------------------------------------------------------
file.s = "D:\Eigene Videos\Open Camera 2.avi"
; ------------------------------------------------------------
If OpenFile(0, file)
  *mem = AllocateMemory(Lof(0))
  ReadData(0, *mem, Lof(0))
  CloseFile(0)
EndIf
; ------------------------------------------------------------
;     OpenWindow(0, 100, 150, MovieWidth(0), MovieHeight(0), "PureBasic - Movie")
OpenWindow(0, 100, 150, 400,500, "PureBasic - Movie")
;     PlayMovie(*mem, WindowID(0))
; ------------------------------------------------------------
PlayVideoFromRam(*mem, WindowID(0)) 
; ------------------------------------------------------------
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

DataSection
  Inc:
  IncludeBinary "D:\Eigene Videos\Open Camera 2.avi"
  ExitProc:
EndDataSection
Verstehe ich nicht, ehrlich gesagt!

Gruss ...Velindos!