Vahid Mohtasham
Vahid Mohtasham

Reputation: 90

how calculate video file size by formula

I want to compress video in Android and upload it. before compressing I want to show the deferent width and height and estimated Size then user chooses one.

 for example:
    240  estimated Size =~20 MB
    480  estimated Size =~40 MB
    640  estimated Size =~90 MB
    720  estimated Size =~130 MB
    1080 estimated Size =~180 MB

now I look for a formula for calculating estimated size. I get width and height and bitrate from MediaMetadataRetriever in Android

 retriever = new MediaMetadataRetriever();
 retriever.setDataSource(path, new HashMap<String, String>());
 width = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
 height = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
 rotation = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);

Upvotes: 1

Views: 1765

Answers (1)

Vahid Mohtasham
Vahid Mohtasham

Reputation: 90

I found it. for calculating file size from Bit rate and duration we can use:

(bitrate() / 8 * duration() / 1000/1000)

for example

file size=((17305731/8)*(4655000/1000/1000))=‭10,069,772‬= 9.6 MB

Upvotes: 3

Related Questions