Extract wav file from video file - c#

I am developing an application in which I need to extract the audio from a video. The audio needs to be extracted in .wav format but I do not have a problem with the video format. Any format will do, as long as I can extract the audio in a wav file.
Currently I am using Windows Media Player COM control in a windows form to play the videos, but any other embedded player will do as well.
Any suggestions on how to do this?
Thanks

If you want to do this with C#, take a look at NAudio library. It can analyze the audio format (like FFMpeg) and also provide the audio stream. Here's one example.
Snippet from the sample:
using NAudio.Wave;
using System.IO;
...
// contentAsByteArray consists of video bytes
MemoryStream contentAsMemoryStream = new MemoryStream(contentAsByteArray);
using (WaveStream pcmStream =
WaveFormatConversionStream.CreatePcmStream(
new StreamMediaFoundationReader(contentAsMemoryStream)))
{
WaveStream blockAlignReductionStream = new BlockAlignReductionStream(pcmStream);
// Do something with the wave stream
}

Here is a link on how to extract audio using GraphEdit, GraphEdit is an front end UI for the DirectShow API so everything it can do you can do with API.
You can use the DirectShow.NET liberty which wraps the DirectShow API for the managed world.

Probably easiest to use ffmpeg for this kinda thing...

Very easy with FFMPEG! I routinely do this to grab audio out of downloaded youtube videos, convert music downlaods to WAV for editing, etc etc. It should work for any file extension:
ffmpeg -i source-of-any-file-extension.avi -vn -ar 44100 -ac 2 -ab 768000 -f wav target-filename.wav

Related

C# Video Streaming

I'm developing a C# video streaming application using NReco library. At this moment I was able to encode audio and video separately and save data in to queue. I can stream video using UDP protocol without audio and it played nicely in ffplay equally I can stream audio using UDP protocol without video and it also played nicely.Now I want to merge these two streams in to one and stream through UDP protocol and player should play both audio and video. But I have no idea how to do it. I would appreciate if some one can give me any points to do this or any other different method achieve this.
Thank You.
The answer highly depends on the source of video and audio streams. NReco.VideoConverter is a wrapper to FFMpeg tool and it actually can combine video and audio streams (see filters configuration in FFMpeg documentation) if either video or audio input can be specified as ffmpeg input source (UDP stream or direct show input device).
If both video and audio data represented by byte stream in your C# code you cannot pass them together using NReco.VideoConverter (ConvertLiveMedia method) because it uses stdin for communicating with ffmpeg and only one stream can be passed from C# code.

How can use Video Converter for .NET (C#) or other FFMpeg wrapper To create Video Thumbnail in Asp MVc

I want to create video thumbnails on my sites by using FFMpeg wrapper like Video Converter for .NET (C#) I am saving my video files in mp4 and wmv locally in video folder.if somebody know other wrapper please let me know and how can I use this
(new NReco.VideoConverter.FFMpegConverter()).GetVideoThumbnail(tmpFile, outputJpegStream);
Regards
User follow code:
var ffmpeg = new FFMpegConverter();
ffmpeg.GetVideoThumbnail(path, ThumbnailPath, second);

open audio formats and audio synthesis using NAudio

How can I open different audio formats(except .mp3 and .wav) using Naudio and C#?
How can I create audio synthesis unsing Naudio and C#?(I mean how to get the sound frequency and other data necesary for audio synthesis).
P.S. I've looked at this tutorial series
http://opensebj.blogspot.com/2009/02/introduction-to-using-naudio.html
and this one
http://www.giawa.com/tutorials/?p=19o
In addition to MP3 and WAV, NAudio can also open AIFF and WMA files with the AiffFileReader and WmaFileReader classes. Beyond that, you will have to write your own WaveStream derived class to read other formats.
See my tutorial on how to play a sine wave in NAudio, which will show you the basics of how to get started with audio synthesis in NAudio.

How to overlay audio file on .wmv video file using c#?

I want to record video and audio files using C#. After recording of audio + video i want to merge them. There can be only one video file and 10 audio file. I want this ten files to overlay on one video file.
I am assure that i want video file in .wmv format. Can you tell me i should record audios in which format so later i can overlay those audio files on .wmv format video file?
Also please let me know how to overlay audio file on .wmv video file?
Hope i will get prompt reply for this
You can use DirectShow Editing Services (DES) to do it. DirectShowLib should provide DES support in C#. Using it, create a timeline with video group (1 track) and audio group (several tracks if you need to overlay/mix some audios, i.e. hear more than one at a time). Place your video and audio files on the timeline in desired positions. Then tell DES to create a DirectShow graph and you'll get one video and one audio output pin. Connect them to ASF writer to save result to WMV.

Decompressing AVI file using DirectShow filters

I am trying to decompress an AVI file using DirectShow filters.
Here is the graph I am building.
File Reader -> AVI Splitter -> AVI decompressor -> SampleGrabber ->AVI Mux -> File Writer
I am suing SampleGrabber to report progress of conversion, nothing else.
The issue that I am having is that once the file is converted there is no audio in it. Video is all ok, but there is no Audio. I have tried the same set of filters using GraphEdt and it converts ok (Both Audio and Video are intact).
I really don't know what might be going wrong in this whole process. Any ideas?
I am using DirectShowNet

Categories

Resources