Convert an MP4 to WAV file using Azure media-services transforms - c#

We have a blob storage that we are putting MP4 files into. We want to create a function that watches for the incoming files (like a pub/sub), and then using azure media-services encode the file to a wav, and save the transformed artifact to another blob storage container. I can create the job to watch for the files that come in, the problem we are having is finding out how to create a wav file using the media-services transforms. We are trying to avoid having to copy the MP4 files to another location to encode them to wav files, then deleting the MP4 file and the wav file once we are done. These files can run into the gig size quite a bit.
We use the wav files to transcribe them into text (our transcription software requires the files in wav format). We looked at the azure speech services to do the transcriptions, but it is cost prohibitive, and the transcription software we currently use is specialized for our line of work and more efficient at transcriptions.
I guess the first question is "Is it possible to transform an MP4 to wav using azure media-services?" If so, does someone have an example on how this is done?
Thanks.

Here is a sample of an Azure function that can encode a Azure blob and output to a blob blob. https://github.com/Azure-Samples/media-services-v3-dotnet-core-functions-integration/tree/master/Encoding

Short answer: no, you can't create a Transform in our service today that will enable you to decode an MP4 input file into a WAV output file.
Where are you running your transcription software? Have you considered running open source SW like ffmpeg on those compute instances to convert MP4 to WAV?
Thanks

Related

How to play encrypted video file using WindowsMediaPlayer?

I encrypt my .mp4 into a custom format (.opu). Now I should decrypt my file and save them into temp folder at the start of my application. and play them using WindowsMediaPlayer control in C#. So I have the risk of stealing my files from temp folder. What is the best way to prevent stealing my files? How to play encrypted video file using WindowsMediaPlayer?
The best way would be to perform the decrypt to a stream in memory and play the video from there. That way there is never an on-disk file to steal.
There is a way using virtualization, i.e. hooks. The idea is to hook functions like ReadFile to provide decrypted data, SetFilePointer to maintain current pointer within a "file" etc. You can view one of the examples at http://www.boxedapp.com/encrypted_video_streaming.html

Playing a .wav file in c# using SoundPlayer

I am currently having a probelm, where a file was sent to me as .m4a and I renamed it to .wav..... (I think that is the issue as I can play other .wav files)
Now it is giving me this error when I run the code:
Additional information: The file located at c:\Windows\Media\dj.wav is not a valid wave file.
Maybe I just need to change it back to .m4a and then have some website convert it to .wav compared to me just renaming it?
My code looks like this:
using System.Media;
playSimpleSound();
private void playSimpleSound()
{
SoundPlayer simpleSound = new SoundPlayer(#"c:\Windows\Media\dj.wav");
simpleSound.Play();
}
Also, how can I write my path, so that it would hit the file in the debug folder? Because I am going to deploy this to a thin client in another building.
Changing the extension of a file does not change the content in it. M4A are MPEG-4 audio-only data, whereas WAV files are typically raw and uncompressed audio samples.
To convert the data itself, you'll need to use an audio transcoding tool like SoX or GoldWave.
As for your path specifier, you can simply use "dj.wav" or "wavfiles\dj.wav", basically relative to where your exe sits. This is because the current working directory is set to where it resides when started with a simple double click in explorer. You can, however also specify the full path using the answer here.
Hope this helps!

How can I use mp3 files in Windows Phone 8?

in my windows phone gaming apps, I have to use lots of sound. Now I have seen that Windows phone does not support mp3 files. So I need to use the wav files. Any mp3 file which is just 500 kb size in mp3 format, when convert that to ".wav" it becomes min 2.5MB. It's actually eating up my apps size and unnecessarily the size of my apps is getting bigger.
Anyone know how can I use the mp3 file? In my solution I have a Asset folder and inside this folder all the ".wav" files are located.
How I am doing this let me write a code
SoundEffect effect;
Iinside constructor-
{
...
var soundFile = "Assets/Jump.wav";
Stream stream = TitleContainer.OpenStream(soundFile);
effect = SoundEffect.FromStream(stream);
And in the code
effect.Play();
Is there any better approach. In some thread I come to know that doing this is not a better way coding as it creates object and used up the system space. Please suggest what to do, how do I add mp3 files and write better code for working with sound files.
you can use BackgroundAudioPlayer to play your wav and mp3 files. SoundEffect class cannot play mp3 data
Go through this it's an entire app on it's own.
Background Audio WP
To use an MP3 file you would have to decode the MP3 into PCM in memory, and use that resulting stream in the SoundEffect.FromStream method.
Another thing you could try is encoding the wav files as ADPCM. This usually compresses the wave file at ratio of 4:1. If you can't use the stream directly, decoding of ADPCM is much more straightforward than decoding an mp3 file.
And one more thing you could try to save space is converting the uncompressed wave files into mono, and a lower sampling rate. You can perform listening tests on the sounds after the conversion to make sure that the loss in quality is acceptable or not.

.swf file duration (length)

I have a problem getting .swf files time duration.
I tried by calling ffmped via cmd in C# and it worked for other video files (.avi, .mp4, .mov etc.), but not for .swf.
(Also, when I open the .swf file in Media Player Classic and when I go to properties, it says the length is 00:00:00, but it plays.)
SWF is a container format. What you're looking for is the length of the *.flv file. That is the actual encoded video. What happens is the SWF file has an internal reference to the FLV file, and then loads / streams that file. AFAIK, ffmpeg should be able to get the length of an FLV file.

Record and save audio in c# .net web application

Is there anyway that I can record sound from a microphone using c# .net
What is the best option if i have to save the audio online in terms of the file occupying storage space.
Any particular format that the file should be saved in for optimum output.
I think you have to use either a small flash application or a silverlight application to do the actual recording. Then you upload the file to your application using a web service or similar.
And mp3 is sort of a standard file format for sound on the web. So I'd go with that.
Have a look at these projects:
http://www.codeproject.com/KB/winsdk/SoundRecord.aspx
http://www.codeproject.com/Articles/67568/Creating-a-Sound-Recorder-in-C-and-Csharp.aspx
http://www.codeproject.com/KB/audio-video/cswavrec.aspx
What is the best option if i have to save the audio online in terms of the file occupying storage space.
May be real media (.rm).
Any particular format that the file should be saved in for optimum output.
Not sure but I think that depends on
your player.
You might also be interested in ffmpeg for converting the media and its c# wrapper library.

Categories

Resources