AVI Film erzeugen
Übersicht

![]() |
Markus2Betreff: AVI Film erzeugen |
![]() Antworten mit Zitat ![]() |
---|---|---|
0815 Funktionen zum erzeugen einer AVI Film Datei .
(ohne Ton,ohne Index,ohne APIs,ohne fremde DLLs und ohne Garantie ![]() Also einfach nur Bitmap Daten als Film . Kann man dann später z.B. mit dem Programm "SUPER" in das Format bringen was man braucht . (Ich benutze den Media Player Classic, der Windows Media Player mag das AVI evtl. nicht...) Code: [AUSKLAPPEN] Function AVIWriteHeader(st:TStream,Width:Int,Height:Int,FrameCount:Int,FramesPerSecond:Int) Local WAVenabled:Int=0 Local BMPHeaderSize:Int=40 'Bytes Local BMPDataSize:Int=(Width*Height)*4 '1 Pixel = 4 Byte Local ChunkSize:Int ChunkSize =212+((8+BMPDataSize)*FrameCount) DebugLog "ChunkSize ="+ChunkSize WriteString st,"RIFF" WriteInt st,ChunkSize WriteString st,"AVI " '----------------------------------------------------------------------------- '1st LISTcccc WriteString st,"LIST" WriteInt st,4+4+4+(14*4) WriteString st,"hdrl" 'MainAVIHeader WriteString st,"avih" WriteInt st,14*4 '=56 Anzahl der Bytes die hier nach kommen bis End MainAVIHeader 'MicroSecPerFrame '1 Sek = 1000 ms = 1.000.000 µs WriteInt st,Int(1000000/FramesPerSecond) 'MaxBytesPerSec WriteInt st,0 'Reserved1 WriteInt st,0 'Flags WriteInt st,0 'AVIF_COPYRIGHTED AVIF_HASINDEX AVIF_MUSTUSEINDEX AVIF_ISINTERLEAVED AVIF_WASCAPTUREFILE 'TotalFrames WriteInt st,FrameCount 'InitialFrames WriteInt st,0 'Streams If WAVenabled Then 'If there is a wav file included WriteInt st,2 'say there are 2 streams; a video stream And a wav stream Else WriteInt st,1 'say there is only 1 stream; a video stream EndIf 'SuggestedBufferSize WriteInt st,BMPDataSize 'Width of the AVI file in pixels WriteInt st,Width 'Height WriteInt st,Height 'Scale WriteInt st,1 'Rate WriteInt st,FramesPerSecond 'Start WriteInt st,0 'Length WriteInt st,FrameCount 'Zeit aller Streams 'End MainAVIHeader '----------------------------------------------------------------------------- 'HEADER For BITMAP VIDEO STREAM 'AVI STREAM info 2nd LISTcccc WriteString st,"LIST" WriteInt st,27*4 WriteString st,"strl" 'strh Header Size WriteString st,"strh" WriteInt st,12*4 WriteString st,"vids" '=Video Stream , auds wäre für ein Audio Stream WriteString st,"DIB " 'Flags WriteInt st,0 'Reserved1 WriteInt st,0 'InitialFrames WriteInt st,0 'Scale WriteInt st,1 'Rate WriteInt st,FramesPerSecond 'dwRate / dwScale = samples/second 'Start WriteInt st,0 'Length WriteInt st,FrameCount 'SuggestedBufferSize WriteInt st,BMPDataSize 'Quality WriteInt st,0 'SampleSize WriteInt st,0 'End AVIStreamHeader 'AVIStreamFormat 'Format '---------------------------------------------------------------- WriteString st,"strf" WriteInt st,BMPHeaderSize '---------------------------------------------------- 'BITMAPINFOHEADER WriteInt st,BMPHeaderSize 'biSize 'Länge BITMAPINFOHEADER in Bytes WriteInt st,Width 'biWidth WriteInt st,Height 'biHeight WriteShort st,1 'biPlanes WriteShort st,4*8 'biBitCount 4 Bytes je Pixel WriteInt st,0 'biCompression WriteInt st,BMPDataSize 'biSizeImage WriteInt st,0 'biXPelsPerMeter WriteInt st,0 'biYPelsPerMeter WriteInt st,0 'biClrUsed WriteInt st,0 'biClrImportant '---------------------------------------------------- '----------------------------------------------------------------------------- WriteString st,"LIST" WriteInt st,4+(4+4+BMPDataSize)*FrameCount WriteString st,"movi" '... hier kommt dann AVIAddPixmap ins Spiel '----------------------------------------------------------------------------- End Function '---------------------------------------------------------------------------------------------------- Function AVIAddPixmap(st:TStream,pix:TPixmap) ' Bild dem AVI hinzu fügen Local BMPDataSize:Int=(PixmapWidth(pix)*PixmapHeight(pix))*4 '4 Byte je Pixel WriteString st,"00db" WriteInt st,BMPDataSize '---------------------------------------------------- '... YFlipPixmap Local x:Int Local y:Int For y=PixmapHeight(pix)-1 To 0 Step -1 For x=0 To PixmapWidth(pix)-1 WriteInt st,ReadPixel(pix,x,y) Next Next End Function Beispiel Code: [AUSKLAPPEN] z.B. FPS=25 oder 30 FramesGesamt die Anzahl der Pixmaps die man da hinzu fügt Local AVIStream:TStream=Null If AVIStream=Null Then AVIStream=OpenFile("MeinFilm.avi",False,True) If AVIStream Then AVIWriteHeader(AVIStream,PixmapWidth(FilmPixmap),PixmapHeight(FilmPixmap),FramesGesamt,FPS) EndIf If AVIStream Then AVIAddPixmap(AVIStream,FilmPixmap) If AVIStream Then CloseFile AVIStream;AVIStream=Null |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group