xref: /aosp_15_r20/frameworks/av/media/tests/SampleVideoEncoder/README.md (revision ec779b8e0859a360c3d303172224686826e6e0e1)
1*ec779b8eSAndroid Build Coastguard Worker# B-Frames Encoding App
2*ec779b8eSAndroid Build Coastguard Worker
3*ec779b8eSAndroid Build Coastguard WorkerThis is a sample android application for encoding AVC/HEVC streams with B-Frames enabled. It uses MediaRecorder APIs to record B-frames enabled video from camera2 input and MediaCodec APIs to encode reference test vector using input surface.
4*ec779b8eSAndroid Build Coastguard Worker
5*ec779b8eSAndroid Build Coastguard WorkerThis page describes how to get started with the Encoder App and how to run the tests for it.
6*ec779b8eSAndroid Build Coastguard Worker
7*ec779b8eSAndroid Build Coastguard Worker
8*ec779b8eSAndroid Build Coastguard Worker# Getting Started
9*ec779b8eSAndroid Build Coastguard Worker
10*ec779b8eSAndroid Build Coastguard WorkerThis app uses the Gradle build system as well as Soong Build System.
11*ec779b8eSAndroid Build Coastguard Worker
12*ec779b8eSAndroid Build Coastguard WorkerTo build this project using Gradle build, use the "gradlew build" command or use "Import Project" in Android Studio.
13*ec779b8eSAndroid Build Coastguard Worker
14*ec779b8eSAndroid Build Coastguard WorkerTo build the app using Soong Build System, run the following command:
15*ec779b8eSAndroid Build Coastguard Worker```
16*ec779b8eSAndroid Build Coastguard Workermmm frameworks/av/media/tests/SampleVideoEncoder/
17*ec779b8eSAndroid Build Coastguard Worker```
18*ec779b8eSAndroid Build Coastguard Worker
19*ec779b8eSAndroid Build Coastguard WorkerThe apk is generated at the following location:
20*ec779b8eSAndroid Build Coastguard Worker```
21*ec779b8eSAndroid Build Coastguard Workerout\target\product\sargo\testcases\SampleVideoEncoder\arm64\SampleVideoEncoder.apk
22*ec779b8eSAndroid Build Coastguard Worker```
23*ec779b8eSAndroid Build Coastguard Worker
24*ec779b8eSAndroid Build Coastguard WorkerCommand to install the apk:
25*ec779b8eSAndroid Build Coastguard Worker```
26*ec779b8eSAndroid Build Coastguard Workeradb install SampleVideoEncoder.apk
27*ec779b8eSAndroid Build Coastguard Worker```
28*ec779b8eSAndroid Build Coastguard Worker
29*ec779b8eSAndroid Build Coastguard WorkerCommand to launch the app:
30*ec779b8eSAndroid Build Coastguard Worker```
31*ec779b8eSAndroid Build Coastguard Workeradb shell am start -n "com.android.media.samplevideoencoder/com.android.media.samplevideoencoder.MainActivity"
32*ec779b8eSAndroid Build Coastguard Worker```
33*ec779b8eSAndroid Build Coastguard Worker
34*ec779b8eSAndroid Build Coastguard WorkerAfter installing the app, a TextureView showing camera preview is dispalyed on one third of the screen. It also features checkboxes to select either avc/hevc and hw/sw codecs. It also has an option to select either MediaRecorder APIs or MediaCodec, along with the 'Start' button to start/stop recording.
35*ec779b8eSAndroid Build Coastguard Worker
36*ec779b8eSAndroid Build Coastguard Worker# Running Tests
37*ec779b8eSAndroid Build Coastguard Worker
38*ec779b8eSAndroid Build Coastguard WorkerThe app also contains a test, which will test the MediaCodec APIs for encoding avc/hevc streams with B-frames enabled. This does not require us to use application UI.
39*ec779b8eSAndroid Build Coastguard Worker
40*ec779b8eSAndroid Build Coastguard Worker## Running the tests using atest
41*ec779b8eSAndroid Build Coastguard WorkerNote that atest command will install the SampleVideoEncoder app on the device.
42*ec779b8eSAndroid Build Coastguard Worker
43*ec779b8eSAndroid Build Coastguard WorkerCommand to run the tests:
44*ec779b8eSAndroid Build Coastguard Worker```
45*ec779b8eSAndroid Build Coastguard Workeratest SampleVideoEncoder
46*ec779b8eSAndroid Build Coastguard Worker```
47*ec779b8eSAndroid Build Coastguard Worker
48*ec779b8eSAndroid Build Coastguard Worker# Ouput
49*ec779b8eSAndroid Build Coastguard Worker
50*ec779b8eSAndroid Build Coastguard WorkerThe muxed ouptput video is saved in the app data at:
51*ec779b8eSAndroid Build Coastguard Worker```
52*ec779b8eSAndroid Build Coastguard Worker/storage/emulated/0/Android/data/com.android.media.samplevideoencoder/files/
53*ec779b8eSAndroid Build Coastguard Worker```
54*ec779b8eSAndroid Build Coastguard Worker
55*ec779b8eSAndroid Build Coastguard WorkerThe total number of I-frames, P-frames and B-frames after encoding has been done using MediaCodec APIs are displayed on the screen.
56*ec779b8eSAndroid Build Coastguard WorkerThe results of the tests can be obtained from the logcats of the test.
57