user15971: I am doing some experiments on the file size of recorded videos in HEVC vs the ones recorded in H264 using a simple Android app that I developed. My impression was that videos recorded in HEVC should generally have almost half size (or at least much lower size) compared to ones recorded in H264 given they have same duration and almost same contents (I capture the same scene with phone's camera). But when I compare their metadata using mediaInfo, it is not really like. I wonder why.
What is going on here? Am I missing anything?! What should I do to prove this concept?
Here is what I set:
    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
    //choose HEVC or H264
    mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    mMediaRecorder.setVideoEncodingBitRate(5000 * 1000);
    mMediaRecorder.setVideoFrameRate(30);
    mMediaRecorder.setVideoSize(1280, 720);

Here is the mediaInfo for the HEVC video:
General 
Complete name : VID_20211225_210352.mp4 
Format : MPEG-4 
Format profile : Base Media / Version 2 
Codec ID : mp42 (isom/mp42) 
File size : 763 KiB 
Duration : 1 s 447 ms 
Overall bit rate : 4 322 kb/s 
Encoded date : UTC 2021-12-25 17:33:56 
Tagged date : UTC 2021-12-25 17:33:56 
com.android.version : 11 

Video 
ID : 1 
Format : HEVC 
Format/Info : High Efficiency Video Coding 
Format profile : Main@L3.1@Main 
Codec ID : hvc1 
Codec ID/Info : High Efficiency Video Coding 
Duration : 1 s 447 ms 
Source duration : 1 s 441 ms 
Bit rate : 4 316 kb/s 
Width : 1 280 pixels 
Height : 720 pixels 
Display aspect ratio : 16:9 
Frame rate mode : Variable 
Frame rate : 29.837 FPS 
Minimum frame rate : 23.112 FPS 
Maximum frame rate : 30.050 FPS 
Standard : PAL 
Color space : YUV 
Chroma subsampling : 4:2:0 
Bit depth : 8 bits 
Bits/(Pixel*Frame) : 0.157 
Stream size : 759 KiB (99%) 
Source stream size : 759 KiB (99%) 
Title : VideoHandle 
Language : English 
Encoded date : UTC 2021-12-25 17:33:56 
Tagged date : UTC 2021-12-25 17:33:56 
Color range : Limited 
Color primaries : BT.709 
Transfer characteristics : BT.709 
Matrix coefficients : BT.709 
mdhd_Duration : 1447 
Codec configuration box : hvcC 

Audio 
ID : 2 
Format : AAC LC 
Format/Info : Advanced Audio Codec Low Complexity 
Codec ID : mp4a-40-2 
Duration : 1 s 408 ms 
Bit rate mode : Constant 
Bit rate : 13.1 kb/s 
Nominal bit rate : 12.2 kb/s 
Channel(s) : 1 channel 
Channel layout : C 
Sampling rate : 8 000 Hz 
Frame rate : 7.812 FPS (1024 SPF) 
Compression mode : Lossy 
Stream size : 2.26 KiB (0%) 
Title : SoundHandle 
Language : English 
Encoded date : UTC 2021-12-25 17:33:56 
Tagged date : UTC 2021-12-25 17:33:56 

And here is the mediaInfo for the H264 video:
General 
Complete name : VID_20211225_210425.mp4 
Format : MPEG-4 
Format profile : Base Media / Version 2 
Codec ID : mp42 (isom/mp42) 
File size : 719 KiB 
Duration : 1 s 409 ms 
Overall bit rate : 4 178 kb/s 
Encoded date : UTC 2021-12-25 17:34:28 
Tagged date : UTC 2021-12-25 17:34:28 
com.android.version : 11 

Video 
ID : 1 
Format : AVC 
Format/Info : Advanced Video Codec 
Format profile : High@L3.1 
Format settings : CABAC / 1 Ref Frames 
Format settings, CABAC : Yes 
Format settings, Reference frames : 1 frame 
Codec ID : avc1 
Codec ID/Info : Advanced Video Coding 
Duration : 1 s 408 ms 
Bit rate : 4 157 kb/s 
Width : 1 280 pixels 
Height : 720 pixels 
Display aspect ratio : 16:9 
Frame rate mode : Variable 
Frame rate : 29.832 FPS 
Minimum frame rate : 23.107 FPS 
Maximum frame rate : 30.050 FPS 
Standard : PAL 
Color space : YUV 
Chroma subsampling : 4:2:0 
Bit depth : 8 bits 
Scan type : Progressive 
Bits/(Pixel*Frame) : 0.151 
Stream size : 714 KiB (99%) 
Title : VideoHandle 
Language : English 
Encoded date : UTC 2021-12-25 17:34:28 
Tagged date : UTC 2021-12-25 17:34:28 
Color range : Limited 
Color primaries : BT.709 
Transfer characteristics : BT.709 
Matrix coefficients : BT.709 
mdhd_Duration : 1408 
Codec configuration box : avcC 

Audio 
ID : 2 
Format : AAC LC 
Format/Info : Advanced Audio Codec Low Complexity 
Codec ID : mp4a-40-2 
Duration : 1 s 409 ms 
Source duration : 1 s 408 ms 
Bit rate mode : Constant 
Bit rate : 13.4 kb/s 
Nominal bit rate : 12.2 kb/s 
Channel(s) : 1 channel 
Channel layout : C 
Sampling rate : 8 000 Hz 
Frame rate : 7.812 FPS (1024 SPF) 
Compression mode : Lossy 
Stream size : 2.31 KiB (0%) 
Source stream size : 2.31 KiB (0%) 
Title : SoundHandle 
Language : English 
Encoded date : UTC 2021-12-25 17:34:28 
Tagged date : UTC 2021-12-25 17:34:28 
mdhd_Duration : 1409 


user35533: You've specified the encoding bit rate to be 5000*1000 kbs. So the constraint here is the file size, not the quality of the video (i.e., all of your videos will be approximately 5 kbs * duration in size, regardless of the choice of encoding).
HEVC has the potential to have higher quality at a given bit rate, though it comes at a cost of encoding speed (i.e., better compression also takes more time; for certain levels of compute, the difference between x264 and HEVC might be de minimus).
See also this answer.

15971: <p>I am doing some experiments on the file size of recorded videos in <code>HEVC</code> vs the ones recorded in <code>H264</code> using a simple Android app that I developed. My impression was that videos recorded in HEVC should generally have <strong>almost half size</strong> (or at least much lower size) compared to ones recorded in H264 given they have same duration and almost same contents (I capture the same scene with phone's camera). But when I compare their metadata using <code>mediaInfo</code>, it is not really like. I wonder why.</p>
<p>What is going on here? Am I missing anything?! What should I do to prove this concept?</p>
<p>Here is what I set:</p>
<pre><code>    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
    //choose HEVC or H264
    mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    mMediaRecorder.setVideoEncodingBitRate(5000 * 1000);
    mMediaRecorder.setVideoFrameRate(30);
    mMediaRecorder.setVideoSize(1280, 720);
</code></pre>
<p>Here is the mediaInfo for the <code>HEVC</code> video:</p>
<pre><code>General 
Complete name : VID_20211225_210352.mp4 
Format : MPEG-4 
Format profile : Base Media / Version 2 
Codec ID : mp42 (isom/mp42) 
File size : 763 KiB 
Duration : 1 s 447 ms 
Overall bit rate : 4 322 kb/s 
Encoded date : UTC 2021-12-25 17:33:56 
Tagged date : UTC 2021-12-25 17:33:56 
com.android.version : 11 

Video 
ID : 1 
Format : HEVC 
Format/Info : High Efficiency Video Coding 
Format profile : Main@L3.1@Main 
Codec ID : hvc1 
Codec ID/Info : High Efficiency Video Coding 
Duration : 1 s 447 ms 
Source duration : 1 s 441 ms 
Bit rate : 4 316 kb/s 
Width : 1 280 pixels 
Height : 720 pixels 
Display aspect ratio : 16:9 
Frame rate mode : Variable 
Frame rate : 29.837 FPS 
Minimum frame rate : 23.112 FPS 
Maximum frame rate : 30.050 FPS 
Standard : PAL 
Color space : YUV 
Chroma subsampling : 4:2:0 
Bit depth : 8 bits 
Bits/(Pixel*Frame) : 0.157 
Stream size : 759 KiB (99%) 
Source stream size : 759 KiB (99%) 
Title : VideoHandle 
Language : English 
Encoded date : UTC 2021-12-25 17:33:56 
Tagged date : UTC 2021-12-25 17:33:56 
Color range : Limited 
Color primaries : BT.709 
Transfer characteristics : BT.709 
Matrix coefficients : BT.709 
mdhd_Duration : 1447 
Codec configuration box : hvcC 

Audio 
ID : 2 
Format : AAC LC 
Format/Info : Advanced Audio Codec Low Complexity 
Codec ID : mp4a-40-2 
Duration : 1 s 408 ms 
Bit rate mode : Constant 
Bit rate : 13.1 kb/s 
Nominal bit rate : 12.2 kb/s 
Channel(s) : 1 channel 
Channel layout : C 
Sampling rate : 8 000 Hz 
Frame rate : 7.812 FPS (1024 SPF) 
Compression mode : Lossy 
Stream size : 2.26 KiB (0%) 
Title : SoundHandle 
Language : English 
Encoded date : UTC 2021-12-25 17:33:56 
Tagged date : UTC 2021-12-25 17:33:56 
</code></pre>
<p>And here is the mediaInfo for the H264 video:</p>
<pre><code>General 
Complete name : VID_20211225_210425.mp4 
Format : MPEG-4 
Format profile : Base Media / Version 2 
Codec ID : mp42 (isom/mp42) 
File size : 719 KiB 
Duration : 1 s 409 ms 
Overall bit rate : 4 178 kb/s 
Encoded date : UTC 2021-12-25 17:34:28 
Tagged date : UTC 2021-12-25 17:34:28 
com.android.version : 11 

Video 
ID : 1 
Format : AVC 
Format/Info : Advanced Video Codec 
Format profile : High@L3.1 
Format settings : CABAC / 1 Ref Frames 
Format settings, CABAC : Yes 
Format settings, Reference frames : 1 frame 
Codec ID : avc1 
Codec ID/Info : Advanced Video Coding 
Duration : 1 s 408 ms 
Bit rate : 4 157 kb/s 
Width : 1 280 pixels 
Height : 720 pixels 
Display aspect ratio : 16:9 
Frame rate mode : Variable 
Frame rate : 29.832 FPS 
Minimum frame rate : 23.107 FPS 
Maximum frame rate : 30.050 FPS 
Standard : PAL 
Color space : YUV 
Chroma subsampling : 4:2:0 
Bit depth : 8 bits 
Scan type : Progressive 
Bits/(Pixel*Frame) : 0.151 
Stream size : 714 KiB (99%) 
Title : VideoHandle 
Language : English 
Encoded date : UTC 2021-12-25 17:34:28 
Tagged date : UTC 2021-12-25 17:34:28 
Color range : Limited 
Color primaries : BT.709 
Transfer characteristics : BT.709 
Matrix coefficients : BT.709 
mdhd_Duration : 1408 
Codec configuration box : avcC 

Audio 
ID : 2 
Format : AAC LC 
Format/Info : Advanced Audio Codec Low Complexity 
Codec ID : mp4a-40-2 
Duration : 1 s 409 ms 
Source duration : 1 s 408 ms 
Bit rate mode : Constant 
Bit rate : 13.4 kb/s 
Nominal bit rate : 12.2 kb/s 
Channel(s) : 1 channel 
Channel layout : C 
Sampling rate : 8 000 Hz 
Frame rate : 7.812 FPS (1024 SPF) 
Compression mode : Lossy 
Stream size : 2.31 KiB (0%) 
Source stream size : 2.31 KiB (0%) 
Title : SoundHandle 
Language : English 
Encoded date : UTC 2021-12-25 17:34:28 
Tagged date : UTC 2021-12-25 17:34:28 
mdhd_Duration : 1409 
</code></pre>
 35533: <p>You've specified the encoding bit rate to be <code>5000*1000</code> kbs. So the constraint here is the file size, not the quality of the video (i.e., all of your videos will be approximately <code>5 kbs * duration</code> in size, regardless of the choice of encoding).</p>
<p>HEVC has the potential to have higher quality at a given bit rate, though it comes at a cost of encoding speed (i.e., better compression also takes more time; for certain levels of compute, the difference between x264 and HEVC might be de minimus).</p>
<p>See also <a href="https://superuser.com/a/1557090/294360">this answer</a>.</p>
