ammen99 / wf-recorder

MIT License
872 stars 63 forks source link

Basic -a audio argument results in audio compressed into first ~1/3 of output #142

Open scott092707 opened 3 years ago

scott092707 commented 3 years ago

When I record a screen recording with the -a argument, so that I can narrate a video, the audio only lasts ~1/3 of the playing time, and I sound like one of the Chipmunks.


scott@ASUS-Prime-B350MA:~$ apt-cache policy sway
sway:
  Installed: 1.5-7

scott@ASUS-Prime-B350MA:~$ apt-cache policy *wlroots*
...
libwlroots6:
  Installed: 0.11.0-3
...

scott@ASUS-Prime-B350MA:~$ uname -a

Using Sway 1.5, wlroots (libwlroots6:  Installed: 0.11.0-3) under Debian Testing
Linux ASUS-Prime-B350MA 5.10.0-1-amd64 #1 SMP Debian 5.10.4-1 (2020-12-31) x86_64 GNU/Linux

scott@ASUS-Prime-B350MA:~$ apt-cache policy wf-recorder
wf-recorder:
  Installed: 0.2.1-3
  Candidate: 0.2.1-3
  Version table:
 *** 0.2.1-3 500
        500 https://deb.debian.org/debian testing/main amd64 Packages
        100 /var/lib/dpkg/status

Invocation:
    wf-recorder -a -f $WFR_FileName

Terminal output:
selected region 0 0 0 0
Setting codec option: crf=20
Setting codec option: preset=ultrafast
Setting codec option: tune=zerolatency
Choosing pixel format yuv420p
[libx264 @ 0x7f4d68001f40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX XOP FMA3 BMI2 AVX2
[libx264 @ 0x7f4d68001f40] profile Constrained Baseline, level 5.2, 4:2:0, 8-bit
[libx264 @ 0x7f4d68001f40] 264 - core 160 r3011 cde9a93 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 lookahead_threads=4 sliced_threads=1 slices=4 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to '/home/scott/Documents/ComputerRelated/Bug_Reports/20210228_192412_wf-recorder_chipmunk.mp4':
    Stream #0:0: Unknown: none (libx264)
    Stream #0:1: Unknown: none (aac)
[mp4 @ 0x7f4d68000dc0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mp4 @ 0x7f4d68000dc0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Using PulseAudio device: default
^C[libx264 @ 0x7f4d68001f40] frame I:2     Avg QP:13.50  size:144690
[libx264 @ 0x7f4d68001f40] frame P:413   Avg QP:13.08  size:   529
[libx264 @ 0x7f4d68001f40] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x7f4d68001f40] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:99.9%
[libx264 @ 0x7f4d68001f40] coded y,uvDC,uvAC intra: 4.2% 1.1% 1.1% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x7f4d68001f40] i16 v,h,dc,p: 93%  4%  3%  0%
[libx264 @ 0x7f4d68001f40] i8c dc,h,v,p: 95%  4%  1%  0%
[libx264 @ 0x7f4d68001f40] kb/s:587.30
[aac @ 0x7f4d68295440] Qavg: 238.668

https://user-images.githubusercontent.com/7544310/109440986-f17d2a80-7a01-11eb-96e1-f15d0794fc15.mp4
omeryagmurlu commented 3 years ago

I have the same issue that is kinda behaving strangely. I can only reproduce this behaviour when the audio is from youtube or nicovideo, if the audio is coming from Zoom (on firefox) or soundcloud, everything is fine. It's probably got something to do with the original audio codec, but I have no clue of the internal workings of pulseaudio, so can't speculate further.

Since I mainly use this tool to record zoom meetings, this is currently not a problem for me.

omeryagmurlu commented 3 years ago

This is probably an issue with pulseaudio, using pipewire with pipewire-pulse solves this issue

scott092707 commented 3 years ago

Yes. I installed pipewire[-pulse, -media-session], and this does seem to have solved it.

scott092707 commented 2 years ago

...well... it seemed to solve it at the time, but now I often sound like a chipmunk again...

I AM using PipeWire:

$ pactl info Server String: /run/user/1000/pulse/native Library Protocol Version: 35 Server Protocol Version: 35 Is Local: yes Client Index: 29589 Tile Size: 65472 User Name: scott Host Name: ASUS-Prime-B350MA Server Name: PulseAudio (on PipeWire 0.3.49) Server Version: 15.0.0 Default Sample Specification: float32le 2ch 48000Hz Default Channel Map: front-left,front-right Default Sink: alsa_output.pci-0000_00_09.2.analog-stereo Default Source: alsa_input.pci-0000_00_09.2.analog-stereo Cookie: 4d49:728a

apt-cache policy pipewire pipewire-bin pipewire-pulse pipewire-media-session pipewire: Installed: 0.3.49-1 Candidate: 0.3.49-1 Version table: 0.3.49-1 500 500 https://deb.debian.org/debian testing/main amd64 Packages 100 /var/lib/dpkg/status pipewire-bin: Installed: 0.3.49-1 Candidate: 0.3.49-1 Version table: 0.3.49-1 500 500 https://deb.debian.org/debian testing/main amd64 Packages 100 /var/lib/dpkg/status pipewire-pulse: Installed: 0.3.49-1 Candidate: 0.3.49-1 Version table: 0.3.49-1 500 500 https://deb.debian.org/debian testing/main amd64 Packages 100 /var/lib/dpkg/status pipewire-media-session: Installed: 0.4.1-2 Candidate: 0.4.1-2 Version table: 0.4.1-2 500 500 https://deb.debian.org/debian testing/main amd64 Packages 100 /var/lib/dpkg/status

Still using sway/wlroots:

$ apt-cache policy sway libwlroots10 wf-recorder sway: Installed: 1.7-2 Candidate: 1.7-2 Version table: 1.7-2 500 500 https://deb.debian.org/debian testing/main amd64 Packages 100 /var/lib/dpkg/status libwlroots10: Installed: 0.15.1-2 Candidate: 0.15.1-2 Version table: 0.15.1-2 500 500 https://deb.debian.org/debian testing/main amd64 Packages 100 /var/lib/dpkg/status wf-recorder: Installed: 0.2.1-4 Candidate: 0.2.1-4 Version table: *** 0.2.1-4 500 500 https://deb.debian.org/debian testing/main amd64 Packages 100 /var/lib/dpkg/status

wf-recorder output (from invocation "wf-recorder -a -f $TempWFR_FileName" ): selected region 0 0 0 0 Setting codec option: crf=20 Setting codec option: preset=ultrafast Setting codec option: tune=zerolatency Choosing pixel format yuv420p [libx264 @ 0x7f035c001e40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX XOP FMA3 BMI2 AVX2 [libx264 @ 0x7f035c001e40] profile Constrained Baseline, level 5.2, 4:2:0, 8-bit [libx264 @ 0x7f035c001e40] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 lookahead_threads=4 sliced_threads=1 slices=4 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0 Output #0, mp4, to '/tmp/WfRecorder_TempFile.mp4': Stream #0:0: Unknown: none (libx264) Stream #0:1: Unknown: none (aac) [mp4 @ 0x7f035c000d40] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead. [mp4 @ 0x7f035c000d40] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead. Using PulseAudio device: default [libx264 @ 0x7f035c001e40] frame I:1 Avg QP:17.00 size:734068 [libx264 @ 0x7f035c001e40] frame P:187 Avg QP:13.16 size: 983 [libx264 @ 0x7f035c001e40] mb I I16..4: 100.0% 0.0% 0.0% [libx264 @ 0x7f035c001e40] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.2% 0.0% 0.0% 0.0% 0.0% skip:99.7% [libx264 @ 0x7f035c001e40] coded y,uvDC,uvAC intra: 19.5% 9.7% 9.5% inter: 0.1% 0.1% 0.1% [libx264 @ 0x7f035c001e40] i16 v,h,dc,p: 81% 16% 3% 1% [libx264 @ 0x7f035c001e40] i8c dc,h,v,p: 85% 11% 3% 1% [libx264 @ 0x7f035c001e40] kb/s:2343.78 [aac @ 0x7f035c295280] Qavg: 242.064

Here is a sample: https://youtu.be/aJv1HXsOSA0

[I tried to use the 'add code' option, but it appeared to remove all CRs leaving each section in one unreadable mass...]

Yutsuten commented 2 years ago

I also have this issue, the recorded audio is played faster than the video.

> pacman -Q wf-recorder pipewire pipewire-alsa wireplumber pipewire-pulse
wf-recorder 0.3.0-1
pipewire 1:0.3.52-2
pipewire-alsa 1:0.3.52-2
wireplumber 0.4.10-3
pipewire-pulse 1:0.3.52-2

For now I think I'll record only video with wf-recorder, and record audio with ffmpeg. I can add the audio to the video after the record...

EDIT: My issue is as in #59, not sure if they are related...

ammen99 commented 2 years ago

Can you try the latest commit on master, which changes the default sample rate to 48000 ?

Yutsuten commented 2 years ago

@ammen99 Tested the latest master here and the issue seems to be fixed!!