kapoorlakshya/screen-recorder

ffmpepg is not closed(killed) properly when I record the video and audio

Rajagopalan-M opened this issue · 3 comments

When the program uses 'recorder.close' to close the recorder, this error is thrown

2023-07-30 11:00:34 ScreenRecorder - ERROR - ffmpeg failed to stop. Force killing it...
2023-07-30 11:00:34 ScreenRecorder - ERROR - Forcefully killed ffmpeg. Recording failed!

I employed the subsequent syntax to capture both the video and audio

     advanced = { log: 'AppData/Logs/recorder.log', f: 'dshow', i: 'audio="virtual-audio-capturer"' }
                ScreenRecorder.ffmpeg_binary = File.expand_path("VideoRecorder/ffmpeg.exe")
                FFMPEG.ffprobe_binary = File.expand_path("VideoRecorder/ffprobe.exe")

recorder = ScreenRecorder::Desktop.new(output: File.expand_path("Output/Video/#{scenario}/#{testcase.first + '_' + testcase[2]}.mp4"), advanced: advanced)

However, when I record only the video using the following syntax, this error is not thrown.

    advanced = {
                  log: 'AppData/Logs/recorder.log'
                }

                  recorder = ScreenRecorder::Desktop.new(output: File.expand_path("Output/Video/#{scenario}/#{testcase.first + '_' + testcase[2]}.mp4"), advanced: advanced)

video log is here


ffmpeg version 4.3.2-2021-02-02-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
[gdigrab @ 00000204fdcdeb40] Capturing whole desktop as 1920x1080x32 at (0,0)
[gdigrab @ 00000204fdcdeb40] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, gdigrab, from 'desktop':
  Duration: N/A, start: 1690695721.999673, bitrate: 1988680 kb/s
    Stream #0:0: Video: bmp, bgra, 1920x1080, 1988680 kb/s, 29.97 fps, 1000k tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, dshow, from 'audio=virtual-audio-capturer':
  Duration: N/A, start: 700576.085000, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (bmp (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 00000204fdced4c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
[libx264 @ 00000204fdced4c0] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 00000204fdced4c0] 264 - core 161 r3043 59c0609 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - 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=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=25 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
Output #0, mp4, to 'C:/A/Rajagopalan/Output/Video/TS1-CreatePackage/CreatePackage_Package1.mp4':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080, q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc
    Metadata:
      encoder         : Lavc58.91.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.91.100 aac
frame=   50 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A dup=35 drop=0 speed=   0x    
[dshow @ 00000204fdce0c00] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
frame=   65 fps= 64 q=29.0 size=       0kB time=00:00:00.20 bitrate=   1.9kbits/s dup=36 drop=0 speed=0.197x    
frame=   80 fps= 53 q=29.0 size=       0kB time=00:00:00.70 bitrate=   0.5kbits/s dup=36 drop=0 speed=0.463x    
frame=   95 fps= 47 q=29.0 size=       0kB time=00:00:01.20 bitrate=   0.3kbits/s dup=36 drop=0 speed=0.59x    
frame=  111 fps= 43 q=29.0 size=       0kB time=00:00:01.73 bitrate=   0.2kbits/s dup=37 drop=0 speed=0.679x    
frame=  126 fps= 41 q=29.0 size=       0kB time=00:00:02.24 bitrate=   0.2kbits/s dup=37 drop=0 speed=0.73x    
frame=  142 fps= 40 q=29.0 size=       0kB time=00:00:02.77 bitrate=   0.1kbits/s dup=37 drop=0 speed=0.776x    
frame=  157 fps= 38 q=29.0 size=       0kB time=00:00:03.26 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.799x    
frame=  172 fps= 37 q=29.0 size=       0kB time=00:00:03.77 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.822x    
frame=  187 fps= 37 q=29.0 size=       0kB time=00:00:04.27 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.837x    
frame=  202 fps= 36 q=29.0 size=       0kB time=00:00:04.77 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.853x    
frame=  217 fps= 36 q=29.0 size=       0kB time=00:00:05.27 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.864x    
frame=  223 fps= 34 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.83x    
frame=  223 fps= 31 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.769x    
frame=  223 fps= 29 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.719x    
frame=  223 fps= 27 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.673x    
frame=  223 fps= 26 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.633x    
frame=  223 fps= 24 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.599x    
frame=  223 fps= 23 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.567x    
frame=  223 fps= 22 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.538x    
frame=  223 fps= 21 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.513x    
frame=  223 fps= 20 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.489x    
frame=  223 fps= 19 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.468x    
frame=  223 fps= 18 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.448x    
frame=  223 fps= 17 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.43x    
frame=  223 fps= 17 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.414x    
frame=  223 fps= 16 q=29.0 size=       0kB time=00:00:05.48 bitrate=   0.1kbits/s dup=38 drop=0 speed=0.398x    
[gdigrab @ 00000204fdcdeb40] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)

Hi, could you kindly investigate this matter? It has been functioning well until I switched my computer, and now I am encountering this problem

Hey, this issue is fixed man. You can close this thread.

Hi, You always shows up when I say problem is solved. Very funny!