Skip to content

Commit

Permalink
local (usb) camera added and monitor editor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
moeiscool committed Dec 27, 2016
1 parent 663b51d commit 7dc713d
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 19 deletions.
20 changes: 15 additions & 5 deletions camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,14 @@ s.ffmpeg=function(y,e,x){
case'mp4':
switch(e.type){
case'h264':
x.acodec='copy',x.vcodec='copy';
x.vcodec='copy';x.acodec='copy';
break;
default:
x.vcodec='libx264';
x.vcodec='libx264';x.acodec='libfaac';
break;
};
if(e.details.vcodec&&e.details.vcodec!==''){x.vcodec=e.details.vcodec}
if(e.details.acodec&&e.details.acodec!==''){x.acodec=e.details.acodec}
break;
case'webm':
x.acodec='libvorbis',x.vcodec='libvpx';
Expand All @@ -219,7 +221,7 @@ s.ffmpeg=function(y,e,x){
// if(e.details.svf){'-vf "rotate=45*(PI/180)'}
switch(e.type){
case'socket':
x.tmp='-loglevel warning -pattern_type glob -f image2pipe -vcodec mjpeg -i -'+x.time+' -vcodec '+x.vcodec+' -r '+e.fps+' -use_wallclock_as_timestamps 1 -q:v 1'+x.vf+' '+e.dir+e.filename+'.'+e.ext;
x.tmp='-loglevel quiet -pattern_type glob -f image2pipe -vcodec mjpeg -i -'+x.time+' -vcodec '+x.vcodec+' -r '+e.fps+' -use_wallclock_as_timestamps 1 -q:v 1'+x.vf+' '+e.dir+e.filename+'.'+e.ext;
break;
case'jpeg':
x.tmp='-loglevel quiet -pattern_type glob -f image2pipe -vcodec mjpeg -i -'+x.time+' -vcodec '+x.vcodec+' -r '+e.fps+' -use_wallclock_as_timestamps 1 -q:v 1'+x.vf+' '+e.dir+e.filename+'.'+e.ext;
Expand All @@ -240,6 +242,14 @@ s.ffmpeg=function(y,e,x){
};
x.tmp='-loglevel quiet -i '+e.url+' -stimeout 2000'+x.watch+' -f image2pipe -vf '+x.svf+' -s '+e.ratio+' pipe:1';
break;
case'local':
if(e.mode=='record'){
x.watch=' -r '+e.fps+' -acodec '+x.acodec+' -movflags frag_keyframe+empty_moov -vcodec '+x.vcodec+' -s '+e.width+'x'+e.height+' -use_wallclock_as_timestamps 1 -q:v 1'+x.vf+' '+e.dir+e.filename+'.'+e.ext
}else{
x.watch='';
};
x.tmp='-loglevel warning -i '+e.path+''+x.watch+' -f image2pipe -vf '+x.svf+' -s '+e.ratio+' pipe:1';
break;
}
return x.tmp.split(' ');
break;
Expand Down Expand Up @@ -403,7 +413,7 @@ s.camera=function(x,e,cn,tx){
}
e.frames=0;
if(!s.users[e.ke].mon[e.id].record){s.users[e.ke].mon[e.id].record={yes:1}};
if(x==='record'||e.type==='mjpeg'||e.type==='h264'){s.users[e.ke].mon[e.id].spawn = spawn('ffmpeg',s.ffmpeg('args',e));}
if(x==='record'||e.type==='mjpeg'||e.type==='h264'||e.type==='local'){s.users[e.ke].mon[e.id].spawn = spawn('ffmpeg',s.ffmpeg('args',e));}
switch(e.type){
case'jpeg':
e.captureOne=function(f){
Expand All @@ -430,7 +440,7 @@ s.camera=function(x,e,cn,tx){
}
e.captureOne()
break;
case'mjpeg':case'h264':case'socket':
case'mjpeg':case'h264':case'socket':case'local':
if(!s.users[e.ke]||!s.users[e.ke].mon[e.id]){s.init(0,e)}
if(s.users[e.ke].mon[e.id].spawn){
s.users[e.ke].mon[e.id].spawn.on('error',function(er){e.error({type:'Spawn Error',msg:er})})
Expand Down
2 changes: 1 addition & 1 deletion sql/framework.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS `Monitors` (
`shto` text,
`shfr` text,
`details` longtext,
`type` enum('jpeg','mjpeg','h264','socket') DEFAULT 'jpeg',
`type` varchar(50) DEFAULT 'jpeg',
`ext` enum('webm','mp4') DEFAULT 'webm',
`protocol` enum('http','https','rtmp','rtsp','axrtsp','axrtpu','axrtsphttp','axrtpm') DEFAULT 'http',
`host` varchar(100) DEFAULT '0.0.0.0',
Expand Down
21 changes: 18 additions & 3 deletions web/libs/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,25 @@ $.aM.f.find('[name="type"]').change(function(e){
})
$.aM.md=$.aM.f.find('[detail]');
$.aM.md.change($.ccio.form.details)
$.aM.f.find('[name="ext"]').change(function(e){
e.v=$(this).val();
$.aM.f.find('.h_f_input').hide()
$.aM.f.find('.h_f_'+e.v).show();
});
$.aM.f.find('[name="type"]').change(function(e){
e.e=$.aM.f.find('.not-socket');
if($(this).val()==='socket'){e.e.hide()}else{e.e.show()}
})
e.v=$(this).val();
$.aM.f.find('.h_t_input').hide()
$.aM.f.find('.h_t_'+e.v).show();
e.h=$.aM.f.find('[name="path"]');
switch(e.v){
case'local':
e.h.attr('placeholder','/dev/video0')
break;
default:
e.h.attr('placeholder','/videostream.cgi?1')
break;
}
});
$.aM.f.find('[name="protocol"]').change(function(e){
e.e=$(this);e.v=e.e.val(),e.t=$.aM.f.find('[name="type"]');
// $.aM.f.find('[name="ext"],[name="type"]').prop('disabled',false)
Expand Down
37 changes: 27 additions & 10 deletions web/pages/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,37 @@ <h4 class="modal-title" id="add_monitorLabel"><i class="fa fa-plus"></i> &nbsp;
<option value="mjpeg">MJPEG</option>
<option value="h264">H.264</option>
<option value="socket">Shinobi Streamer</option>
<option value="local">Local</option>
</select>
</label>
</div>
<div class="form-group">
<label><span>File Type</span>
<select class="form-control" name="ext">
<option value="webm">WebM (libvpx)</option>
<option value="mp4">MP4 (libx264)</option>
<option value="mp4">MP4 (copy, libx264, libx265)</option>
</select>
</label>
</div>
<div class="not-socket">
<div class="form-group">
<div class="form-group h_f_input h_f_mp4">
<label><span>Video Codec</span>
<select class="form-control" detail="vcodec">
<option value="">Auto</option>
<option value="libx264">libx264</option>
<option value="libx265">libx265</option>
</select>
</label>
</div>
<div class="form-group h_f_input h_f_mp4">
<label><span>Audio Codec</span>
<select class="form-control" detail="acodec">
<option value="">Auto</option>
<option value="libfaac">libfaac</option>
<option value="aac">aac</option>
</select>
</label>
</div>
<div class="form-group h_t_input h_t_h264 h_t_jpeg h_t_mjpeg">
<label><span>Connection Type</span>
<select class="form-control" name="protocol">
<option value="http">HTTP</option>
Expand All @@ -217,38 +235,37 @@ <h4 class="modal-title" id="add_monitorLabel"><i class="fa fa-plus"></i> &nbsp;
</select>
</label>
</div>
<div class="form-group">
<div class="form-group h_t_input h_t_h264 h_t_jpeg h_t_mjpeg">
<label><span>Host</span>
<input class="form-control" name="host" placeholder="111.111.111.111">
</label>
</div>
<div class="form-group">
<div class="form-group h_t_input h_t_h264 h_t_jpeg h_t_mjpeg h_t_local">
<label><span>Path</span>
<input class="form-control" name="path" placeholder="/videostream.cgi?1">
</label>
</div>
<div class="form-group">
<div class="form-group h_t_input h_t_h264 h_t_jpeg h_t_mjpeg">
<label><span>Port</span>
<input class="form-control" name="port" placeholder="Leave blank for Port 80">
</label>
</div>
<div class="form-group">
<div class="form-group h_t_input h_t_h264 h_t_jpeg h_t_mjpeg">
<label><span>Image Width</span>
<input class="form-control" name="width">
</label>
</div>
<div class="form-group">
<div class="form-group h_t_input h_t_h264 h_t_jpeg h_t_mjpeg">
<label><span>Image Height</span>
<input class="form-control" name="height">
</label>
</div>
</div>
<div class="form-group">
<label><span>Record Speed (FPS)</span>
<input class="form-control" name="fps">
</label>
</div>
<div class="form-group">
<div class="form-group h_t_input h_t_socket">
<label><span>Streamer Capture Rate <small>in Milliseconds</small></span>
<input class="form-control" detail="sfps">
</label>
Expand Down
18 changes: 18 additions & 0 deletions web/pages/streamer.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,18 @@
},$.ccio.framerate);
$('[record]').unbind('click').click($.ccio.end)
};







$.ccio.vid = {e:$('#video'),c:$('#canvas')};
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia||navigator.mediaDevices.getUserMedia;
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
navigator.getUserMedia({video: true},function(stream,fn) {
//set video element
if ($.ccio.vid.e[0].mozSrcObject !== undefined) {
$.ccio.vid.e[0].mozSrcObject = stream;
} else {
Expand All @@ -70,6 +78,16 @@
$('[record]').click($.ccio.start)
})
}, function(err){console.error('getUserMedia',err)});










//draw selectable mons
var tmp='';
if($user.mons&&$user.mons.length>0){
Expand Down

0 comments on commit 7dc713d

Please sign in to comment.