Android Question Camera2 Video recording compression level

Discussion in 'Android Questions' started by skrjabin, Jan 11, 2019.

  1. skrjabin

    skrjabin Active Member Licensed User

    I am recording videos with the Camera2 lib and the CamEx2 class. It works fine, but the size of recorded mp4 files is about 60 MB per minute. This is a bit to large, because I want to upload many of this files to my server.

    Is it possibe to use a stronger compression when recording or to do this afer recording with another library? For my needs only the audio is importand. The video does't have to be in this quality. Any suggestions?
     
  2. skrjabin

    skrjabin Active Member Licensed User

    It seems, I am stucked with that. The CamEx2 class comes with so many parameter settings, like AF_MODE "OFF", "AUTO", ... or EFFECT_MODE "OFF", "MONO", ...
    Could it be possible, to set the video quality as explaned here?
    Something like intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); ?
    or CamcorderProfile mProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);?

    Sorry, my knowlige in java is zero. I am not able to do this extension in the CamEx2 by myself. But I think, it would be a great thing, to create also smaller videos, which can be transfered via internet.

    The other solution could be, to compress a large video in a second step. But also for this I could not find a way.
     
  3. moster67

    moster67 Expert Licensed User

    I am not familiar with the Camera libs but probably my ffmpegencoder-library can help you out:
    https://www.b4x.com/android/forum/threads/b4a-ffmpegencoder.70778/

    You can work on the saved files and then encode them to a much smaller format, even cancelling the video so only audio is left.

    If you are interested, send me a PM
     
    skrjabin and Johan Schoeman like this.
  4. Erel

    Erel Administrator Staff Member Licensed User

    1. You can decrease PreviewSize. It will change the video size.
    2. You can reduce the frame rate:
    Code:
    'PrepareSurfaceForVideo
    Dim FrameRate As Int = 12
    MediaRecorder.RunMethod(
    "setVideoFrameRate"Array(FrameRate))
     
    skrjabin and DonManfred like this.
  5. skrjabin

    skrjabin Active Member Licensed User

    Thanks, it works. I added this FrameRate changing code into the PrepareSurfaceForVideo Sub, just before the line Camera.StartSession(tv, PreviewSize, CaptureSize, 0, 0, True) and also set the PreviewSize to cam.PreviewSize.Initialize(176, 144). Now I get small videos about 1 MB per 10 seconds. Thats great! I'´m only not shure yet, this format will be accepted in every android and also iOS device. Have to test...

    @monster67 your lib also sounds super interesting. I will contact you.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice