• Stars
    star
    1,227
  • Rank 36,926 (Top 0.8 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Powerful custom Android Camera with granular control over the video quality and filesize, restricting recordings to landscape only.

LandscapeVideoCamera

Build Status Codecov.io Release MethodCount License

Highly flexible Android Camera which offers granular control over the video quality and filesize, while restricting recordings to be landscape only.

Get it on Google Play

There are a number of issues with the default Android intent to capture videos (MediaStore.ACTION_VIDEO_CAPTURE) which led me to create this library project:

  1. The default intent only accepts integer quality parameters of 0 (MMS quality) or 1 (highest available quality), using the intent extra MediaStore.EXTRA_VIDEO_QUALITY.
  2. The default intent does not return the URI of the recorded file if it was specified when launching the intent.
  3. The default intent doesn't care whether users capture their video in portrait mode or landscape.

LandscapeVideoCamera in action

Features

This library provides a full and reusable custom camera, which:

  • Forces the users to rotate their device to landscape
  • Allows to specify the filename, or have the library generate one for you
  • Allows very granular control over the capture settings:
    • Resolution
    • Bitrate
    • Max filesize
    • Max video duration
    • audio/video codec
    • switch between front and rear facing camera
    • ...

How to use

  1. Add the Jitpack repository to your project:
          repositories {
              maven { url "https://jitpack.io" }
          }
  1. Add a dependency on the library:
          compile 'com.github.jeroenmols:LandscapeVideoCamera:1.3.0'
  1. Specify the VideoCaptureActivity in your manifest:
         <activity
             android:name="com.jmolsmobile.landscapevideocapture.VideoCaptureActivity"
             android:screenOrientation="sensor" >
         </activity>
  1. Request the following permissions in your manifest:
         <uses-permission android:name="android.permission.RECORD_AUDIO" />
         <uses-permission android:name="android.permission.CAMERA" />
         <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  1. Create a CaptureConfiguration using the Builder
         // Choose one of both
         CaptureConfiguration.Builder builder = new CaptureConfiguration.Builder(CaptureResolution resolution, CaptureQuality quality);
         CaptureConfiguration.Builder builder = new CaptureConfiguration.Builder(int videoWidth, int videoHeight, int bitrate);

         // Optional
         builder.maxDuration(maxDurationSec);
         builder.maxFileSize(maxFileSizeMb);
         builder.frameRate(framesPerSec);
         builder.showRecordingTime();         // Show the elapsed recording time
         builder.noCameraToggle();            // Remove button to toggle between front and back camera

         // Get the CaptureConfiguration
         CaptureConfiguration configuration = builder.build();

Note: When no CaptureConfiguration is specified, a default configuration will be used.

Note 2: Subclass the CaptureConfiguration class to set more advanced configurations. (codecs, audio bitrate,...)

  1. Launch the VideoCaptureActivity for result, add the CaptureConfiguration as an parcelable extra EXTRA_CAPTURE_CONFIGURATION and optionally add a String extra EXTRA_OUTPUT_FILENAME.
         final Intent intent = new Intent(getActivity(), VideoCaptureActivity.class);
         intent.putExtra(VideoCaptureActivity.EXTRA_CAPTURE_CONFIGURATION, config);
         intent.putExtra(VideoCaptureActivity.EXTRA_OUTPUT_FILENAME, filename);
         startActivityForResult(intent, RESULT_CODE);
  1. Check the resultcode (RESULT_OK, RESULT_CANCELLED or VideoCaptureActivity.RESULT_ERROR) and in case of success get the output filename in the intent extra EXTRA_OUTPUT_FILENAME.

Questions

@molsjeroen

Thanks

Android Arsenal

More Repositories

1

ModularizationExample

Easy to understand real-life example of a modularized Android app
Kotlin
734
star
2

FeatureFlagExample

Powerful architecture to mange feature flags locally and remotely
Kotlin
280
star
3

MockitoExample

Sample project to demonstrate Mockito usage on Android
Java
86
star
4

ArtifactoryExample

Example code to upload and use artefacts from Artifactory
Java
69
star
5

AndroidUninstall

Batch uninstall Android apps by provinding (part of) a package name
Shell
57
star
6

MockitoCollectionMatchers

Extension of Mockito that provides easy to use matchers for Collections
Java
48
star
7

Legofy

Android library to Legofy any image
Java
47
star
8

MethodCountExample

Sample project to shrink huge libraries and reduce their method count.
Java
33
star
9

GitAsMaven

Gradle script to use Git as a private Maven repository
28
star
10

WagonGitExample

Example code to upload and use artefacts from Bitbucket
Java
17
star
11

ResourceNamingExample

Non working sample project to demonstrate how to name resources
Java
9
star
12

MigrateArtifactsMavenCentral

Script to migrate existing artifacts from JCenter to Maven Central
Shell
8
star
13

jeroenmols.github.io

Personal blog and website
JavaScript
8
star
14

TravisCoverallsExample

Example code to configure Travis CI and Coveralls
Java
6
star
15

FragmentBackNavigation

Sample project to demonstrate a peculiarity with Fragment back navigation
Kotlin
6
star
16

architecturediagrams

Interactive, versionable architecture diagrms
2
star
17

StrandHoggAttackRecents

Demonstration of a StrandHogg attack via the task switcher
Kotlin
2
star
18

Snap

Sample project to experiment with a full Kotlin reactive app
Kotlin
2
star
19

ReactTicTacToe

My solution to https://reactjs.org/tutorial/tutorial.html#setup-for-the-tutorial
JavaScript
1
star
20

LibraryExample

Demonstrate how to consume release artifacts in project
Kotlin
1
star