ammen99 / wf-recorder

MIT License
859 stars 63 forks source link

segfault when attempting to record as gif #16

Closed tmccombs closed 5 years ago

tmccombs commented 5 years ago

When I attempted to run wf-recorder -f test.gif -g "$(slurp)" -o DVI-I-1

I got a segfault. Here is the output:

Adjusted geometry: 2092,285 794x572
selected region 2092 285 794 572
[libx264 @ 0x7f9c18014e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX XOP FMA3 BMI1
[libx264 @ 0x7f9c18014e00] profile Constrained Baseline, level 3.1, 4:2:0, 8-bit
Output #0, gif, to 'test.gif':
    Stream #0:0: Unknown: none (libx264)
[gif @ 0x7f9c18033980] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[gif @ 0x7f9c18033980] GIF muxer supports only a single video GIF stream.
[swscaler @ 0x7f9c18000bc0] Warning: data is not aligned! This can lead to a speed loss
zsh: segmentation fault (core dumped)  wf-recorder -f test.gif -g "$(slurp)" -o DVI-I-1
ammen99 commented 5 years ago

I would need a bit more info:

  1. Is this related to recording only a part of your screen, i.e. if you record the whole output, does it still happen?
  2. Run wf-recorder in gdb and post the backtrace or compile and run with address sanitizing support (pass -Db_sanitize=address,undefined to meson), then give me the reported backtrace.
  3. Run with the -l flag, it will enable ffmpeg debugging information, which might reveal a bit more.
tmccombs commented 5 years ago
  1. It happens if I try to record the whole output as well
  2. running with gdb gives me this stacktrace:
    #0  0x00007ffff6897ebe in ?? () from /usr/lib/libavformat.so.58
    #1  0x00007ffff689a3ea in av_interleaved_write_frame () from /usr/lib/libavformat.so.58
    #2  0x0000555555557fcf in ?? ()
    #3  0x0000555555558884 in ?? ()
    #4  0x00007ffff6623063 in std::execute_native_thread_routine (__p=0x55555559c710) at /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80
    #5  0x00007ffff6531a9d in start_thread () from /usr/lib/libpthread.so.0
    #6  0x00007ffff6461b23 in clone () from /usr/lib/libc.so.6
  3. the -l option doesn't give any additional output.
tmccombs commented 5 years ago

I just realized I wasn't running with the most up to date code, and compiled it again. I get slightly different output now (and an abort instead of a segfault):

selected region 0 0 0 0
Setting codec option: crf=20
Setting codec option: preset=ultrafast
Setting codec option: tune=zerolatency
[libx264 @ 0x7f064c001cc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX XOP FMA3 BMI1
[libx264 @ 0x7f064c001cc0] profile Constrained Baseline, level 4.2, 4:2:0, 8-bit
Output #0, gif, to 'test.gif':
    Stream #0:0, 0, 1/60: Unknown: none (libx264)
[file @ 0x7f064c080300] Setting default whitelist 'file,crypto'
[gif @ 0x7f064c000c40] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[gif @ 0x7f064c000c40] GIF muxer supports only a single video GIF stream.
Failed to write file header
error marshalling arguments for capture_output (signature nio): null value passed for arg 2
Error marshalling request: Invalid argument
zsh: abort (core dumped)  wf-recorder -f test.gif -o HDMI-A-1 -l

And the backtrace is now:

#0  0x00007ffff5da1d7f in raise () from /usr/lib/libc.so.6
#1  0x00007ffff5d8c672 in abort () from /usr/lib/libc.so.6
#2  0x00007ffff7f6cf80 in ?? () from /usr/lib/libwayland-client.so.0
#3  0x00007ffff7f68cc0 in wl_proxy_marshal_array_constructor_versioned () from /usr/lib/libwayland-client.so.0
#4  0x00007ffff7f68efc in wl_proxy_marshal_constructor () from /usr/lib/libwayland-client.so.0
#5  0x0000555555558f78 in main ()
ammen99 commented 5 years ago

Okay, so the problem is GIF muxer supports only a single video GIF stream., which on my system is highlighted in red. This means that the codec is not compatible with GIF (after all, the default codec is libx264). You need to also set the codec to GIF but I am still looking into what pixel format we'll need, as YUV420p isn't supported by GIF.

ammen99 commented 5 years ago

I found out that the GIF codec supports only RGB8 and such. I will soon write a patch to use the supported formats in the codec, not the hardcoded YUV420p

ammen99 commented 5 years ago

Hi again, I pushed https://github.com/ammen99/wf-recorder/tree/gif-support . You need to specify both output file as gif and set the codec to gif (so wf-recorder -f file.gif -c gif). Can you verify that it works?

ammen99 commented 5 years ago

Reopen if this still happens, I have been able to record GIFs now.

Jpfonseca commented 5 years ago

Can confirm it's working @ammen99, with the image selection region too

Jpfonseca commented 5 years ago

Can you add this info on the Readme.md also ? I started looking to other recorders since I didn't knew about this issue until now.