Exemplo n.º 1
0
 public string GetVideoByCode(string code, string id)
 {
     return(VideoUtility.GetClientVideo(id)
            .FirstOrDefault(v => v.Code == code) ?
            .Url
            .Replace(_videoPath, "~/Videos"));
 }
        public IHttpActionResult UploadVideo()
        {
            var files = HttpContext.Current.Request.Files;

            if (files.Count == 0)
            {
                return(Response(new { Success = false }));
            }

            var file = files[0];
            //and it's name
            var fileName = file.FileName;


            //file extension and it's type
            var fileExtension = Path.GetExtension(fileName);

            if (!string.IsNullOrEmpty(fileExtension))
            {
                fileExtension = fileExtension.ToLowerInvariant();
            }

            var contentType = file.ContentType;

            if (string.IsNullOrEmpty(contentType))
            {
                contentType = VideoUtility.GetContentType(fileExtension);
            }

            if (contentType == string.Empty)
            {
                return(Response(new { Success = false }));
            }

            var bytes = new byte[file.ContentLength];

            file.InputStream.Read(bytes, 0, bytes.Length);

            //create a new media
            var media = new Media()
            {
                MediaType   = MediaType.Video,
                Binary      = bytes,
                MimeType    = contentType,
                Name        = fileName,
                UserId      = _workContext.CurrentCustomer.Id,
                DateCreated = DateTime.UtcNow
            };

            _mediaService.WriteVideoBytes(media);
            //insert now
            _mediaService.Insert(media);
            return(Response(new {
                Success = true,
                Video =
                    media.ToModel(_mediaService, _mediaSettings, _workContext, _storeContext, _userService,
                                  _customerProfileService, _customerProfileViewService, _customerFollowService, _friendService,
                                  _commentService, _likeService, _pictureService, Url, _webHelper)
            }));
        }
Exemplo n.º 3
0
        public string SetVideos(IEnumerable <string> codes, string id, DateTime startTime, DateTime endTime)
        {
            //_reservation
            if (startTime > DateTime.Now)
            {
                _reservation.AddClientReservation(id, startTime, endTime, codes);
                return(VideoUtility.GetConnectionIdByIp(id));
            }
            var videos = new List <Video>();

            foreach (var code in codes)
            {
                var video = videos
                            .Where(w => w.Code == code);

                if (video.Any())
                {
                    videos.Add(video.First());
                }
            }

            VideoUtility.UpdateVideo(id, videos);
            VideoUtility.UpdateActiveStatus(id, true);
            return(VideoUtility.GetConnectionIdByIp(id));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> SetVideo([FromBody] SetParams setParams)
        {
            var ipInfo = _service.GetClientIdentities()
                         .FirstOrDefault(i => i.Id.ToString() == setParams.Id);

            if (ipInfo == null)
            {
                return(new JsonResult("No client."));
            }

            var ip = ipInfo.Ip;

            _service.SetVideos(setParams.Codes, ip, _videoPath);

            var ips = VideoUtility.GetClientConnetionIdDic();

            if (!ips.ContainsKey(ip))
            {
                return(new JsonResult("No online client."));
            }

            await _videoHub.Clients.Client(ips[ip])
            .PlayVideo(_service.GetVideoListByIp(ip)
                       .Select(VideoToViewModel));

            return(new JsonResult("Ok"));
        }
        public IHttpActionResult UploadVideo()
        {
            var files = HttpContext.Current.Request.Files;

            if (files.Count == 0)
            {
                VerboseReporter.ReportError("No file uploaded", "upload_videos");
                return(RespondFailure());
            }

            var file = files[0];
            //and it's name
            var fileName = file.FileName;


            //file extension and it's type
            var fileExtension = Path.GetExtension(fileName);

            if (!string.IsNullOrEmpty(fileExtension))
            {
                fileExtension = fileExtension.ToLowerInvariant();
            }

            var contentType = file.ContentType;

            if (string.IsNullOrEmpty(contentType))
            {
                contentType = VideoUtility.GetContentType(fileExtension);
            }

            if (contentType == string.Empty)
            {
                VerboseReporter.ReportError("Invalid file type", "upload_videos");
                return(RespondFailure());
            }

            var bytes = new byte[file.ContentLength];

            file.InputStream.Read(bytes, 0, bytes.Length);

            //create a new media
            var media = new Media()
            {
                MediaType   = MediaType.Video,
                Binary      = bytes,
                MimeType    = contentType,
                Name        = fileName,
                UserId      = ApplicationContext.Current.CurrentUser.Id,
                DateCreated = DateTime.UtcNow
            };

            _mediaService.WriteVideoBytes(media);
            //insert now
            _mediaService.Insert(media);
            return(RespondSuccess(new
            {
                Media = media.ToModel(_mediaService, _mediaSettings)
            }));
        }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="infourcc"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public NV12FromXXXXConverter(FourCC infourcc, int width, int height)
 {
     this.h        = height;
     this.w        = width;
     this.infourcc = infourcc;
     nv12buf       = new byte[height * width * VideoUtility.GetBitsPerPixel(FourCC.NV12) / 8];
     llconverter   = new NV12FromXXXXLowLevelConverter();
 }
Exemplo n.º 7
0
        public IHttpActionResult UploadVideo()
        {
            var files = HttpContext.Current.Request.Files;

            if (files.Count == 0)
            {
                VerboseReporter.ReportError("No file uploaded", "upload_videos");
                return(RespondFailure());
            }

            var file = files[0];
            //and it's name
            var fileName = file.FileName;


            //file extension and it's type
            var fileExtension = Path.GetExtension(fileName);

            if (!string.IsNullOrEmpty(fileExtension))
            {
                fileExtension = fileExtension.ToLowerInvariant();
            }

            var contentType = file.ContentType;

            if (string.IsNullOrEmpty(contentType))
            {
                contentType = VideoUtility.GetContentType(fileExtension);
            }

            if (contentType == string.Empty)
            {
                VerboseReporter.ReportError("Invalid file type", "upload_videos");
                return(RespondFailure());
            }

            var bytes = new byte[file.ContentLength];

            file.InputStream.Write(bytes, 0, file.ContentLength);

            //create a new media
            var media = new Media()
            {
                MediaType = MediaType.Video,
                Binary    = bytes,
                MimeType  = contentType,
                Name      = fileName
            };

            _mediaService.WriteVideoBytes(media);

            return(RespondSuccess(new {
                VideoId = media.Id,
                VideoUrl = WebHelper.GetUrlFromPath(media.LocalPath, _generalSettings.VideoServerDomain),
                ThumbnailUrl = WebHelper.GetUrlFromPath(media.ThumbnailPath, _generalSettings.ImageServerDomain),
                MimeType = file.ContentType
            }));
        }
Exemplo n.º 8
0
        public static string GetMountedVideoDiscPath(string imagePath)
        {
            if (!IsMounted(imagePath))
            {
                return(null);
            }

            string drive = DaemonTools.GetVirtualDrive();

            return(VideoUtility.GetVideoPath(drive));
        }
Exemplo n.º 9
0
        public IHttpActionResult UploadVideo()
        {
            var files = HttpContext.Current.Request.Files;

            if (files.Count == 0)
            {
                return(Response(new { Success = false, Message = "No file uploaded" }));
            }

            var file = files[0];
            //and it's name
            var fileName = file.FileName;


            //file extension and it's type
            var fileExtension = Path.GetExtension(fileName);

            if (!string.IsNullOrEmpty(fileExtension))
            {
                fileExtension = fileExtension.ToLowerInvariant();
            }

            var contentType = file.ContentType;

            if (string.IsNullOrEmpty(contentType))
            {
                contentType = VideoUtility.GetContentType(fileExtension);
            }

            if (contentType == string.Empty)
            {
                return(Response(new { Success = false, Message = "Invalid file type" }));
            }

            var tickString = DateTime.Now.Ticks.ToString();
            var savePath   = ControllerUtil.MobSocialPluginsFolder + "Uploads/" + tickString + fileExtension;

            file.SaveAs(HostingEnvironment.MapPath(savePath));

            //wanna generate the thumbnails for videos...ffmpeg is our friend
            var ffmpeg            = new FFMpegConverter();
            var thumbnailFilePath = ControllerUtil.MobSocialPluginsFolder + "Uploads/" + tickString + ".thumb.jpg";

            ffmpeg.GetVideoThumbnail(HostingEnvironment.MapPath(savePath), HostingEnvironment.MapPath(thumbnailFilePath));
            //save the picture now

            return(Json(new {
                Success = true,
                VideoUrl = savePath.Replace("~", ""),
                ThumbnailUrl = thumbnailFilePath.Replace("~", ""),
                MimeType = file.ContentType
            }));
        }
Exemplo n.º 10
0
        private void Init()
        {
            foreach (var identity in _clientIdentity.GetAll())
            {
                VideoUtility.AddClientIdentity(identity);
            }

            foreach (var category in _category.GetAll())
            {
                _videoPath.InitDirectory(category.Name)
                .InitDirectory(DateTime.Now.ToString("yyyyMMdd"));
            }
        }
Exemplo n.º 11
0
        public Media GetMediaInstance(IFormFile mediaFile, int userId)
        {
            byte[] fileBytes;
            using (var stream = new MemoryStream())
            {
                mediaFile.CopyTo(stream);
                fileBytes = stream.ToArray();
            }

            var saveDirectory = ServerHelper.MapPath(ApplicationConfig.MediaDirectory, true);
            var fileName      = SafeWriteBytesToFile(mediaFile.FileName, saveDirectory, fileBytes);

            //file extension and it's type
            var fileExtension = _localFileProvider.GetExtension(mediaFile.FileName);

            if (!string.IsNullOrEmpty(fileExtension))
            {
                fileExtension = fileExtension.ToLowerInvariant();
            }

            var contentType = mediaFile.ContentType;

            //an image?
            if (string.IsNullOrEmpty(contentType))
            {
                contentType = PictureUtility.GetContentType(fileExtension);
            }
            //no? a video?
            if (string.IsNullOrEmpty(contentType))
            {
                contentType = VideoUtility.GetContentType(fileExtension);
            }
            //no? let it be default one then
            if (string.IsNullOrEmpty(contentType))
            {
                contentType = "application/octet-stream";
            }
            var media = new Media()
            {
                MimeType        = contentType,
                UserId          = userId,
                Name            = mediaFile.FileName,
                CreatedOn       = DateTime.UtcNow,
                SystemName      = fileName,
                AlternativeText = mediaFile.FileName
            };

            media.ThumbnailPath = GetPictureUrl(media, 150, 150, true);
            media.LocalPath     = GetPictureUrl(media, 0, 0, true);
            return(media);
        }
Exemplo n.º 12
0
        // Start playback of a file (detects format first)
        public void playFile(string media)
        {
            VideoFormat videoFormat = VideoUtility.GetVideoFormat(media);

            if (videoFormat != VideoFormat.NotSupported)
            {
                playFile(media, videoFormat);
            }
            else
            {
                logger.Warn("'{0}' is not a playable video file.", media);
                resetPlayer();
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Takes
        /// </summary>
        /// <param name="nv12surf"></param>
        /// <param name="srcframe"></param>
        /// <param name="offset"></param>
        public unsafe void ConvertToNV12FrameSurface(ref mfxFrameSurface1 nv12surf, byte[] srcframe, int offset)
        {
            int compactFrameSize = w * h * VideoUtility.GetBitsPerPixel(infourcc) / 8;

            //Trace.Assert(srcframe.Length == compactFrameSize);

            // expect by caller
            //encoder.LockFrame(f);
            fixed(byte *frameptr = &srcframe[offset])
            {
                byte *nv12   = (byte *)nv12surf.Data.Y;
                byte *nv12uv = (byte *)nv12surf.Data.UV;

                llconverter.ConvertToNV12FrameSurface(infourcc, nv12surf.Data.Pitch, w, h, frameptr, nv12, nv12uv);
            }

            //encoder.UnlockFrame(f);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Convert a non-NV12 raw frame to NV12. for RGB3, I420, etc...
        /// </summary>
        /// <param name="inbuf">Raw frame</param>
        /// <param name="allocateNewArray">True = allocate a new array on each call</param>
        public unsafe byte[] ConvertToNV12(byte[] inbuf, bool allocateNewArray = true)
        {
            int inbuflen = h * w * VideoUtility.GetBitsPerPixel(infourcc) / 8;

            Trace.Assert(inbuf.Length == inbuflen);

            byte[] buf = nv12buf;

            if (allocateNewArray)
            {
                buf = new byte[nv12buf.Length];


                fixed(byte *nv12 = buf)
                fixed(byte *srcframe = inbuf)
                llconverter.ConvertToNV12FrameSurface(infourcc, w, w, h, srcframe, nv12, nv12 + w * h);

                return(buf);
        }
    }
Exemplo n.º 15
0
        private string getCustomIntroFile(string path)
        {
            try {
                if (File.Exists(path))
                {
                    return(path);
                }
                if (Directory.Exists(path))
                {
                    Random          r      = new Random();
                    List <FileInfo> videos = VideoUtility.GetVideoFilesRecursive(new DirectoryInfo(path));
                    if (videos.Count == 0)
                    {
                        return(null);
                    }
                    return(videos[r.Next(videos.Count)].FullName);
                }
            }
            catch (Exception e) {
                logger.Error("Unexpected error searching for custom intro: " + e.Message);
            }

            return(null);
        }
Exemplo n.º 16
0
 public IEnumerable <ClientIdentity> GetClientIdentities()
 {
     return(VideoUtility.GetAllClientInfo());
 }
Exemplo n.º 17
0
 public IEnumerable <Video> GetVideoListById(string id)
 {
     return(VideoUtility.GetClientVideo(id));
 }
Exemplo n.º 18
0
 public void RemoveConnetionId(string id)
 {
     VideoUtility.RemoveConnetionId(id);
 }
Exemplo n.º 19
0
 public void UpdateOnlineStatus(string id, bool isOnline)
 {
     VideoUtility.UpdateOnlineStatus(id, isOnline);
 }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            ConfirmQuickSyncReadiness.HaltIfNotReady();

            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
            // keep ascending directories until 'media' folder is found
            for (int i = 0; i < 10 && !Directory.Exists("Media"); i++)
            {
                Directory.SetCurrentDirectory("..");
            }
            Directory.SetCurrentDirectory("Media");


            int     width, height;
            string  inFilename;
            mfxIMPL impl   = mfxIMPL.MFX_IMPL_AUTO;
            FourCC  fourcc = FourCC.NV12;   // supported: RGB3 RGB4 BGR4 BGR3 NV12 I420 IYUV YUY2 UYVY YV12 P411 P422

            inFilename = "BigBuckBunny_320x180." + fourcc + ".yuv"; width = 320; height = 180;
            //inFilename = "BigBuckBunny_1920x1080." + fourcc + ".yuv"; width = 1920; height = 1080;


            string outFilename = Path.ChangeExtension(inFilename, "enc.264");


            Console.WriteLine("Working directory: {0}", Environment.CurrentDirectory);
            Console.WriteLine("Input filename: {0}", inFilename);
            Console.WriteLine("Input width: {0}  Input height: {1}", width, height);
            Console.WriteLine();

            if (!File.Exists(inFilename))
            {
                Console.WriteLine("Input file not found.");
                Console.WriteLine("Please let Decoder1 run to completion to create input file");
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
                return;
            }


            Stream         infs, outfs;
            BenchmarkTimer bt = null;


#if !ENABLE_BENCHMARK
            infs  = File.Open(inFilename, FileMode.Open);
            outfs = File.Open(outFilename, FileMode.Create);
#else       // delete this code for most simple example
            // * Benchmark Mode *
            // this block does a couple things:
            //   1. causes the file to be pre-read into memory so we are not timing disk reads.
            //   2. replaces the output stream with a NullStream so nothing gets written to disk.
            //   3. Starts the timer for benchmarking
            // this pre-reads file into memory for benchmarking
            long maximumMemoryToAllocate = (long)4L * 1024 * 1024 * 1024;
            Console.WriteLine("Pre-reading input");
            infs = new PreReadLargeMemoryStream(File.Open(inFilename, FileMode.Open), maximumMemoryToAllocate);
            Console.WriteLine("Input read");

            outfs = new NullStream();
            bt    = new BenchmarkTimer();
            bt.Start();

            int minimumFrames = 4000;
#endif
            Console.WriteLine("Output filename: {0}",
                              Path.GetFileName((outfs as FileStream)?.Name ?? "NO OUTPUT"));
            Console.WriteLine();


            mfxVideoParam mfxEncParams = new mfxVideoParam();
            mfxEncParams.mfx.CodecId                 = CodecId.MFX_CODEC_AVC;
            mfxEncParams.mfx.TargetUsage             = TargetUsage.MFX_TARGETUSAGE_BALANCED;
            mfxEncParams.mfx.TargetKbps              = 2000;
            mfxEncParams.mfx.RateControlMethod       = RateControlMethod.MFX_RATECONTROL_VBR;
            mfxEncParams.mfx.FrameInfo.FrameRateExtN = 30;
            mfxEncParams.mfx.FrameInfo.FrameRateExtD = 1;
            mfxEncParams.mfx.FrameInfo.FourCC        = FourCC.NV12;
            mfxEncParams.mfx.FrameInfo.ChromaFormat  = ChromaFormat.MFX_CHROMAFORMAT_YUV420;
            mfxEncParams.mfx.FrameInfo.PicStruct     = PicStruct.MFX_PICSTRUCT_PROGRESSIVE;
            mfxEncParams.mfx.FrameInfo.CropX         = 0;
            mfxEncParams.mfx.FrameInfo.CropY         = 0;
            mfxEncParams.mfx.FrameInfo.CropW         = (ushort)width;
            mfxEncParams.mfx.FrameInfo.CropH         = (ushort)height;
            // Width must be a multiple of 16
            // Height must be a multiple of 16 in case of frame picture and a multiple of 32 in case of field picture
            mfxEncParams.mfx.FrameInfo.Width  = QuickSyncStatic.ALIGN16(width);
            mfxEncParams.mfx.FrameInfo.Height = QuickSyncStatic.AlignHeightTo32or16(height, mfxEncParams.mfx.FrameInfo.PicStruct);
            mfxEncParams.IOPattern            = IOPattern.MFX_IOPATTERN_IN_SYSTEM_MEMORY; // must be 'in system memory'
            mfxEncParams.AsyncDepth           = 4;                                        // Pipeline depth. Best at 4


            BitStreamChunk bsc = new BitStreamChunk(); //where we receive compressed frame data

            //var encoder = new LowLevelEncoder2(mfxEncParams, impl);
            ILowLevelEncoder encoder = new LowLevelEncoder(mfxEncParams, impl);


            string impltext = QuickSyncStatic.ImplementationString(encoder.session);
            Console.WriteLine("Implementation = {0}", impltext);
            //string memtext = QuickSyncStatic.ImplementationString(encoder.deviceSetup.memType);
            //Console.WriteLine("Memory type = {0}", memtext);

            var formatConverter = new NV12FromXXXXConverter(fourcc, width, height);


            int inputFrameLength = width * height * VideoUtility.GetBitsPerPixel(fourcc) / 8;

            byte[] uncompressed = new byte[inputFrameLength];

            int count = 0;

            while (infs.Read(uncompressed, 0, inputFrameLength) == inputFrameLength)
            {
                int ix = encoder.GetFreeFrameIndex();  //get index of free surface

                formatConverter.ConvertToNV12FrameSurface(ref encoder.Frames[ix], uncompressed, 0);

                encoder.EncodeFrame(ix, ref bsc);

                if (bsc.bytesAvailable > 0)
                {
                    outfs.Write(bsc.bitstream, 0, bsc.bytesAvailable);

                    if (++count % 100 == 0)
                    {
                        Console.Write("Frame {0}\r", count);
                    }
                }

#if ENABLE_BENCHMARK     // delete this code for most simple example
                if (infs.Position + inputFrameLength - 1 >= infs.Length)
                {
                    infs.Position = 0;
                }
                if (count >= minimumFrames)
                {
                    break;
                }
#endif
            }



            while (encoder.Flush(ref bsc))
            {
                if (bsc.bytesAvailable > 0)
                {
                    outfs.Write(bsc.bitstream, 0, bsc.bytesAvailable);

                    if (++count % 100 == 0)
                    {
                        Console.Write("Frame {0}\r", count);
                    }
                }
            }

            if (bt != null)
            {
                bt.StopAndReport(count, infs.Position, outfs.Position);
            }

            infs.Close();
            outfs.Close();

            encoder.Dispose();

            Console.WriteLine("Encoded {0} frames", count);

            if (Debugger.IsAttached)
            {
                Console.WriteLine("done - press a key to exit");
                Console.ReadKey();
            }
        }
Exemplo n.º 21
0
        public List <DBLocalMedia> GetLocalMedia(bool returnOnlyNew)
        {
            logger.Debug("Scanning: {0}", Directory.FullName);

            // default values
            string volume = string.Empty;
            string label  = string.Empty;
            string serial = string.Empty;
            string format = string.Empty;

            // validate the import path
            if (!_replaced && this.IsAvailable)
            {
                if (!this.IsUnc)
                {
                    // Logical volume (can be a mapped network share)
                    int retry = 0;
                    while (serial == string.Empty)
                    {
                        // Grab information for this logical volume
                        DriveInfo driveInfo = Directory.GetDriveInfo();
                        if (driveInfo != null && driveInfo.IsReady)
                        {
                            // get the volume properties
                            volume = driveInfo.GetDriveLetter();
                            label  = driveInfo.VolumeLabel;
                            serial = driveInfo.GetVolumeSerial();
                            format = driveInfo.DriveFormat;
                            logger.Debug("Drive='{0}', Label='{1}', Serial='{2}', Format='{3}'", volume, label, serial, format);
                        }

                        // check if the serial is empty
                        // logical volumes SHOULD have a serial number or something went wrong
                        // Currently the only exception is when a NDFS filesystem is detected to cover the special case of network paths mounted by 3rd party programs
                        // todo: to prevent more exceptions in the future we should keep an eye out for these special cases and come up with a better solution
                        if (serial == string.Empty && format != "NDFS")
                        {
                            // If we tried 3 times already then we should report a failure
                            if (retry == 3)
                            {
                                logger.Error("Canceled scan for '{0}': Could not get required volume information.", Directory.FullName);
                                return(null);
                            }

                            // up the retry count and wait for 1 second
                            retry++;
                            Thread.Sleep(1000);
                            logger.Debug("Retrying: {1} ({0})", Directory.FullName, retry);
                        }
                    }
                } // todo: for UNC paths we could consider using the host part of the UNC path as the MediaLabel (ex. '//SomeHost/../..' => 'SomeHost')
            }
            else
            {
                if (this.IsRemovable)
                {
                    if (this.IsUnc)
                    {
                        // network share
                        logger.Info("Skipping scan for '{0}': the share is offline.", Directory.FullName);
                    }
                    else if (this.IsOpticalDrive)
                    {
                        // optical drive
                        logger.Info("Skipping scan for '{0}': the drive is empty.", Directory.FullName);
                    }
                    else
                    {
                        // all other removable paths
                        logger.Info("Skipping scan for '{0}': the volume is disconnected.", Directory.FullName);
                    }
                }
                else
                {
                    logger.Error("Scan for '{0}' was cancelled because the import path is not available.", Directory.FullName);
                }

                // returning nothing
                return(null);
            }

            // Grab the list of files and validate them
            List <DBLocalMedia> rtn = new List <DBLocalMedia>();

            try {
                List <FileInfo> fileList = null;

                // When the option to ignore interactive content is enabled (applies to optical drives that are internally managed)
                // we first check for known video formats (DVD, Bluray etc..) before we are going to scan for all files on the disc.
                if (MovingPicturesCore.Settings.IgnoreInteractiveContentOnVideoDisc && IsOpticalDrive && InternallyManaged)
                {
                    string videoPath = VideoUtility.GetVideoPath(Directory.FullName);
                    if (VideoUtility.IsVideoDisc(videoPath))
                    {
                        // if we found one we can safely asume by standards that this will be the
                        // only valid video file on the disc so we create the filelist and add only this file
                        fileList = new List <FileInfo>();
                        fileList.Add(new FileInfo(videoPath));
                    }
                }

                // if the fileList is null it means that we didn't find an 'exclusive' video file above
                // and we are going to scan the whole tree
                if (fileList == null)
                {
                    fileList = VideoUtility.GetVideoFilesRecursive(Directory);
                }

                // go through the video file list
                DriveType type = GetDriveType();
                foreach (FileInfo videoFile in fileList)
                {
                    // Create or get a localmedia object from the video file path
                    DBLocalMedia newFile = DBLocalMedia.Get(videoFile.FullName, serial);

                    // The file is in the database
                    if (newFile.ID != null)
                    {
                        // for optical paths + DVD we have to check the actual DiscId
                        // todo: add bluray disc id support
                        if (IsOpticalDrive)
                        {
                            if ((newFile.IsDVD) && !newFile.IsAvailable)
                            {
                                string discId = newFile.VideoFormat.GetIdentifier(newFile.FullPath);
                                // Create/get a DBLocalMedia object using the the DiscID
                                newFile = DBLocalMedia.GetDisc(videoFile.FullName, discId);
                            }
                        }

                        // If the file is still in the database continue if we only want new files
                        if (newFile.ID != null && returnOnlyNew)
                        {
                            continue;
                        }
                    }
                    else if (!IsOpticalDrive && !IsUnc)
                    {
                        // Verify the new file, if we find a similar file it could be that the serial has changed
                        List <DBLocalMedia> otherFiles = DBLocalMedia.GetAll(newFile.FullPath);
                        if (otherFiles.Count == 1)
                        {
                            DBLocalMedia otherFile = otherFiles[0];
                            if (type != DriveType.Unknown && type != DriveType.CDRom && type != DriveType.NoRootDirectory)
                            {
                                bool fileAvailable = otherFile.IsAvailable;
                                if ((String.IsNullOrEmpty(otherFile.VolumeSerial) && fileAvailable) || (!fileAvailable && File.Exists(otherFile.FullPath)))
                                {
                                    // the disk serial was updated for this file
                                    otherFile.VolumeSerial = serial;
                                    otherFile.MediaLabel   = label;
                                    otherFile.Commit();
                                    logger.Info("Disk information updated for '{0}'", otherFile.FullPath);
                                    continue;
                                }
                            }
                        }
                    }

                    // NEW FILE

                    // Add additional file information
                    newFile.ImportPath   = this;
                    newFile.VolumeSerial = serial;
                    newFile.MediaLabel   = label;

                    // add the localmedia object to our return list
                    logger.Debug("New File: {0}", videoFile.Name);
                    rtn.Add(newFile);
                }
            }
            catch (Exception e) {
                if (e.GetType() == typeof(ThreadAbortException))
                {
                    throw e;
                }


                if (logger.IsDebugEnabled)
                {
                    // In debug mode we log the geeky version
                    logger.DebugException("Error scanning '" + Directory.FullName + "'", e);
                }
                else
                {
                    // In all other modes we do it more friendlier
                    logger.Error("Error scanning '{0}': {1}", Directory.FullName, e.Message);
                }
            }

            return(rtn);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Convert an NV12 frame to another fourcc format
        /// </summary>
        /// <param name="destFourcc">One of NV12 RGB3 RGB4 UYVY YUY2 YV12 BGR3 P411 P422 I420_IYUV</param>
        /// <param name="Y">Y plane of NV12 input</param>
        /// <param name="UV">UV plane of NV12 input</param>
        /// <param name="outputFramePtr">where output frame goes</param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="outputLen"></param>
        /// <param name="srcPitch">Pitch of the source NV12</param>
        /// <param name="dstPitch">Pitch of the dest frame</param>
        /// <param name="alpha">Only used for formats with sn alpha plane: RGB4, ...</param>
        public unsafe void ConvertFromNV12(FourCC destFourcc, byte *Y, byte *UV, byte *outputFramePtr, int width, int height, int outputLen, int srcPitch = 0, int dstPitch = 0, byte alpha = 255)
        {
            int bitsPerPixel = VideoUtility.GetBitsPerPixel(destFourcc);
            // int dstpitch = bitsPerPixel * width / 8;
            int compactFrameSize = width * height * bitsPerPixel / 8;

            Trace.Assert(outputLen == compactFrameSize);



            //byte* nv12uv = nv12 + width * height;


            roisize.height = height;
            roisize.width  = width;

            NativeResizeConvertStatus sts = NativeResizeConvertStatus.NativeStatusNoErr;



            if (srcPitch == 0)
            {
                srcPitch = width * 1;
            }

            if (dstPitch == 0)
            {
                dstPitch = width * VideoUtility.GetPackedPitchMultiplier(destFourcc);
            }


            switch (destFourcc)
            {
            case FourCC.BGR3:
                sts = NV12Convert.NV12ToBGR3(Y, srcPitch, UV, srcPitch, outputFramePtr, dstPitch, roisize);
                break;

            case FourCC.BGR4:
                sts = NV12Convert.NV12ToBGR4(Y, srcPitch, UV, srcPitch, outputFramePtr, dstPitch, roisize, alpha);
                break;


            case FourCC.RGB4:
                sts = NV12Convert.NV12ToRGB4(Y, srcPitch, UV, srcPitch, outputFramePtr, dstPitch, roisize, alpha);
                break;

            case FourCC.RGB3:
                sts = NV12Convert.NV12ToRGB3(Y, srcPitch, UV, srcPitch, outputFramePtr, dstPitch, roisize);
                break;



            case FourCC.YUY2:
                sts = NV12Convert.NV12ToYUY2(Y, srcPitch, UV, srcPitch, outputFramePtr, dstPitch, roisize);

                break;

            case FourCC.YV12:
                pdst[0] = outputFramePtr;
                // This seems wrong, backwards, maybe a bug in IPP 7.x
                // indicies should be 1,2 not 2,1
                //manual check indicates this is what works correctly 2/22/15
                pdst[2]    = outputFramePtr + height * width;
                pdst[1]    = outputFramePtr + height * width + height * width / 2 / 2;
                dststep[0] = dstPitch;
                dststep[1] = dstPitch / 2;
                dststep[2] = dstPitch / 2;

                fixed(byte **p1 = pdst)
                fixed(int *p2 = dststep)
                sts           = NV12Convert.NV12ToYV12(Y, srcPitch, UV, srcPitch, p1, p2, roisize);

                break;

            case FourCC.UYVY:
                sts = NV12Convert.NV12ToUYVY(Y, srcPitch, UV, srcPitch, outputFramePtr, dstPitch, roisize);
                break;

            case FourCC.I420_IYUV:
                pdst[0]    = outputFramePtr;
                pdst[1]    = outputFramePtr + height * width;
                pdst[2]    = outputFramePtr + height * width + height * width / 2 / 2;
                dststep[0] = dstPitch;
                dststep[1] = dstPitch / 2;
                dststep[2] = dstPitch / 2;

                fixed(byte **p1 = pdst)
                fixed(int *p2 = dststep)
                sts           = NV12Convert.NV12ToYV12(Y, srcPitch, UV, srcPitch, p1, p2, roisize);

                break;

            case FourCC.P411:

                pdst[0]    = outputFramePtr;
                pdst[1]    = outputFramePtr + height * width;
                pdst[2]    = outputFramePtr + height * width + height * width / 4;
                dststep[0] = dstPitch;
                dststep[1] = dstPitch / 4;
                dststep[2] = dstPitch / 4;

                fixed(byte **p1 = pdst)
                fixed(int *p2 = dststep)
                sts           = NV12Convert.NV12ToP411(Y, srcPitch, UV, srcPitch, p1, p2, roisize);

                break;

            case FourCC.P422:
                pdst[0]    = outputFramePtr;
                pdst[1]    = outputFramePtr + height * width;
                pdst[2]    = outputFramePtr + height * width + height * width / 2;
                dststep[0] = dstPitch;
                dststep[1] = dstPitch / 2;
                dststep[2] = dstPitch / 2;

                fixed(byte **p1 = pdst)
                fixed(int *p2 = dststep)
                sts           = NV12Convert.NV12ToP422(Y, srcPitch, UV, srcPitch, p1, p2, roisize);

                break;

            case FourCC.NV12:

                // XXX nonono
                // does not work for pitch!=width  !!
                //memmove(outputFramePtr, Y, height * width);
                //memmove(outputFramePtr + height * width, UV, height * width / 2);
                for (int i = 0; i < height; i++)
                {
                    FastMemcpyMemmove.memcpy(outputFramePtr + i * dstPitch, Y + i * srcPitch, width);
                }
                outputFramePtr += height * dstPitch;
                for (int i = 0; i < height / 2; i++)
                {
                    FastMemcpyMemmove.memcpy(outputFramePtr + i * dstPitch, UV + i * srcPitch, width);
                }
                break;

            default:
                throw new Exception("fourcc conversion not supported, contact Lime Video  support for options");
            }

            if (sts != NativeResizeConvertStatus.NativeStatusNoErr)
            {
                throw new Exception("FourCC convert error:" + sts.ToString());
            }
        }
Exemplo n.º 23
0
        unsafe static void Main(string[] args)
        {
            ConfirmQuickSyncReadiness.HaltIfNotReady();

            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
            // keep ascending directories until 'media' folder is found
            for (int i = 0; i < 10 && !Directory.Exists("Media"); i++)
            {
                Directory.SetCurrentDirectory("..");
            }
            Directory.SetCurrentDirectory("Media");


            CodecId codecId = CodecId.MFX_CODEC_JPEG;
            FourCC  fourcc  = FourCC.UYVY;  // supported: RGB4, YUY2 NV12 [UYVY through tricks! see below]
            mfxIMPL impl    = mfxIMPL.MFX_IMPL_AUTO;


            int    width, height;
            string inFilename;

            //inFilename = "BigBuckBunny_320x180." + fourcc + ".yuv"; width = 320; height = 180;
            inFilename = "BigBuckBunny_1920x1080." + fourcc + ".yuv"; width = 1920; height = 1080;
            string outFilename = Path.ChangeExtension(inFilename, "enc.jpeg");


            Console.WriteLine("Working directory: {0}", Environment.CurrentDirectory);
            Console.WriteLine("Input filename: {0}", inFilename);
            Console.WriteLine("Input width: {0}  Input height: {1}", width, height);


            if (!File.Exists(inFilename))
            {
                Console.WriteLine("Input file not found.");
                Console.WriteLine("Please let Decoder1 run to completion to create input file");
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
                return;
            }


            Stream         infs, outfs;
            BenchmarkTimer bt = null;


#if !ENABLE_BENCHMARK
            infs  = File.Open(inFilename, FileMode.Open);
            outfs = File.Open(outFilename, FileMode.Create);
#else       // delete this code for most simple example
            // * Benchmark Mode *
            // this block does a couple things:
            //   1. causes the file to be pre-read into memory so we are not timing disk reads.
            //   2. replaces the output stream with a NullStream so nothing gets written to disk.
            //   3. Starts the timer for benchmarking
            // this pre-reads file into memory for benchmarking
            long maximumMemoryToAllocate = (long)4L * 1024 * 1024 * 1024;
            Console.WriteLine("Pre-reading input");
            infs = new PreReadLargeMemoryStream(File.Open(inFilename, FileMode.Open), maximumMemoryToAllocate);
            Console.WriteLine("Input read");

            outfs = new NullStream();
            bt    = new BenchmarkTimer();
            bt.Start();

            int minimumFrames = 4000;
#endif

            Console.WriteLine("Output filename: {0}",
                              Path.GetFileName((outfs as FileStream)?.Name ?? "NO OUTPUT"));
            Console.WriteLine();

            // The encoder cannot encode UYVY, but if you are the only decoder of the JPEG
            // files, you can encode UYVY as YUY2 and everything is good.
            if (fourcc == FourCC.UYVY)
            {
                fourcc = FourCC.YUY2;
            }


            mfxVideoParam mfxEncParams = new mfxVideoParam();
            mfxEncParams.mfx.CodecId     = codecId;
            mfxEncParams.mfx.TargetUsage = TargetUsage.MFX_TARGETUSAGE_BALANCED;
            //mfxEncParams.mfx.TargetKbps = 2000;
            //mfxEncParams.mfx.RateControlMethod = RateControlMethod.MFX_RATECONTROL_VBR;
            mfxEncParams.mfx.Quality                 = 90;
            mfxEncParams.mfx.Interleaved             = 1;
            mfxEncParams.mfx.FrameInfo.FrameRateExtN = 30;
            mfxEncParams.mfx.FrameInfo.FrameRateExtD = 1;
            mfxEncParams.mfx.FrameInfo.FourCC        = fourcc;


            switch (fourcc)
            {
            case FourCC.NV12:
            case FourCC.YV12:
                mfxEncParams.mfx.FrameInfo.ChromaFormat = ChromaFormat.MFX_CHROMAFORMAT_YUV420;
                break;

            case FourCC.YUY2:
                mfxEncParams.mfx.FrameInfo.ChromaFormat = ChromaFormat.MFX_CHROMAFORMAT_YUV422V;     // fatal on SKYLAKE!
                mfxEncParams.mfx.FrameInfo.ChromaFormat = ChromaFormat.MFX_CHROMAFORMAT_YUV422;
                break;

            case FourCC.RGB4:
                mfxEncParams.mfx.FrameInfo.ChromaFormat = ChromaFormat.MFX_CHROMAFORMAT_YUV444;
                break;

            default:
                Trace.Assert(false);
                break;
            }


            mfxEncParams.mfx.FrameInfo.PicStruct = PicStruct.MFX_PICSTRUCT_PROGRESSIVE;
            mfxEncParams.mfx.FrameInfo.CropX     = 0;
            mfxEncParams.mfx.FrameInfo.CropY     = 0;
            mfxEncParams.mfx.FrameInfo.CropW     = (ushort)width;
            mfxEncParams.mfx.FrameInfo.CropH     = (ushort)height;
            // Width must be a multiple of 16
            // Height must be a multiple of 16 in case of frame picture and a multiple of 32 in case of field picture
            mfxEncParams.mfx.FrameInfo.Width  = QuickSyncStatic.ALIGN16(width);
            mfxEncParams.mfx.FrameInfo.Height = QuickSyncStatic.AlignHeightTo32or16(height, mfxEncParams.mfx.FrameInfo.PicStruct);
            mfxEncParams.IOPattern            = IOPattern.MFX_IOPATTERN_IN_SYSTEM_MEMORY; // must be 'in system memory'
            mfxEncParams.AsyncDepth           = 4;                                        // Pipeline depth. Best at 4


            mfxEncParams.mfx.FrameInfo.Width  = QuickSyncStatic.ALIGN32(width);
            mfxEncParams.mfx.FrameInfo.Height = QuickSyncStatic.ALIGN32(height);


            BitStreamChunk bsc = new BitStreamChunk(); //where we receive compressed frame data

            ILowLevelEncoder encoder = new LowLevelEncoder(mfxEncParams, impl);
            //ILowLevelEncoder encoder = new LowLevelEncoder(mfxEncParams, impl);


            string impltext = QuickSyncStatic.ImplementationString(encoder.session);
            Console.WriteLine("Implementation = {0}", impltext);


            // not needed for YUY2 encoding
            //var formatConverter = new NV12FromXXXXConverter(fileFourcc, width, height);


            int inputFrameLength = width * height * VideoUtility.GetBitsPerPixel(fourcc) / 8;

            byte[] uncompressed = new byte[inputFrameLength];

            int count = 0;

            // we do not call encoder.LockFrame() and encoder.UnlockFrame() as this example is
            // for system memory.


            while (infs.Read(uncompressed, 0, inputFrameLength) == inputFrameLength)
            {
                int ix = encoder.GetFreeFrameIndex();  //this call relys locks in authoritative array of surf

                //formatConverter.ConvertToNV12FrameSurface(ref encoder.Frames[ix], uncompressed, 0);
                mfxFrameSurface1 *f = (mfxFrameSurface1 *)encoder.Frames[ix];


                switch (fourcc)
                {
                case FourCC.NV12:
                    Trace.Assert(f->Data.Pitch == width * 1);

                    fixed(byte *aa = &uncompressed[0])
                    FastMemcpyMemmove.memcpy(f->Data.Y, (IntPtr)aa, height * width);

                    fixed(byte *aa = &uncompressed[height * width])
                    FastMemcpyMemmove.memcpy(f->Data.UV, (IntPtr)aa, height / 2 * width);

                    break;

                case FourCC.YUY2:

                    Trace.Assert(f->Data.Pitch == width * 2);

                    fixed(byte *aa = &uncompressed[0])
                    FastMemcpyMemmove.memcpy(f->Data.Y, (IntPtr)aa, height * width * 2);

                    break;

                default:
                    Trace.Assert(false);
                    break;
                }

                encoder.EncodeFrame(ix, ref bsc);

                if (bsc.bytesAvailable > 0)
                {
                    outfs.Write(bsc.bitstream, 0, bsc.bytesAvailable);

                    if (++count % 100 == 0)
                    {
                        Console.Write("Frame {0}\r", count);
                    }
                }

#if ENABLE_BENCHMARK     // delete this code for most simple example
                if (infs.Position + inputFrameLength - 1 >= infs.Length)
                {
                    infs.Position = 0;
                }
                if (count >= minimumFrames)
                {
                    break;
                }
#endif
            }

            while (encoder.Flush(ref bsc))
            {
                if (bsc.bytesAvailable > 0)
                {
                    outfs.Write(bsc.bitstream, 0, bsc.bytesAvailable);

                    if (++count % 100 == 0)
                    {
                        Console.Write("Frame {0}\r", count);
                    }
                }
            }

            if (bt != null)
            {
                bt.StopAndReport(count, infs.Position, outfs.Position);
            }

            infs.Close();
            outfs.Close();

            encoder.Dispose();

            Console.WriteLine("Encoded {0} frames", count);

            // make sure program always waits for user, except F5-Release run
            if (Debugger.IsAttached ||
                Environment.GetEnvironmentVariable("VisualStudioVersion") == null)
            {
                Console.WriteLine("done - press a key to exit");
                Console.ReadKey();
            }
        }
        public JsonResult UpdateVideos(string vidName, string vid, bool isCompleted, int userId)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                QuestionViewModel model         = new QuestionViewModel();
                DbfunctionUtility dbfunction    = new DbfunctionUtility(_appSettings);
                VideoUtility      _videoUtility = new VideoUtility(_appSettings, _dbContext);

                if (vidName == "1")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 1, userId, isCompleted);
                    }
                }

                if (vidName == "2")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 2, userId, isCompleted);
                    }
                }

                if (vidName == "3")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 3, userId, isCompleted);
                    }
                }

                if (vidName == "4")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 4, userId, isCompleted);
                    }
                }

                if (vidName == "5")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 5, userId, isCompleted);
                    }
                }

                if (vidName == "6")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 6, userId, isCompleted);
                    }
                }

                if (vidName == "7")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 7, userId, isCompleted);
                    }
                }

                if (vidName == "8")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 8, userId, isCompleted);
                    }
                }

                if (vidName == "9")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 9, userId, isCompleted);
                    }
                }

                if (vidName == "10")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 10, userId, isCompleted);
                    }
                }

                if (vidName == "11")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 11, userId, isCompleted);
                    }
                }

                if (vidName == "12")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 12, userId, isCompleted);
                    }
                }

                if (vidName == "13")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 13, userId, isCompleted);
                    }
                }

                if (vidName == "14")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 14, userId, isCompleted);
                    }
                }

                if (vidName == "15")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 15, userId, isCompleted);
                    }
                }

                if (vidName == "16")
                {
                    if (Convert.ToString(vid) != "0")
                    {
                        _videoUtility.UpdateVideo(vid, 16, userId, isCompleted);
                    }
                }

                if (isCompleted)
                {
                    var videoId             = Convert.ToInt32(vidName);
                    var testId              = _dbContext.tbl_Testvideos.Where(w => w.Id == videoId).Select(s => s.TestId).FirstOrDefault();
                    var testVideoList       = _dbContext.tbl_Testvideos.Where(w => w.TestId == testId).Select(s => s.Id).ToList();
                    var checkUserTestVideos = _dbContext.tbl_AttendentTestVideos.Where(w => w.UserId == userId && testVideoList.Contains(w.VideoId)).Select(s => s.IsCompleted ?? false).ToList();
                    if (checkUserTestVideos.Where(w => w == false).Count() == 0 && checkUserTestVideos.Count() == testVideoList.Count())
                    {
                        response.Message = "C";
                        HttpContext.Session.SetString("ShowTest", "True");
                    }
                    else
                    {
                        response.Message = "I";
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(Json(response));
        }
Exemplo n.º 25
0
 public string CleanVideo(string id)
 {
     VideoUtility.UpdateVideo(id, new List <Video>());
     VideoUtility.UpdateActiveStatus(id, false);
     return(VideoUtility.GetConnectionIdByIp(id));
 }
Exemplo n.º 26
0
 public void AddConnetionId(string id, string connectionId)
 {
     VideoUtility.AddConnetionId(id, connectionId);
 }
Exemplo n.º 27
0
        public IActionResult Videos()
        {
            var videoViewModel = new VideoViewModel();

            var          attendantVideoList = _dbContext.tbl_AttendentTestVideos.Where(w => w.UserId == UserId).ToList();
            var          videoList          = _dbContext.tbl_Testvideos.ToList();
            VideoUtility _videoUtility      = new VideoUtility(_appSettings, _dbContext);

            VideoTimeDuration VideoDetail1  = _videoUtility.GetVideo(attendantVideoList, 1, UserId);
            VideoTimeDuration VideoDetail2  = _videoUtility.GetVideo(attendantVideoList, 2, UserId);
            VideoTimeDuration VideoDetail3  = _videoUtility.GetVideo(attendantVideoList, 3, UserId);
            VideoTimeDuration VideoDetail4  = _videoUtility.GetVideo(attendantVideoList, 4, UserId);
            VideoTimeDuration VideoDetail5  = _videoUtility.GetVideo(attendantVideoList, 5, UserId);
            VideoTimeDuration VideoDetail6  = _videoUtility.GetVideo(attendantVideoList, 6, UserId);
            VideoTimeDuration VideoDetail7  = _videoUtility.GetVideo(attendantVideoList, 7, UserId);
            VideoTimeDuration VideoDetail8  = _videoUtility.GetVideo(attendantVideoList, 8, UserId);
            VideoTimeDuration VideoDetail9  = _videoUtility.GetVideo(attendantVideoList, 9, UserId);
            VideoTimeDuration VideoDetail10 = _videoUtility.GetVideo(attendantVideoList, 10, UserId);
            VideoTimeDuration VideoDetail11 = _videoUtility.GetVideo(attendantVideoList, 11, UserId);
            VideoTimeDuration VideoDetail12 = _videoUtility.GetVideo(attendantVideoList, 12, UserId);
            VideoTimeDuration VideoDetail13 = _videoUtility.GetVideo(attendantVideoList, 13, UserId);
            VideoTimeDuration VideoDetail14 = _videoUtility.GetVideo(attendantVideoList, 14, UserId);
            VideoTimeDuration VideoDetail15 = _videoUtility.GetVideo(attendantVideoList, 15, UserId);
            VideoTimeDuration VideoDetail16 = _videoUtility.GetVideo(attendantVideoList, 16, UserId);

            videoViewModel.Video1  = VideoDetail1.Duration;
            videoViewModel.Video2  = VideoDetail2.Duration;
            videoViewModel.Video3  = VideoDetail3.Duration;
            videoViewModel.Video4  = VideoDetail4.Duration;
            videoViewModel.Video5  = VideoDetail5.Duration;
            videoViewModel.Video6  = VideoDetail6.Duration;
            videoViewModel.Video7  = VideoDetail7.Duration;
            videoViewModel.Video8  = VideoDetail8.Duration;
            videoViewModel.Video9  = VideoDetail9.Duration;
            videoViewModel.Video10 = VideoDetail10.Duration;
            videoViewModel.Video11 = VideoDetail11.Duration;
            videoViewModel.Video12 = VideoDetail12.Duration;
            videoViewModel.Video13 = VideoDetail13.Duration;
            videoViewModel.Video14 = VideoDetail14.Duration;
            videoViewModel.Video15 = VideoDetail15.Duration;
            videoViewModel.Video16 = VideoDetail16.Duration;


            videoViewModel.Video1Completed  = VideoDetail1.Completed;
            videoViewModel.Video2Completed  = VideoDetail2.Completed;
            videoViewModel.Video3Completed  = VideoDetail3.Completed;
            videoViewModel.Video4Completed  = VideoDetail4.Completed;
            videoViewModel.Video5Completed  = VideoDetail5.Completed;
            videoViewModel.Video6Completed  = VideoDetail6.Completed;
            videoViewModel.Video7Completed  = VideoDetail7.Completed;
            videoViewModel.Video8Completed  = VideoDetail8.Completed;
            videoViewModel.Video9Completed  = VideoDetail9.Completed;
            videoViewModel.Video10Completed = VideoDetail10.Completed;
            videoViewModel.Video11Completed = VideoDetail11.Completed;
            videoViewModel.Video12Completed = VideoDetail12.Completed;
            videoViewModel.Video13Completed = VideoDetail13.Completed;
            videoViewModel.Video14Completed = VideoDetail14.Completed;
            videoViewModel.Video15Completed = VideoDetail15.Completed;
            videoViewModel.Video16Completed = VideoDetail16.Completed;


            CareGiverVideoViewModel careGiverVideoViewModel = new CareGiverVideoViewModel();

            careGiverVideoViewModel.Videos = videoViewModel;
            var documents = new List <DocumentViewModel>();

            documents = (from document in _dbContext.tbl_Documents
                         where document.SeasonId == 1
                         select new DocumentViewModel
            {
                DocumentId = document.DocumentId,
                Name = document.Name,
                IsActive = document.IsActive,
                CreatedDate = document.CreatedDate,
                Description = document.Description
            }).ToList();
            careGiverVideoViewModel.Documents = documents;
            return(View(careGiverVideoViewModel));
        }