savonet / liquidsoap

Liquidsoap is a statically typed scripting general-purpose language with dedicated operators and backend for all thing media, streaming, file generation, automation, HTTP backend and more.
http://liquidsoap.info
GNU General Public License v2.0
1.39k stars 126 forks source link

`output.file` with some encoders produces paddings #2841

Open vitoyucepi opened 1 year ago

vitoyucepi commented 1 year ago

Describe the bug Output to file with encoders %mp3, %shine and $ffmpeg(mp3) produces padding at the start and the end.

To Reproduce

def o(codec, file)
    output.file(
        reopen_delay=2.0,
        reopen_when={true},
        codec,
        file,
        sine(amplitude=0.5, 10000.)
    )
end

p='/tmp/'
s='%H_%M_%S'
o(%shine(samplerate=48000, bitrate=320), '#{p}shine_#{s}.mp3')
o(%mp3(samplerate=48000, bitrate=320), '#{p}mp3_#{s}.mp3')
o(%opus(samplerate=48000, bitrate=320), '#{p}opus_#{s}.opus')
o(%vorbis.cbr(samplerate=48000, bitrate=320), '#{p}vorbis_#{s}.ogg')
o(%ffmpeg(format="mp3", %audio(codec="libmp3lame", samplerate=48000, b="320k")), '#{p}ffmpeg_mp3_#{s}.mp3')
o(%ffmpeg(format="opus", %audio(codec="libopus", samplerate=48000, b="320k")), '#{p}ffmpeg_opus_#{s}.opus')
o(%ffmpeg(format="ogg", %audio(codec="libvorbis", samplerate=48000, b="320k")), '#{p}ffmpeg_vorbis_#{s}.ogg')

Screenshots from audacity

Expected behavior %mp3, %shine and $ffmpeg(mp3) encoders should produce files without paddings.

Version details

Install method Deb package from liquidsoap releases at github

Common issues https://github.com/savonet/liquidsoap/discussions/2838#discussioncomment-4645835

2726

Additional I've found some oddities in %vorbis encoder.

vitoyucepi commented 4 months ago

Paddings in %mp3 and %shine still exist in 2.2.4-1. It seems that some encoders can loose/duplicate data when liquidsoap reopens files.

toots commented 4 months ago

The missing data was most likely addressed with the fix for https://github.com/savonet/liquidsoap/issues/3675

vitoyucepi commented 4 months ago

I'm not sure if this is a bug or intended behavior. Discontinuity in mp3 file encoded with ffmpeg+mp3 Distortion close-up in mp3 file encoded with ffmpeg+mp3 Discontinuity in opus file encoded with ffmpeg+opus