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.
Related
I have the following issue.
I want to play a WAV audio file in my C# program, which I converted from MP3 to WAV before. I can't just play it as a MP3 as C# needs the Media Player library added first, but I don't want to use any other library that increases file size or adds another library dll to my export.
So when I use Audacity to convert the file from MP3 to WAV, playing the file in C# works fine, but the WAV file just gets very big, which I want to avoid (from 3 MB MP3 to 25 MB WAV).
Accordingly, I switched to Adobe Premiere Pro because this offers more options to adjust the end size of the file.
Now there are 5 different audio codecs in Adobe Premiere Pro:
Uncompressed
IMA ADPCM
Microsoft ADPCM
CCITT A-Law
GSM 6.10
With the uncompressed mode, the WAV can be played in C# without any problems. The file size is still very large in this case.
All other audio codecs allow me to reduce the file size up to 80% without audible audio loss, but with each of them I get the error message: "System.InvalidOperationException: "The wave header is corrupt." at runtime.
I tried to fix that with previous threads saying I should try reloading the stream or changing the position of the stream to 0 but that didn't work for me, I still got the same error message.
I don't know if there is even a way to fix it as it might be an issue with the compression?
I am able to play those WAV files with Media Player tho.
Is there any workaround?
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
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!
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.
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.