Hi, I'm using Mediainfo to take the average bitrate of a video but I've found that many times it's not there.
I have two questions:
1) what other ways are there to get the average bitrate?
2) If there are more than one way, what parameters can you count on? That is, what parameters are definitely present?
+ Reply to Thread
Results 1 to 30 of 36
-
-
1) what about taking your calculator and do size / duration?
2) what parameters are you referring to? -
Hi, it took some time for me to realise, but this one program called 'Avanti' have an feature called Bitrate/Filesize Calculator. Ive been using v.0.9.2 together with FFMpeg Essentials v.6.0 and it is working pretty good! This bitrate calculator will display the source files duration (time in hour/minute/seconds), and allso it is possible to click 'Calc bitrate' and it will display the source files bitrate, the video i tested the bitrate calc with have variable bitrate (VBR) and it display an pretty accurate estimate of the bitrate that ive compared the bitrate with an other program, ellse it say in the program it is mostly reliable with CBR (Constant Bitrate), it seem to be working fine with VBR allso!.. (You can find this function on the right side of 'Bitrate Kbit/s and it is an button 'C' to click on which wil load the Bitrate calculator).
The program is avalible for download here on VideoHelp, it is allso required to aqquire FFMpeg for this program to function which can be found here (FFMpeg) aswell in many different version.Last edited by Swedaniel; 17th Nov 2023 at 11:48.
-
1) Yes, I had thought about it, but sometimes the size of the video is not there.
2) I'm referring to the parameters returned by Mediainfo. Which of these are definitely present and come back with the mediainfo command? Of course, those that allow me to calculate the bitrate. -
Assuming you know the filesize and running time, see here for an example
https://forum.videohelp.com/threads/397023-why-does-file-size-increase-so-much-when-tr...rn#post2581789 -
but sometimes the size of the video is not there.
Which of these are definitely present and come back with the mediainfo command? -
-
-
Why don't you try?
-
-
Maybe with an example
Code:mediainfo "video.mkv" -f General Count : 350 Count of stream of this kind : 1 Kind of stream : General Kind of stream : General Stream identifier : 0 Unique ID : 219964994478558908138968093440097951937 Unique ID : 219964994478558908138968093440097951937 (0xA57BB78A94A5B53CFFC7FE173FD4A0C1) Count of video streams : 1 Count of audio streams : 1 Video_Format_List : AVC Video_Format_WithHint_List : AVC Codecs Video : AVC Audio_Format_List : AAC LC Audio_Format_WithHint_List : AAC LC Audio codecs : AAC LC Audio_Channels_Total : 2 Complete name : ... File name extension : ... File name : ... File extension : mkv Format : Matroska Format : Matroska Format/Url : https://matroska.org/downloads/windows.html Format/Extensions usually used : mkv mk3d mka mks Commercial name : Matroska Format version : Version 4 File size : 998829184 File size : 953 MiB File size : 953 MiB File size : 953 MiB File size : 953 MiB File size : 952.6 MiB Duration : 6535675 Duration : 1 h 48 min Duration : 1 h 48 min 55 s 675 ms Duration : 1 h 48 min Duration : 01:48:55.675 Duration : 01:48:57;07 Duration : 01:48:55.675 (01:48:57;07) Overall bit rate : 1222618 Overall bit rate : 1 223 kb/s Frame rate : 23.976 Frame rate : 23.976 FPS Frame count : 156699 IsStreamable : Yes Encoded date : 2022-08-15 12:11:21 UTC File creation date : 2023-11-14 11:28:40.610 UTC File creation date (local) : 2023-11-14 12:28:40.610 File last modification date : 2023-10-12 20:38:32.773 UTC File last modification date (local) : 2023-10-12 21:38:32.773 Writing application : HandBrake 1.4.0 2021071800 Writing application : HandBrake 1.4.0 2021071800 Writing library : Lavf58.76.100 Writing library : Lavf58.76.100 ErrorDetectionType : Per level 1 Video Count : 381 Count of stream of this kind : 1 Kind of stream : Video Kind of stream : Video Stream identifier : 0 StreamOrder : 0 ID : 1 ID : 1 Unique ID : 14949589773543386298 Format : AVC Format : AVC Format/Info : Advanced Video Codec Format/Url : http://developers.videolan.org/x264.html Commercial name : AVC Format profile : Main@L3.1 Format settings : CABAC / 4 Ref Frames Format settings, CABAC : Yes Format settings, CABAC : Yes Format settings, Reference frames : 4 Format settings, Reference frames : 4 frames Internet media type : video/H264 Codec ID : V_MPEG4/ISO/AVC Codec ID/Url : http://ffdshow-tryout.sourceforge.net/ Duration : 6535654.000000 Duration : 1 h 48 min Duration : 1 h 48 min 55 s 654 ms Duration : 1 h 48 min Duration : 01:48:55.654 Duration : 01:48:57;07 Duration : 01:48:55.654 (01:48:57;07) Width : 720 Width : 720 pixels Height : 304 Height : 304 pixels Sampled_Width : 720 Sampled_Height : 304 Pixel aspect ratio : 1.000 Display aspect ratio : 2.368 Display aspect ratio : 2.35:1 Frame rate mode : CFR Frame rate mode : Constant FrameRate_Mode_Original : VFR Frame rate : 23.976 Frame rate : 23.976 (24000/1001) FPS FrameRate_Num : 24000 FrameRate_Den : 1001 Frame count : 156699 Color space : YUV Chroma subsampling : 4:2:0 Chroma subsampling : 4:2:0 Bit depth : 8 Bit depth : 8 bits Scan type : Progressive Scan type : Progressive Delay : 21 Delay : 21 ms Delay : 21 ms Delay : 21 ms Delay : 00:00:00.021 Delay : 00:00:00;00 Delay : 00:00:00.021 (00:00:00;00) Delay, origin : Container Delay, origin : Container Writing library : x264 - core 163 r3059 b684ebe0 Writing library : x264 core 163 r3059 b684ebe0 Encoded_Library_Name : x264 Encoded_Library_Version : core 163 r3059 b684ebe0 Encoding settings : cabac=1 / ref=2 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=6 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=240 / keyint_min=24 / scenecut=40 / intra_refresh=0 / rc_lookahead=30 / rc=crf / mbtree=1 / crf=20.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=14000 / vbv_bufsize=14000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00 Default : Yes Default : Yes Forced : No Forced : No colour_description_present : Yes colour_description_present_Source : Container / Stream Color range : Limited colour_range_Source : Container / Stream Color primaries : BT.601 NTSC colour_primaries_Source : Container / Stream Transfer characteristics : BT.709 transfer_characteristics_Source : Container / Stream Matrix coefficients : BT.601 matrix_coefficients_Source : Container / Stream Audio Count : 285 Count of stream of this kind : 1 Kind of stream : Audio Kind of stream : Audio Stream identifier : 0 StreamOrder : 1 ID : 2 ID : 2 Unique ID : 7924595837062408030 Format : AAC Format : AAC LC Format/Info : Advanced Audio Codec Low Complexity Commercial name : AAC Format settings, SBR : No (Explicit) Format settings, SBR : No (Explicit) Format_AdditionalFeatures : LC Codec ID : A_AAC-2 Duration : 6535658.000000 Duration : 1 h 48 min Duration : 1 h 48 min 55 s 658 ms Duration : 1 h 48 min Duration : 01:48:55.658 Duration : 01:48:55.658 Channel(s) : 2 Channel(s) : 2 channels Channel positions : Front: L R Channel positions : 2/0/0 Channel layout : L R Samples per frame : 1024 Sampling rate : 48000 Sampling rate : 48.0 kHz Samples count : 313711584 Frame rate : 46.875 Frame rate : 46.875 FPS (1024 SPF) Compression mode : Lossy Compression mode : Lossy Delay : 0 Delay : 00:00:00.000 Delay : 00:00:00.000 Delay, origin : Container Delay, origin : Container Delay relative to video : -21 Delay relative to video : -21 ms Delay relative to video : -21 ms Delay relative to video : -21 ms Delay relative to video : -00:00:00.021 Delay relative to video : -00:00:00.021 Title : Stereo Default : Yes Default : Yes Forced : No Forced : No
-
You can extract elementary streams and calculate average bitrate based on this, containers always add some overhead so overall file size is bigger than sum of all elementary streams sizes - there is many reasons for this - for example packetization, metadata, container structure etc.
So whenever you need to know average video bitrate go for video elementary stream and calculate it by yourself.
Btw mediainfo frequently may provide inaccurate informations. -
if mediainfo does not provide some values, try ffprobe:
Code:@echo off SETLOCAL ENABLEDELAYEDEXPANSION set "ffprobe=F:\tools\ffprobe.exe" set "arg[0]=width" set "arg[1]=height" set "arg[2]=bit_rate" ffprobe -v quiet -select_streams v:0 -show_entries stream=%arg[0]%,%arg[1]%,%arg[2]% -of default=noprint_wrappers=1:nokey=1 "%~1" >video.txt set "index=0" for /f "delims=" %%x in (video.txt) do call :set_value %%x echo %width% echo %height% echo %bit_rate% set "arg[0]=bit_rate" ffprobe -v quiet -select_streams a:0 -show_entries stream=%arg[0]% -of default=noprint_wrappers=1:nokey=1 "%~1" >audio.txt set "index=0" for /f "delims=" %%x in (audio.txt) do call :set_value %%x echo %bit_rate% ENDLOCAL&echo press any key to exit&pause>nul&exit :set_value <value> set "!arg[%index%]!=%1" set /A index=%index%+1 goto :eof
-
-
Thanks to you, your solution is the one that should work. It's heavy in terms of pc work, but I don't see any other solution. Since I don't need a precise value, I'm undecided whether to extract the audio tracks, to do it first, and make the difference. I have to do some tests... Thank you, thank you, thank you.
-
If the video is an mkv and you don't care about modifying the file, you can use mkvpropedit to add all the missing statistics.
Code:mkvpropedit --add-track-statistics-tags video.mkv
-
-
You can use ffprobe to output each frame size in bits - all bits added together and divided by duration will give average video bitrate - this can be done semiautomatically.
You can use script from here https://forum.videohelp.com/threads/412226-Losslessly-Extract-Keyframes#post2711854
pkt_duration_time and pkt_size is most interesting for you - add all pkt_duration_time together and it will give duration ; add all pkt_size together and multiply by 8 so you get bits then divide this by calculated duration and you will get correct average bitrate.Last edited by pandy; 18th Nov 2023 at 16:15.
-
I knocked this up.
You need the following programs in the folder with the videos,
or in the System %path%
or provide the absolute path '\program path\program_name.exe' (which I did).
ffmpeg.exe
mkvpropedit.exe
MediaInfo.exe (CLI version)
Code:if exist list.txt del /q list.txt :: Create an MKV from all MP4 videos. for %%a in (*.mp4) do "C:\VidAud\ffmpeg64\bin\ffmpeg.exe" -i "%%a" -c copy -y "%%~na.mkv" :: Process each MKV video - Output to list.txt for %%a in (*.mkv) do call :process "%%a" goto :end :process :: Complete all tags in the MKV videos "C:\Program Files\MKVToolNix\mkvpropedit.exe" --add-track-statistics-tags "%~1" ::Run MediaInfo to get the required statistics "C:\VidAud\MediaInfoCLI\MediaInfo.exe" "--Output=General;File Name: %%FileNameExtension%%\r\nDuration: %%Duration/String3%%\r\nSize: %%FileSize/String%%" "%~1" >> list.txt "C:\VidAud\MediaInfoCLI\MediaInfo.exe" "--Output=Video;V_bitrate: %%BitRate%%" "%~1" >> list.txt "C:\VidAud\MediaInfoCLI\MediaInfo.exe" "--Output=Audio;A_bitrate: %%BitRate%%" "%~1" >> list.txt echo. >> list.txt goto :eof :end start /i list.txt pause
Cheers.Last edited by pcspeak; 19th Nov 2023 at 03:17. Reason: Spelling.
-
-
-
-
Thanks for testing it, I will note it for my programs. Unfortunately I can't think of any other method that someone else hasn't already mentioned. But if you are going to convert mp4 to mkv I think it is better to use mkvmerge instead of ffmpeg, this way you don't need to use mkvpropedit, because mkvmerge already adds the bitrate directly.
Code:mkvmerge -o output.mkv input.mp4
-
I have a problem, the conversions with mkvmerge and ffmpeg come with different sizes from each other and with the original. Original 587MiB, mkmerge 548 MiB, ffmpeg 568 MiB
Code:general_FileNameExtension:aoa.mp4 general_Duration/String3:00:03:09.211 general_FileSize/String:587 MiB video_bitrate: video_Duration:189155 video_Bits-(Pixel*Frame): mkvmerge v80.0 ('Roundabout') 64-bit 'aoa.mp4': Using the demultiplexer for the format 'MPEG transport stream'. 'aoa.mp4' track 0: Using the output module for the format 'HEVC/H.265 (unframed)'. 'aoa.mp4' track 1: Using the output module for the format 'AAC'. The file 'aoa_merge.mkv' has been opened for writing. 'aoa.mp4' track 0: Extracted the aspect ratio information from the video bitstream and set the display dimensions to 3840/2160. The cue entries (the index) are being written... Multiplexing took 15 seconds. general_FileNameExtension:aoa_merge.mkv general_Duration/String3:00:03:09.162 general_FileSize/String:548 MiB video_bitrate:24086816 video_Duration:189156.000000 video_Bits-(Pixel*Frame):0.048 ffmpeg version 6.1-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers built with gcc 12.2.0 (Rev10, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 58. 29.100 / 58. 29.100 libavcodec 60. 31.102 / 60. 31.102 libavformat 60. 16.100 / 60. 16.100 libavdevice 60. 3.100 / 60. 3.100 libavfilter 9. 12.100 / 9. 12.100 libswscale 7. 5.100 / 7. 5.100 libswresample 4. 12.100 / 4. 12.100 libpostproc 57. 3.100 / 57. 3.100 Input #0, mpegts, from 'aoa.mp4': Duration: 00:03:09.14, start: 1.080722, bitrate: 26034 kb/s Program 1 Stream #0:0[0x101]: Video: hevc (Main) ([36][0][0][0] / 0x0024), yuv420p(tv), 3840x2160 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn Stream #0:1[0x102](und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 192 kb/s Output #0, matroska, to 'aoa.mkv': Metadata: encoder : Lavf60.16.100 Stream #0:0: Video: hevc (Main) ([36][0][0][0] / 0x0024), yuv420p(tv), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 59.94 tbr, 1k tbn Stream #0:1(und): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 192 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help [out#0/matroska @ 000001a5d3d86080] video:577256kB audio:4433kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.019352% size= 581801kB time=00:03:09.12 bitrate=25201.5kbits/s speed=18.8x The file is being analyzed. The file is read in order to create track statistics. Progress: 100% The changes are written to the file. Done. general_FileNameExtension:aoa.mkv general_Duration/String3:00:03:09.156 general_FileSize/String:568 MiB video_bitrate:25000499 video_Duration:189155.683333 video_Bits-(Pixel*Frame):0.050
code used:
Code:@echo off setlocal enabledelayedexpansion echo( call :mediainfo General "FileNameExtension Duration/String3 FileSize/String" "aoa.mp4" echo general_FileNameExtension:%general_FileNameExtension% echo general_Duration/String3:%general_Duration/String3% echo general_FileSize/String:%general_FileSize/String% echo( call :mediainfo Video "BitRate Duration Bits-(Pixel*Frame)" "aoa.mp4" echo video_bitrate:%video_bitrate% echo video_Duration:%video_Duration% echo video_Bits-(Pixel*Frame):%video_Bits-(Pixel*Frame)% echo( mkvmerge -o aoa_merge.mkv aoa.mp4 echo( call :mediainfo General "FileNameExtension Duration/String3 FileSize/String" "aoa_merge.mkv" echo general_FileNameExtension:%general_FileNameExtension% echo general_Duration/String3:%general_Duration/String3% echo general_FileSize/String:%general_FileSize/String% echo( call :mediainfo Video "BitRate Duration Bits-(Pixel*Frame)" "aoa_merge.mkv" echo video_bitrate:%video_bitrate% echo video_Duration:%video_Duration% echo video_Bits-(Pixel*Frame):%video_Bits-(Pixel*Frame)% echo( ffmpeg.exe -i "aoa.mp4" -c copy -y "aoa.mkv" mkvpropedit.exe --add-track-statistics-tags "aoa.mkv" echo( call :mediainfo General "FileNameExtension Duration/String3 FileSize/String" "aoa.mkv" echo general_FileNameExtension:%general_FileNameExtension% echo general_Duration/String3:%general_Duration/String3% echo general_FileSize/String:%general_FileSize/String% echo( call :mediainfo Video "BitRate Duration Bits-(Pixel*Frame)" "aoa.mkv" echo video_bitrate:%video_bitrate% echo video_Duration:%video_Duration% echo video_Bits-(Pixel*Frame):%video_Bits-(Pixel*Frame)% pause goto :eof ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :mediainfo "section" "parameters" "video" set "section=%~1" set "parameters=%~2" set "video=%~3" set "cmdline=mediainfo "--inform=!section!;" set "i=1" :loop1 FOR /F "tokens=1* delims= " %%G IN ("!parameters!") DO ( set "v[!i!]=!section!_%%G" set "cmdline=!cmdline!%%%%G%%\r\n" set "parameters=%%H" ) if defined parameters set /A i+=1 & goto loop1 set "cmdline=!cmdline:~0,-4!"" set "i=1" for /f "tokens=1,* delims=]" %%f in ('%cmdline% "!Video!" ^| find /N /V ""') do ( set "P=%%g" for %%G in (!i!) do ( set "!v[%%G]!=" if defined P set "!v[%%G]!=%%g" ) set /A i+=1 ) goto:eof :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
EDIT: Going to look with the Mediainfo GUI I found out that the files that looked like MP4 actually had TS format. Could this be what created that size difference?Last edited by einstein1969; 20th Nov 2023 at 03:01.
Similar Threads
-
10-bit video and lower bitrate vs 8-bit video and higher bitrate
By Federico9827 in forum Newbie / General discussionsReplies: 5Last Post: 11th Oct 2022, 07:16 -
batch that calculate the total duration for a series of video file
By marcorocchini in forum Newbie / General discussionsReplies: 0Last Post: 15th Mar 2022, 16:25 -
how to do average bitrate h264 encoding with ffmpeg?
By Anonymous543 in forum Newbie / General discussionsReplies: 38Last Post: 15th Feb 2022, 07:02 -
Calculate width and height of rendered subtitles
By albfullsoft in forum SubtitleReplies: 0Last Post: 10th May 2020, 20:12 -
How to determine max min and average bitrates for video rendering?
By Bencuri in forum Video ConversionReplies: 4Last Post: 16th Oct 2019, 12:02