Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to add wave file to wmv file

How to add wave file to wmv file

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hemant kulkarni
    wrote on last edited by
    #1

    Hi, I have the wmv file and a wave file. I want to add the wave file into wmv file. How can we achive this? Regards, Hemant.

    M 2 Replies Last reply
    0
    • H Hemant kulkarni

      Hi, I have the wmv file and a wave file. I want to add the wave file into wmv file. How can we achive this? Regards, Hemant.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Like I keep telling you. The Windows Media Format SDK is made for this. It's THE SDK for ASF files, which is what a WMV file is.

      1 Reply Last reply
      0
      • H Hemant kulkarni

        Hi, I have the wmv file and a wave file. I want to add the wave file into wmv file. How can we achive this? Regards, Hemant.

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        While I can't write it and post it here, maybe I can point you in the right direction. You'll need to read the video stream(s) (there could be more than one) and write them to to the new file. At the same time you will read PCM samples from the wave file and write them to a new, separate audio stream in the new file. For synchronizing audio and video you'll need to handle the sample time (passed to IWMWriter::WriteSample()) somehow. It's alot of code to post an example here but there is plenty of sample code in the Windows Media Format SDK. The "WMVCopy" sample application is a good place to start. Hope this helps, Mark

        H 1 Reply Last reply
        0
        • M Mark Salsbery

          While I can't write it and post it here, maybe I can point you in the right direction. You'll need to read the video stream(s) (there could be more than one) and write them to to the new file. At the same time you will read PCM samples from the wave file and write them to a new, separate audio stream in the new file. For synchronizing audio and video you'll need to handle the sample time (passed to IWMWriter::WriteSample()) somehow. It's alot of code to post an example here but there is plenty of sample code in the Windows Media Format SDK. The "WMVCopy" sample application is a good place to start. Hope this helps, Mark

          H Offline
          H Offline
          Hemant kulkarni
          wrote on last edited by
          #4

          Hi, Thanks for your comments!. Now I am using the Windows Media Format SDK for adding the wave file to wmv file. I have written the following code, but it is not allowing to add audio to me. It adds either audio or video and not the both. WHat may be the reason public static void AddAudioVideo() { try { // Create a WMEncoder object. WMEncoder Encoder = new WMEncoder(); // Retrieve the source group collection. IWMEncSourceGroupCollection SrcGrpColl = Encoder.SourceGroupCollection; // Add a source group to the collection. IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("SG_1"); // Add a video and audio source to the source group. IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); SrcAud.SetInput("D:\\wmv\\input\\2006_10_16_13_9_49_759.wav", "", ""); IWMEncVideoSource2 SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO); SrcVid.SetInput("D:\\wmv\\output\\TestOutPut.wmv", "", ""); // Specify a file object in which to save encoded content. IWMEncFile File = Encoder.File; File.LocalFileName = "D:\\wmv\\output\\OutputFile.wmv"; // Choose a profile from the collection. IWMEncProfileCollection ProColl = Encoder.ProfileCollection; IWMEncProfile Pro; for (int i = 0; i < ProColl.Count; i++) { Pro = ProColl.Item(i); if (Pro.Name == "Windows Media Video 8 for Local Area Network (384 Kbps)") { SrcGrp.set_Profile(Pro); break; } } // Start the encoding process. // Wait until the encoding process stops before exiting the application. Encoder.PrepareToEncode(true); Encoder.Start(); Console.WriteLine("Press Enter when the file has been encoded."); Console.ReadLine(); // Press Enter after the file has been encoded. } catch (Exception e) { // TODO: Handle exceptions. } } /////// } Regards, Hemant.

          M 1 Reply Last reply
          0
          • H Hemant kulkarni

            Hi, Thanks for your comments!. Now I am using the Windows Media Format SDK for adding the wave file to wmv file. I have written the following code, but it is not allowing to add audio to me. It adds either audio or video and not the both. WHat may be the reason public static void AddAudioVideo() { try { // Create a WMEncoder object. WMEncoder Encoder = new WMEncoder(); // Retrieve the source group collection. IWMEncSourceGroupCollection SrcGrpColl = Encoder.SourceGroupCollection; // Add a source group to the collection. IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("SG_1"); // Add a video and audio source to the source group. IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); SrcAud.SetInput("D:\\wmv\\input\\2006_10_16_13_9_49_759.wav", "", ""); IWMEncVideoSource2 SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO); SrcVid.SetInput("D:\\wmv\\output\\TestOutPut.wmv", "", ""); // Specify a file object in which to save encoded content. IWMEncFile File = Encoder.File; File.LocalFileName = "D:\\wmv\\output\\OutputFile.wmv"; // Choose a profile from the collection. IWMEncProfileCollection ProColl = Encoder.ProfileCollection; IWMEncProfile Pro; for (int i = 0; i < ProColl.Count; i++) { Pro = ProColl.Item(i); if (Pro.Name == "Windows Media Video 8 for Local Area Network (384 Kbps)") { SrcGrp.set_Profile(Pro); break; } } // Start the encoding process. // Wait until the encoding process stops before exiting the application. Encoder.PrepareToEncode(true); Encoder.Start(); Console.WriteLine("Press Enter when the file has been encoded."); Console.ReadLine(); // Press Enter after the file has been encoded. } catch (Exception e) { // TODO: Handle exceptions. } } /////// } Regards, Hemant.

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            What language is that code written in? :) *shrug*

            H 1 Reply Last reply
            0
            • M Mark Salsbery

              What language is that code written in? :) *shrug*

              H Offline
              H Offline
              Hemant kulkarni
              wrote on last edited by
              #6

              It is written in c#

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups