Beispiel #1
0
        public ActionResult Create([Bind(Include = "id,client_id,device_source_url,source_name,restream_source_url,source_description,camera_control_address,has_audio,mime_type")] source source)
        {
            if (ModelState.IsValid)
            {
                db.sources.Add(source);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(source));
        }
Beispiel #2
0
 public ActionResult DeleteVideo(long id = 0)
 {
     if (id > 0)
     {
         using (db = new video_streamingEntities())
         {
             VideoSteam vs = new VideoSteam();
             vs = db.VideoSteams.Where(m => m.SrNo == id).FirstOrDefault();
             db.VideoSteams.Remove(vs);
             db.SaveChanges();
         }
     }
     return(RedirectToAction("Index", "Home"));
 }
Beispiel #3
0
        public ActionResult Index(HttpPostedFileBase file, FormCollection formCollection)
        {
            VideoSteam video = new VideoSteam();

            if (file != null)
            {
                string path = Server.MapPath("~/Upload/TempUpload/" + file.FileName);
                file.SaveAs(path);

                var    ffmpag = new FFMpegConverter();
                var    tname  = Guid.NewGuid();
                string output = Server.MapPath("~/Upload/TempUpload/" + tname + ".mp4");
                ffmpag.ConvertMedia(path, output, Format.mp4);

                byte[] buffer = new byte[file.ContentLength];
                using (MemoryStream ms = new MemoryStream())
                {
                    using (FileStream tempfile = new FileStream(output, FileMode.Open, FileAccess.Read))
                    {
                        buffer = new byte[tempfile.Length];
                        tempfile.Read(buffer, 0, (int)tempfile.Length);
                        ms.Write(buffer, 0, (int)tempfile.Length);
                    }
                }
                string fname = Guid.NewGuid().ToString();
                string ftype = "mp4";
                using (db = new video_streamingEntities())
                {
                    video.FileName = formCollection["DisplayName"];
                    // video.FileName = fname;
                    video.FileType = ftype;
                    video.Video    = buffer;
                    db.VideoSteams.Add(video);
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("Index", "Home"));
        }