LandscapeVideoCamera


Source link: https://github.com/JeroenMols/LandscapeVideoCamera

LandscapeVideoCamera

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

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.

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

Resources

SharP wraps your SharedPreferences into a clean, type-safe Java interface. It uses annotation processing to generate the boilerplate code for you.

Android Five Stars Library is a small library that helps developers add a "Rate My App" dialog to their applications.

A simple tool for code generation of android.content.SharedPreferences based on model class described in java with a little help of annotations. Provides an ability to encapsulate data, saves time writing boiler-plate code, goes beyond SharedPreferences usage with easy-to use Serialization & default values evaluation at runtime.

Actions for android animations. Inspired by libgdx scene2d actions.

The main goal of this project is making creating of complex animations easier.

A lovely snail, you can use it as a seekbar or progressbar.

A beautiful RefreshLayout.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes