Create a mp3 file using System.Speech.dll in WPF - wpf

I understand that the SpeechSynthesizer (System.Speech.dll) can be used to convert text to speech. I am working on an application that requires the ability of saving the text as mp3 and wav file.
Is this possible using WPF?

I believe that you should be easily able to save to a WAV file via SpeechSynthesizer::SetOutputToWaveFile. I don't think there is built-in support in .NET for converting to MP3, but this should be straightforward with the help of a 3rd party library/utility (like LAME) once you have the audio data as WAV.

Related

Decoding audio from non-file source with Microsoft Media Foundation

My question is basically that I am new to this framework and I am looking at pointers to how to work with non-file sources in media foundation since the documentation in this front seems lacking in my mind. Below is some info on what I am doing and what approach I am working with right now but I have no idea if it is the correct way to use the framework.
I am currently trying to use Microsoft Media Foundation to decode audio that I'm getting over Bluetooth and then send it along as PCM audio. When looking at the documentation for ms media foundation it seems that almost all examples assume the source is a file.
Looking at the tutorial for decoding audio for example they use MFCreateSourceReaderFromURL, which I cannot use since my source is not a file.
As I wanted to follow the tutorial and change as little as possible Im thinking that I need only change how I create the source reader and the rest of the process would be the same. I looked at the other SourceReaders available and MFCreateSourceReaderFromByteStream sounds about right for my purposes.
Is there a chance that I only need to create a bytestream and continuously fill it with data that I get over the air as we go and the media source created by MFCreateSourceReaderFromByteStream handle this well? Or do I need to create a custom media source and do more manual work at the lower parts of the API to get something like this to work?
Or maybe a source reader is the wrong approach altogether when the source is not a file? In the main page about Source Reader here they have the following picture:
And this picture shows the media source within the source reader pointing to a source file only, is this a real limitation or simply and example?
Im writing this in plain c, but pointing to c++ documentation or examples is fine as its usually pretty straightforward to translate c++ to c and there seems to be no documentation for c anyways.
Edit:
Im adding a image on what kind of data Im getting, the red area being the chunks of data I refer to in comments below Source.
Non-file source is not a accurate description. Does it have a file structure, just not a file? Structured differently? Raw stream?
If you look at samples with source reader, they assume presence and usage of stream handler capable to parse incoming stream into elementary streams with known type and properties. Then you or Media Foundation could apply decoder or otherwise transform the data.
As you specified that the data come "in chunks", most likely that you are interested in an alternate option to use AAC Decoder explicitly. You can create an instance of it, initialize input and output types, then feed it with compressed audio and pull decoded PCM on the output. The decoder has MFT interface.

How to play MP4 video from System.IO.Stream in WPF App?

I'm developing a WPF based app in C# and I want to play an h.264/aac encoded mp4 file from a stream source that derives from System.IO.Stream.
I can play videos directly from local files, and from a URL source, but I also need to playback video from a data source that derives from System.IO.Stream. Specifically, I'm using a product from Eldos called Solid File System (http://eldos.com/solfs/) which allows you to create virtual file systems inside a single file. To access data stored inside a SolidFS file they offer SolFSStream which derives from System.IO.Stream.
Does anyone know of a .Net Framework API, or third party API that will allow me to play the video by passing in the stream reference?
My preference would be to copy the files to a temp directory that the application can access, then use a simple to use and robust library to play the file e.g http://msdn.microsoft.com/en-us/library/system.windows.media.mediaplayer.aspx
My reasoning would be that supporting stream may not be the best criterea to choose a third party library to play mp4 files. You need to ensure that the library is robust and easy to integrate with your existing application.
Please note, by referring to the MediaPlayer class I am not saying that this is the most robust library, but it has met my use cases in the past and was easy to integrate with the application.
DirectX had some methods to play custom streams, but I don't know details. Also, we offer OS edition of SolFS for usage scenarios like yours - you can have a virtual disk with OS edition and play from there (and disk access can be restricted to only your application and the player for security).

Editing/Decoding AVI files using system-installed proprietary codecs

I've been searching for this for a few days now, but nothing seems to quite answer or work for me, so please forgive me if I'm asking a stupid question or one that seems to have been answered elsewhere.
I have an AVI file encoded using the GMP4 video codec, currently installed on my computer so I can PLAY the file in Windows Media Player for instance. What I'm trying to do is open/decode the file for editing purposes, in order to be able to stitch two video files together. I do not require it to be output in the same format, but rather only opened for editing, get the frames and then I can output to a more standard format.
The problem I'm getting is that there is no DirectShow filter created for this format, so it won't open using that for me (haven't worked too deeply into it, but all samples fail to load the video file). FFMPEG tries to read the file, states that the header is incorrect but it'll attempt to read it anyway, then dies stating that I need the GMP4 codec. As I'd stated earlier, I have the particular codec installed but FFMPEG doesn't seem to notice or have access to it.
Is there anything that will allow me to use the system-installed codecs to decode the video frames? It seems strange to me that Windows Media Player can do something, but I can't programatically repeat it. I'm not restricted to C++ or C#, though C# would definitely be a preferred language.
Thanks All,
Alex
I spent all day with the same problem. Solution is to install AVISynth, and then you can load with ffmpeg any AVI file for whom the system has a VfW codec. Instead of passing ffmpeg your AVI input file, create an .avs file with a single line containing AviSource("your-avi-filename") and passing ffmpeg the .avs filename.
Suppose you want to convert your input.avi in a proprietary video CODEC into an h263 format (supposing your input.avi has a supported h263 frame size):
echo AviSource("input.avi") > input.avs
ffmpeg -i inputs.avs -vcodec h263 output.avi
Nuno has a great answer, but you want to avoid command line converts, you can use the AForge.Net c# library to access AfW codecs, FFMpeg codecs or even DShow codecs (some CCTV DVRs do encode in DShow).
There is also a way to open Windows Media Player as a c# object and grab frames from it. Email me if you want more information - it sounds like we're working on similar projects.

MediaElement: Find out if file contains supported format

So the Silverlight MediaElement has certain supported media formats. I let my users upload files to a directory and have a MediaElement play these (via a SharePoint 2010 Media WebPart).
I could check the file extensions of the uploaded files and depending on that display them in the Media WebPart. The problem is that the file extensions given are: MP3, ASF, MP4, 3GP, WMV. However when I have an AVI file containing H264 encoded material it would also work, but the file extension would not tell me that.
Is there a way to check files for compatibility with the Silverlight MediaElement?
I don't believe their is but what is on the list of accepted formats.
Their is the option that you could reformat with a back end system to break the format down and re build it as an appropriate file.

Which is the best way to encode batch videos on server side?

I am making a general question since I am a developer and I have no advance experience on video elaboration. I have to preparare a web application with the purpose to allow video files upload on our company server and then video elaboration by server, on user command. The purpose of the web application is to allow to the user to make some elaboration on video depending on user action launch from the web app:
(server has to ) convert video in different format(mp4, flv...)
extact keyframes from video and saves them in jpeg format
possibility to extract audio from video
automatic control of quality audio & video (black frames,silences detection)
change scene detection and keyframe extraction
.....
This what's my bosses wanted from the web based application (with the server support obviously), and I understand only the first 3 points of this list, the rest for me was arabic....
My question is: Which is the best and fastest server side application for this works, that can support multiple batch video conversions, from command line (comand line for php-soap-socket interaction or something else..)?
Is suitable Adobe Media Server for batch video conversion?
Which are adobe products that can be used for this purpose?
Note: I have experience with Indesign Server scripting programing (sending xml with php and soap call...), and I am looking to something similiar for video elaboration.
I will appreciate any answers.
THANKS ALL
I suggest you start with the open source project FFmpeg. You can call the program from the command line and via a series of arguments specify the desired output types, thumbnails, etc.
As an aside, when you start looking around at Video related projects (MediaShare for example) you will find they are all using FFmpeg for their video processing.
as Nathan suggested, FFMPEG is the first choice. Also you can check MEncoder
Just to elaborate:
1) (server has to ) convert video in different format(mp4, flv...)
both FFMPEG and mencoder do this well
2) extact keyframes from video and saves them in jpeg format
as I know it's impossible using command-line interface of FFMPEG, not sure about mencoder. However they can save all frames as separate images
3) possibility to extract audio from video
both FFMPEG and mencoder do this well
4) automatic control of quality audio & video (black frames,silences detection)
you need to code this, using FFMPEG libraries or mencoder
5) change scene detection and keyframe extraction
it's not clear what your boss imposes here
I tried lot of videos converting in server side using advance Xuggler API libraries.
Xuggler is a free open-source library for Java developers which can be used to uncompress,
manipulate, and compress recorded or live video in real time. Xuggler uses the very
powerful FFmpeg media handling libraries under the hood, essentially playing the role of a
java wrapper around them. It is the easy way to uncompress, modify, and re-compress any
media file (or stream) from Java.
WebLinks : 1) http://www.xuggle.com/ -official website
2) http://www.javacodegeeks.com/2011/02/introduction-xuggler-video-
manipulation.html - example

Resources