1# B-Frames Encoding App 2 3This 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 5This page describes how to get started with the Encoder App and how to run the tests for it. 6 7 8# Getting Started 9 10This app uses the Gradle build system as well as Soong Build System. 11 12To build this project using Gradle build, use the "gradlew build" command or use "Import Project" in Android Studio. 13 14To build the app using Soong Build System, run the following command: 15``` 16mmm frameworks/av/media/tests/SampleVideoEncoder/ 17``` 18 19The apk is generated at the following location: 20``` 21out\target\product\sargo\testcases\SampleVideoEncoder\arm64\SampleVideoEncoder.apk 22``` 23 24Command to install the apk: 25``` 26adb install SampleVideoEncoder.apk 27``` 28 29Command to launch the app: 30``` 31adb shell am start -n "com.android.media.samplevideoencoder/com.android.media.samplevideoencoder.MainActivity" 32``` 33 34After 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 36# Running Tests 37 38The 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 40## Running the tests using atest 41Note that atest command will install the SampleVideoEncoder app on the device. 42 43Command to run the tests: 44``` 45atest SampleVideoEncoder 46``` 47 48# Ouput 49 50The muxed ouptput video is saved in the app data at: 51``` 52/storage/emulated/0/Android/data/com.android.media.samplevideoencoder/files/ 53``` 54 55The total number of I-frames, P-frames and B-frames after encoding has been done using MediaCodec APIs are displayed on the screen. 56The results of the tests can be obtained from the logcats of the test. 57