c# ile video yapma kodları
using
AForge.Video.FFMPEG;
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
VideoWriter
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void
buttonCreateVideo_Click(
object
sender, EventArgs e)
{
int
width = 640;
int
height = 480;
VideoFileWriter writer =
new
VideoFileWriter();
writer.Open(
"code-bude_test_video.avi"
, width, height, 25, VideoCodec.MPEG4, 1000000);
Bitmap image =
new
Bitmap(width, height);
Graphics g = Graphics.FromImage(image);
g.FillRectangle(Brushes.Black, 0, 0, width, height);
Brush[] brushList =
new
Brush[] { Brushes.Green, Brushes.Red, Brushes.Yellow, Brushes.Pink, Brushes.LimeGreen };
Random rnd =
new
Random();
for
(
int
i = 0; i < 250; i++)
{
int
rndTmp = rnd.Next(1, 3);
Application.DoEvents();
g.FillRectangle(brushList[i%5], (i % width)*2, (i % height) * 0.5f, i%30, i%30);
g.FillRectangle(brushList[i % 5], (i % width)*2, (i % height)*2, i % 30, i % 30);
g.FillRectangle(brushList[i % 5], (i % width) * 0.5f, (i % height) *2, i % 30, i % 30);
g.Save();
writer.WriteVideoFrame(image);
}
g.DrawString(
"(c) 2013 by code-bude.net"
,
new
System.Drawing.Font(
"Calibri"
, 30), Brushes.White, 80, 240);
g.Save();
for
(
int
i = 0; i < 125; i++)
{
writer.WriteVideoFrame(image);
}
writer.Close();
}
}
}
Hiç yorum yok:
Yorum Gönder