Unity - audio taking up over half the memory? Compression? - c#

Ok, I am new to audio with unity but despite reading all the Unity posts regarding audio adding 2 short .wav clips (I heard wav was smaller than mp3) to my app has added over 200mb. If this is the case, I will not be able to incorporate sound.
I have checked override iOS as that is how to compress images, but I don't know if my settings are compressing accurately.
Here is my settings right now:
Why are my audio files taking up so much space? How can I reduce this size?

Set "Load Type" to "compressed in memory" and you can reduce the quality to about 70%. And enable "Force To Mono".

Related

Why my audio gets distorted in an Android build (Unity3D)

I have a game in Unity3D, In this game I imported some audio files that are songs, I composed them in a program called Bosca Ceoil, save it as .wav, then, I imported and edited them in Audacity, as the same, saved them as .wav, and finally imported them to Unity.
The thing here is that these audios sound distorted, like if they were to loud and kind of a robotic effect.
So I turned off the Doppler effect in the Audio Source and also in the project settings.
Its a little weird because this audios only gets distorted when I build it in my Android device, in my computer, in the editor works fine.
Also, the distorted parts are only specific ones, curiosly the parts with drums dont get distorted, all the others yes do, and this is very strange because the distorted parts are not loud.
Unity does not have a built-in compressor, which means any waveforms that add up to over 1 will distort. (This will invariably happen if you are importing high-quality and/or loud clips.)
You can use the Audio Manager in Unity’s Editor to tweak the maximum Volume of all sounds played in the scene.
but if it works in the editor it could be the below
If you are experiencing issues with sound quality, volume, distortion etc and you are running Android 5.x Lollipop please try disabling 'Nuplayer' from the developer settings. This is an experimental player Google introduced to Android and is known to cause some issues.

DirectShow webcam video and audio async - audio lag

I try to save a video with audio and save it as an uncompressed avi file. The graph is as you can see in the picture. The problem is that the sound recording is ~500ms behind the video. It doesn't matter which sources I have. What can I do to have video and audio in sync?
Default audio capture buffer is pretty large and is about 500 ms in length. You start getting the data once the buffer is filled and hence the lag. Large buffers might be okay for some scenarios and are not good for other. You can use IAMBufferNegotiation interface to adjust the buffering.
See related (you will see 500 ms lag is a typical complaint):
Audio Sync problems using DirectShow.NET
Minimizing audio capture latency in DirectShow
Delay in video in DirectShow graph

Decode GIF frames and encode to a video C#

I'm developing an app that consumes the 8tracks API. Some of the playlists have gifs as the playlist art and I would like to have those gifs play in the app. UWP does not support native gif playback so i'm trying to figure out a way to make them play. So far I have tried using XamlAnimatedGif but its performance is bad, especially on phones.
Now i'm using Giphy API to upload the gif which also creates an mp4 version of the gif and plays back smoothly in a MediaElement. I can play up to 10 MP4s at a time smoothly(not that ill ever need that many playing at a given time). I'm wondering if i can eliminate Giphy and have the computer/phone just take each frame from the gif and then encode them to an mp4(or other video file). Is this a good option? what would be any cons to doing this vs. what im already doing with Giphy? If i decide to at least try this Is there any where i can read up on decoding the gifs to frames and encoding them to a video?
You could use the GifBitmapDecoder to get the frames
https://msdn.microsoft.com/en-us/library/system.windows.media.imaging.gifbitmapdecoder(v=vs.90).aspx
and there are a number of options here to convert stills to a video:
How can I create a video from a directory of images in C#?

Best way to render images as a video clip in a mobile device

I have tried to approach this problem several ways.
I have a web application that will load a sprite (which is a large jpeg that 'holds' 100 frames. Using the offset of div properties I am able to 'move' the image along so it looks like a movie clip.
This works well.
I need to produce the same on mobile devices.
I have to support Windows Mobile 6.5.
I was using jQuery/ajax to move the sprite image along to stop any flickering of the image within the browser.
Windows mobile 6.5 does not support this.
So, i decided to do a native app using C# Framework 2.0.
I thought about converting the sprite to a mp4 file and playing within a web browser control. but IE on the device will not support html5.
I have been told there is a CAB file from adobe so that I can play flash videos on the IE. But, apart from using ffmpeg to convert these images to a flv there is not much control as to adding menu like pause,stop,play etc when playing the flv file. I have not started any of this by the way i assume that would be the case.
So.. I thought if I download the sprite to the device i could use the graphics object of a picture box and render the rectangle of interest from large sprite to picture box.
I could not download the Sprite and save it to an image though. I get 'out of memory exception'.
I used the OpenNetCF.Drawing as it is supposed to support large files. I still get the error message. I have reduced the size of the image and it will work on about 20 frames.
I would then have to 'stack' these images containing 20 frames and load them up when necessary.
I am beginning to wonder now whether i am doing the right thing?
Is there a different way of trying to achieve what i am trying to achieve that is quicker and more efficient as I have run out of ideas.
If I am OK doing it this way then what is the best way to render images in a picturebox like a video. Memory efficiency says load the image from the file on the device when needed and dispose of it but that would cause 'flickering'. What IS the best way to handle multitude of images on a device?
i have plenty of code I can upload but I was worried the question would look 'messy' as I have tried so many things. I will of course edit/upload the code as required.
Thanks.

C# - What's the best way to reduce the size of an image (for streaming over tcp)

I've written an application that streams live screen to a remote app. It grabs the screen (resizes the image to 640x480) and then compresses the image using GIF compression (using System.Drawing), saves it into a byte[] array and transfers it to the other app.
The problem is that the image I get is about 50KB which means that at 30FPS it would require 1.5MB of data transferred each second. At the moment I only get 8-10 FPS. I know it's possible to solve this somehow. Maybe using the technique that flash videos use?
Personally I'd recommend using VNCSharp - it will do most of the heavy lifting for you. Some might say that it'd be madness to code this up again.
If not then streaming images is a waste of bandwidth - you need to effectively build a video stream and transmit that.
Since you don't need animation and want to stay with loss-less compression you would get somewhat better compression with PNG instead of GIF (and PNG is patent-free). According to this the savings is between 10 to 30%.
I think use screen by screen capture isn´t a good approach to get a live screen streaming. Video formats, usually, assumes that between a lot of frames you have a small couple of areas that changes. In the other hand you´ll need to work a bit more to capture a video from the screen.
You can start from these articles:
http://betterlogic.com/roger/2010/07/list-of-available-directshow-screen-capture-filters/
http://www.codeproject.com/KB/dialog/screencap.aspx
Rather than compressing images, you'd better compress video streams. This is how video codec achieve high compression : by exploiting similarities into consecutives images in the stream.
If you compress your images one by one, you loose this performance advantage, and it makes a huge difference in bandwidth.

Categories

Resources