« Company Birthday: 17 … | Home | Windows User Notifica… »

JPEGs to Movie

The last weeks, I had a little hobby project which included writing a movie out based on some picture files. Normally in the last years we used 
QTPictureMovieTrackMBS class. This works fine in Real Studio applications on Mac and Windows, but QuickTime is deprecated. You can still use it in Xojo (32-bit Mac), but you need to use our plugin classes to create movie and pass a movie handle. 
Newer projects on Mac should move to use AVFoundation plugin, e.g. AVAssetWriterInputPixelBufferAdaptorMBS class as you see in our examples. For example see the example project Make Video From Images.

A third way for a cross platform project is my new class JPEGMovieMBS.

This class simply writes a QuickTime Movie file without using QuickTime, so it should works cross platform. The movie has only one track with JPEG compressed picture data. You can specify the width and height, duration per picture and of course the JPEGs to include.

There is an example: 

// get a picture
dim p as Picture = LogoMBS(500)
// start movie building
dim m as new JPEGMovieMBS
m.Width = 500
m.Height = 500
m.SecondsPerFrame = 0.5
// add frames where we count up
for i as integer = 1 to 20
  dim c as new Picture(500, 500)
  dim g as Graphics = c.Graphics
  g.ForeColor = &c000000
  g.TextSize = 50
  g.DrawPicture p, 0, 0
  g.DrawString str(i), 20, 50
  dim j as string = c.GetData(c.FormatJPEG)
  m.AddFrame j
// generate movie
dim MovieData as string = m.BuildMovie
// and write to file
dim f as FolderItem = SpecialFolder.Desktop.Child("test.mov")
dim b as BinaryStream = BinaryStream.Create(f, true)
b.Write MovieData
Maybe someone finds it useful. For me it works nice. The videos can be played in QuickTime player and VLC. Windows Media Player can't decode them. 
02 04 17 - 15:58
No comments

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.