public string ConvertFile(FileStream fs)
        {
            FfmpegConverter converter  = new FfmpegConverter();
            string          outputpath = ConfigurationManager.AppSettings["OutputPath"].ToString();

            converter.LogPath    = Path.Combine(outputpath, "log.txt");
            converter.FfmpegPath = ConfigurationManager.AppSettings["FFMpegPath"].ToString();
            //Output output = converter.ConvertTo3GP(fs,"h263");
            Output output = converter.ConvertTo3GP(fs);

            if (output.Success)
            {
                FileStream outStream = File.OpenWrite(Path.Combine(outputpath, output.FileName));
                output.VideoStream.WriteTo(outStream);
                outStream.Flush();
                outStream.Close();
                fs.Close();
                return(Path.Combine(outputpath, output.FileName));
            }
            else
            {
                fs.Close();
            }
            return(null);
        }
Example #2
0
        static void Main(string[] args)
        {
            // RunEventArgsSandbox();

            var converter = new FfmpegConverter("/usr/bin/ffmpeg");

            converter.OggToMp3Async("/home/matterai/Downloads/yandex.ogg", "/home/matterai/Downloads/yandex.mp3");

            Console.ReadKey();
        }
        public string ConvertFile(string inputPath, string userName, string tempName)
        {
            string outputOf = string.Empty;

            try
            {
                FfmpegConverter converter  = new FfmpegConverter();
                string          outputpath = ConfigurationManager.AppSettings["OutputPath"].ToString();
                if (ConfigurationManager.AppSettings["TempPath"].ToString() == "tmp")
                {
                }
                else
                {
                    converter.OutputPath = ConfigurationManager.AppSettings["OutputPath"].ToString();
                }
                converter.LogPath    = Path.Combine(outputpath, "log.txt");
                converter.FfmpegPath = ConfigurationManager.AppSettings["FFMpegPath"].ToString();
                //FileStream fs = new FileStream(inputPath, FileMode.Open, FileAccess.ReadWrite);
                converter.ImagePath = Path.Combine(ConfigurationManager.AppSettings["OutputPath"].ToString(), Path.GetFileNameWithoutExtension(inputPath) + ".png");
                Output output = converter.ConvertToMP4(inputPath);
                output.Success = true;

                //StringBuilder sb = new StringBuilder();

                /*sb.AppendLine("Outputpath " + outputpath);
                 * sb.AppendLine("Logpath " + converter.LogPath);
                 * sb.AppendLine("FfmpegPath " + converter.FfmpegPath);
                 * sb.AppendLine("ImagePath " + converter.ImagePath);
                 * sb.AppendLine("Output Error " + output.Message);
                 */

                if (output.Success)
                {
                    string renamedMP4 = Path.Combine(outputpath, output.FileName);
                    //renamedMP4 = Path.ChangeExtension(renamedMP4, "mp4");

                    //FileStream outStream = new FileStream(renamedMP4, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                    //output.VideoStream.WriteTo(outStream);
                    //output.VideoStream.Close();

                    //byte[] fileBytes = new byte[outStream.Length];
                    byte[] imageBytes = File.ReadAllBytes(converter.ImagePath);
                    //outStream.Flush();
                    //outStream.Close();

                    //fileBytes = File.ReadAllBytes(renamedMP4);
                    //Copy to data lake here then pass to videoPath
                    //set videoPath here
                    string videoPath = PutVideoToDataLake(Path.GetFileName(renamedMP4));
                    ETUDataControls.DataBridgeConnector dbc = new DataBridgeConnector("");
                    object[] objArray = new object[7];
                    objArray.SetValue(userName, 0);
                    objArray.SetValue(Path.GetFileName(renamedMP4).Replace(tempName, ""), 1);
                    objArray.SetValue(null, 2);
                    objArray.SetValue(videoText, 3);
                    objArray.SetValue(videoPath, 4);
                    objArray.SetValue(0, 5);
                    objArray.SetValue(converter.ImagePath, 6);

                    object[] outputQuery = dbc.ExecuteSQLNonQueryWithOutput("sp_UP_InsertVideo", objArray);

                    messageID = Convert.ToInt32(outputQuery[0]);
                    outputOf  = renamedMP4;
                    //After the file is created on disk, perform the same task on Blob Storage and delete
                    //the local file **TODO Venkatesh
                    //context.Session["updategrid"];
                    return(outputOf);
                }
                else
                {
                    return(outputOf);
                }
            }
            catch (Exception ex)
            {
                return(outputOf);
            }
        }