简体   繁体   中英

File size of videos captured in HEVC vs H264

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 

You are setting the bitrate for both formats to 5 Mbps - therefore you are getting about the same size for both formats. In theory - if you encode HEVC with 5 Mbps you should get a higher quality than H.264 with 5 Mbps. So you should lower the bitrate for HEVC - try 2.5 Mbps - and then compare the quality using for example PSNR.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM