Android cropping and decreasing video size - java

we are going to start an app that captures videos or picks videos from gallery. The videos will be exactly 30 seconds, so users can crop or trim videos like video editor.
At this point, we got 2 main problems. The first one is video size. You know the video size could be huge for uploading :) So we need to decrease video size. The other problem is when iOS device captures and uploads video to server, there are some problems when trying to play that video on android app.
We have used “ffmpeg” library before for an another project but that library has varous problems like slow compression or library .so file’s size. And also have compatibility issues with sdk 24 (nougat)
Anyone has an experience about that? Or any ideas to overcome those problems? Thank u all.

I don't know what problems you have with ffmpeg. But it is definetely the best and the fastest library available for video editing,creating etc. Use ffmpeg4android if size is important for you. The library is about 6 megabytes and it is a wrapper for ffmpeg and has most usable methods of ffmpeg.

Please check Android MediaMuxer Api https://developer.android.com/reference/android/media/MediaMuxer.html
With this you can crop video, change it's frame rate and resolution

Related

How to reduce video bit rate from a webm file online for Android?

This webm video will not play on an android device because I THINK that the bit rate is too high. Looking at the supported versions on the Android Developer website, I think that the bit rate for this type of video (codec VP8) should be around 2 Mbps and it is at about 9 Mbps.
I have tried using FFmpeg but I have not had luck so far.
I don't need to store the video permanently on the phone because it is so short so I don't really need an output file.
I just need to take the video from the server, cut it down to about 2 Mbps, then play it with a VideoView/MediaController/MediaPlayer

Compress movies on Android

I have a game where users complete assignment by making a picture that will be send to the backend. Before sending this to the backend the image is resized to limit the amount of data that has to be send. This all works fine.
Now I want to extend this with movie clips. Movie clips are a lot bigger then picture. Especially if you don't compress them. The problem is that I have no clue how to do this.
So the main question is how can change my app that the user records a video and after it compress it to make the file smaller in size. Are there libraries around to do this? Or is there something in Android itself to use?
One approach that works is to use ffmpeg to do the compression.
There are some well used ffmpeg libraries that will allow you include ffmpge via a wrapper and then use standard ffmpeg syntax to perform the compression within your app.
See this one which includes examples:
https://github.com/WritingMinds/ffmpeg-android-java
Note that video compression is power and battery intensive, and takes time so you may want to limit the clip size if you plan to have users use this functional regularly.

BlackBerry Java Media Unsupported

I download an MP4 file from the internet and play it on the blackberry device. I get the following error: "the video portion of the media being played uses an unsupported format". The audio starts playing, but the video doesn't play, while showing this error.
It should be noted that this only happens on Device OS 5 & 6. The same video plays properly or OS 7 and OS 7.1. I am guessing this is because RIM included some updates to MMAPI. What could i do to allow devices prior to OS 7 play the videos? OS 5 & 6 devices play MP4 files, just not all of them.
I have been looking into custom decoding the bytes of the MP4 file, but that will take a lot of time, looking into existing decoder implementation before adapting to J2ME, not an easy task.
Any help would be great here.
Edit:
The video content owners have control of the videos on the server side, but arent willing to re encode, mainly due to size concerns on the server, even though i recommended they do as well.
The resolution of the video is about 720w x 400h. This is quite high for a BB, but Bold 9790 and Torch 9810 both play it without a problem. So why cant Bold 9780 play the same file?
Update:
Regarding the problem with the video playing on a 9790 and not a 9780, those are different devices. The 9790 came out about a year after the 9780, and apparently RIM added more capability.
From 9780 specs:
Video player DivX/WMV/XviD/3gp
From 9790 specs:
DivX/XviD/MP4/H.264/H.263/WMV player
So, that explains why you can't get that video to play on the 9780. If playing this video is fundamental to your app, you might change the settings in BlackBerry App World to list it as incompatible with 9780s. If this is only one of many features of your app, you might at least catch the media exception and inform the user gracefully that their device can't play the video requested, so they don't think it's your app's fault.
Original Answer:
MP4 actually contains a family of related formats.
The actual support for your video probably depends both on your BlackBerry OS version (e.g. 5/6/7) and also the device itself.
Here is a BlackBerry reference document that describes video format capabilities of various BlackBerry devices.
See also this reference document.
Of course, different devices also have different sizes of screens.
It might be useful for you to produce the videos in a variety of formats and resolutions, and have your BlackBerry app download different versions of the video depending on the device. Since video downloads are slow, doing it this way will also ensure that the user sees the fastest possible download on their device. There's no use downloading a higher resolution than the device can display.
You didn't specify whether you have control of the videos on the server side or not, so this may not be an option for you.

If I want a faster camera preview FPS, will I have to use the NDK?

I'm trying to get the preview frame rate up, but setPreviewFrameRate isn't supported on my phone. The max I can get using setPreviewCallbackWithBuffer and with no extra processing is about 17 fps, which I think most people would agree is kind of crappy. Am I missing something in the Android Java SDK or will I need to learn about the NDK to handle data at a full 30 fps? (I should point out that the camera can capture and save files at this rate -- apparently it just can't preview at this rate).
Are there any disadvantages of using the NDK that I should know about?
I've been in this situation, and reading from the camera was faster in the NDK. However, I rooted the phone and read straight from the framebuffer, and it probably wasn't the same phone you're developing for, so YMMV.

java:web cam application

I am looking to do develop the following application. How to proceed?
Scan the system for installed webcams and their supported video modes.
Let the user select a cam and a video mode.
Displays a video of the camera.
Starts a frame grabber/processor, it doesn't have to do nothing for now. I want to have the possibility to elaborate frames or at least one frame every x.
Not sure if it's possible but i'd need also a routine to overlay processed frames on the playing video.
Check this post on SO for inspiration.
The JMF framework supports capturing real-time data, audio or video, as detailed in this article
You can also try LTI-Civil
I would recommend you using Webcam Capture project since neither JMF nor LTI-CIVIL are maintained any more. Webcam capture is a cross-platform, open source project hosted on Github. There are plenty of examples, e.g. of how to do things you've asked:
How to enumerate webcams and listen for new devices connected
Display video from camera
Enable grabbing and take snapshot on demand
Unfortunately there is no possibility to overlay image obtained thru Webcam Capture API on the playing video. At least not within the Webcam Capture itself, but you could use Xuggler to do that - it contains example of how this can be done.
Please note that Webcam Capture API can be used on top of the JMF, FMJ, LTI-CIVIL, GStreamer, OpenIMAJ and other.

Categories

Resources