images icon indicating copy to clipboard operation
images copied to clipboard

Recording with audio

Open bonigarcia opened this issue 2 years ago • 10 comments

I'm trying to record a browser in Docker container using the Aerokube images when in the browser some audio is being played (e.g., in a YouTube video or a WebRTC application). Is this possible?

The steps I made to try to achieve it are the following:

  1. Start Docker container:
docker run --rm --cap-add=SYS_ADMIN -p 4444:4444 -p 5900:5900 -e ENABLE_VNC=true selenoid/vnc:chrome_92.0
  1. Start recording (supposing that the address of the previous container is 172.17.0.2):
docker run --rm -v `pwd`:/data -e BROWSER_CONTAINER_NAME=172.17.0.2 -e FILE_NAME=myrecording.mp4 selenoid/video-recorder:7.1
  1. Connect to the browser container, start Chrome, navigate to YouTube, and reproduce some video.
  2. Stop the recorder container.

At the end of this process, I have the recording in the file myrecording.mp4, but this media file does not have audio track. Besides, I can see the following errors in the browser container:

Waiting X server...
2021/07/25 17:20:07 [INIT] [Listening on :7070]
Logging to: /dev/null
Waiting X server...
Starting ChromeDriver 91.0.4472.101 (af52a90bf87030dd1523486a1cd3ae25c5d76c9b-refs/branch-heads/4472@{#1462}) on port 4444
All remote connections are allowed. Use an allowlist instead!
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

 --- x11vnc loop: 1 ---

 --- x11vnc loop: waiting for: 95

PORT=5900
[97:142:0725/172022.685423:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[97:197:0725/172022.745935:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[97:197:0725/172022.745975:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[97:197:0725/172022.746020:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[97:197:0725/172022.746046:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[97:197:0725/172022.746071:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[151:151:0725/172022.794152:ERROR:viz_main_impl.cc(160)] Exiting GPU process due to errors during initialization
[97:155:0725/172022.804444:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172022.804474:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[274:274:0725/172022.813384:ERROR:gpu_init.cc(440)] Passthrough is not supported, GL is swiftshader
[97:155:0725/172024.152630:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172024.152656:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[1154:19:0725/172117.862168:ERROR:broker_posix.cc(46)] Received unexpected number of handles
[153:167:0725/172117.870201:ERROR:broker_posix.cc(46)] Received unexpected number of handles
[1154:8:0725/172120.420794:ERROR:broker_posix.cc(46)] Received unexpected number of handles
[153:167:0725/172120.426797:ERROR:broker_posix.cc(46)] Received unexpected number of handles
--2021-07-25 17:21:20--  https://clients2.google.com/cr/report
Resolving clients2.google.com (clients2.google.com)... 216.58.215.142, 2a00:1450:4003:800::200e
Connecting to clients2.google.com (clients2.google.com)|216.58.215.142|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: '/dev/fd/4'

     0K                                  
 Crash dump id:  55086edef1cdb022 
                   2.14M=0s

2021-07-25 17:21:21 (2.14 MB/s) - '/dev/fd/4' saved [16]

--2021-07-25 17:21:21--  https://clients2.google.com/cr/report
Resolving clients2.google.com (clients2.google.com)... 216.58.209.78, 2a00:1450:4003:801::200e
Connecting to clients2.google.com (clients2.google.com)|216.58.209.78|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: '/dev/fd/4'


     0K   Crash dump id:   4c9812e3785a2b7b 
                                                  2.08M=0s

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
[1213:1213:0725/172123.709365:ERROR:alsa_util.cc(204)] PcmOpen: default,No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
[1213:1213:0725/172123.709681:ERROR:alsa_util.cc(204)] PcmOpen: plug:default,No such file or directory
[97:155:0725/172123.733113:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733166:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733180:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733191:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733203:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733234:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733251:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733275:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733285:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733299:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733309:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733319:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733329:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.733339:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.739257:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[97:155:0725/172123.739285:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon

I don't know the source of the first group of errors (Failed to connect to the bus: Failed to connect to socket). Any idea about that?

Then, it seems there are some problems related with the audio (ALSA lib confmisc.c:767:(parse_card) cannot find card '0').

Is there any issue in the browser (or recorder) or perhaps I am doing something wrong? Thanks in advance.

PS: Is this issue somehow related to #403?

bonigarcia avatar Jul 25 '21 18:07 bonigarcia

@bonigarcia try more recent video recorder image.

vania-pooh avatar Jul 26 '21 14:07 vania-pooh

@vania-pooh I though that version of selenoid/video-recorder was the latest, according to Docker Hub. If not is that, what is the latest version?

bonigarcia avatar Jul 26 '21 14:07 bonigarcia

@bonigarcia in your example command you have: selenoid/video-recorder:7.1.

vania-pooh avatar Jul 26 '21 14:07 vania-pooh

Yes, I though the tag 7.1 (uploaded 8 months ago) was the latest versions, since it is the greater number, and it is also the newest versions according to Docker Hub (even more than the tag latest-release, uploaded a year ago):

image

Do you mean that I should use latest-release tag instead? I am going to test with that version also.

bonigarcia avatar Jul 26 '21 14:07 bonigarcia

@bonigarcia just checked. Should work with 7.1 and recent browser images. Please try with previous Chrome versions like 91.0. So far as we can see Chrome 92.0 have GPU-related issue. Not sure whether this influences sound recording.

vania-pooh avatar Jul 26 '21 14:07 vania-pooh

@vania-pooh I have tried with Chrome 91.0, and different setups and recorders (7.1 and latest-release), but I didn't manage to record the sound. I have also tried to use in-memory filesystem (tmpfs) and shared memory, but still, no luck.

docker run --rm --cap-add=SYS_ADMIN -p 4444:4444 -p 5900:5900 -e ENABLE_VNC=true --mount type=tmpfs,destination=/tmp,tmpfs-size=512m --shm-size=1g selenoid/vnc:chrome_91.0

I think the problem is not in recorder, since the media info of the recording file shows an audio track (but it seems is basically silence):

$ mediainfo myrecording.mp4 
General
Complete name                            : myrecording.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 2.06 MiB
Duration                                 : 41 s 584 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 415 kb/s
Writing application                      : Lavf58.45.100

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 41 s 584 ms
Bit rate                                 : 409 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 12.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.016
Stream size                              : 2.03 MiB (99%)
Writing library                          : x264 core 157
Encoding settings                        : 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=12 / lookahead_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=12 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 36 s 846 ms
Bit rate mode                            : Variable
Bit rate                                 : 2 171 b/s
Maximum bit rate                         : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 9.77 KiB (0%)
Default                                  : Yes
Alternate group                          : 1

On the other side, as explained in my original post, there are errors related to the sound in the browser container (both in Chrome 91 and 92):

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
[1252:1252:0726/152924.163117:ERROR:alsa_util.cc(204)] PcmOpen: plug:default,No such file or directory
[98:156:0726/152924.364663:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon
[98:156:0726/152924.364697:ERROR:bus.cc(393)] Failed to connect to the bus: Address does not contain a colon

bonigarcia avatar Jul 26 '21 15:07 bonigarcia

@vania-pooh Any update regarding fixing it for the next release of chrome?

GhaziTriki avatar Dec 14 '21 21:12 GhaziTriki

@GhaziTriki not yet. Instead of just summoning us to the issue, you could meanwhile do your own investigation. That's open-source.

vania-pooh avatar Dec 15 '21 03:12 vania-pooh

@vania-pooh I am not a sys admin expert. Since Aerokube implemented it I thought you would have a better idea about how to bring it back to the product, since having audio working is critical to have in Selenoid. We are planning to do some investigation of course.

GhaziTriki avatar Dec 15 '21 06:12 GhaziTriki

For me with applying this fix for chrome made it.
Fixed nicely the audio in recordings: https://github.com/aerokube/images/pull/646 I also updated the recording image build: https://github.com/aerokube/images/pull/647

misi avatar Oct 24 '23 10:10 misi

Looks like https://github.com/aerokube/images/pull/646 fixed it for me!

Juice10 avatar Apr 19 '24 15:04 Juice10

Let's close then.

vania-pooh avatar Apr 30 '24 05:04 vania-pooh