/// <summary> /// 处理Dvr信息 /// </summary> /// <param name="dvrVideo"></param> /// <param name="rs"></param> /// <returns></returns> public static bool OnDvr(DvrVideo dvrVideo) { try { dvrVideo.Deleted = false; dvrVideo.UpdateTime = DateTime.Now; var onPublishList = FastUsefulApis.GetOnPublishMonitorListByDeviceId(dvrVideo.Device_Id !, out ResponseStruct rs); var ret = onPublishList.FindLast(x => x.Client_Id == dvrVideo.Client_Id); if (ret != null) { dvrVideo.ClientIp = ret.MonitorIp; dvrVideo.MonitorType = ret.MonitorType; dvrVideo.RecordDate = DateTime.Now.ToString("yyyy-MM-dd"); } lock (Common.LockDbObjForDvrVideo) { OrmService.Db.Insert(dvrVideo).ExecuteAffrows(); } } catch (Exception ex) { Console.WriteLine("存DVR错误:" + ex.Message); } return(true); }
public int OnDvr(ReqSrsDvr dvr) { DateTime currentTime = DateTime.Now; DvrVideo tmpDvrVideo = new DvrVideo() { Device_Id = dvr.Device_Id, Client_Id = dvr.Client_Id, ClientIp = dvr.Ip, ClientType = ClientType.Monitor, VideoPath = dvr.File, App = dvr.App, Stream = dvr.Stream, Param = dvr.Param, Vhost = dvr.Vhost, Dir = Path.GetDirectoryName(dvr.File), }; FileInfo dvrFile = new FileInfo(dvr.File); tmpDvrVideo.FileSize = dvrFile.Length; if (FFmpegGetDuration.GetDuration(Program.CommonFunctions.FFmpegBinPath, dvr.File !, out long duration)) { tmpDvrVideo.Duration = duration; tmpDvrVideo.StartTime = currentTime.AddMilliseconds(duration * (-1)); tmpDvrVideo.EndTime = currentTime; }
/// <summary> /// 处理Dvr信息 /// </summary> /// <param name="dvrVideo"></param> /// <param name="rs"></param> /// <returns></returns> public static bool OnDvr(DvrVideo dvrVideo) { try { dvrVideo.Deleted = false; dvrVideo.Undo = false; dvrVideo.UpdateTime = DateTime.Now; var onPublishList = FastUsefulApis.GetOnPublishMonitorListByDeviceId(dvrVideo.Device_Id !, out ResponseStruct rs); var ret = onPublishList.FindLast(x => x.Client_Id == dvrVideo.Client_Id); if (ret != null) { dvrVideo.ClientIp = ret.MonitorIp; dvrVideo.MonitorType = ret.MonitorType; dvrVideo.RecordDate = DateTime.Now.ToString("yyyy-MM-dd"); } SrsManager srs = SystemApis.GetSrsManagerInstanceByDeviceId(dvrVideo.Device_Id !); dvrVideo.Url = ":" + srs.Srs.Http_server !.Listen + dvrVideo.VideoPath !.Replace(srs.Srs.Http_server.Dir !, ""); lock (Common.LockDbObjForDvrVideo) { OrmService.Db.Insert(dvrVideo).ExecuteAffrows(); } } catch (Exception ex) { Console.WriteLine("存DVR错误:" + ex.Message); } return(true); }