I am creating a movie file using QTMovie from QTKit and everything's working nicely. The only problem I have is that the audio in the resulting MOV file is just the raw AIFF hence the file size is larger than I'd like. I've seen plenty about third party libraries capable of encoding to AAC but are there any Apple APIs which I can call to do this job? I don't mind converting the AIFF to AAC prior to adding it to my QTMovie or having the encoding done as part of writing the QTMovie to disk.
This was actually easily achievable using QTKit. I just needed to set the QTMovieExportType to 'mpg4' and QTMovieExport to be YES when calling writeToFile:withAttributes:.
Related
I'm using Windows.Media.SpeechSynthesis (C++/WinRT) to convert text to audio file. Previously I was using SAPI where was possible to set Audio Format when binding to a file via SPBindToFile(...) before speaking.
Is there any similar method in Windows.Media.SpeechSynthesis? Seems that there is only possible to get 16kHz, 16Bit, Mono wave stream, does it?
Does SpeechSynthesisStream already contain a real audio stream after speech synthesis, or does it hold some precalculated raw data, and does actual encoding happen when accessing its data (playback on a device or copying to another not-speech-specific stream)?
Thank you!
I think there should be possible to control the speech synthesis stream format somehow.
The WinRT synthesis engines output 16Khz 16-bit mono data. There isn't any resampling layer to change the format.
Boss handed me a bit of a challenge that is a bit out of my usual ballpark and I am having trouble identifying which technologies/projects I should use. (I don't mind, I asked for something 'new' :)
Job: Build a .NET server-side process that can pick up a bitmap from a buffer 10 times per second and produce/serve a 10fps video stream for display in a modern HTML5 enabled browser.
What Lego blocks should I be looking for here?
Dave
You'll want to use FFmpeg. Here's the basic flow:
Your App -> FFmpeg STDIN -> VP8 or VP9 video wrapped in WebM
If you're streaming in these images, probably the easiest thing to do is decode the bitmap into a raw RGB or RGBA bitmap, and then write each frame to FFmpeg's STDIN. You will have to read the first bitmap first to determine the size and color information, then execute the FFmpeg child process with the correct parameters. When you're done, close the pipe and FFmpeg will finish up your output file. If you want, you can even redirect FFmpeg's STDOUT to somewhere like blob storage on S3 or something.
If all the images are uploaded at once and then you create the video, it's even easier. Just make a list of the files in-order and execute FFmpeg. When FFmpeg is done, you should have a video.
One additional bit of information that will help you understand how to build an FFmpeg command line: WebM is a container format. It doesn't do anything but keep track of how many video streams, how many audio streams, what codecs to use for those streams, subtitle streams, metadata (like thumbnail images), etc. WebM is basically Matroska (.mkv), but with some features disabled to make adopting the WebM standard easier for browser makers. Inside WebM, you'll want at least one video stream. VP8 and VP9 are very compatible codecs. If you want to add audio, Opus is a standard codec you can use.
Some resources to get you started:
FFmpeg Documentation (https://ffmpeg.org/documentation.html)
Converting raw images to video (https://superuser.com/a/469517/48624)
VP8 Encoding (http://trac.ffmpeg.org/wiki/Encode/VP8)
FFmpeg Binaries for Windows (https://ffmpeg.zeranoe.com/builds/)
I have an mp3 file into one large array of audio samples.
I want the audio samples to be floats.
NAudio.Wave.WaveStream pcm=NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(OFD.FileName));
so far I get the pcm stream and can play that back fine but I don't know how to read the raw data out of the stream.
Use AudioFileReader. This implements ISampleProvider so the Read method allows you to read directly into a float array of samples.
Alternatively use the ToSampleProvider method after your Mp3FileReader. You don't need to use WaveFormatConversionStream, since Mp3FileReader (and AudioFileReader) already decompress the MP3 frames.
I have a Mac app communicating with a web service that can only deal with mp3 files. I found out after hours of debugging that kAudioFormatMPEGLayer3 is decode only. So, I need to either take the resulting audio data and convert it straight to mp3 or convert it to AAC or some other supported format to mp3. Compatability with iOS is not a concern.
Also, please don't recommend LAME the license is not acceptable for this particular case. And any code demos would be greatly appreciated.
MP3 is a patented file format. You can't just write an MP3 encoder and stick it in your app unless you pay a licensing fee.
http://mp3licensing.com/royalty/
Your best bet is to stick with the built-in AAC encoding.
I am trying to record audio from a microphone/iSight camera from Mac to a NSData object.
I have tried to do it using QTKit, but I found out that you could only save it as a .mov file.
But the fact is that I want to recode the audio into a FLAC file. Is that posible, or I'll need to use another framework?.
Thanks.
Grab the source for VLC (if you can deal w/GPL -- it has limitations on use that many find onerous) and have a read. It does transcoding, amongst other things.
Beyond that, one dead simple approach is to save as AIFF and then use a command line tool (via NSTask) to do the conversion.
Or you could just go with Apple Lossless -- it is open source these days.
Of course, this also begs the question; why do you need lossless compression when recording voice [low bandwidth in the first place] via a relatively sub-par microphone?