Bitrate calculation hack

Moderators: Gully, peteru

Post Reply
prl
Wizard God
Posts: 32706
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Bitrate calculation hack

Post by prl » Sun Jun 10, 2018 17:36

Code: Select all

root@artaxerxes:/media/hdd/movie# cat ~/bitrates.awk
FNR == 1 { l = split($0, x, ":"); service = x[l]; servs[service]++; }
FNR == 6 { time[service] += $0 / 90000 / 3600; }
FNR == 7 { len[service] += $0 / 1000000000; }
END { for(serv in servs) { printf "%-20s %5.1fGB/hr (%d)\n", serv, len[serv]/time[serv], servs[serv]; } }
Run as something like:

Code: Select all

root@artaxerxes:~# awk -f bitrates.awk /media/hdd/movie/*.ts.meta | sort
7TWO Canberra          1.9GB/hr (6)
7flix                  1.0GB/hr (1)
9Gem                   1.5GB/hr (17)
9HD Canberra           2.8GB/hr (8)
9Life                  0.9GB/hr (1)
ABC                    2.1GB/hr (3)
ABC HD                 1.9GB/hr (12)
ABC ME                 1.3GB/hr (1)
ABC2/KIDS              2.0GB/hr (4)
ABCComedy/Kids         1.6GB/hr (1)
ELEVEN Canberra        1.2GB/hr (1)
ONE Canberra           1.4GB/hr (34)
PRIME7 Canberra        2.1GB/hr (6)
PRIME7 HD Canberra     2.6GB/hr (3)
SBS ONE                1.4GB/hr (13)
SBS ONE HD             2.1GB/hr (42)
SBS VICELAND           1.4GB/hr (1)
SBS VICELAND HD        1.8GB/hr (6)
WIN Canberra HD        2.4GB/hr (1)
root@artaxerxes:~#  
The number in parentheses is the number of recordings that contributed to the average.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

stevebow
Master
Posts: 482
Joined: Thu Sep 03, 2015 11:21
Location: Sydney

Re: Bitrate calculation hack

Post by stevebow » Tue Jun 12, 2018 11:39

Nice one, thank you very much!

prl
Wizard God
Posts: 32706
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Bitrate calculation hack

Post by prl » Tue Jun 12, 2018 13:13

stevebow wrote:
Tue Jun 12, 2018 11:39
Nice one, thank you very much!

No problem

If you want to change the output units, you need to know that time is measured in units of 1/90000 sec. So to get Mb/s, you need:

Code: Select all

FNR == 6 { time[service] += $0 / 90000; }
FNR == 7 { len[service] += $0 * 8 / 1000000; }
And change units in the printf string.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

stevebow
Master
Posts: 482
Joined: Thu Sep 03, 2015 11:21
Location: Sydney

Re: Bitrate calculation hack

Post by stevebow » Thu Jul 05, 2018 13:36

prl wrote:
Tue Jun 12, 2018 13:13
If you want to change the output units, you need to know that time is measured in units of 1/90000 sec.

I have to ask out of mere curiosity... why 1/90000 sec.?

prl
Wizard God
Posts: 32706
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Bitrate calculation hack

Post by prl » Thu Jul 05, 2018 14:42

stevebow wrote:
Thu Jul 05, 2018 13:36
prl wrote:
Tue Jun 12, 2018 13:13
If you want to change the output units, you need to know that time is measured in units of 1/90000 sec.

I have to ask out of mere curiosity... why 1/90000 sec.?

I had thought that it was a value that allowed the inter-frame time for all common frame rates to be expressed as an integer multiple of 1/90000, but that doesn't work for 27.5 frames/sec (90000/27.5 = 3272.7272... - 275 has prime factors of 5 & 11, but 900000 has prime factors of 2, 3 & 5). It does work for 50, 25, 60, 30, 24 & 48 frames/sec, and some silent film rates of 16, 18 & 20 fps.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

User avatar
peteru
Uber Wizard
Posts: 9739
Joined: Tue Jun 12, 2007 23:06
Location: Sydney, Australia
Contact:

Re: Bitrate calculation hack

Post by peteru » Thu Jul 05, 2018 20:35

prl wrote:
Thu Jul 05, 2018 14:42
27.5 frames/sec

What an odd frame rate. Where did you encounter that?

"Beauty lies in the hands of the beer holder."
Blog.

prl
Wizard God
Posts: 32706
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Bitrate calculation hack

Post by prl » Fri Jul 06, 2018 11:34

peteru wrote:
Thu Jul 05, 2018 20:35
prl wrote:
Thu Jul 05, 2018 14:42
27.5 frames/sec

What an odd frame rate. Where did you encounter that?

It's one of the old frame rates listed in the Wikipedia Telecine entry.

(1/90000)sec units can also accurately represent the actual NTSC frame rate (30/1.001), but not the NTSC field rate (60/1.001).
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

Post Reply

Return to “Developers Community”