Skip to content

Commit

Permalink
Merge pull request homebridge-plugins#19 from SphtKr/add-stillimageso…
Browse files Browse the repository at this point in the history
…urce-option

Add `stillImageSource` option in config.json
  • Loading branch information
KhaosT authored Nov 13, 2016
2 parents 9d63067 + 5edda9d commit 0a6d77e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ ffmpeg plugin for [Homebridge](https://github.com/nfarina/homebridge)

### Config.json Example

{
{
"platform": "Camera-ffmpeg",
"cameras": [
{
"name": "Camera Name",
"videoConfig": {
"source": "-re -i rtsp://myfancy_rtsp_stream",
"stillImageSource": "-i http://faster_still_image_grab_url/this_is_optional.jpg"
"maxStreams": 2,
"maxWidth": 1280,
"maxHeight": 720,
Expand All @@ -27,3 +28,5 @@ ffmpeg plugin for [Homebridge](https://github.com/nfarina/homebridge)
}
]
}

Incidentally, check [iSpyConnect's camera database](https://www.ispyconnect.com/sources.aspx) to find likely protocols and URLs to try with your camera.
4 changes: 3 additions & 1 deletion ffmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function FFMPEG(hap, ffmpegOpt) {
}

this.ffmpegSource = ffmpegOpt.source;
this.ffmpegImageSource = ffmpegOpt.stillImageSource;

this.services = [];
this.streamControllers = [];
Expand Down Expand Up @@ -122,7 +123,8 @@ FFMPEG.prototype.handleCloseConnection = function(connectionID) {

FFMPEG.prototype.handleSnapshotRequest = function(request, callback) {
let resolution = request.width + 'x' + request.height;
let ffmpeg = spawn('ffmpeg', (this.ffmpegSource + ' -t 1 -s '+ resolution + ' -f image2 -').split(' '), {env: process.env});
var imageSource = this.ffmpegImageSource !== undefined ? this.ffmpegImageSource : this.ffmpegSource;
let ffmpeg = spawn('ffmpeg', (imageSource + ' -t 1 -s '+ resolution + ' -f image2 -').split(' '), {env: process.env});
var imageBuffer = Buffer(0);

ffmpeg.stdout.on('data', function(data) {
Expand Down

0 comments on commit 0a6d77e

Please sign in to comment.