I am planning on using Purebasic to load a frame of video, maybe alter it, and then save it as an image, then continue for all of the frames of a video.
Any ideas if there are any Movie or Image tools that will allow me to load a frame of a movie as an image - Or will it require understanding the encoding method and using the raw bytes of the video file to load the image to screen?
Converting a video to individual images.
Re: Converting a video to individual images.
Use ffmpeg to extact the image: (RunProgram())
https://www.bannerbear.com/blog/how-to- ... ng-ffmpeg/
https://www.bannerbear.com/blog/how-to- ... ng-ffmpeg/
Re: Converting a video to individual images.
Or: LoadMovie() -> PlayMovie -> MovieSeek() -> PauseMovie() -> Save image of window.
Re: Converting a video to individual images.
Last time I tried that, the video was an overlay and the frame cannot be saved. Is working that in all platforms?BarryG wrote: Mon Dec 11, 2023 12:44 pm Or: LoadMovie() -> PlayMovie -> MovieSeek() -> PauseMovie() -> Save image of window.
[:: PB Registered ::]
Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti
Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti
Re: Converting a video to individual images.
Great ideas. Thanks.
I'll be able to get at least one of those to work.
I'll be able to get at least one of those to work.
Re: Converting a video to individual images.
This works for Windows, but I don't know how to make it cross-platform as I don't have Mac/Linux.Saboteur wrote: Mon Dec 11, 2023 1:18 pmLast time I tried that, the video was an overlay and the frame cannot be saved. Is working that in all platforms?
Run this, and after 3 seconds the current frame is saved as a PNG image and app quits.
Adapt to your needs (as Rashad says) with MovieSeek(), PauseMovie(), proper error-checking, etc.
Code: Select all
UsePNGImageEncoder()
Procedure SaveWindowImage(hWnd,file$)
GetWindowRect_(hWnd,@win.RECT)
w=win\right-win\left
h=win\bottom-win\top
hBitmap=CreateImage(#PB_Any,w,h)
If hBitmap
hDC=StartDrawing(ImageOutput(hBitmap))
If hDC
SelectObject_(hDC,hBitmap)
If BitBlt_(hDC,0,0,w,h,GetDC_(0),win\left,win\top,#SRCCOPY)
f=SaveImage(hBitmap,file$,#PB_ImagePlugin_PNG)
EndIf
StopDrawing()
FreeImage(hBitmap)
EndIf
EndIf
EndProcedure
If OpenWindow(0,0,0,640,480,"test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ig=ImageGadget(0,0,0,640,480,0)
InitMovie()
LoadMovie(0,"D:\Movie.avi")
ResizeMovie(0,0,0,640,480)
PlayMovie(0,ig)
AddWindowTimer(0,0,3000)
Repeat
ev=WaitWindowEvent()
If ev=#PB_Event_Timer
RemoveWindowTimer(0,0)
PauseMovie(0)
SaveWindowImage(ig,"D:\MovieImage.png")
End
EndIf
Until ev=#PB_Event_CloseWindow
EndIf
Re: Converting a video to individual images.
Please have a look to Movie2Image
https://www.purebasic.fr/english/viewtopic.php?t=17729
https://www.purebasic.fr/english/viewtopic.php?t=17729
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...