While developing an Android app what format of sound/image should i should be using so that i can control the overall size of the app after completion.
here is a link to all the media types supported by Android.
For sound I would probably use a low-bitrate .mp3 or a .midi and for images either a compressed .jpg or .gif
For supported media formats see this.
For images you'll probably end up with JPG or PNG (if you need transparency). You should also scrape the images to remove all unnecessary meta data etc. For linux, a nice tool for this is Trimage.
Take a look at Supported Media Formats.
My choice would be:
Images: go with JPG for compression or PNG for quality and transparency support.
Audio: go with MP3-VBR (variable bit rate) for compression and quality.
The size of your file will be greatly affected by compression level. At some point, if you compress too much you will see/hear artifacts. The acceptable level of compression is subjective and really depends on the input data (image or audio). You should be testing different levels of compression to see what works.
Related
I have a remuxing.c example working from ffmpeg but I need to change resolution to minimize file size, anybody can explain me how to do that? Or if there is another way to "compress" mp4 files without command line? I'm a begginer with FFmpeg and need to send video files from android to server, and I'm deploying a NDK library to make this job because FFmpeg command-line implementation have some limitations and is very slow.
Thanks
You should take a look at the filtering video and the transcoding examples. The first one goes through how you add "filters" in ffmpeg. It includes a scaling filter, which will rescale the video to a given resolution. Transcoding includes some filtering, and you can actually change the filter_spec string to be whatever you want, and the program should scale your input video.
This is probably not the best solution, I just found it myself, but it at least introduces you to the components being used.
In my app I need to convert photos (taken by the user) into some playable (on both Android device and pc web browser) vide format.
My first and obvious choice was GIF, I've managed to get it working using this https://github.com/nbadal/android-gif-encoder but the result was of very poor quality. What I didn't now was gif is a terrible standard - only 256 colors per frame, virtually no compression, so for my purposes it's useless.
I know it is possible to use ffmpeg for this, but I have no experience with NDK (and I've used C only at the university).
Are there any other options worth exploring?
EDIT: it needs to work on ICS (minSdkVersion=15)
You can use MediaMuxer (for android over 4.3) to convert your images to mp4.
I've been developing an Android app which takes picture and save it. And I want make the upload speed more faster by compressing the image. But as I compressed them using BitmapCompress, the image seems lost its quality. Here :
RAW :
COMPRESSED :
BEFORE :
DIMENSION - 1920X1920
FILE SIZE - 2.94MB
AFTER :
DIMENSION - 960X960
FILE SIZE - 644KB
I wonder if there's a way, a library perhaps that will solve my problem? Instagram seems to be doing this compression stuff without losing the image quality.
Compressing will always lead to decreased quality in the one or the other way.
Here is what you could do:
Change your compression format to PNG, if you are not already using that.
Find a perfect compromise for the quality value between size and quality
I agree with #Saret BitmapCompress will decrease the file size with a good quality. You can get ~800-900KB photo from ~3MB photo using 80% quality compressing without scaling. You can get better result if you crop the photo.
If you don't care scaling and details in depth are not important for you, I strongly recommend following libraries:
https://github.com/shaohui10086/AdvancedLuban
https://github.com/zetbaitsu/Compressor
Bitmap yourbitmap
[...]
OutputStream os = new FileOutputStream(filename);
yourbitmap.compress(CompressFormat.JPEG, 80, os); // 80% compression
This will keep your image light and with a good quality.
Some keywords worth looking into:
'EXIF removal' libraries
'lossless compression' libraries
Explanations:
Remove some of the excess EXIF data
You can try reducing filesize by removing the EXIF data that is stored in the image. In many cases, the EXIF data takes up a lot of room, and often contains more information than the user might need for their use case.
A quick google search shows the following tool could be helpful in removing the EXIF data. Has Windows and Mac versions:
http://www.exifpurge.com/
As for a tool that would work in your android build process, that needs further searching. But at least 'EXIF removal android library' are good keywords to start with
Lossless compression
Another alternative is researching lossless compression. I've used them in the past in web development. In my case, I used libraries which worked from the command line together with 'grunt' a build tool.
A quick google search showed the following site which works direct from your browser.
https://compressor.io/compress
I'm developing an android application that has over 111MB of mp3 files.
I need to compress these files and put them in my package (like raw folder) and after my app was installed on a device, it decompresses files to use them.
How could I do this? Is this possible?
You can reduce mp3 file size by reducing the bit rate. Reducing the bit rate will result in smaller file size but lower quality, so you have to check what works best for you. You can improve the quality by using Variable Bit Rate (VBR) instead of Constant Bit Rate (CBR).
You can do that using a software such as Audacity.
Use Super C freeware, convert to AAC will also help.
I would like to ask a few question about texture encoding and loading pvr.ccz file in Android. I'm using Cocos2dx Game Engine.
I can't load pvr.ccz file with texture encoding format PVRTCv2 and PVRTCv4. But, I can load it with RGBA 8888, RGBA 4444, etc. I've checked cocos2dx source. It just doesn't allow Android to load with those two encoding format. I would like to know if there is any work-around to load for those two encoding format in Android.
I've changed the pvr.ccz file encoding to RGBA 8888. And it can be loaded in both iOS and Android. But, the problem is when the pvr.ccz file is larger than approximately 2.4 MB, Android can't load it again. In memory usage, it's telling me that the size of pvr.ccz file is even larger than 16 MB. Maybe it's because Android decompress pvr.ccz file. I would like to know if there any work-around for that memory issue in Android.
I'm using Samsung Galaxy Tab P7500 to test and I assume it use PowerVR GPU. It should be ok with PVRTCv2 or PVRTCv4. But, in the source of cocos2dx, it's not checking anything related to GPU. It just don't allow Android to load PVRTCv2 or PVRTCv4. Our Game is using too many Graphic, if we are using RGBA 8888, the size of the game would become around 40 MB while the size would be only 18 MB when we use PVRTCv2.
Any Suggestion would be Appreciate !! ..
Thanks !
Have you considered doing a fork of cocos2d and tuning it for your needs?
If you are targeting more Android devices I would go for ETC1 compression for opaque textures first, gives decent compression and would make your apk smaller. Check android.opengl.ETC1Util namespace for some utility code to load just one compressed image (you will need to load each mipmap level from a compressed file).
For non-opaque textures use vendor specific extensions. Check this: Android OpenGL Texture Compression