Currently we're trying to create a project which has access via web cam to capture
the Video and Audio and store it on Cache.
We have been able to successfully capture the Video into the "Isolated Storage" or "Raw" File format. The next step is to create a silverlight friendly format like WMV version 8 or 9 which can be used for Replay.
Asof now we have been able to successfully get a project from Link
to capture the video and encode it into AVI format for replay mode. Unfortunately we've not been able to get a client version code snippet or API that allows encoding into WMV format directly.
Any pointers in the direction would be most appreciated.
TIA
For the moment there is no easy solution for encoding video/audio raw format from SL, and I think SL5 does not have that capabilities as well.
The only solution I found when I had that question too, was from StreamCoders's SilverSuite product, but it was too pricey for my needs. You might have a look there:
http://www.streamcoders.com/products/silversuite.html
Another solution would be to upload the raw data to a server and perform the encoding there, problem is the size of the raw data file are so big that it make it even not suitable.
I tried to zip the raw file, for a 45 second video/audio I had ~ 320 MB file size and ~ 210 after zipping. That was still way too high for my need.
So far I've not see much hope encoding raw file from the client side apart from the StreamCoders products.
Good luck
We have been developing the same application as a Pure Silverlight Browser solution and moved towards an out of browser solution where -
We capture the RAW Isolated Storage Format and convert it into AVI using AVIDLL available from the following urls -
Silverlight 4 More on Capturing Videos from Webcams
Silverlight 4 Yet More on Capturing Videos from Webcams
And later convert the AVI video (RAW->AVI) which is still large into a WMV file using FFMpeg.exe
Statistics on SIZE:
RAW atleast 700MB for a 1 min recording
AVI atleast 600MB after conversion from RAW
WMV atleast 500KB after conversion from AVI
Statistics on TIMELINE:
RAW to AVI conversion takes about 1min for the 700MB conversion
AVI to WMV conversion takes another 1min for the 600MB conversion
Comparing this with the RAW file upload to the server and converting it would be quite a time consuming process considering that the RAW file size is large.
Any optimizations which could help change the time taken to convert or perform a direct conversion to WMV could make the solution better.
Cheers !
Related
I am trying to convert a .wav to an .mp3 file.
My code usually works but now I have gotten a .wav file that was exported with Imovie and I get the error 'NoDriver calling acmFormatSuggest'.
The internet suggest my machine is missing a codec.
But if I run the file, my machine is able to play the file with standard windows media player, so I guess it is on my machine.
When I put the file into https://www.metadata2go.com/ I can see that the problematic file has the codec pcm_s24le with a sample rate of 48000.
When I create a file with the same codec pcm_s24le but with a sample rate of 44100 the code does not trigger this error. So the problem seems to lie in the combination codec - sample rate.
Naudio's github page refers to this page with guides to fix the error.
it says under option 5 (i'm only playing back a wav file in my example)
What you need to do is search the web for an ACM codec that can decode
the format you are using. Unfortunately this is not always a simple
process,
It does unfortunately not provide any help on how or where to find these codecs. And, as I'm able to playback the file and the same codec with a different sample rate works fine, I'm also not sure this is the actual problem.
My code runs on a Windows 11 pro v21H2.
The following basic code (this is not my conversion code) throws the error
var outputDevice = new WaveOutEvent();
var audioFile = new AudioFileReader(path);
outputDevice.Init(audioFile);
outputDevice.Play();
Opening up the wav file and saving it with a different sample rate seems to solve the problem, but that is manual labor I would rather do without, since there are potentially a lot of files to convert in my case.
Any ideas would be appreciated.
It looks like Naudio has components to do the resampling of .WAV files, as noted on this page: How to Resample Audio with NAudio.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
bitmaps to avi file c# .Net
I am bit struck with an idea to convert the sequence image files into a single video file. I am using dotnet as a platform.How should i proceed. No clear idea...
And more to that need to add audio(mp3) speech while the image sequenceare displayed...
The general idea here is you want to pass your raw images through an encoder and encode the file that way. The encoder will take care of generating all your keyframes and intermediary (P and B) frames as well as generating any necessary decoding metadata that needs to be stored. On top of that running it through an encoding tool such as ffmpeg will also take care of saving the video file in a known container format and properly structuring your video headers. All of this is complicated and tedious to do by hand, not to mention error prone.
Whether you use ffmpeg or some other encoder it's up to you. I suggest using ffmpeg because it has the necessary functionality you need. If you want to do this all in code, ffmpeg is open source and you can wrap the pieces you need in a .net shell and call things that way. Though, keep in mind ffmpeg's licenses if you are developing a distributable application.
This should get you started: Making movies from image files using ffmpeg/mencoder
To add audio check this: https://stackoverflow.com/questions/1329333/how-can-i-add-audio-mp3-to-a-flv-just-video-with-ffmpeg
Now if you want to synchronize the audio and video (lets say the image sequence is people talking and the audio is their speech) you have a much more difficult problem on your hands. At this point you need to properly multiplex audio and video frames based on their durations. FFMpeg probably won't do that well since it will set each image in your video sequence to play at the same duration, which doesn't usually correlate properly with audio frames.
I am developing a windows phone 7 application and it does video recording. I would like to get the sound portion of the video file (MP4) and do some enhancements on the sound. I believe sound is saved as AAC frames in MP4. (Right?) How can I extract sound of a videa MP4 file?
Since this is a video file, it can be huge file. So uploading to cloud and processing there is not a good option. Since this WP7 application I cannot use unmaged dlls :( Is there a way to do in pure C#? Any open source tools/samples?
Thanks!
MP4 is a container format and realistically the sound portion isn't always AAC. It could be MP3 or any other number of different audio formats. You may be thinking of M4A, which I believe requires either AAC or ALAC.
On the subject of audio extraction, it should be possible to extract the audio from an MP4 using just managed code. You'll have to read up on the MP4 format (here, for example - this question is also worth reading) and then search through the file for the location of the audio and then either copy it to its own buffer or do your manipulations in chunks. Even then, you'll have to be able to recognize when it isn't an audio format that your app won't support.
It's possible that there already exists a .net library that can do all of this but I don't know of any. It's probably not very popular because managed code is definitely not the best angle to approach this from, but considering this is Windows Phone, it is, as you noted, your only avenue of approach.
Good luck!
I want to change an audio file format into another. Specifically, I want to convert any audio file into 6khz, 16 bit, mono, PCM wav format.
How can I cope with this problem.
Thanks again in advance.
You can also do this using the open source C# audio library NAudio. Have a look at the NAudioDemo project for an example of passing WAV files through the ACM codecs installed on your machine to convert to another format. If your input file is not WAV or MP3, you will first need something that converts it to WAV though.
I would use the BASS Library. It has many possibilities to do format conversions using the built in encoding/decoding capabilities. It also has a .NET wrapper availabe.
I'm not entirely sure whether you'll be able to do this as well as you may like.
To start with refer to the windows API for dealing with RIFF files (that's the file group for WAV files.)
You'll need to read the headers, extract the data and uncompress it to get the raw data format. I beleive that the header data will tell you what codec was used for compression.
You'll need to perform some processing on the raw data. Conversion to mono and 16bit may not be a problem, but I'm not too sure about changes to the sampling rate.
You can then recompress using your specified codec.
I'm looking to develop a Silverlight application which will take a stream of data (not an audio stream as such) from a web server.
The data stream would then be manipulated to give audio of a certain format (G.711 a-Law for example) which would then be converted into PCM so that additional effects can be applied (such as boosting the volume).
I'm OK up to this point. I've got my data, converted the G.711 into PCM but my problem is being able to output this PCM audio to the sound card.
I basing a solution on some C# code intended for a .Net application but in Silverlight there is a problem with trying to take a copy of a delegate (function pointer) which will be the topic of a separate question once I've produced a simple code sample.
So, the question is... How can I output the PCM audio that I have held in a data structure (currently an array) in my Silverlight to the user? (Please don't say write the byte values to a text box)
If it were a MP3 or WMA file I would play it using a MediaElement but I don't want to have to make it into a file as this would put a crimp on applying dynamic effects to the audio.
I've seen a few posts from people saying low level audio support is poor/non-existant in Silverlight so I'm open to any suggestions/ideas people may have.
The simple answer is that there is no support for PCM playback from Silverlight in version 2. So unless you want to write a fully managed PCM to MP3 converter you are stuck. Even then I'm not sure you could get the MediaElement to play from isolated storage.
Is there any chance you could use a web service to perform the conversion?
See also this question:
Where's the sound API in Silverlight? Or, how do I write a music app to run in the browser?
Update: Silverlight 3 supports your custom audio sources. However, it won't let you intercept samples to perform effects on WMA or MP3, presumably for DRM reasons, so you would still potentially need to write your own decoder.
Short answer is use a MediaElement + a MediaStreamSource
Check out these:
http://blogs.msdn.com/gillesk/archive/2009/03/23/playing-back-wave-files-in-silverlight.aspx
http://code.msdn.microsoft.com/wavmss/Release/ProjectReleases.aspx?ReleaseId=2417
Basically, write a decoder in managed code to convert G.711 a-Law to PCM, then do whatever modifications you want to the raw values, then pass those into a MediaStreamSource.
Looks like Silverlight 3 supports direct PCM output now, or will when released. I don't see anything in the docs about the raw AV pipeline yet.
Mark Heath's answer is correct - only certain formats are supported - mp3 and certain flavours of WMA (unfortunately not WMA lossless which would be 'closer' to PCM).
To play PCM data in Silverlight, you could do the following:
* Convert the PCM into mp3 data, and store it in memory.
* Play the mp3 data using the technique presented at ManagedMediaHelpers. The idea here involves a class called Mp3MediaStreamSource (derived from System.Windows.Media.MediaStreamSource) that provides mp3 chunks to a MediaElement to play. The chunks will need to be in a stream, but of course a memory stream will do.
I initially thought you might be able to provide PCM chunks via MediaStreamSource, but this does not work. It's a real shame as it would solve your problem (and the one I was facing - making a Speex audio file player) really easily!