Hi, today i’m posting a FLV Video Encoder written in W-language…

It works on WinDev, WebDev and WinDev Mobile.

It is not meant to be fast, it was just the first iteration, another proof that you can do anything on WinDev.

You can find the Download here.

It uses the ScreenVideo codec, and it has been tested with flvcheck, and passed all tests.

NOTE: It creates FLV files, not SWF files, and with the ScreenVideo codec, this means that you cannot play the FLV file on all players, for example, i couldn’t played it with VLC, GOM and Windows Media Player… But i played it well with an SWF player named EasyFLV FLV Player.

Currently the source code is a mix between english and spanish… sorry for that, i’ll polish it latter…

Here is a code snippet on how to use the code:


// First step is to create our Encoder... The FLV Encoder is tought
// to support multiple encoders
// But right now only ScreenVideo is finished...
// We need to tell the Encoder that the image is on IMG_Captura,
// and the difference mask between
// the current image and the last image is on IMG_Mascara
// Also we specify the width and height of each box (internal ScreenVideo encoder workings...)
// Just be sure to specify 64, 128, 256, 512
Senc is ScreenVideoEncoder dynamic = new ScreenVideoEncoder(IMG_Captura..Name, IMG_Mascara..Name, 256, 128)

// Now we create the actual FLV Encoder, and we tell him that
// it would encode the video using the ScreenVideoEncoder that we just created
// We also tell him that the total video time is 8 seconds
FlvEnc is FLVEncoder dynamic = new FLVEncoder(Senc, 8 )

// We Start the Encoding (initialize global state)
FlvEnc.StartEncode()

// Previous image used
sNomAnt is string = ""

// 9 frames, frame for second 0, 1, 2, 3, ... 8, 8 seconds in total
FOR i = 0 _TO_ 8
// We name our actual image: SSHOT_0001.png
sNomImg is string = "SSHOT_" + NumToString(i, "04d") + ".png"

// Routine for generating the IMG_Mascara
// And assigning IMG_Captura, its something like this:
// IMG_Referencia = sNomAnt
// IMG_Captura = sNomImg
// dCopyBlt(IMG_Referencia, IMG_MascaraSaved)
// dCopyBlt(IMG_Captura, IMG_MascaraSaved, copySrcInvert)
// dCopyBlt(IMG_MascaraSaved, IMG_Mascara, copySrcCopy)
GenerarImagenes(sNomAnt, sNomImg)

// We move the time... It's measured in milliseconds
FlvEnc.SetTimestamp(i * 1000)

// Check if it's the first frame
IF i = 0 THEN
// If it's the first frame, render all the frame
FlvEnc.EncodeFrame(VideoEncoder::Keyframe)
ELSE
// If it's NOT the first frame, render only the differences
// using IMG_Mascara as the Mask image
FlvEnc.EncodeFrame(VideoEncoder::Interframe)
END

sNomAnt = sNomImg
END

// Encode the final video to "video.flv"
FlvEnc.EndEncode("video.flv")

Currently the FLVEncoder only encodes Video, i’ll program the Audio part later…

As i said, it’s VERY slow, i made this in about 5 hours, most of the time reading the FLV spec pdf… Use it at your own risk, you can use it in any project, it doesn’t have any license restrictions, but i would like to recive a notice that you are using, or that it was useful for your project.

C’yall