Android Compress Video before Upload to Server - android

How can I compress a video file in Android before uploading to a remote server? I'm not looking to zip up the file, because I don't think that will help much. I want to compress the video and re-encode it with a lower bit-rate or resolution. The idea is to get a standard 360х480, 30 FPS video file from every device. This way I can avoid users with better cameras being forced to upload huge video files.
I know iOS makes it fairly simple to force video file resolutions. 10 second video recorded on iPhone 4:
high (1280х720) = ~14MB = ~11Mbit/s
640 (640х480) = ~4MB = ~3.2Mbit/s
medium (360х480) = ~1MB = ~820Kbit/s
low (144х192) = ~208KB = ~170Kbit/s
Is there any easy way to do this in Android? Do I need to find some external library that will let me re-encode the video file, then save it to the SD card (or overwrite the old video file), then upload that file? Mainly looking for general direction here and not code to copy and paste, although anything is helpful.

I got a similar problem. Where I had to upload video in server having size within 5.4mb. But due to different camera resolutions of different phones, there was a problem. These are the solutions which I have opted
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mediaRecorder.setVideoEncodingBitRate(690000 );
Hope these will help you

One of the app that I worked on earlier has this requirement of sending the video file after compressing it. Here are the steps I followed which worked:
Compress the file using a Silicompressor library in android. Run the compression task on a background thread.
The output file format will have the mime type "video/raw". You can check that in logcat. So, you need to add this mime type in your server so that the compressed file format is uploaded successfully.
After this is done, trying sending the compressed file and it should work.
Make sure the mime type of the file you are uploading to server is accepted by the server.

Read About this Library, its the best for new mobile which has a Full HD cameras
Compress Video with high quality for Java and Kotlin

We decided to save this functionality for another iteration of the project. We opted to warn the users of the large data payload (especially if they are not on Wi-Fi). I'm confident this can be done, and the link provided by tabbykitten is the best related SO post I've found on this topic to this date.

From API level 18 onwards you have direct android API to do Video Encoding but if you are targeting Less than API level 18 it not straight forward
the below link does the encoding
https://github.com/google/grafika/blob/master/src/com/android/grafika/VideoEncoderCore.java

Related

In Android, possible to save video directly in Amazon server while recording

While uploading the videos/audio files from my application,mostly i followed the following ways,
Record the file (video/audio)
Save into Internal/External Storage (inside application folder)
Then upload in server.
here my question is, whether its possible to save directly in the server (Amazon s3 or others). Why i'm asking this, while i using Periscope application they streaming the video as well as stored the video in their server.
Checkout LibStreaming : https://github.com/fyhertz/libstreaming or some of the suggestion in : Streaming video from Android camera to server
You can see this github or use ffmpeg
I think that it all depends on the importance of your video. When you use your original approach you guarantee that you have the full video in hand (device) and you can make sure it will be fully uploaded to your server. On the other hand, streaming it directly to the server can make you lose frames (connectivity hiccups and such) and hurt the video. I'm sure that streaming is done using UDP which makes loosing packages a really good option.

VideoJS not working on mobile

I am using VideoJS to play videos served up from a fileserver. The files are in mp4 format, and work fine (using Flash fallback) on any desktop browser. However they do not work at all on mobile devices. For reference, feel free to check out:
http://74.203.203.93/content/aacfc5e7-fbeb-4785-ad04-023856a54a3d
I've tried to work the code around every which way I can think of to get it to work, but apparently I'm missing something somewhere. Does anyone have any ideas/suggestions?
More information:
Constants:
Video is in mp4 format (H.264 according to MediaInfo showing video codec being AVC).
Multiple formats are not possible (there will be no more than 1 (one) "source" tag).
Video file is hosted in a file server without a filename. Browser gets the location, and gets a source type tag.
Server is IIS.
Server supports byte-range requests.
Attempts so far:
Per http://help.videojs.com/discussions/problems/539-playing-mp4-on-android-using-videojs
Removed "type='video/mp4'" from tag.
Checked MIME types on server, video/mp4 is showing.
Per https://github.com/zencoder/video-js/blob/master/docs/api.md
Added javascript to call play() on ready.
Extension of above: tried javascript to call play() on click.
Tried adding '.mp4' to the end of the guid in the src location.
Swapped position of "type" and "src" elements of "source" tag.
I have changed the https:// in the source to http:// per several locations saying mobile doesn't do https well.
I changed the relative url in the src to an absolute url.
I will update with more information as I continue...
In the great media wars flash has been eliminated from androids, thats why the webm file is a key component in videojs.The mp4 file must be converted into a webm file and both sources used. You can just upload the webm vid to fileserver as well and link both sources in the player. The filenames in the link to the server must end in .mp4 and .webm to be recognized.
2 must reads -
http://www.zdnet.com/androids-flash-player-is-dead-live-with-it-7000002668/
http://www.pcadvisor.co.uk/how-to/google-android/3417930/how-get-flash-in-android-jelly-bean/
The quickest way to convert a mp4 to webm without software is to upload it to youtube, once the video is there copy the link and go to keepvid.com, then download the webm. Remember the highest quality webm file is not always optimal do to the size of mobile devices and slow internet connections planetwide. The video quality toggle on videojs is on the way though.

Posting large video file on Facebook from android

Hi am trying to post video file on Facebook from my android application, I am able to post 5MB file successfully but when I am trying to post large file say 95MB java.lang.OutOfMemoryError brokes out. I followed this link to post the video.
Is there any other methods to post the video file on Facebook. Please help me to resolved this issue.
Thank you.
Your video filesize is probably larger than the amount of free memory allocated on your device. Considering that you said you were trying to upload a 95MB file on your smartphone, that is too large to hold in a byte[].
I found solutions online that allows you to upload chunks of data at a time to prevent OOM exceptions, but AFAIK our Facebook Android SDK doesn't have that sort of option available. Your best bet is to either compress/scale the video to a more acceptable size, or write your own method to POST a video to Facebook in chunks.

Upload 3gpp file to a web server

My question is I have used many examples of http uploads of files for the android. They all seem to work except for video files that are .3gpp. I use the same code for .mov video files and it works OK. On the web side is just a PHP script. Does any know or have successfully uploaded a video (.3gpp) to a server? I don't get any error that I can see. The code I use also works for image files (jpg). It's just the .3gpp file type.
Thanks for any help you can give me..
isnt it 3gp
is it possible u are giving it the wrong extension?
i would say that the method u are using to upload should be pretty dumb to what files its uploading so it should work (as u said). the only other thing is i would try to match file size. so do a 5mb picture then a 5min video to ensure it is the file type causing the error
i would also say that maybe the 3 in the extension could cause problems (depending on how or what is reading it)

using ogg or mp3 with android?

1.What are the benefits if using oggvorbis over mp3 in android?
2.if we use ogg vorbis,is it possible to change its header(xor or encryption) and make it unplayble?
regards,
hitendra gohil
The problem is more specific to encryption rather than using ogg or mp3, I had a similar issue where client wants that the downloaded images can only be viewed through his apps, what I applied is I cut the 32 bytes from the beginning of every file and write it database and when I want the resource to be used I pick that 32 bytes and the original file to make usable file at some hidden location.
I hope the point is clear and might help.

Categories

Resources