You are not logged in.

#1 2012-08-14 17:43:23

xlatedst
Member
Registered: 2010-12-31
Posts: 6

PulseAudio & ffmpeg streaming

Hi,

I've spent all day looking for a solution to this but to no avail. I'm trying to use ffmpeg to record my screen and sound from Pulseaudio. PA is configured (via null sinks) to take audio from output capture and the USB mic, and that bit works, but the recorded result is full of audible glitches, slowing down (speed and pitch) and crackles. ffmpeg seems to drop frames.

I tried reverting to Pulseaudio's interrupt-based scheduling with the below in /etc/pulse/default.pa:

load-module module-udev-detect tsched=0

The sound then seems to be clearer but a new problem presents itself: I'm trying to stream games via Wine, and Wine sounds only works through Pulseaudio with timer-based scheduling, so I have to find another solution to the distortion.

I read somewhere this is a problem with the ALSA driver. The sound card is an onboard VT1708S. CPU is AMD Phenom II X6 2.80GHz and it has 8GB DDR3 so I doubt it's just too slow.

Any ideas? I could just boot into Windows and stream from that without any issues but I'd like to demonstrate the viability of Linux-based gaming.

Thank you.

$ ffmpeg -loglevel verbose -f x11grab -s "1920x1080" -i :0.0 -aq 128k \
 -f alsa -ac 2 -i pulse -vcodec libx264 -crf 30 \
 -acodec libmp3lame -ar 44100 -threads 2 \
 -f flv out.mkv

ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
  built on Jun  9 2012 13:50:13 with gcc 4.7.0 20120505 (prerelease)
  configuration: --prefix=/usr --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-libgsm --enable-libspeex --enable-postproc --enable-shared --enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libschroedinger --enable-libopenjpeg --enable-librtmp --enable-libpulse --enable-libv4l2 --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-debug --disable-static
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[x11grab @ 0x1568220] device: :0.0 -> display: :0.0 x: 0 y: 0 width: 1920 height: 1080
[x11grab @ 0x1568220] shared memory extension found
[x11grab @ 0x1568220] Estimating duration from bitrate, this may be inaccurate
Input #0, x11grab, from ':0.0':
  Duration: N/A, start: 1344968991.991578, bitrate: 1988667 kb/s
    Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1080, 1988667 kb/s, 29.97 tbr, 1000k tbn, 29.97 tbc
[alsa @ 0x157b8a0] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, alsa, from 'pulse':
  Duration: N/A, start: 1344968992.026006, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
File 'out.mkv' already exists. Overwrite ? [y/N] y
w:1920 h:1080 pixfmt:bgr0 tb:1/1000000 sar:0/1 sws_param:flags=2
[buffersink @ 0x1565280] No opaque field provided
[format @ 0x1566ee0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'format'
[scale @ 0x1565440] w:1920 h:1080 fmt:bgr0 sar:0/1 -> w:1920 h:1080 fmt:yuv420p sar:0/1 flags:0x4
[abuffer @ 0x15f2580] tb:1/1000000 samplefmt:s16 samplerate: 48000 ch layout:0x3
[aformat @ 0x163f580] auto-inserting filter 'auto-inserted resampler 0' between the filter 'src' and the filter 'aformat'
[aresample @ 0x161f5c0] chl:stereo fmt:s16 r:48000Hz -> chl:stereo fmt:s16 r:44100Hz
[libx264 @ 0x1563b40] using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT
[libx264 @ 0x1563b40] profile High, level 4.0
[libx264 @ 0x1563b40] 264 - core 124 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=30.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'out.mkv':
  Metadata:
    encoder         : Lavf54.6.100
    Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 1920x1080, q=-1--1, 1k tbn, 29.97 tbc
    Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx264)
  Stream #1:0 -> #0:1 (pcm_s16le -> libmp3lame)
Press [q] to stop, [?] for help
*** drop!16 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s    
*** drop!32 fps= 30 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s dup=0 drop=1    
DTS 27417033, next:27417119 st:0 invalid dropping0:00:25.49 bitrate= 428.3kbits/s dup=0 drop=2    
PTS 27417033, next:27417119 invalid dropping st:0
DTS 27579850, next:27579970 st:0 invalid dropping
PTS 27579850, next:27579970 invalid dropping st:0
DTS 33899007, next:33899075 st:0 invalid dropping0:00:31.23 bitrate= 382.2kbits/s dup=0 drop=2    
PTS 33899007, next:33899075 invalid dropping st:0
DTS 44107651, next:44107722 st:0 invalid dropping0:00:41.50 bitrate= 366.4kbits/s dup=0 drop=2    
PTS 44107651, next:44107722 invalid dropping st:0
DTS 49376019, next:49376220 st:0 invalid dropping0:00:47.44 bitrate= 344.8kbits/s dup=0 drop=2    
PTS 49376019, next:49376220 invalid dropping st:0
DTS 64479227, next:64479259 st:0 invalid dropping0:01:00.62 bitrate= 396.8kbits/s dup=0 drop=2    
PTS 64479227, next:64479259 invalid dropping st:0
DTS 78840186, next:78840216 st:0 invalid dropping0:01:15.17 bitrate= 416.6kbits/s dup=0 drop=2    
PTS 78840186, next:78840216 invalid dropping st:0

Offline

#2 2012-08-15 11:16:21

xlatedst
Member
Registered: 2010-12-31
Posts: 6

Re: PulseAudio & ffmpeg streaming

The recording seems to be fine for the first 20 seconds or so before it suddenly degrades. It sounds almost like a buffer underrun... hmm

The distortion occurs around about the time pulseaudio begins spitting out these messages:

$ tail -f /var/log/everything.log | fgrep "null-sink"
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.265|   7.606) [null-sink][modules/module-loopback.c:421 sink_input_pop_cb()] Could not peek into queue
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.265|   0.000) [null-sink][modules/module-loopback.c:479 sink_input_process_msg_cb()] Requesting rewind due to end of underrun.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.265|   0.000) [null-sink][modules/module-null-sink.c:144 process_rewind()] Requested to rewind 252 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.265|   0.000) [null-sink][pulsecore/sink.c:935 pa_sink_process_rewind()] Processing rewind...
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.265|   0.000) [null-sink][pulsecore/sink-input.c:985 pa_sink_input_process_rewind()] Have to rewind 208 bytes on render memblockq.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.265|   0.000) [null-sink][pulsecore/sink-input.c:985 pa_sink_input_process_rewind()] Have to rewind 208 bytes on render memblockq.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.265|   0.000) [null-sink][pulsecore/source.c:864 pa_source_process_rewind()] Processing rewind...
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.265|   0.000) [null-sink][modules/module-null-sink.c:161 process_rewind()] Rewound 208 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.265|   0.000) [null-sink][modules/module-loopback.c:479 sink_input_process_msg_cb()] Requesting rewind due to end of underrun.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.266|   0.000) [null-sink][modules/module-null-sink.c:144 process_rewind()] Requested to rewind 252 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.275|   0.009) [null-sink][modules/module-loopback.c:421 sink_input_pop_cb()] Could not peek into queue
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.275|   0.000) [null-sink][modules/module-loopback.c:479 sink_input_process_msg_cb()] Requesting rewind due to end of underrun.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.275|   0.000) [null-sink][modules/module-null-sink.c:144 process_rewind()] Requested to rewind 252 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.275|   0.000) [null-sink][pulsecore/sink.c:935 pa_sink_process_rewind()] Processing rewind...
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.275|   0.000) [null-sink][pulsecore/sink-input.c:985 pa_sink_input_process_rewind()] Have to rewind 196 bytes on render memblockq.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.276|   0.000) [null-sink][pulsecore/sink-input.c:985 pa_sink_input_process_rewind()] Have to rewind 196 bytes on render memblockq.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.276|   0.000) [null-sink][pulsecore/source.c:864 pa_source_process_rewind()] Processing rewind...
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.276|   0.000) [null-sink][modules/module-null-sink.c:161 process_rewind()] Rewound 196 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.276|   0.000) [null-sink][modules/module-loopback.c:479 sink_input_process_msg_cb()] Requesting rewind due to end of underrun.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.276|   0.000) [null-sink][modules/module-null-sink.c:144 process_rewind()] Requested to rewind 252 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.285|   0.009) [null-sink][modules/module-loopback.c:421 sink_input_pop_cb()] Could not peek into queue
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.286|   0.000) [null-sink][modules/module-loopback.c:479 sink_input_process_msg_cb()] Requesting rewind due to end of underrun.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.286|   0.000) [null-sink][modules/module-null-sink.c:144 process_rewind()] Requested to rewind 252 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.286|   0.000) [null-sink][pulsecore/sink.c:935 pa_sink_process_rewind()] Processing rewind...
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.286|   0.000) [null-sink][pulsecore/sink-input.c:985 pa_sink_input_process_rewind()] Have to rewind 180 bytes on render memblockq.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.286|   0.000) [null-sink][pulsecore/sink-input.c:985 pa_sink_input_process_rewind()] Have to rewind 180 bytes on render memblockq.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.286|   0.000) [null-sink][pulsecore/source.c:864 pa_source_process_rewind()] Processing rewind...
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.286|   0.000) [null-sink][modules/module-null-sink.c:161 process_rewind()] Rewound 180 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.286|   0.000) [null-sink][modules/module-loopback.c:479 sink_input_process_msg_cb()] Requesting rewind due to end of underrun.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.286|   0.000) [null-sink][modules/module-null-sink.c:144 process_rewind()] Requested to rewind 252 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.295|   0.009) [null-sink][modules/module-loopback.c:421 sink_input_pop_cb()] Could not peek into queue
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.296|   0.000) [null-sink][modules/module-loopback.c:479 sink_input_process_msg_cb()] Requesting rewind due to end of underrun.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.296|   0.000) [null-sink][modules/module-null-sink.c:144 process_rewind()] Requested to rewind 252 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.296|   0.000) [null-sink][pulsecore/sink.c:935 pa_sink_process_rewind()] Processing rewind...
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.296|   0.000) [null-sink][pulsecore/sink-input.c:985 pa_sink_input_process_rewind()] Have to rewind 120 bytes on render memblockq.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.296|   0.000) [null-sink][pulsecore/sink-input.c:985 pa_sink_input_process_rewind()] Have to rewind 120 bytes on render memblockq.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.296|   0.000) [null-sink][pulsecore/source.c:864 pa_source_process_rewind()] Processing rewind...
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.296|   0.000) [null-sink][modules/module-null-sink.c:161 process_rewind()] Rewound 120 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.305|   0.009) [null-sink][modules/module-loopback.c:421 sink_input_pop_cb()] Could not peek into queue
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.306|   0.000) [null-sink][modules/module-loopback.c:479 sink_input_process_msg_cb()] Requesting rewind due to end of underrun.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.306|   0.000) [null-sink][modules/module-null-sink.c:144 process_rewind()] Requested to rewind 252 bytes.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.306|   0.000) [null-sink][pulsecore/sink.c:935 pa_sink_process_rewind()] Processing rewind...
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.306|   0.000) [null-sink][pulsecore/sink-input.c:985 pa_sink_input_process_rewind()] Have to rewind 44 bytes on render memblockq.
Aug 15 13:36:58 pr0 pulseaudio[7168]: (  38.306|   0.000) [null-sink][pulsecore/sink-input.c:985 pa_sink_input_process_rewind()] Have to rewind 44 bytes on render memblockq.

alsa-sink messages:

Aug 15 13:37:15 pr0 pulseaudio[7168]: (  55.628|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)
Aug 15 13:37:15 pr0 pulseaudio[7168]: (  55.628|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)
Aug 15 13:37:15 pr0 pulseaudio[7168]: (  55.628|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)
Aug 15 13:37:15 pr0 pulseaudio[7168]: (  55.628|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)
Aug 15 13:37:15 pr0 pulseaudio[7168]: (  55.628|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)
Aug 15 13:37:15 pr0 pulseaudio[7168]: (  55.628|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)
Aug 15 13:37:15 pr0 pulseaudio[7168]: (  55.628|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)
Aug 15 13:37:15 pr0 pulseaudio[7168]: (  55.628|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)
Aug 15 13:37:15 pr0 pulseaudio[7168]: (  55.628|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)
Aug 15 13:37:15 pr0 pulseaudio[7168]: (  55.628|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)
Aug 15 13:37:15 pr0 pulseaudio[7168]: (  55.628|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)
Aug 15 13:37:21 pr0 pulseaudio[7168]: (  61.496|   0.227) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:21 pr0 pulseaudio[7168]: (  61.504|   0.006) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:21 pr0 pulseaudio[7168]: (  61.505|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:21 pr0 pulseaudio[7168]: (  61.505|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:21 pr0 pulseaudio[7168]: (  61.509|   0.003) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:21 pr0 pulseaudio[7168]: (  61.509|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:21 pr0 pulseaudio[7168]: (  61.509|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:26 pr0 pulseaudio[7168]: (  66.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:26 pr0 pulseaudio[7168]: (  66.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:26 pr0 pulseaudio[7168]: (  66.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:26 pr0 pulseaudio[7168]: (  66.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:26 pr0 pulseaudio[7168]: (  66.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:26 pr0 pulseaudio[7168]: (  66.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:26 pr0 pulseaudio[7168]: (  66.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:26 pr0 pulseaudio[7168]: (  66.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:26 pr0 pulseaudio[7168]: (  66.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:31 pr0 pulseaudio[7168]: (  71.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:31 pr0 pulseaudio[7168]: (  71.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:31 pr0 pulseaudio[7168]: (  71.216|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:31 pr0 pulseaudio[7168]: (  71.217|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:31 pr0 pulseaudio[7168]: (  71.220|   0.003) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:31 pr0 pulseaudio[7168]: (  71.221|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:31 pr0 pulseaudio[7168]: (  71.221|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:31 pr0 pulseaudio[7168]: (  71.221|   0.000) [alsa-sink][pulsecore/memblock.c:265 mempool_allocate_slot()] Pool full
Aug 15 13:37:38 pr0 pulseaudio[7168]: (  78.399|   0.000) [alsa-sink][pulsecore/flist.c:156 pa_flist_push()] pulsecore/memblockq.c: list_items flist is full (don't worry)

A second or two later, ffmpeg has this to say:

Audio timestamp 59763 < 59767 invalid, cliping=00:00:58.66 bitrate=8839.7kbits/s      
[matroska @ 0x1a80940] Audio timestamp 59760 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59757 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59754 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59751 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59747 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59744 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59741 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59739 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59736 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59733 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59730 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59727 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59724 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59722 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59719 < 59767 invalid, cliping
[matroska @ 0x1a80940] Audio timestamp 59717 < 59767 invalid, cliping

If I kill ffmpeg and start again, I get another 20-30 seconds of clean recorded audio before the same thing happens.

Last edited by xlatedst (2012-08-15 12:53:44)

Offline

#3 2012-08-15 17:47:40

xlatedst
Member
Registered: 2010-12-31
Posts: 6

Re: PulseAudio & ffmpeg streaming

Sorry to keep bumping this but I have more information.

Recording from output directly works perfectly. The issue seems to be solely with the loopback.

I removed the mic loopback and just kept the one for output to loop to the null sink, so the only difference between a working and broken recording is the sink/single loopback.

I've also taken video out of the equation, so the command for recording is simply:

ffmpeg -f alsa -i pulse out.wav

Once the recording process begins, the PA errors above appear at the time the recording becomes distorted. This is a new message that I've discovered:

Aug 15 18:28:36 pr0 pulseaudio[5813]: ( 549.090|   0.000) [pulseaudio][modules/module-loopback.c:198 adjust_rates()] Should buffer 464 bytes, buffered at minimum 14720 bytes
Aug 15 18:28:46 pr0 pulseaudio[5813]: ( 559.090|   0.000) [pulseaudio][modules/module-loopback.c:198 adjust_rates()] Should buffer 472 bytes, buffered at minimum 15824 bytes
Aug 15 18:28:56 pr0 pulseaudio[5813]: ( 569.090|   0.000) [pulseaudio][modules/module-loopback.c:198 adjust_rates()] Should buffer 472 bytes, buffered at minimum 10868 bytes
Aug 15 18:29:06 pr0 pulseaudio[5813]: ( 579.090|   0.000) [pulseaudio][modules/module-loopback.c:198 adjust_rates()] Should buffer 472 bytes, buffered at minimum 2360 bytes
Aug 15 18:29:16 pr0 pulseaudio[5813]: ( 589.091|   0.000) [pulseaudio][modules/module-loopback.c:198 adjust_rates()] Should buffer 472 bytes, buffered at minimum 0 bytes
Aug 15 18:29:26 pr0 pulseaudio[5813]: ( 599.091|   0.000) [pulseaudio][modules/module-loopback.c:198 adjust_rates()] Should buffer 472 bytes, buffered at minimum 0 bytes
Aug 15 18:29:28 pr0 pulseaudio[5813]: ( 601.379|   0.000) [pulseaudio][modules/module-loopback.c:198 adjust_rates()] Should buffer 7056 bytes, buffered at minimum 0 bytes
Aug 15 18:29:38 pr0 pulseaudio[5813]: ( 611.379|   0.000) [pulseaudio][modules/module-loopback.c:198 adjust_rates()] Should buffer 7048 bytes, buffered at minimum 0 bytes

The distortion occurs between 18:29:06 and 18:29:16, after which the messages start reading 'minimum 0 bytes'.

Some other forums/lists seem to think this may be related to sample frequency. Sample rate in /etc/pulse/daemon.conf is 44100 and the same for ffmpeg. Tried changing this to 48000 on both sides but made no difference.

Offline

#4 2012-08-15 19:08:28

xlatedst
Member
Registered: 2010-12-31
Posts: 6

Re: PulseAudio & ffmpeg streaming

Fixed. Loopback from the output monitor to a PulseAudio JACK sink. In qjackctl, connect the PulseAudio JACK sink and microphone to ffmpeg.

No impressed, PulseAudio, but at least this is a workable solution.

Offline

#5 2012-08-15 22:54:15

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: PulseAudio & ffmpeg streaming

best bugs are those that solve themselves. can you edit the title of your first post?


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#6 2012-08-15 22:57:18

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,579
Website

Re: PulseAudio & ffmpeg streaming

Yep, please mark as solved.  Also - for future refernce - you can always edit a previous post to add new information.  This is preferred over bumping.

Last edited by Trilby (2012-08-15 22:57:36)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2013-09-18 20:42:14

SuperV1234
Member
From: Italy
Registered: 2013-07-02
Posts: 14
Website

Re: PulseAudio & ffmpeg streaming

Really sorry for bumping an ancient thread, but I have the same issue and I cannot load the pulseaudio jack sink module

$ sudo pactl load-module module-jack-sink
Failure: Module initialization failed

I'm trying to record gameplay from dosbox + live voice commentary. Is there a workaround to fix the sound degradation issue after 20-30 seconds?

Offline

#8 2013-10-15 23:55:19

VidarPT
Member
Registered: 2013-03-15
Posts: 5

Re: PulseAudio & ffmpeg streaming

I'm having the same issue. I reverted back interrupt-based scheduling but sound still crackles like crazy after a few seconds, then sound slows down too and video drops frames to 27. I don't understand what was done here:

Fixed. Loopback from the output monitor to a PulseAudio JACK sink. In qjackctl, connect the PulseAudio JACK sink and microphone to ffmpeg.

Help would be appreciated

Offline

Board footer

Powered by FluxBB