IT Community - Software Programming, Web Development and Technical Support

How to create a movie from jpgs and Songs inC#?

This is a discussion on How to create a movie from jpgs and Songs inC#? within the C# Programming forums, part of the Software Development category; Hi, I want to create a wmv file using multiple jpgs and songs? Is it possible? Can anyone give an ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 10-27-2007, 05:15 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default How to create a movie from jpgs and Songs inC#?

Hi,

I want to create a wmv file using multiple jpgs and songs? Is it possible? Can anyone give an idea? And also play this in my application?
__________________
The OXYGEN
Delivers edgy, intelligent Technology to all...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-27-2007, 05:19 AM
Balasubramanian.S Balasubramanian.S is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 182
Balasubramanian.S is on a distinguished road
Default Re: How to create a movie from jpgs and Songs inC#?

Hi,

This is the sample to code to create a video file from images and songs.

Copy and paste the following code.

using WMEncoderLib;

FolderBrowserDialog folderBrowserDialog;

string[] sourceFiles;
public static string profileName = "imageencoder4.wme";// @"D:\Workarea\S.Bala\FLASH\MPEG\imageencoder4.wme" ;
public static string movie_dest = "D:\\Test.AVC";
WMEncoder glbEncoder = new WMEncoder();
IWMEncSourceGroupCollection SrcGrpColl = null;
int currentFileProcessed = 0;
int totalFiles = 0;
bool finished = true;

private bool sEncodeFile(string[] files, string destinationFileName)
{
string folderPath = files[0].Substring(0, files[0].LastIndexOf("\\"));
try
{
File.Delete(folderPath + "\\Thumbs.db");
}
catch { }
files = Directory.GetFiles(folderPath);
sourceFiles = files;
try
{
totalFiles = files.Length;
IWMEncProfile SourceProfile = null;
SrcGrpColl = glbEncoder.SourceGroupCollection;
IWMEncProfileCollection ProColl = glbEncoder.ProfileCollection;
IWMEncProfile Pro;
for (int i = 0; i < ProColl.Count - 1; i++)
{
Pro = ProColl.Item(i);
if (Pro.Name == "Windows Media Video 8 for Local Area Network (256 Kbps)")
SourceProfile = Pro;
}
string previousId = "";
IWMEncSourceGroup2 SrcGrp = null;

for (int i = 0; i < files.Length; i++)
{
string fileExtn = files[i].Substring(files[i].LastIndexOf(".")).ToLower();
if (fileExtn == ".jpg" || fileExtn == ".jpeg" || fileExtn == ".png" || fileExtn == ".tiff" || fileExtn == ".gif" || fileExtn == ".bmp")
{
SrcGrp = (IWMEncSourceGroup2)SrcGrpColl.Add("ImageFileSourc e_" + i);
previousId = "ImageFileSource_" + i;
SrcGrp.set_Profile(SourceProfile);
IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
//SrcAud.SetInput(@"D:\\song.mp3", "", "");
SrcAud.SetInput(Environment.CurrentDirectory + "\\song.mp3", "", "");
IWMEncVideoSource2 SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_ TYPE.WMENC_VIDEO);
SrcVid.SetInput(files[i], "", "");
}
}
glbEncoder.File.LocalFileName = destinationFileName;


try
{
glbEncoder.PrepareToEncode(true);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
try
{
timer1.Start();
finished = false;
glbEncoder.Start();
MessageBox.Show("Started making File ");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return false;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (currentFileProcessed < totalFiles)
{
string fileExtn = sourceFiles[currentFileProcessed].Substring(sourceFiles[currentFileProcessed].LastIndexOf(".")).ToLower();
if (fileExtn == ".jpg" || fileExtn == ".jpeg" || fileExtn == ".png" || fileExtn == ".tiff" || fileExtn == ".gif" || fileExtn == ".bmp")
{
if (SrcGrpColl.Item(currentFileProcessed) != null)
{
IWMEncSourceGroup selectedSource = SrcGrpColl.Item(currentFileProcessed);
if (selectedSource.Name.StartsWith("ImageFileSource") )
{
glbEncoder.SourceGroupCollection.Active = selectedSource;
}
}
}
}
else
{
stopEncoder();
}
currentFileProcessed++;
}

Thanks..

S.Balasubramanian..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-27-2007, 05:24 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: How to create a movie from jpgs and Songs inC#?

Hi,

I have executed your code. But it only create a video file. Please give me any sample code to play the video file in C#.
__________________
The OXYGEN
Delivers edgy, intelligent Technology to all...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-27-2007, 05:29 AM
Balasubramanian.S Balasubramanian.S is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 182
Balasubramanian.S is on a distinguished road
Default Re: How to create a movie from jpgs and Songs inC#?

Hi,

First extract the zip file that I have attached and add the class file.
Then add the following code in page load_event.

MCI.Media media = new MCI.Media();
media.Open(fileDialog.FileName, this.videoPictureBox);
media.Play();
media.Volume = 1000;

Thanks..

S.Balasubramanian..
Attached Files
File Type: zip MCI.zip (1.5 KB, 6 views)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HD-DVD as a movie format is dead... qaz555 The Lounge 0 03-21-2008 04:35 AM
Open color picker And choosing,applying a color to a Movie Clip in Flash oxygen Flash Actionscript Programming 1 07-25-2007 05:00 AM
HTML Movie tripnautic HTML, CSS and Javascript Coding Techniques 0 03-19-2007 11:04 PM
If you to make a movie... djree The Lounge 0 03-08-2007 01:24 PM


All times are GMT -7. The time now is 11:07 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0