ammen99 / wf-recorder

MIT License
859 stars 63 forks source link

Using timeout with wf-recorder breaks output file #63

Closed apiraino closed 4 years ago

apiraino commented 4 years ago

Hi!

This is not an issue with wf-recorder, but I can't figure out how to solve.

I'd like to script wf-recorder in sway to record only for a certain amount of seconds, example, record a GIF with geometry for 2 seconds, then automatically exit:

timeout 2 wf-recorder -g "1135,613 247x240" -f saved.gif --codec=gif

However when I use timeout (or timelimit) the output GIF is corrupt. I tried setting different killing signals (9,15, ...) to no avail.

Without using timeout I simply ctrl+c and interrupt wf-recorder and everything's fine.

Is there any apparent reason why?

thanks!

soreau commented 4 years ago

I'd like to script wf-recorder in sway to record only for a certain amount of seconds, example, record a GIF with geometry for 2 seconds, then automatically exit:

timeout 2 wf-recorder -g "1135,613 247x240" -f saved.gif --codec=gif

You can also try sleep: wf-recorder -g "1135,613 247x240" -f saved.gif --codec=gif & sleep 2; killall -SIGINT wf-recorder

However when I use timeout (or timelimit) the output GIF is corrupt. I tried setting different killing signals (9,15, ...) to no avail.

Can you show a sample of what you mean by corrupt? Is it completely unusable or just not perfect? Your timeout command worked here and I got the same result when running the command manually.

Without using timeout I simply ctrl+c and interrupt wf-recorder and everything's fine.

Is there any apparent reason why?

thanks!

apiraino commented 4 years ago

hey thanks @soreau your bash oneliner works better than mine :-)

Here's attached the "broken" GIF that my command creates. It has the correct GIF header but always the same 800 bytes size and Gimp or another preview application wont open it.

I'm on Linux 5.3.0-24-generic #26-Ubuntu SMP Thu Nov 14 01:33:18 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

saved

EDIT: one piece of important information that I missed is that I'm not invoking wf-recorder from the cli but from a bash script, which is likely the cause. Example:

#!/bin/bash                                                                                     

rm -f saved.gif                                                                  
params=$(slurp -d)                                                                                 
timeout 2 wf-recorder -g "$params" -f saved.gif --codec=gif                      
exit 0
soreau commented 4 years ago

hey thanks @soreau your bash oneliner works better than mine :-)

Glad to hear it.

Here's attached the "broken" GIF that my command creates. It has the correct GIF header but always the same 800 bytes size and Gimp or another preview application wont open it.

You'd have to debug why this happens but I think you're right that it isn't an issue with wf-recorder so I will close this for now.