logo
down
shadow

How to record a video less than 10 mb using Android


How to record a video less than 10 mb using Android

Content Index :

How to record a video less than 10 mb using Android
Tag : android , By : abuiles
Date : November 23 2020, 01:01 AM

I think the issue was by ths following , You need to add one more parameter MediaStore.EXTRA_SIZE_LIMIT while initiating recording,
i.e.:
private void recordVideo() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO);
    Toast.makeText(getApplicationContext(), fileUri.toString(), Toast.LENGTH_LONG).show();
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

//add one more parameter
    long maxVideoSize = 10*1024*1024; // 10 MB
    intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, maxVideoSize);

    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); 
    startActivityForResult(intent, CAMERA_CAPTURE_VIDEO_REQUEST_CODE);
}

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Android: Record raw audio and record video at the same time


Tag : android , By : JSebok
Date : March 29 2020, 07:55 AM
I hope this helps you . According bigflake

android - MediaCodec record video with timestamp on each video frame


Tag : android , By : mlapida
Date : March 29 2020, 07:55 AM
I hope this helps . Take your time and explore this link to get an idea how to feed the Camera preview into a video file. Once you are confident about the mechanism, you should be able to feed the MediaCodec input surface with some kind of OpenGL magic to put extra graphics on the top of the Camera's preview. I would recommend to tweak the example code's drawExtra() as a start.

Record video without sound recording with default video intent ACTION_VIDEO_CAPTURE or Remove sound after video record l


Tag : android , By : Jesenko Mehmedbasic
Date : March 29 2020, 07:55 AM
This might help you "MODIFY_AUDIO_SETTINGS" permission is necessary to change audio settings. so first declare below permission in your manifest file:
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    Button btnRecord;
    int REQUEST_CODE_TAKE_VIDEO = 201;
    private final int MY_PERMISSIONS_REQUEST_FOR_VIDEO = 202;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video);
        btnRecord = findViewById(R.id.btnRecord);
        btnRecord.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {

                    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED
                                && ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
                            && ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED
                            && ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
                            && ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {

                        ActivityCompat.requestPermissions(MainActivity.this,
                                new String[]{android.Manifest.permission.RECORD_AUDIO,
                                        android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
                                        android.Manifest.permission.READ_PHONE_STATE,
                                        android.Manifest.permission.READ_EXTERNAL_STORAGE,
                                        Manifest.permission.CAMERA
                                },
                                MY_PERMISSIONS_REQUEST_FOR_VIDEO);

                    } else {
                        takeVideo();
                    }

                } else {
                    takeVideo();
                }
            }
        });
    }


    @Override
    public void onRequestPermissionsResult(int requestCode,
                                           String permissions[], int[] grantResults) {
        switch (requestCode) {
            case MY_PERMISSIONS_REQUEST_FOR_VIDEO: {
                // If request is cancelled, the result arrays are empty.
                if (grantResults.length > 0
                        && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

                    takeVideo();

                } else {

                    Toast.makeText(MainActivity.this, "Permissions Declined! Can't record video withon permissions. ", Toast.LENGTH_SHORT).show();
                }
                return;
            }

        }
    }


    private void takeVideo() {
        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
        intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 3000);
        startActivityForResult(intent, REQUEST_CODE_TAKE_VIDEO);
        setMicMuted(true);
    }

    private void setMicMuted(Boolean state){
//        AudioManager myAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
        AudioManager myAudioManager = (AudioManager)getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
        // get the working mode and keep it
        int workingAudioMode = myAudioManager.getMode();

        myAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);

        // change mic state only if needed
        if (myAudioManager.isMicrophoneMute() != state) {
            myAudioManager.setMicrophoneMute(state);
        }

        // set back the original working mode
        myAudioManager.setMode(workingAudioMode);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        try{
            if (requestCode == REQUEST_CODE_TAKE_VIDEO) {
                if (resultCode == RESULT_OK) {
                    Uri videoUri = data.getData();
                    Toast.makeText(this, "Video saved to:\n" +
                            videoUri, Toast.LENGTH_LONG).show();
                } else if (resultCode == RESULT_CANCELED) {
                    Toast.makeText(this, "Video recording cancelled.",
                            Toast.LENGTH_LONG).show();
                } else {
                    Toast.makeText(this, "Failed to record video",
                            Toast.LENGTH_LONG).show();
                }
            }
        }catch (Exception e){
            Log.e("Unexpected error", "@video recording " + e.toString());
        }

    }

}

Record Video on Android without showing the video on screen


Tag : android , By : pdkent
Date : March 29 2020, 07:55 AM

Android - Record video in background and simultaneously show the recording video in a Surface View


Tag : android , By : woxorz
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Why it fail to upload apk to google play console?
  • How do I get more than 500 contact lists on Android?
  • Android layer-list affecting position of floating action button
  • Koin: NoBeanDefFoundException, Check your module definitions
  • How to Ensure View is Removed After Animation on repeated touches
  • Differentiate ambiguous Extensions in Kotlin
  • Firestore how to putExtra object using Geopoint
  • Apple Maps and Google Maps API feasibility
  • Jetpack Navigation: Hide label in toolbar
  • get thumbnail from video URL but it takes more than 5 seconds to load data on recycler view
  • How to fix 'Android SDK not found at this location' error while installing flutter?
  • Android Shared Storage protection issue
  • How can I clone views using java code in Android Studio
  • Hide title and action bar for splash screen and remove White screen in start
  • Why can not hashing key android for facebook
  • Can not create handler inside thread that has not called Looper.prepare()
  • ID of the child views in a custom view are same in Android
  • Android: unable to hide appbar on scrolling
  • Best layout for form-style screen
  • How To create multiple function in Adapter Class Android with Retrofit
  • Can the Android Flow virtual layout handle variable-width Views
  • How to fix "Unable to load class 'dagger.Multibindings'" due to problems with gradle
  • VpnService always-on "not supported by this app"
  • Android Studio - Gradle "Sync now" is not Available
  • How do i get my code to give my current location?
  • Could not initialize class sun.util.calendar.ZoneInfoFile while using Flutter firebase-notifications
  • How to implement circular to check / tick animation in Android?
  • Toolbar shadow not showing
  • Android Sqlite get rows where first character is not an Alphabet
  • why I receive "bad request" in my request by retrofit
  • Intercept NavigationUI.onNavDestinationSelected() to make backstack pop with "inclusive = true"
  • I have a problem with the navigation fragments in my proyect, it sais that I need a defaut nav host atribute but I alrea
  • How can I keep a BottomSheetDialogFragment height to always match_parent?
  • How to reference a timerPicker in android studio using kotlin
  • Firebase Crashlytics - get stacktrace info to display during CrashlyticsListener.crashlyticsDidDetectCrashDuringPrevious
  • Schedule a repeating alarm clock
  • Can't assign values outside onTouchListener
  • Is setContentView() needed to inflate a fragment?
  • Why instead of string method returns Kotlin.Unit?
  • Retrofit slash as Query
  • When does onCreateView() get called in this app?
  • Fragment is reloaded each time after rejecting location permission
  • How to read ViewModel data from sttrings.xml list of items
  • Flutter doctor does not see vs code ,VS code does not detect flutter/bin
  • How to build aar in flutter
  • Is displayMetrix xdpi and ydpi accurate?
  • How to detect doubletap on a View?
  • how to play an encrypted file in Android
  • Android: keytool error on the command line when locating debug.keystore
  • Android paint/canvas issue; drawing smooth curves
  • Problems with starting an activity in onStart
  • Performance of map overlay in conjunction with ItemizedOverlay is very poor
  • How to change android indeterminate ProgressBar color?
  • How do I change the Mobile Country Code (MCC) in the Android Emulator?
  • Stop Progressbar manual scrolling in Android
  • Android: download large file
  • Android : uploaded .apk file to server but cant download that .apk file
  • How do I distribute Android app to beta tester without using Market
  • Android Unable to launch the Inbox from a notification
  • Android: Ringer mode changed to silent doesn't stop the phone vibrating
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com