Videos: Improve avc bitrate bitrate estimate #703

This commit is contained in:
Michael Mayer 2021-02-14 19:23:52 +01:00
parent 7d52efc39d
commit 6ae0002930
2 changed files with 5 additions and 5 deletions

View file

@ -309,7 +309,7 @@ func (c *Convert) AvcBitrate(f *MediaFile) string {
return "8M"
}
bitrate := int(math.Round(float64(f.Width()*f.Height()*15) / 1000000))
bitrate := int(math.Ceil(float64(f.Width()*f.Height()*15) / 1000000))
if bitrate <= 0 {
return "8M"

View file

@ -249,7 +249,7 @@ func TestConvert_AvcBitrate(t *testing.T) {
conf := config.TestConfig()
convert := NewConvert(conf)
t.Run("8M", func(t *testing.T) {
t.Run("1M", func(t *testing.T) {
fileName := filepath.Join(conf.ExamplesPath(), "gopher-video.mp4")
assert.Truef(t, fs.FileExists(fileName), "input file does not exist: %s", fileName)
@ -260,7 +260,7 @@ func TestConvert_AvcBitrate(t *testing.T) {
t.Fatal(err)
}
assert.Equal(t, "8M", convert.AvcBitrate(mf))
assert.Equal(t, "1M", convert.AvcBitrate(mf))
})
t.Run("20M", func(t *testing.T) {
@ -280,7 +280,7 @@ func TestConvert_AvcBitrate(t *testing.T) {
assert.Equal(t, "20M", convert.AvcBitrate(mf))
})
t.Run("31M", func(t *testing.T) {
t.Run("32M", func(t *testing.T) {
fileName := filepath.Join(conf.ExamplesPath(), "gopher-video.mp4")
assert.Truef(t, fs.FileExists(fileName), "input file does not exist: %s", fileName)
@ -294,7 +294,7 @@ func TestConvert_AvcBitrate(t *testing.T) {
mf.width = 1920
mf.height = 1080
assert.Equal(t, "31M", convert.AvcBitrate(mf))
assert.Equal(t, "32M", convert.AvcBitrate(mf))
})
t.Run("133M", func(t *testing.T) {