kapoorlakshya / screen-recorder Goto Github PK
View Code? Open in Web Editor NEWA Ruby gem to video record and take screenshots of your desktop or specific application window. Works on Windows, Linux, and macOS.
License: MIT License
A Ruby gem to video record and take screenshots of your desktop or specific application window. Works on Windows, Linux, and macOS.
License: MIT License
Examples
calc.exe vs Calculator
chrome.exe vs SRWare Iron or iron
Fix is to remove this check:
# window_titles.rb:33
.select { |t| t.match?(/#{application}/i) } # Narrow down to given application
Drawback is that the returned list will now have Windows OLE related window names, such as OleMainThreadWndName
and nsAppShell:EventWindow
. This will require an update to the README to inform the users of this change in behavior.
Also, need to update the filtering on N/A
and blank window titles. These are usually present when using Chrome which spawns a new process for each extension.
raw_list.map { |i| i.gsub(/^Window Title:( N\/A|\s+)?/) }.reject!(&:empty?)
Error: invalid log level: (ArgumentError)
Possible solution: Ensure a default level is set.
Branch: https://github.com/kapoorlakshya/screen-recorder/tree/macos_support
pre
version.All tests are currently grouped under the ScreenRecorder
spec. They should be grouped by the class/object they test instead.
Check -loglevel
here: https://ffmpeg.org/ffmpeg.html#toc-Generic-options
Consider ScreenRecorder::
or something similar instead of using FFMPEG
as the top-level namespace. Probably a good idea to not pollute streamio's namespace.
Renaming the project (gem) is not required. Will keep ffmpeg in the name so people know that it's FFmpeg based.
Currently, the user has to provide the format, for example gdigrab
on Windows, through the options. The gem should automatically choose one based on the operating system IF the user does not provide it.
This could be an alternate approach to recording to disk and then calling #discard
when the test passes.
childprocess
gem provides methods like #alive?
and #exited?
which will be useful for checking the state of the process. It also provides a better way to handle the ffmpeg log file creation and force killing the processed when needed.
Make framerate
an optional parameter and default it to 15.
On Microsoft Windows, title for calc.exe
is Calculator in the GUI, but #fetch
returns CicMarshalWnd
based on the information in the Task Manager.
In these cases, the user will have to manually provide the window title or use a third-party tool like WinLister.
Hi, I have moved from Ruby 2.5.1 to Ruby 2.5.3, now it's throwing this error
FFMPEG::Error: [gdigrab @ 000002a00ad4a540] Invalid properties, aborting
title=OleMainThreadWndName: I/O error
ffmpeg.log
ffmpeg version N-93075-gb429c86d84 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20181201
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 46.100 / 58. 46.100
libavformat 58. 26.100 / 58. 26.100
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 48.100 / 7. 48.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[gdigrab @ 000001a07c30a540] Found window OleMainThreadWndName, capturing 0x0x32 at (0,0)
[gdigrab @ 000001a07c30a540] Invalid properties, aborting
title=OleMainThreadWndName: I/O error
#stop should log to DEBUG: [libx264 @ 000001da3adef5c0] kb/s:234.63
.
Update spec to initialize @recorder
before each instead of all.
Once #32 is merged, we will no longer be using and exposing the FFMPEG
namespace. The ffmpeg
in the name can hence be dropped and the name can be simplified to screen-recorder
to match the new namespace ScreenRecorder
.
TODO
beta13
beta13
README
and CHANGES
filesscreen_recorder 1.0.0
Resources
https://brandonhilkert.com/blog/ruby-gem-post-install-message/
ScreenRecorder::Desktop.screenshot(output: 'desktop.jpeg')
ScreenRecorder::Window.screenshot(output: 'window.jpeg')
ffmpeg -f gdigrab -framerate 1 -i desktop -vframes 1 output.jpeg
MKV is the only container that doesn't produce an invalid file (missing headers) when ffmpeg is force killed.
Accept input/output params separately to appropriately place them in the parsed (final) command.
advanced = {
input: {
framerate: 30,
pix_fmt: 'yuv420p',
video_size: '1280x720',
show_cursor: 1
},
output: {
framerate: 15,
pix_fmt: 'yuv420p'
},
log: 'recorder.log',
loglevel: 'level+debug', # For FFmpeg
}
Maybe it should be its own Class to handle the options/parameter parsing and sending to ffmpeg
logic?
:advanced
key@recorder.new(opts, browser)
use browser
object to interact with Watir::Browser
interface.
Also support Selenium Ruby.
Hi, My recording is successfully happening for firefox. But even after the successful recording, it throws the following error
FFMPEG::Error: [libx264 @ 00000225731ae940] ref B L1: 95.2% 4.8%
[libx264 @ 00000225731ae940] kb/s:192.70
And May I know this recorder can be used for Chrome as well? I haven't gotten any success with chrome yet. If it can be done, Can you let me know how that is?
Will need OS specific logic. This one works on macOS and possibly on Linux:
def stop_ffmpeg
# ...
rescue Timeout::Error
ScreenRecorder.logger.error 'FFmpeg failed to stop. Force killing it...'
pid = (@process.pid + 1) # Parent process + 1
Process.kill 'TERM', pid
end
Could combine with #18.
See if audio recording can be supported through advanced
. If not, look into implementing parameters for it.
I am using two monitor, One monitor my RubyMine would be opened and in my another monitor, Browser opens and runs on it. If I use desktop recorder, then it records both the monitor together, Can I have any way to record the second monitor only? I ask this because when I recorder firefox or chrome, it records only the first window, the second window if opens as a result of the click is not captured at all.
Steps to reproduce:
FFMPEG::WindowTitles.fetch 'chrome'
This will raise ArgumentError (invalid byte sequence in UTF-8)
. We could perform encode('UTF-8')
(source) on the retrieved title, but I am not sure if ffmpeg
wants an exact match on the title.
Workaround
Workaround is to open or switch to a web page with a clean title, start the recording, and then switch back to the window title with unsupported characters.
Run rubocop with specs.
Default it to -s 1280x720
and allow the user to provide one.
This can be helpful when the user wants to discard the recording for successful/passing test cases.
Support JRuby 9.x.
Is this gem ffmpeg-screenrecorder no longer been maintained? I have been working with this gem. You supported few months back?
What's the change? I can't record chrome screen so far. Can I record chrome screen if I use your new gem?
WindowTitles.fetch 'chrome', strict: true
or full_match: true
.
This will only return titles with "chrome" in them, and filter out the OLE ones.
Fix is to use @ffmpeg_binary
from streamio
gem instead of directly using fmpeg
.
Update: The gem actually does use @ffmpeg_binary
and that logic is fine. The problem is with #ffmpeg_exists?
in #start_ffmpeg
which does only looks for the binary in ENV. It does not check to see if @ffmpeg_binary
has a path to it.
The fix will actually be to first check ENV and then check if @ffmpeg_binary
. Note: @ffmpeg_binary
returns "ffmpeg"
assuming it exists in ENV if use does not define a path to it. So, to work around this, the condition will be:
@ffmpeg_binary != "ffmpeg"
. It should have a full path to the binary instead.dist: xenial
to get ffmpeg from official repo instead of adding a ppa
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.