[PAID] VideoRekorder: Record video with preview in custom layout without any external app ($8 or INR 501)

1. Overview

VideoRekorder is an advanced extension for App Inventor2 that allows users to record videos directly within a custom layout. It supports multiple features like switching between front and back cameras, adjusting video quality, and enabling flash. Users can start, pause, mute, and resume recordings effortlessly. The extension also includes events for handling errors and tracking recording status changes, such as when a video is successfully saved. It's an all-in-one solution for video recording without needing any external apps.

Latest Version: 1
Published: 2024-08-12T18:30:00Z
Last Updated: 2024-08-12T18:30:00Z
Min Api: Android 5 (api 21)
Aix size: 1.8 mb

2. Blocks




image

3. Documentation

Events

CameraSwitchedEvent raised when camera is switched to front from back or vice-versa
isFrontCamera | boolean
RecordingPausedEvent raised when recording is successfully paused
RecordingMutedEvent raised when recording is successfully muted
RecordingUnmutedEvent raised when recording is successfully unmuted
RecordingResumedEvent raised when recording is successfully resumed
VideoRecordedEvent raised when video is successfully recorded and saved to given path
videoPath | text
ErrorOccurredEvent raised when any error occurs
errorMsg | text
CameraPreviewStartedEvent raised when camera preview started showing in the layout
CameraPreviewStoppedEvent raised when camera preview stopped showing in the layout

Methods

IsFeatureAvailableReturns whether provided feature is supported or not
feature | text
InitializeCameraInitializes preview view in the provided layout and opens default camera. Back camera is always opened by default.
container | component
StartRecordingStarts video recording with configurations set through properties.
outputPath | text
SwitchCameraSwitches between front and back camera.
StopRecordingStops currently running video recording and saves video.
PauseRecordingPauses currently running video recording.
MuteRecordingMutes currently running video recording.
UnMuteRecordingUnmutes currently running video recording.
ResumeRecordingResumes video recording.
StopCameraStops camera preview and removes it from registered layout.
EnableFlashSets flash state. Use this method only after preview started.
enable | boolean
IsFlashOnReturns whether flash is on or not
GetSupportedVideoQualitiesReturns supported video qualities for opened camera. Use this method only after preview started.
SetQualitySet quality for video recording. Use this method only after preview started.
quality | text

Properties

RecordAudioSets whether to record audio or not. Effective only when set before InitializeCamera method.
Property Type : write-only
Accepts : boolean
UseFrontCameraSets whether to open and use front camera or back camera. Effective only when set before InitializeCamera method.
Property Type : write-only
Accepts : boolean
FlashOnSets whether to enable flash or not in camera preview and video recording. Effective only when set before InitializeCamera method.
Property Type : write-only
Accepts : boolean
CameraOrientationSets orientation (rotation) used in camera preview and video recording. Effective only when set before InitializeCamera method.
Property Type : write-only
Accepts : number
QualitySets video quality used in camera preview and video recording. Effective only when set before InitializeCamera method.
Property Type : write-only
Accepts : text
FeatureBackCameraBack camera feature
Property Type : read-only
Accepts : text
FeatureAutofocusCameraAutofocus camera feature
Property Type : read-only
Accepts : text
FeatureCameraFlashCamera flash feature
Property Type : read-only
Accepts : text
FeatureFrontCameraFront camera feature
Property Type : read-only
Accepts : text
ScaleTypeSets preview scale type
Property Type : write-only
Accepts : number
ScaleTypeFillCenterScale type FILL_CENTER
Property Type : read-only
Accepts : number
ScaleTypeFitCenterScale type FIT_CENTER
Property Type : read-only
Accepts : number
AspectRatioSets aspect ratio of preview and video
Property Type : write-only
Accepts : number
AspectRatio4n3Aspect ratio 4:3
Property Type : read-only
Accepts : number
AspectRatio16n9Aspect ration 16:9
Property Type : read-only
Accepts : number
AspectRatioDefaultAspect ratio default
Property Type : read-only
Accepts : number

4. Usage

Initialize Camera preview in layout

Property blocks are effective only when called before InitializeCamera block. Also, aspect ratio works best with FitCenter scale type.

GetSupportedVideoQualities returns a list of supported qualities for currently opened camera. (back or front)
In addition to these values, HIGHEST and LOWEST quality are always supported.


Change quality and switch camera on-demand
There are some limited features which can altered after opening camera.


Record Video

You can leave outputPath empty. A randomly generated file path will be used.

You can Pause and Resume recording using respective blocks.

Close camera when done recording
Make sure to close camera preview when you no longer need it.

image

This will trigger CameraPreviewStopped event, if camera was closed successfully.

5. Purchase Extension

6. Demo Video

Thank you.
Hope it helps!

10 Likes

Stunning !!

4 Likes

:hugs:

1 Like

Added demo video.

This is cool!!! :+1:

2 Likes

Thank you :hugs: :hugs:

1 Like

Good job as always

1 Like

Q1. What are the number settings for CameraOrientation, and what impact do they have on the video that is output ?

Q2. I notice that if I transfer a video taken with the phone in portrait poistion, that the video is rotated by 90 degrees (one way for the front camera, the other way for the rear camera?

Q3. I am not able to select HIGHEST or LOWEST video settings ?

90, 180 and 270 are accepted values. I mean you can put values between them as well but in saved recording only these values will be used. Like any value between 45 and 135 will be converted into 90.
Orientation effects preview view and recording.

I am unable to understand this. Can you post a recording here (or in pm) ?

These quality options are always available for use, but not returned by GetSupportedVideoQualities block.
For example my phone has FHD , HD and SD options. So if I set quality to HIGHEST then best quality available (in this case FHD) will be used for recording, and SD will be used for LOWEST quality.

Q2. cont'd

Here is the relevant output from ffmpeg:

###################################
Not using the extension, but using the device camera app:
###################################

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'PXL_20240814_202349394.mp4':
  com.android.capture.fps: 30.000000
  Duration: 00:00:05.96, start: 0.000000, bitrate: 19880 kb/s
  Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 190 kb/s (default)
    Metadata:
      rotate          : 90
   
  Stream #0:1(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, smpte170m/bt470bg/smpte170m), 1920x1080, 19685 kb/s, SAR 1:1 DAR 16:9, 30.02 fps, 30 tbr, 90k tbn, 90k tbc (default)
    Metadata:
      rotate          : 90

    Side data:
      displaymatrix: rotation of -90.00 degrees

###################################
Using the extension FRONT camera
###################################

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'FHD1723665514014.mp4':
  Duration: 00:00:06.36, start: 0.000000, bitrate: 16687 kb/s
  Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuvj420p(pc, smpte170m/bt470bg/smpte170m), 1920x1080, 16585 kb/s, 30.02 fps, 30.02 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 90
    Side data:
      displaymatrix: rotation of -90.00 degrees

###################################
Using the extension REAR camera (selfie...)
###################################

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SDR1723665953763.mp4':
  Duration: 00:00:06.16, start: 0.000000, bitrate: 2984 kb/s
  Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuvj420p(pc, smpte170m/bt470bg/smpte170m), 720x480, 2945 kb/s, 30.03 fps, 30 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 270
    Side data:
      displaymatrix: rotation of 90.00 degrees

Screenshot of FRONT camera video on computer (using mplayer) - rotated 90 degrees anti-clockwise. Same output from camera app...

The video for the REAR camera is rotated 90 degrees clockwise

I recorded a video using front camera and retrieved metadata.

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'recording_1723727629671.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2024-08-15T13:13:54.000000Z
    com.android.version: 14
  Duration: 00:00:03.76, start: 0.000000, bitrate: 1731 kb/s
  Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m, progressive), 720x480, 1469 kb/s, 30.08 fps, 30.08 tbr, 90k tbn (default)
      Metadata:
        creation_time   : 2024-08-15T13:13:54.000000Z
        handler_name    : VideoHandle
        vendor_id       : [0][0][0][0]
      Side data:
        displaymatrix: rotation of 90.00 degrees
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
      Metadata:
        creation_time   : 2024-08-15T13:13:54.000000Z
        handler_name    : SoundHandle
        vendor_id       : [0][0][0][0]

I am not sure how to interpret this data.

So I checked again with MediaInfo and yes rotation is 270, but MediaPlayer on Windows 11 plays with correct rotation. Same on Android.

Interestingly if i playback video on my computer with ffplay the orientation is correct:

ffplay -i FHD1723665514014.mp4

will see what my smart tv does... hmm plays back rotated :frowning:

Can you try recording video on a different phone?

On a Nexus7 Android 6.01

Same output, same rotation

Note videos play back OK on Google Drive.

Seems video recording is blighted with the same issue and image/picture taking on Google devices, they look OK when android/google is handling it but anything else (e.g. AI2..?)

My guess is that if I try to rotate the camera with the extension, playback will just be wrong? I need to do some more testing...

What does this mean? :thinking:
No issues with camera app?

Same issue with camera app :slight_smile:

Okay, so this issue is only on/due to Google devices? :sweat_smile:

On a normal phone, yes.

If I rotate the phone to landscape and make a video, this plays back rotated everywhere except with mplayer :smiley:

There is a parameter -vf rotate=1 that fixes playback for mplayer with the earlier video tests, and I can encode (as I probably will) to unrotate.

But expectation is, I guess, that a user should have some sort of WYSIWYG experience...

If I set the preview window to say 320x180 (16:9), and take a video, then I should get back a video of what I could see in the preview window, in the correct orientation? - but it seems Google messes with the metadata...

image

(experience based on using @Kumaraswamy 's Procam extension which takes an image of the preview window. Now this may not be possible for video...)

I think I can handle orientation changes of phone and update video recording rotation at runtime, I'll see.