1

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 : [email protected]@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 : [email protected] 
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 
0

1 Answer 1

1

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.

2
  • Ok..So if I make the hevc bitrate half, what should be the acceptable psnr? So if too off, I increase the hevc bitrate more than half.
    – angel_30
    Commented Dec 28, 2021 at 19:34
  • 1
    If you're comparing x264/HEVC to the uncompressed original, you should be able to get the same PSNR using a lower bitrate with HEVC. You might have to fiddle with some of the encoding settings and you might decide to have a slightly higher HEVC bitrate than half of an acceptable x264 bitrate to achieve the same quality.
    – Tahlor
    Commented Dec 28, 2021 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.