Coder Social home page Coder Social logo

matthutchinson / videosnap Goto Github PK

View Code? Open in Web Editor NEW
161.0 12.0 28.0 580 KB

Simple command line tool to record video and audio from any attached capture device

License: MIT License

Objective-C 86.42% Roff 12.42% C 1.16%
capture-video record-video avfoundation command-line-tool coremediaio macos

videosnap's Introduction

VideoSnap

VideoSnap is an macOS command line tool for recording video and audio from any attached capture device (including screen capture from connected iOS devices).

You can specify which device to capture from (by device name), the duration, encoding and a delay period (before capturing starts).

By default VideoSnap will capture both video and audio from the default capture device at 30fps, with a Medium quality preset and a short (0.5s) warm-up delay.

If no duration is specified, VideoSnap will record until you cancel with [Ctrl+c] or you can pause (and resume) recording with [Ctrl+z].

VideoSnap can list attached capture devices by name.

Requirements

  • macOS 10.9+ (Intel/M1)
  • A web cam or iOS device

If you need to capture video on older versions of macOS (e.g. 32-bit OSX) try wacaw

Installation

Download the latest release and run the installer.

This will copy the binary and man page to your /usr/local directory.

Usage

The following options are available:

  -l    List attached capture devices
  -w    Set delay before capturing starts (in seconds, default 0.5s)
  -t    Set duration of video (in seconds)
  -d    Set the capture device by name (use -l to list attached devices)
  -p    Set the encoding preset (use High, Medium (default), Low, 640x480 or 1280x720)
  -v    Turn ON verbose mode (OFF by default)
  -h    Show help
  --no-audio
        Don't capture audio (audio IS captured by default)

Examples

Capture 10.75 secs of video in 1280x720 720p HD format saving to movie-{timestamp}.mov

videosnap -t 10.75 -p '1280x720'

Capture 1 minute of video (Medium preset), but no audio from the "FaceTime HD Camera (Built-in)" device, delaying for 5 secs, saving to video.mov

videosnap -t 60 -w 5 -d 'FaceTime HD Camera (Built-in)' --no-audio video.mov

List all attached devices by name

videosnap -l

Warming Up

Since some camera hardware can take a while to warm up, a default delay of 0.5 seconds is applied. Override this with the -w argument (0 meaning no delay).

NOTE: Videosnap will also wait 0.5s to allow any connected devices to be discovered (e.g. for iOS screen capture).

Encoding Presets

The AVFoundation framework provides the following video encoding presets:

Resolution Comments
High Highest recording quality. This varies per device.
Medium Suitable for Wi-Fi sharing. The actual values may change.
Low Suitable for 3G sharing. The actual values may change.
640x480 VGA.
1280x720 720p HD.

Use the -p flag to choose a preset.

Capturing from connected iOS devices

It is possible to screen capture video & audio from an attached iOS device.

For the device to be discovered you must confirm that you Trust This Computer on the device when it is connected and unlocked.

There are some limitations and issues with iOS screen capturing.

  • (issue) the --no-audio flag currently has no effect (workaround: mute the device)
  • (issue) currently broken on M1 macs (due to this error)
  • (limitation) when capturing, the device will not output any audio (but audio will be recorded to the movie file)
  • (limitation) occasionally the device fails to be discovered, this can happen when
    • another process is already capturing from the device
    • the macOS kernel fails to connect to the DAL assistant to communicate with the virtual capture device

Help

Get command help with:

videosnap -h
# or via the man page with
man videosnap

If you have any problems, please do raise an issue on GitHub. When reporting a bug, remember to mention what platform and hardware you are using and the steps I can take to reproduce the issue.

Development

I try to keep the project up to date with the latest general XCode release.

After opening videosnap.xcodeproj, you can set the arguments passed to the command when it runs in XCode, simply edit the Run action in the default videosnap Scheme. (Product -> Scheme -> Edit Scheme...)

You can also build the project from the command line. After cloning run:

  xcodebuild clean install
  # you'll find the build executable at
  ./build/Debug/videosnap
  # which symlinks to here
  ./build/pkgroot/usr/local/bin/videosnap

If you see this message:

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory "..."

Try this to fix your environment:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Contributing

Bug reports and pull requests are welcome on GitHub. Before submitting pull requests, please read the contributing guidelines for more details.

This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct. See here for more details.

Development

VideoSnap is coded with Objective-C and uses the AVFoundation framework. You can build the project with Xcode (using the Xcode project workspace in the repository, or with the xcodebuild command).

Future Work

Work in progress is usually mentioned at the top of the CHANGELOG. If you'd like to get involved in contributing, here are some ideas:

  • Allow VideoSnap to pipe captured bytes to the STDOUT stream
  • Submit VideoSnap as a package for Homebrew
  • Allow more size/quality options for video and/or audio
  • Smile detection while capturing video/image, determine a happiness factor/score
  • Allow VideoSnap to capture a single frame to an image file (with compression options based on file type like ImageSnap)
  • A comprehensive test suite

License

VideoSnap is distributed under the terms of the MIT License.

Who's Who?

videosnap's People

Contributors

matthutchinson avatar mkj-is avatar vlussenburg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

videosnap's Issues

unknown duration?

What if you want to record a video of an unknown length? Is there a way to have it record the video until you press Ctrl+C?

Select audio source

Hi,
I'm trying to capture both audio and video from a USB device (AV to USB). While the video capture works perfectly, the audio is being recorded from my Mac's mic. Is there a flag to force the audio source as well? Thanks :)

Is there a way to record audio only with no video?

This code is a true gem! I've got it up and running, and it works as stated. My one question: I see that it is possible to record video with no audio, but is it possible tor record audio only (no video)? Any adjustments I could do from my end, or would this require a revision from ground up? Any input or ideas are appreciated! Sorry if this is the improper way to ask, I'm unfamiliar. Thanks for sharing!

can not find iphone devices which I plugged into my mac

actually I want to use this command line tool to capture video of my iphone which I plugged into my mac when I do some manipulations on it, but after I execute videosnap in my mac: ./video -l, it only list my facetime HD camera, but no my iphone, but I can see my iphone when I open quicktime, any suggestions,thanks.

2016-05-20 11 27 28

Webcams with same name: target by port ID?

Hi,

Thanks for this tool. I’ve been using it a lot for multiple plugged webcams.

Yet, lately the webcams lost their unique identifier, they are all named BRIO. There is no way for me to rename then. It makes it impossible to target one since the name is always the same.

Is there a way, I could target the Port instead (similar to openCV)?

Kind Regards,

Clément

Add crop

I would like a CLI for recording a specific part of the screen with Quicktime Player
Current manual method:
Quicktime Player (10.4)

  • File > New Screen Recording
  • Click red circle "Record" button.
  • Drag with mouse rectangle dimensions that you want to record. (Starts recording on mouseup).
  • Stop recording by clicking round black circle in menu bar.

Need to be able to pass TopLeft(x,y) and BottomRight(x,y) to record just that part of the screen.

Multiple simultaneous recordings support

When I open two terminals and call videosnap in both at roughly the same time, the second instance waits till the first is done recording and only then starts recording even when using two different webcams. So it is not possible to capture multiple webcam streams at the same time

Running multiple videosnap sessions simultaneously

I was wondering if it was possible to run multiple versions of videosnap (say I have 3 cameras attached) is there a way to launch videosnap on each one simultaneously (perhaps by defining which attached camera I am want for each)? Or will it kill the earlier session when I run the new one?

Devices with diacritics in a name can't be used

Thanks you very much for this tool!

I found out during testing it that it doesn't handle diacritics in a device name properly. (Maybe non-ASCII characters or some issue with UTF-8 vs. UTF-16 encoding?)

kaspar@Matejs-MacBook-Pro Downloads % ./videosnap -l
Found 2 available video devices:
* FaceTime HD Camera (Built-in)
* Kašpar's iPhone XS
kaspar@Matejs-MacBook-Pro Downloads % ./videosnap --no-audio -d "Kašpar's iPhone XS"
Device "Kašpar's iPhone XS" not found - aborting

Cannot record video from iPhone on M1 based Macs

I am not able to capture any videorecording on connected iPhone. Recording works as expected using QuickTime.
See the verbose output of videosnap -p High -d "$DEVICE_NAME" "$FILENAME" below:

(caught signal: [2])
(stopping recording)
(finished writing to movie file)
(stopping capture session)

Failed to capture any video
(reason: Cannot Record)

Turns out this is supposedly an issue on Apple side. See https://developer.apple.com/forums/thread/677199?login=true&page=1#692431022

Faster startup time?

videosnap is awesome, it gives much better experience compared to ffmpeg on video recording. Onething is that the startup time is quite costly, which is not ideal if you need to record multiple small videos instead of a big one. I wonder if there is a way to speed that up, if not, perhaps allow videosnap to run in server mode where it possible to tell it when to start/stop capture video and it will respond in just a matter of milliseconds.

AVFoundation/Pipes?

This is a useful application. I forked it because I need pipes support. While I'm digging around, I noticed that QTKit is deprecated. I'm just about done moving it to AVFoundation. Do you want me to do a pull request when I'm done?

not working on Remotely(SSH)

Target device:
ProductName: Mac OS X
ProductVersion: 10.14.4
BuildVersion: 18E226

Error: abort trap: 6

_Request:

  1. is it possible to run this remotely??
  2. is it possible to add a screenrecord,screenshot and camcapture. like FFMPEG, the video is so much smoother than the FFMPEG. great job._

'videosnap: Bad CPU type in executable' on Intel Core Duo 1.66ghz / 10.5.8

Hello. I've been using this happily on newer hardware, but I just inherited an older 2006 era Mac Mini running at 1.66ghz and on Mac OS X.5.8 (Leopard). As per the readme, this should be supported? The thing is, I get "videosnap: Bad CPU type in executable" when running videosnap -l

Any ideas?

Thank you for the awesome utility :)

Camera access privacy-sensitive

I use command line tool app and i have a crash because "because it attempted to access privacy-sensitive data without a usage description".

I tried to build my own command line tool which record from connected camera but I get the same issue. I tried to add info.plist with NSCameraUsageDescription key and add Request authorization for Capture function but i didn't get any success. It crashes and I get the same error.

Resultant Files Won't Play on iOS 12

I apologize if this has nothing to do with this program; I suspect this is the case, but I've searched about high and low and cannot figure it out. I'm wondering if you might have some time to offer any input/advice.

I'm running on a Mac Mini (Late 2014) 2.6ghz i5, running the public beta of Mojave 10.14.3.

When I execute the program, I immediately get the following output:

GVA encoder info: recomputed for fps: 29.970030, got size in pics: 29, got size in sec: 1.000000

Everything appears to run smoothly after this, and it creates a file that I can view as I would expect...

The thing is: the files won't play on iOS. I see a thumbnail, and when I tap it, the timeline appears to load, but then just nothing happens; no audio, no video.

I've been uploading the files to iCloud Drive and sharing them out to family members; they can only view the files on a Mac (haven't tried on a windows box). Out of 6-7 different iOS devices (mostly running iOS 12), nobody can view the videos (unless they use a Mac).

I've tried several other more direct file transfers to account for iCloud Drive weirdness (e.g. directly to my iPhone X); nothing plays.

The only thing that does work on iOS is to view things through VLC.

Are you aware of any codec changes that might have happened in AVFoundation in Mojave or its betas that might cause this? Any idea how to work around it? I'm going to attempt to un-enrol from the beta and see what happens.

Many thanks for your time and expertise! Feel free to close this without comment if you just don't have time.

Fantastical

Maybe this is outdated and there's a better Solution but if not then I don't know what people think what is important.

I mean what is practical. I am living on windows still unfortunately though.

Maybe there is a Windows version or a possibility to execute this from

I just have to get the OS X Docker container running. And then I will try this amazing thing. Thank you

Fix videosnap millisec record time issues

Exact length timing of captured output is imperfect given camera warm up time. Investigate possible fixes so that exact duration can be specified to the milli-second. (use ffmpeg -i to examine video output)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.