VideoHelp Forum




+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 36
  1. 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?
    Quote Quote  
  2. Captures & Restoration lollo's Avatar
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    1) what about taking your calculator and do size / duration?

    2) what parameters are you referring to?
    Quote Quote  
  3. Banned
    Join Date
    Nov 2023
    Location
    Europe
    Search Comp PM
    Originally Posted by einstein1969 View Post
    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?
    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.
    Quote Quote  
  4. Originally Posted by lollo View Post
    1) what about taking your calculator and do size / duration?

    2) what parameters are you referring to?
    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.
    Quote Quote  
  5. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    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
    Quote Quote  
  6. Captures & Restoration lollo's Avatar
    Join Date
    Jul 2018
    Location
    Italy
    Search Comp PM
    but sometimes the size of the video is not there.
    It is always there, mouse right click on the video file and select properties

    Which of these are definitely present and come back with the mediainfo command?
    Why don't you try?
    Quote Quote  
  7. Originally Posted by Swedaniel View Post
    Originally Posted by einstein1969 View Post
    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?
    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.
    sorry I forgot to mention that I'm using mediainfo CLI. I need to create a cmd batch.
    Quote Quote  
  8. Originally Posted by lollo View Post
    but sometimes the size of the video is not there.
    It is always there, mouse right click on the video file and select properties

    Which of these are definitely present and come back with the mediainfo command?
    Why don't you try?
    I need to do these calculations in a batch and I'm using mediainfo CLI. Let me explain, so you understand. I need to calculate the bitrate of the video alone. If I query the file, in the Video section sometimes both the bitrate and the Video size are missing.
    Quote Quote  
  9. Why don't you try?
    I tried but didn't come to a conclusion. I thought someone here knew about fixed parameters. I'm not very experienced.
    Quote Quote  
  10. Originally Posted by davexnet View Post
    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
    Thanks for the formula, I had already thought about it only that sometimes there is not the size of either the video part or the audio part (where there can be even more tracks)
    Quote Quote  
  11. 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
    This is just an example, MediaInfo does not come out with the video bitrate, nor with the video dimension, nor with the audio dimension. Sometimes the overall bitrate would be sufficient, but if the audio tracks are many and consistent, it doesn't match at all.
    Quote Quote  
  12. 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.
    Quote Quote  
  13. 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
    Quote Quote  
  14. Originally Posted by _Al_ View Post
    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
    Thank you for the script, you saved me so much time.

    Unfortunately my videos are strange. You can't do that with ffprobe either.
    Quote Quote  
  15. Originally Posted by pandy View Post
    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.
    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.
    Quote Quote  
  16. Member
    Join Date
    Jul 2022
    Location
    Spain
    Search Comp PM
    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
    The information should then be available in mediainfo.
    Quote Quote  
  17. I did some tests. ffprobe is faster than mediainfo although in some cases mediainfo returns more information and ffprobe fails.
    Quote Quote  
  18. Originally Posted by vongooB9 View Post
    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
    The information should then be available in mediainfo.
    I've tried it and it looks phenomenal. I just need to find a way to turn mp4s into mkvs painlessly. Thank you very much too.
    Quote Quote  
  19. Originally Posted by einstein1969 View Post
    Originally Posted by pandy View Post
    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.
    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.
    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.
    Quote Quote  
  20. I'm a Super Moderator johns0's Avatar
    Join Date
    Jun 2002
    Location
    canada
    Search Comp PM
    Use mkvmerge to turn mp4 to mkv,does this without re-encoding.
    I think,therefore i am a hamster.
    Quote Quote  
  21. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    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
    It will need a tweak or two to give you what you want.
    Cheers.
    Last edited by pcspeak; 19th Nov 2023 at 03:17. Reason: Spelling.
    Quote Quote  
  22. Member
    Join Date
    Jul 2022
    Location
    Spain
    Search Comp PM
    I'm not 100% sure, but I think you don't need to convert mp4 to mkv, because I think all mp4s show that information in mediainfo. Or at least I didn't find any that didn't have it. But I'm not sure, maybe I'm wrong.
    Quote Quote  
  23. Originally Posted by pandy View Post
    Originally Posted by einstein1969 View Post
    Originally Posted by pandy View Post
    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.
    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.
    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.
    Thanks for the report, I did a test and unfortunately, although it is possible to make it completely automatic, the execution time was very long. I'm considering the best method.
    Quote Quote  
  24. Originally Posted by einstein1969 View Post
    Thanks for the report, I did a test and unfortunately, although it is possible to make it completely automatic, the execution time was very long. I'm considering the best method.
    True - ffprobe strangely perform such analysis slowly but at least it is reliable and free way to get such information.
    Quote Quote  
  25. Originally Posted by johns0 View Post
    Use mkvmerge to turn mp4 to mkv,does this without re-encoding.
    Thanks, it was also suggested to me to use ffmpeg for conversion. Do you know which is the best in terms of reliability and speed?
    Quote Quote  
  26. Originally Posted by pcspeak View Post
    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
    It will need a tweak or two to give you what you want.
    Cheers.
    Thanks for the script. I'm adapting it to mine. Very valuable
    Quote Quote  
  27. Originally Posted by vongooB9 View Post
    I'm not 100% sure, but I think you don't need to convert mp4 to mkv, because I think all mp4s show that information in mediainfo. Or at least I didn't find any that didn't have it. But I'm not sure, maybe I'm wrong.
    thanks , i will check and report
    Quote Quote  
  28. Originally Posted by einstein1969 View Post
    Originally Posted by vongooB9 View Post
    I'm not 100% sure, but I think you don't need to convert mp4 to mkv, because I think all mp4s show that information in mediainfo. Or at least I didn't find any that didn't have it. But I'm not sure, maybe I'm wrong.
    thanks , i will check and report
    unfortunately, I found mp4 files where the bitrate was missing.
    Quote Quote  
  29. Member
    Join Date
    Jul 2022
    Location
    Spain
    Search Comp PM
    Originally Posted by einstein1969 View Post
    unfortunately, I found mp4 files where the bitrate was missing.
    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
    Quote Quote  
  30. 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
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    Is this normal?

    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.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!