Open jimmy-1000 opened 1 year ago
+1.
please add an average bitrate property. When playing a media file: average bitrate = filesize / duration.
Please some help here (input.conf)
F5 no-osd cycle-values osd-msg1 "" "${file-size}/${duration}"
Unless an avg-bitrate property is added to mpv, you would need an external script to perform the simple math operation: avg-bitrate_kbps = 0.008 * file-size_bytes / duration_s
The (keyframe based) video-bitrate
property isn't always very useful for two reasons:
Video file average_bitrate calculation using filesize_Bytes/duration_s
avg-bitrate (in kilobits per second, kb/s) = 8/1000.0 * file-size_bytes / duration_s
for local video/audio files seems to match mediainfo > Overall bit rate
.
Customization: this script can operate every time a new file is loaded or (by default) on demand via a keybinding.
mpv script: avg-bitrate.js v0.1 by butterw https://github.com/butterw/bShaders/blob/c33139cf0e7bb3b01e2a2b5df02beff06b0af4fa/mpv/settings/scripts/avg-bitrate.js ! images have duration: 0 ! video streamed with yt-dlp have filesize: NaN use --osd-msg1=" ${video-bitrate}" instead.
It works good, thanks a lot !! 👌
The correct link (v0.11) is: https://github.com/butterw/bShaders/blob/master/mpv/settings/scripts/avg-bitrate.js The script shows that the calculation works and provides a useful result for local files. So I think it would be useful to add an avg-bitrate property to mpv.
Script calculation vs built-in property ? I'm not sure about the script limitations in mpv, but I haven't seen anything suggesting a script can provide a return value usable directly in input.conf.
If the avg-bitrate was written to any existing unused String property (let's say: osd-msg2) when the video is loaded, you could use this property in input.conf removing the need to customize the script for a specific usage.
F5 no-osd cycle-values osd-msg1 osd-msg2 ""
While this hack works, it would be quite confusing when reading input.conf.
....
I agree, this "average bitrate" of video should be part of the mpv core. I have a question about osd-msg:
F1 no-osd cycle-values osd-msg1 "" "File: ${filename} \n Size: ${file-size} \n script-message avg-bitrate"
This doesn't work. Is there a way to call your script from this line with osd-msg using input.conf?
Instead of using osd-msg2 as suggested in my previous post, you can use a user-data property. I'm testing on Windows, with mpv 0.35.0-542-gcab54488 (Jul 16 2023). I think you need a fairly recent version of mpv for this feature.
You just need to modify the script so that the the property "user-data/avg-bitrate" is set each time a new file is loaded. mp.set_property("user-data/avg-bitrate", bitrate_kbps +" kb/s");
input.conf: F1 no-osd cycle-values osd-msg1 "" "File: ${filename} \n Size: ${file-size} \n ${user-data/avg-bitrate}"
EDIT: however this doesn't work exactly the way you want, because you need to cycle F1 for the OSD to update (this is also the case for the properties filename, file-size, etc). You don't have this problem with a permanent display --osd-msg1="File: ${filename} \n Size: ${file-size} \n ${user-data/avg-bitrate}".
Sadly I get "(error)". I use mpv 0.36
(error) means user-data/avg-bitrate has not been set.
run mpv from terminal for testing. Ensure you only have one version of the script in the correct scripts directory (ie move out any old versions to avoid conflicts).
Could you maybe clarify what your end goal is: is it having a simplified stats display that you can toggle on/off ?
Unrelated to the avg-bitrate property, the way you were trying to set your keybinding doesn't work (because the osd doesn't auto-update when a new file is loaded). IMO this is how you can do it:
https://forum.doom9.org/showthread.php?p=1990436#post1990436 how to toggle a custom osd with a keybinding (the osd is permanently visible until disabled, it updates when a new file is loaded): --osd-msg2="${filename}\n${file-size}" input.conf: O no-osd cycle-values osd-level 2 1
Maybe I did an incorrect modification, can you verified? (I added txt extension to upload here)
v0.20: https://github.com/butterw/bShaders/blob/master/mpv/settings/scripts/avg-bitrate.js this version of avg-bitrate.js uses the new user-data feature (requires mpv v0.36).
Basic use: display avg-bitrate on osd for 2 seconds when you press key a: input.conf: a no-osd show-text "${user-data/avg-bitrate}" 2000
To toggle a custom osd with a keybinding (the osd is permanently visible until disabled, it updates when a new file is loaded): mpv.conf or mpv cli: --osd-msg2="${filename}\n${file-size}\n${user-data/avg-bitrate}" input.conf: O no-osd cycle-values osd-level 2 1
v0.20: https://github.com/butterw/bShaders/blob/master/mpv/settings/scripts/avg-bitrate.js this version of avg-bitrate.js uses the new user-data feature (requires mpv v0.36). ...
It works!! 👏 Thanks a lot for your help 👌
v0.20: https://github.com/butterw/bShaders/blob/master/mpv/settings/scripts/avg-bitrate.js 此版本的 avg-bitrate.js 使用新的用户数据功能(需要 mpv v0.36)。
基本用途: 当您按下 a 键时,在 osd 上显示平均比特率 2 秒: input.conf:无 osd 显示文本“${user-data/avg-bitrate}”2000
要使用键绑定切换自定义 osd(osd 永久可见,直到禁用,它会在加载新文件时更新): mpv.conf 或 mpv cli: --osd-msg2="${文件名}\n${文件大小}\n${用户数据/平均比特率}" input.conf:O 无 osd 周期值 osd 级别 2 1
Hi, how to display MB instead of KB?
v0.20: https://github.com/butterw/bShaders/blob/master/mpv/settings/scripts/avg-bitrate.js 此版本的 avg-bitrate.js 使用新的用户数据功能(需要 mpv v0.36)。 基本用途: 当您按下 a 键时,在 osd 上显示平均比特率 2 秒: input.conf:无 osd 显示文本“${user-data/avg-bitrate}”2000 要使用键绑定切换自定义 osd(osd 永久可见,直到禁用,它会在加载新文件时更新): mpv.conf 或 mpv cli: --osd-msg2="${文件名}\n${文件大小}\n${用户数据/平均比特率}" input.conf:O 无 osd 周期值 osd 级别 2 1
Hi, how to display MB instead of KB?
I prefer Kbps because most players showed it to me that way, so now it's familiar data to me.
v0.20: https://github.com/butterw/bShaders/blob/master/mpv/settings/scripts/avg-bitrate.js 此版本的 avg-bitrate.js 使用新的用户数据功能(需要 mpv v0.36)。 基本用途: 当您按下 a 键时,在 osd 上显示平均比特率 2 秒: input.conf:无 osd 显示文本“${user-data/avg-bitrate}”2000 要使用键绑定切换自定义 osd(osd 永久可见,直到禁用,它会在加载新文件时更新): mpv.conf 或 mpv cli: --osd-msg2="${文件名}\n${文件大小}\n${用户数据/平均比特率}" input.conf:O 无 osd 周期值 osd 级别 2 1
你好,请问如何显示MB而不是KB?
我更喜欢 Kbps,因为大多数玩家都以这种方式向我展示它,所以现在它对我来说是熟悉的数据。
Where can I modify it to display MB? If it is not too much trouble, I hope you can answer it.
Please add a feature to obtain the average bitrate of the videos like other players and applications do. For example with MPC-HC, Avidemux and Freemake Video Converter all the three give me exactly the same value of the video track bitrate, it never changes.