'===========
'QBVMAKE.BAS v0.10
'===========
'Makes .QBV Audio/Video files for QB64.
'Uses .jpg image sequences and .ogg sound files.
'Coded by Dav, MAY/2020
'QBVMAKE makes a .QBV audio/video file using a sequence
'of .jpg images and uses an .OGG sound file to add audio.
'This way you can make and use video files in you projects.
'This demo builds a video called BIRD.QBV in the current
'directory. It will then play the video. This is only an
'example so you can see how to make your own .QBV video.
'NOTE: YOU WILL HAVE TO ADAPT THIS CODE FOR YOUR FILES
'===========================================================
' SET YOUR OWN QBV INFORMATION IN THIS AREA.....
' The following are my demo file settings.
' You will need to replace them with your own.
QBV$ = "bird.qbv" '<<<--- NAME OF YOUR QBV TO MAKE
'Point to your image sequence location below and prefix
'My images are saved like, bird000.jpg.....
source$ = ".\qbvmake-demo\bird" '<<<---- YOUR IMAGE DIRECTORY
OGG$ = ".\qbvmake-demo\bird.ogg" '<<<--- Name of you .OGG file
'------
'NOW SET YOUR VIDEO INFO BELOW...
Audio = 1 '<<<--- SET TO 1 IF ADDING AUDIO, 0 IF NO AUDIO
fps = 15 'My demo video has 15 frames per second
frames = 165 'My video has 165 images in the sequence
vidwidth = 512 'The width of my video image files
vidheight = 288 'The height of my video image files
'==============================================================
'Now here we start making the QBV file....
'If adding audio, copy it first...
SL
= LOF(3) ''Length of OGG sound file... 'save it to QBV file
SL = 0 'No audio size at all
'Now we same the jpg images to the .QBV file.
'We start at frame 0, because image sequences start at 0 usually.
'This is set to use 0000 series numbers (ie: bird0000.jpg)
'If yours are different, you will have to adjust the code.
'Go through images...
'load a .jpg image file (a frame)
f$ = source$ + tag$ + ".jpg"
'Grab it, CLOSE it
'Get size of frame
'Save it's length to file
'Now save the frame data to file
IF Auido$
= "0" THEN OGG$
= "(no audio)" PRINT "Using audio file: "; OGG$
PRINT "Adding frame"; t
+ 1;
"of"; frames;
"..."
'Now we add a Footer to the end of the .QBV file.
'This will save all the .QBV settings information.
'Set what version of .QBV file this is.
'Set if QBV has audio of not.
'Save the width of video
'Save the height of video
'Now, save the OGG file size to the end in MKL format
'Now save number of frames in MKI format
'Now save FPS to file in MKI format
PRINT "Press any key to playback...."
'============================================================
'Now lets play back the video we just made....
'Open the demo file bird.qbv below.....
'set x/y pos, Zoom x2, resize screen to fit vid, loop option
PlayQBV "bird.qbv", 0, 0, 2, 1, 1
'=============================================================
SUB PlayQBV
(file$
, x
, y
, zoom
, fit
, loopit
) 'file$ = QBV file to play
'x = x position on screen
'y = y position on screen
'zoom factor of video, 1 is regular size,
' 2 is double size, etc...
'fit = fit video to match your current screen resolution
'loopit = Loop video or not. 1 is loop, 0 is play once.
'Get info saved at end of file
Ver$
= INPUT$(7, FF
) 'Version of QBV video format Audio$
= INPUT$(1, FF
) 'Audio setting vidwidth
= CVI(INPUT$(2, FF
)) 'Width of video vidheight
= CVI(INPUT$(2, FF
)) 'Height of video VidData
= CVL(INPUT$(4, FF
)) 'Place in file Video data starts frames
= CVI(INPUT$(2, FF
)) 'How many frames in file
'Set screen based on vid setting...
'make a temp jpg on disk
'load it
'erase it
KILL "_tmp_qbv_frame_.jpg"
_PUTIMAGE (x
, y
)-(x
+ (vidwidth
* zoom
), x
+ (vidheight
* zoom
)), frm&
'A little keyboad control if you want.
'If you don't want, comment this out....