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 ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| 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... |
| Sponsored Links |
| |||
| 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.. |
| |||
| 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... |
| |||
| 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.. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 |