Thanks for clearifying.
Getting the anim format argument correct solved it for both IFF and GIF.
For IFF and GIF the FPS argument is not needed in
BeginAnimStream(), and the Delay argument will work as it should regardless if FPS is set or not.
So I would say the manual is correct.
On the other hand AVI (MJPEG) does use the FPS argument to set the playback rate.
But PlayAnim(1, 0, 0, {speed = #DEFAULTSPEED}) seem to ignore the FPS setting, it plays the video at full rate anyway.
If I play the AVI video in an external player like VLC the FPS setting is working.
The FPS setting does have huge impact on the AVI file size. The lower FPS, the bigger the file size gets.
That is strange since as a general rule the lower frame rate should result in smaller files (according to google).
From example below, 7 frame 640x480 anim file sizes:
GIF = 8 kb
IFF = 10 kb
AVI (25 FPS) = 156 kb
AVI (2 FPS) = 711 kb
AVI (1 FPS) = 1314 kb
This example which also generates a sample anim file for testing the various formats
Code: Select all
CreateBrush(1, 640, 480)
SelectBrush(1)
SetFillStyle(#FILLCOLOR)
BeginAnimStream(1, "anim.gif", 640, 480)
For Local k = 1 To 7
Box(50,200, 200, 30, #BLACK)
TextOut(50, 200, "FRAME NUMBER "..k)
WriteAnimFrame(1, 1)
Next
FinishAnimStream(1)
EndSelect
animfile$ = "anim.gif"
;animfile$ = FileRequest("Select anim file", {Filters = "avi|iff|gif"})
OpenAnim(1, animfile$)
Local animwidth = GetAttribute(#ANIM, 1, #ATTRWIDTH)
Local animheight = GetAttribute(#ANIM, 1, #ATTRHEIGHT)
Local animframes = GetAttribute(#ANIM, 1, #ATTRNUMFRAMES)
CreateBrush(9, animwidth*(Max(animframes, frameno)), animheight, #WHITE)
SelectBrush(9)
For i = 1 To animframes
LoadAnimFrame(10, i, animfile$)
DisplayBrush(10, (i*animwidth)-animwidth, 0)
Next
animformat = SystemRequest("Anim format", "Supported formats are:\n IFF Anim\n GIF Anim\n (AVI doesn't handle individual\nframe delay.\nYou set the FPS rate.)","AVI|IFF|GIF")
animfile$ = FileRequest("Output anim file name", { Mode = #REQ_SAVEMODE, Filters = "avi|iff|gif"})
Switch animformat
Case 1:
animformat = #ANMFMT_MJPEG
animfps = StringRequest("Set FPS","Enter playback speed in FPS\nDefault speed is 25", 25, #NUMERICAL)
BeginAnimStream(1, animfile$, animwidth, animheight, animformat, {FPS=animfps})
Case 2:
animformat = #ANMFMT_IFF
sel = SystemRequest("Anim delay choice", "How to apply frame delay?\n Set individual frame delays\n or same delay for all frames","Individual|Common delay")
If sel = 0
framedelay = StringRequest("Frame delay","Enter the delay in ms for all frames", 200, #NUMERICAL)
framedelay = Val(framedelay)
EndIf
BeginAnimStream(1, animfile$, animwidth, animheight, animformat)
Case 0:
animformat = #ANMFMT_GIF
sel = SystemRequest("Anim delay choice", "How to apply frame delay?\n Set individual frame delays\n or same delay for all frames","Individual|Common delay")
If sel = 0
framedelay = StringRequest("Frame delay","Enter the delay in ms for all frames", 200, #NUMERICAL)
framedelay = Val(framedelay)
EndIf
BeginAnimStream(1, animfile$, animwidth, animheight, animformat)
EndSwitch
For i = 1 To Max(animframes+addwidth, frameno)
CopyBrush(9, 11)
CropBrush(11, (i*animwidth)-animwidth, 0, animwidth, animheight)
If sel = 1
framedelay = StringRequest("Frame delay","Enter the delay in ms for frame "..i, 200, #NUMERICAL)
framedelay = Val(framedelay)
EndIf
WriteAnimFrame(1, 11, {Delay = framedelay})
Next
FinishAnimStream(1)
EndSelect()
FreeBrush(9)
FreeBrush(10)
FreeBrush(11)
LoadAnim(1, animfile$)
PlayAnim(1, 0, 0, {speed = #DEFAULTSPEED})
CloseAnim(1)