Play movies on the propeller
Dr_Acula
Posts: 5,484
The color video thread has evolved to the point of being able to play movies http://www.youtube.com/watch?v=170HLfl6VfI
Of course, having uploaded this, Youtube has kindly linked it with a video by PropGFX showing this was first done back in 2008!
So, belatedly, the video itself is just a single binary file that is played through Kye's 160x120 video driver. Speed works out fast enough to play the video at the right speed. There are enough cogs free for other things (? audio).
Hardware is a prop demo board with an SD card attached to pins 12,13,14,15.
The most complicated part is the pre-processing. Grab a Youtube video with Savetube and run it through AVS4YOU to create hundreds of bitmap files. Then run a vb.net program to shrink those down to 160x120 and reduce the color depth to 64 colors.
New vb.net code automates the process of creating screens from bitmaps of any size.
Spin code uses Kye's objects from the Obex.
And the vb.net processing routine
Screenshot of the IDE attached.
Of course, having uploaded this, Youtube has kindly linked it with a video by PropGFX showing this was first done back in 2008!
So, belatedly, the video itself is just a single binary file that is played through Kye's 160x120 video driver. Speed works out fast enough to play the video at the right speed. There are enough cogs free for other things (? audio).
Hardware is a prop demo board with an SD card attached to pins 12,13,14,15.
The most complicated part is the pre-processing. Grab a Youtube video with Savetube and run it through AVS4YOU to create hundreds of bitmap files. Then run a vb.net program to shrink those down to 160x120 and reduce the color depth to 64 colors.
New vb.net code automates the process of creating screens from bitmaps of any size.
Spin code uses Kye's objects from the Obex.
{ Propeller Movie player by James Moxham, November, 2010 See also the vb.net program to create the movie files } CON _clkfreq = 80_000_000 _clkmode = xtal1 + pll16x _clockDataPin = 29 _clockClockPin = 28 _cardDataOutPin = 12 _cardClockPin = 13 _cardDataInPin = 14 _cardChipSelectPin = 15 _pinGroup = 2 _switchRate = 5 ' Keyboard NUM = %100 CAPS = %010 SCROLL = %001 RepeatRate = 40 MaxIcons = 15 OBJ pix: "VGA64_PIXEngine.spin" ' thanks to Kye 160x120 fat: "SD2.0_FATEngine.spin" ' thanks to Kye kb : "keyboard" ' keyboard VAR Word Key long i PUB Main ifnot(pix.PIXEngineStart(_pinGroup)) reboot ifnot(fat.FATEngineStart(_cardDataOutPin, _cardClockPin, _cardDataInPin, _cardChipSelectPin, _clockDataPin, _clockClockPin)) reboot fat.mountPartition(0,0) ' mount the sd card kb.startx(26, 27, NUM, RepeatRate) 'Start Keyboard Driver if required Wallpaper ' startup splash screen repeat i from 1 to 600000 ' delay for vga screen to warm up Movie(837) ' play n frames in the movie PUB Wallpaper fat.openfile(string("prop160.vga"),"R") ' 160x120 fat.readdata(pix.displaypointer,19200) fat.closefile PUB Movie(n) | d fat.openfile(string("taz.pmv"),"R") ' 160x120 per frame, saved as a binary file repeat i from 1 to n ' number of frames fat.readdata(pix.displaypointer,19200) ' possibly add a delay here fat.closefile
And the vb.net processing routine
Dim sizex As Integer Dim sizey As Integer Dim PixelValue As Color sizex = 160 - 1 ' kye screen is 160x120 sizey = 120 - 1 Dim PixelArray(sizex, sizey, 3) As Byte ' R,G,B and calculated prop byte so 4 values Dim x, y, i As Integer Dim Propbyte As Byte Dim OutputArray(20000) As Byte Dim t As Integer Dim Sourcefile As String Dim DestinationFile As String Dim StartNumber As Integer Dim FinishNumber As Integer Dim Filecounter As Integer Dim LineofText As String DestinationFile = TextBox10.Text + TextBox14.Text StartNumber = Strings.Val(TextBox12.Text) FinishNumber = Strings.Val(TextBox13.Text) Dim OutputVGA As New FileStream(DestinationFile, FileMode.Create, FileAccess.Write) For Filecounter = StartNumber To FinishNumber Sourcefile = TextBox10.Text + TextBox11.Text ' directory plus rootname ' add the right number of leading zeros, (AVS4YOU adds a different number based on how big the total file is) LineofText = Strings.Right("000000" + Trim(Strings.Str(Filecounter)), Strings.Len(TextBox12.Text)) ' convert to a string Label25.Text = LineofText Sourcefile += LineofText + ".bmp" ' this little bit of code replaces new sytem.drawing.bitmap as the latter leaves the file locked eg so paintshop can't save a new file Dim img As Image Dim fs As New FileStream(Sourcefile, IO.FileMode.Open) img = Image.FromStream(fs) fs.Close() ' displa the image in the picture box PictureBox4.Image = img ' Get the source bitmap. Dim bm_source As New Bitmap(PictureBox4.Image) ' Make a bitmap for the result shrunk to 160x120 Dim bm_dest As New Bitmap(CInt(160), CInt(120)) ' Make a Graphics object for the result Bitmap. Dim gr_dest As Graphics = Graphics.FromImage(bm_dest) ' Copy the source image into the destination bitmap. gr_dest.DrawImage(bm_source, 0, 0, bm_dest.Width + 1, bm_dest.Height + 1) ' Display the result. PictureBox5.Image = bm_dest gr_dest.Dispose() Dim MyBitmap As New System.Drawing.Bitmap(PictureBox5.Image) 'image from picture box For y = 0 To sizey For x = 0 To sizex PixelValue = MyBitmap.GetPixel(x, y) ' get the color PixelArray(x, y, 0) = PixelValue.R ' red byte PixelArray(x, y, 1) = PixelValue.G ' green byte PixelArray(x, y, 2) = PixelValue.B ' blue byte PixelArray(x, y, 3) = 0 ' pre fill the prop byte with %00000000 for Kye's code Next Next ' create the propeller color byte For y = 0 To sizey For x = 0 To sizex For i = 0 To 2 ConvertColor(PixelArray(x, y, i), Propbyte) ' get the value 0-3 Select Case i Case 0 : Propbyte = Propbyte * 64 ' shift to red position Case 1 : Propbyte = Propbyte * 16 ' shift to green position Case 2 : Propbyte = Propbyte * 4 ' shift to blue position End Select PixelArray(x, y, 3) = PixelArray(x, y, 3) + Propbyte ' add to existing color Next i Next x Next y 'PictureBox3.Image = MyBitmap ' bitmap array to picturebox - need to convert pixelarray back to mybitmap to show the decreased color depth ' now turn the pixelarray x,y,3 into a binary file t = 0 For y = 0 To sizey For x = 0 To sizex OutputArray(t) = PixelArray(x, y, 3) ' move to output array t += 1 Next Next System.Windows.Forms.Application.DoEvents() ' update the display OutputVGA.Write(OutputArray, 0, 19200) ' save 19200 bytes Next Filecounter OutputVGA.Close() End Sub
Screenshot of the IDE attached.
Comments
only "Rayman" seems to have actually tried it.
The prop can record live B/W video with sound to an SD. It is controlled by a InfraRed remote.
It is still very primative, I work on it sporadically, but there you will find a black and white video recorder that has a test video of myself.
That program records audio at every horizontal pulse, I have to change that though, because of the a nine missing horizontal pulses during vertical sync.
simply change the SD interface to you desired pins and you will see it.
I have a newer version with a short clip from "The Flintstones"
I believe it is possible to get it to record color as well.
http://forums.parallax.com/showthread.php?t=98516&highlight=stupid%2C+video
Perry
I've ponderd a number of video capture solutions. The one I must get around to testing is to use one of those keychain video recorders that record to a micro SD. Then use Kye's SD code to read back the file and process it.
B&W video capture could be perfect for robotic applications. Reading your thread now...