Git Product home page Git Product logo

landscapevideocamera's Introduction

LandscapeVideoCapture

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 wheter users capture their video in portait 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
    • ...

Screenshots

Portrait

Not recording

Not recording

Not recording

How to use

  1. Add the maven dependency to your project:

     compile 'com.github.jmolsmobile:landscapevideocamera:1.0.7'
    
  2. Specify the VideoCaptureActivity in your manifest:

    <activity
        android:name="com.jmolsmobile.landscapevideocapture.VideoCaptureActivity"
        android:screenOrientation="sensor" >
    </activity>
    
  3. 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" />
    
  4. Create a CaptureConfiguration - object with the desired parameters. (optional)

    Capture configuration = CaptureConfiguration(CaptureResolution resolution, CaptureQuality quality);
    Capture configuration = CaptureConfiguration(CaptureResolution resolution, CaptureQuality quality, int maxDurationSecs, int maxFilesizeMb);
    Capture configuration = CaptureConfiguration(int videoWidth, int videoHeight, int bitrate);
    Capture configuration = CaptureConfiguration(int videoWidth, int videoHeight, int bitrate, int maxDurationSecs, int maxFilesizeMb);
    

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);
    
  2. 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

landscapevideocamera's People

Contributors

jeroenmols avatar alexquinlivan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.