posts: automatically tag videos with sound.
Automatically add the `sound` tag if the post has sound. Remove the tag if the post doesn't have sound. A video is considered to have sound if its peak loudness is greater than -70 dB. The current quietest post on Danbooru has a peak loudness of -62 dB (post #3470668), but it's possible to have audible sound at -80 dB or possibly even lower. It's hard to draw a clear line between "silent" and "barely audible".
This commit is contained in:
@@ -124,6 +124,11 @@ class ExifTool
|
||||
metadata.has_key?("PNG:Dream")
|
||||
end
|
||||
|
||||
# True if the video has audible sound. False if the video doesn't have an audio track, or the audio track is inaudible.
|
||||
def has_sound?
|
||||
metadata["FFmpeg:AudioPeakLoudness"].to_f >= 0.0003 # -70 dB
|
||||
end
|
||||
|
||||
def width
|
||||
metadata.find { |name, value| name.match?(/\A(File|PNG|GIF|RIFF|Flash|Track\d+):ImageWidth\z/) }&.second
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user