Package: ffmpeg
Version: 7:5.1.6-0+deb12u1
Severity: normal
X-Debbugs-Cc: krzpyrk...@gmail.com

Dear Maintainer,

-f pulse cuts last 2-3 seconds of audio when stopped by hitting "q".

How to reproduce: I observed the behavior by recording screen with
x11grab for video and pulse for audio. Last 2 seconds of audio are
missing in every file. Start playing music in the background (with mpv,
or whatever program), then start recording (substitute the
alsa_output...monitor for your device name, it can be obtained with
"pactl list short sources"):

$ ffmpeg -y -f x11grab -i "$DISPLAY" -f pulse -i 
alsa_output.pci-0000_05_00.6.analog-stereo.monitor /tmp/recording.mp4
The video will be fully recorded, the audio will stop 2 seconds before
the end, even though it was still being played when pressing "q".

I decided to split video and audio with -map to separate files to
measure the stream length, and indeed audio is shorter:

$ ffmpeg -y -f x11grab -i "$DISPLAY" -f pulse -i 
alsa_output.pci-0000_05_00.6.analog-stereo.monitor -map 0:v /tmp/foo.mp4 -map 
1:a /tmp/foo_audio.mp4
$ ffprobe /tmp/foo_audio.mp4 |& grep Duration
  Duration: 00:00:02.08, start: 0.000000, bitrate: 135 kb/s
$ ffprobe /tmp/foo.mp4 |& grep Duration
  Duration: 00:00:04.37, start: 0.000000, bitrate: 912 kb/s

It's not an issue with x11grab. Passing an arbitrary file in its place
(-i something.mp4) produces the same effect with the audio being 2-3
seconds shorter.

The audio is not cut when total recording length is specified
beforehand, with -t 15. It happens only when "q" is hit.

I confirmed the problem exists on ffmpeg versions 5.1, 7.1 (Debian
stable/sid), x86 and arm64. There's no difference between the pulseaudio
or pipewire-pulse as the backend. It seems to me it is a Debian-specific
problem - I built ffmpeg 6.0, 7.0 and 7.1 locally, from the ffmpeg
release tarballs, without dpkg, and the length of audio is the same as
video.

Another Debian user reproduced the problem as well.

Regards,
Krzysztof

Reply via email to