Search code examples
bashawkmediainfo

How can I display my video bitrate in MBps using MediaInfo on the command line with --Inform


I have this command:

mediainfo --Inform="Video;%CodecID% %BitRate/String% %Height%p" ./filename.mp4

which displays:

avc1 882 kb/s 720p

but I would like it to display in MBps instead, with a max of one decimal place, like 1.1 MBps.

can I do this out of the box without using bash and numfmt? If I do need numfmt, how could I use that?


Solution

  • Remove /String to get bit rate in bps and append:

    | awk '{$2=sprintf("%.1f Mbps",$2/1024/1024)}1'