Inheritance: MediaInfoBase
Esempio n. 1
0
        public WidgetMovieTrack()
        {
            this.Build ();
            Editable = false;
            _movieInfo = new MediaInfo();

            comboRotation.Changed += delegate { OnAnyValueChanged(); };
            comboCodec.Changed += delegate { OnAnyValueChanged(); };
            comboAspect.Changed += delegate { OnAnyValueChanged(); };
            comboFrameRate.Changed += delegate { OnAnyValueChanged(); };
            comboBitRate.Changed += delegate { OnAnyValueChanged(); };
            checkAutorotate.Toggled += delegate { OnAnyValueChanged(); };

            //ComboBoxEntry
            checkKeep.Toggled += delegate { OnAnyValueChanged(); };
            chBoxResolution.Toggled += delegate { OnAnyValueChanged(); };
            chBoxAspect.Toggled += delegate { OnAnyValueChanged(); };
            chBoxBitRate.Toggled += delegate { OnAnyValueChanged(); };
            chBoxFrameRate.Toggled += delegate { OnAnyValueChanged(); };
            chBoxRotation.Toggled += delegate { OnAnyValueChanged(); };

            eventBoxCodec.ButtonPressEvent+= OnCodecEventBoxButtonPressEvent;

            entryWidth.Changed += OnEntryWidthChanged;
            entryHeight.Changed += OnEntryHeightChanged;
        }
Esempio n. 2
0
        public WidgetContainer()
        {
            this.Build ();

            Editable = false;
            _info = new MediaInfo();

            comboContainer.Changed+=delegate { OnAnyValueChanged(); };
            eventBoxContainer.ButtonPressEvent += OnContainerEventBoxButtonPressEvent;
        }
        public void FillFrom(MediaInfo sourceInfo)
        {
            if (sourceInfo != null)
            {
                sourceInfo.Copyto(_sourceMovieInfo,false);
            } else
            {
                SourceMovieInfo.Clear();
            }

            Fill();
        }
Esempio n. 4
0
        public WidgetAudioTracks()
        {
            this.Build ();

            _info = new MediaInfo();

            Editable = false;

            comboChannels.Changed+= delegate { OnAnyValuechanged(); };
            comboBitrate.Changed+= delegate { OnAnyValuechanged(); };
            comboSampleRate.Changed+= delegate { OnAnyValuechanged(); };
        }
 public WidgetGeneralMediaInfo()
 {
     this.Build ();
     _sourceMovieInfo = new MediaInfo();
 }
Esempio n. 6
0
        public void FillFrom(MediaInfo mInfo)
        {
            if (mInfo != null)
            {
                mInfo.Copyto(_info,false);
            } else
                _info.ClearTracks();

            Fill();
        }
Esempio n. 7
0
        public static string MakeFFMpegScreenShot(MediaInfo sourceMovie, int secondsDelay = 0)
        {
            if (sourceMovie.FirstVideoTrack != null && File.Exists(sourceMovie.FileName))
            {
                var ffmpegCommandArgs = String.Empty;

                var timeSpan = TimeSpan.FromSeconds(secondsDelay);
                //var timeAsStrig = timeSpan.ToString("hh:mm:ss");
                var timeAsString = string.Format("{0}:{1}",
                                                 timeSpan.Minutes.ToString().PadLeft(2,'0'),
                                                 timeSpan.Seconds.ToString().PadLeft(2,'0'));

                var picFileName = sourceMovie.FileName + ".jpg";

                var counter = 0;
                while (File.Exists(picFileName))
                {
                    counter++;
                    picFileName = sourceMovie.FileName + "." + counter.ToString().PadLeft(2,'0')+".jpg";
                }

                // https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video
                // ffmpeg -i input.flv -ss 00:00:14.435 -f image2 -vframes 1 out.png

                ffmpegCommandArgs = " -i {filename} -ss {time} -f image2 -vframes 1 {pic}";

                ffmpegCommandArgs = ffmpegCommandArgs.Replace("{filename}","\"" + sourceMovie.FileName + "\"");
                ffmpegCommandArgs = ffmpegCommandArgs.Replace("{time}",timeAsString);
                ffmpegCommandArgs = ffmpegCommandArgs.Replace("{pic}","\"" + picFileName + "\"");

                SupportMethods.ExecuteAndReturnOutput(MediaConvertGUIConfiguration.FFMpegPath,ffmpegCommandArgs);

                return picFileName;
            }

            return null;
        }
Esempio n. 8
0
        /// <summary>
        /// Makes the FF MPEG command.
        /// </summary>
        /// <returns>The FF MPEG command.</returns>
        /// <param name="sourceMovie">Source movie.</param>
        /// <param name="targetMovie">Target movie.</param>
        /// <param name="currentPass">Current pass.</param>
        public static string MakeFFMpegCommand(MediaInfo sourceMovie, MediaInfo targetMovie, int currentPass)
        {
            var res= String.Empty;

            // single audio convert?
            if ( (targetMovie.AudioTracks.Count > 0) &&
                (targetMovie.FirstAudioTrack.TargetAudioCodec!= AudioCodecEnum.none) &&
                ( 	(targetMovie.FirstVideoTrack == null) ||
                    (targetMovie.TargetVideoCodec == VideoCodecEnum.none) ||
                    (targetMovie.TargetContainer == null) ||
                    (targetMovie.TargetContainer == ContainerEnum.none)
                ) &&
                (currentPass>1))
            {
                return res;
            }

            // codec copy  - single pass
            if ( (targetMovie.FirstVideoTrack != null) && (targetMovie.TargetVideoCodec==VideoCodecEnum.copy) &&
                (currentPass>1))
            {
                return res;
            }

            var sourceFile = " -i \"" + sourceMovie.FileName+"\"";
            var ext = System.IO.Path.GetExtension(sourceMovie.FileName);
            var targetFile = sourceMovie.FileName+".converted" + ext;
            var video = " -vn";  // disable video

            var audio = " -an "; // disable audio

            var map = String.Empty;

            if (targetMovie.FirstVideoTrack != null && targetMovie.TargetVideoCodec!=VideoCodecEnum.none &&
                targetMovie.TargetContainer != null && targetMovie.TargetContainer != ContainerEnum.none)
            {
                var videoSettings= String.Empty;
                var container = String.Empty;

                container = " -f " + MediaInfoBase.VideoContainerToFFMpegContainer [targetMovie.TargetContainer];
                ext = MediaInfoBase.VideoContainerToExtension[targetMovie.TargetContainer];

                targetFile = sourceMovie.FileName+".converted" + ext;

                videoSettings += container;

                var aspect = " -aspect " + targetMovie.FirstVideoTrack.Aspect;
                var	scale =   " -s " + targetMovie.FirstVideoTrack.Width.ToString() + "x"+targetMovie.FirstVideoTrack.Height.ToString();
                var	bitrate = " -b:v " + targetMovie.FirstVideoTrack.Bitrate;
                var frameRate = " -r " + targetMovie.FirstVideoTrack.FrameRate.ToString().Replace(",","."); // TODO: invariant culture

                // auto rotation
                var rotation90AnglesCount = Convert.ToInt32(sourceMovie.FirstVideoTrack.RotatationAngle);
                var autoRotate = " -vf ";

                if (rotation90AnglesCount == 90) autoRotate += " transpose=2"; // 90CounterClockwise
                else
                if (rotation90AnglesCount == 180) autoRotate += " transpose=1,transpose=1"; // 2*90Clockwise
                else
                if (rotation90AnglesCount == 270) autoRotate += " transpose=1"; // 90Clockwise
                else
                autoRotate = "";  // unsupported transposition

                var rotationAngle = " -metadata:s:v:0 rotate=" + Convert.ToInt32(targetMovie.FirstVideoTrack.RotatationAngle).ToString();

                if (targetMovie.EditAspect)	videoSettings += aspect;
                if (targetMovie.EditResolution) videoSettings += scale;
                if (targetMovie.EditBitRate) videoSettings += bitrate;
                if (targetMovie.EditFrameRate) videoSettings += frameRate;
                if (targetMovie.EditRotation) videoSettings += rotationAngle;
                if (targetMovie.AutoRotate) videoSettings += autoRotate;

                if (targetMovie.TargetVideoCodec!=VideoCodecEnum.copy)
                {
                    var pass = String.Format(" -pass {0} -passlogfile \"{1}\"",currentPass,targetFile + ".passlog");
                    videoSettings += pass;
                }

                switch (targetMovie.TargetVideoCodec)
                {
                    case VideoCodecEnum.copy: video = " -vcodec copy"+videoSettings; break;
                    case VideoCodecEnum.xvid: video = " -vcodec libxvid"+videoSettings; break;
                    case VideoCodecEnum.flv: video = " -vcodec flv"+videoSettings; break;
                    case VideoCodecEnum.h263: video = " -vcodec h263"+videoSettings; break;
                    case VideoCodecEnum.h264: video = " -vcodec h264"+videoSettings; break;
                    case VideoCodecEnum.mpeg: video = " -vcodec mpeg1video"+videoSettings; break;
                    case VideoCodecEnum.theora: video = " -vcodec theora"+videoSettings; break;
                    case VideoCodecEnum.vp8: video = " -vcodec libvpx"+videoSettings; break;
                }
            }

            // only first Audio Track!
            if (targetMovie.AudioTracks.Count>0)
            {
                var targetAudioTrack = targetMovie.FirstAudioTrack;

                var audioQuality = String.Format(" -ac {0} -ar {1} -ab {2}",
                                                 targetAudioTrack.Channels,
                                                 targetAudioTrack.SamplingRateHz,
                                                 targetAudioTrack.Bitrate);

                switch (targetAudioTrack.TargetAudioCodec)
                {
                    case AudioCodecEnum.copy:audio = " -acodec copy "; break;
                    case AudioCodecEnum.mp3: audio = String.Format(" -acodec libmp3lame"+audioQuality); ext = ".mp3"; break;
                    case AudioCodecEnum.vorbis: audio = String.Format(" -acodec libvorbis "+audioQuality); ext = ".ogg"; break;
                    case AudioCodecEnum.aac: audio = String.Format(" -acodec libfaac "+audioQuality); ext = ".aac"; break;
                    case AudioCodecEnum.flac: audio = String.Format(" -acodec flac "+audioQuality); ext = ".flac"; break;
                    case AudioCodecEnum.ac3: audio = String.Format(" -acodec ac3 "+audioQuality); ext = ".ac3"; break;
                    default: audio = " -an "; break;
                }

                if ( (targetMovie.FirstVideoTrack == null) ||
                     (targetMovie.TargetVideoCodec == VideoCodecEnum.none) ||
                     (targetMovie.TargetContainer == ContainerEnum.none)
                    )
                {
                    // converting single audio
                    targetFile = sourceMovie.FileName+".converted" + ext;
                }
            }

            // more audio tracks? supporting only the first one
            if (sourceMovie.AudioTracks.Count > 1 && sourceMovie.FirstVideoTrack != null)
            {
                map = " -map 0:0 -map 0:1";
            }

            targetMovie.FFMPEGOutputFileName = targetFile + ".log";
            targetMovie.FFMPEGPassLogFileName = targetFile + ".passlog";
            targetMovie.FileName = targetFile;

            /*
            if (File.Exists(targetMovie.FFMPEGOutputFileName))
                    File.Delete(targetMovie.FFMPEGOutputFileName);
            if (File.Exists(targetMovie.FFMPEGPassLogFileName))
                    File.Delete(targetMovie.FFMPEGPassLogFileName);
            */

            targetFile = String.Format(" \"{0}\"",targetFile);

            res = MediaConvertGUIConfiguration.FFMpegPath+" -y -dump " + sourceFile + map + video + audio + targetFile;

            return res;
        }
 public WidgetGeneralMediaInfo()
 {
     this.Build();
     _sourceMovieInfo = new MediaInfo();
 }
Esempio n. 10
0
 public void Copyto(MediaInfo mInfo,bool videoOnly)
 {
     mInfo.ClearTracks();
     foreach(var track in Tracks)
     {
         if ((videoOnly==false) || ((track.TrackType =="Video")) )
         {
             var tr = new TrackInfo();
             track.CopyTo(tr);
             mInfo.Tracks.Add(tr);
         }
     }
     mInfo.TargetVideoCodec = TargetVideoCodec;
     mInfo.TargetContainer = TargetContainer;
     mInfo.FileName = FileName;
     mInfo.FileSize = FileSize;
     mInfo.EditAspect = EditAspect;
     mInfo.EditBitRate = EditBitRate;
     mInfo.EditFrameRate = EditFrameRate;
     mInfo.EditResolution = EditResolution;
     mInfo.EditRotation = EditRotation;
 }
Esempio n. 11
0
 public void AppendTracksTo(MediaInfo mInfo,decimal durationMS, string onlyType="")
 {
     foreach(var track in Tracks)
     {
         if ((onlyType=="") || ((track.TrackType ==onlyType)) )
         {
             var tr = new TrackInfo();
             track.CopyTo(tr);
             tr.DurationMS = durationMS;
             mInfo.Tracks.Add(tr);
         }
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Makes the FF MPEG command.
        /// </summary>
        /// <returns>The FF MPEG command.</returns>
        /// <param name="sourceMovie">Source movie.</param>
        /// <param name="targetMovie">Target movie.</param>
        /// <param name="currentPass">Current pass.</param>
        public static string MakeFFMpegCommand(MediaInfo sourceMovie, MediaInfo targetMovie, int currentPass)
        {
            var res = String.Empty;

            // single audio convert?
            if ((targetMovie.AudioTracks.Count > 0) &&
                (targetMovie.FirstAudioTrack.TargetAudioCodec.Name != "none") &&
                ((targetMovie.FirstVideoTrack == null) ||
                 (targetMovie.TargetVideoCodec == MediaConvertGUIConfiguration.GetVideoCodecByName("none")) ||
                 (targetMovie.TargetContainer == null) ||
                 (targetMovie.TargetContainer.Name == "none")
                ) &&
                (currentPass > 1))
            {
                return(res);
            }

            // codec copy  - single pass
            if ((targetMovie.FirstVideoTrack != null) && (targetMovie.TargetVideoCodec == MediaConvertGUIConfiguration.GetVideoCodecByName("copy")) &&
                (currentPass > 1))
            {
                return(res);
            }

            var sourceFile = " -i \"" + sourceMovie.FileName + "\"";
            var ext        = System.IO.Path.GetExtension(sourceMovie.FileName);
            var targetFile = sourceMovie.FileName + ".converted" + ext;
            var video      = " -vn";         // disable video

            var hwaccel = String.Empty;

            var audio = " -an ";             // disable audio

            var map = String.Empty;

            if (targetMovie.FirstVideoTrack != null && targetMovie.TargetVideoCodec != MediaConvertGUIConfiguration.GetVideoCodecByName("none") &&
                targetMovie.TargetContainer != null && targetMovie.TargetContainer.Name != "none")
            {
                var videoSettings = String.Empty;
                var container     = String.Empty;

                container = " -f " + targetMovie.TargetContainer.Name;
                ext       = targetMovie.TargetContainer.Extension;

                targetFile = sourceMovie.FileName + ".converted" + ext;

                videoSettings += container;

                var aspect    = " -aspect " + targetMovie.FirstVideoTrack.Aspect;
                var scale     = " -s " + targetMovie.FirstVideoTrack.Width.ToString() + "x" + targetMovie.FirstVideoTrack.Height.ToString();
                var bitrate   = " -b:v " + targetMovie.FirstVideoTrack.Bitrate;
                var frameRate = " -r " + targetMovie.FirstVideoTrack.FrameRate.ToString().Replace(",", ".");                // TODO: invariant culture

                // auto rotation
                var rotation90AnglesCount = Convert.ToInt32(sourceMovie.FirstVideoTrack.RotatationAngle);
                var autoRotate            = " -vf ";

                if (rotation90AnglesCount == 90)
                {
                    autoRotate += " transpose=2";                                              // 90CounterClockwise
                }
                else
                if (rotation90AnglesCount == 180)
                {
                    autoRotate += " transpose=1,transpose=1";                                               // 2*90Clockwise
                }
                else
                if (rotation90AnglesCount == 270)
                {
                    autoRotate += " transpose=1";                                               // 90Clockwise
                }
                else
                {
                    autoRotate = "";              // unsupported transposition
                }
                var rotationAngle = " -metadata:s:v:0 rotate=" + Convert.ToInt32(targetMovie.FirstVideoTrack.RotatationAngle).ToString();

                if (targetMovie.EditAspect)
                {
                    videoSettings += aspect;
                }
                if (targetMovie.EditResolution)
                {
                    videoSettings += scale;
                }
                if (targetMovie.EditBitRate)
                {
                    videoSettings += bitrate;
                }
                if (targetMovie.EditFrameRate)
                {
                    videoSettings += frameRate;
                }
                if (targetMovie.EditRotation)
                {
                    videoSettings += rotationAngle;
                }
                if (targetMovie.AutoRotate)
                {
                    videoSettings += autoRotate;
                }

                if (targetMovie.TargetVideoCodec != MediaConvertGUIConfiguration.GetVideoCodecByName("copy"))
                {
                    var pass = String.Format(" -pass {0} -passlogfile \"{1}\"", currentPass, targetFile + ".passlog");
                    videoSettings += pass;
                }

                video   = targetMovie.TargetVideoCodec.Command + videoSettings;
                hwaccel = String.IsNullOrEmpty(targetMovie.TargetVideoCodec.HWAcceleration) ? "" : " -hwaccel " + targetMovie.TargetVideoCodec.HWAcceleration;
            }

            // only first Audio Track!
            if (targetMovie.AudioTracks.Count > 0)
            {
                var targetAudioTrack = targetMovie.FirstAudioTrack;

                var audioQuality = String.Format(" -ac {0} -ar {1} -ab {2}",
                                                 targetAudioTrack.Channels,
                                                 targetAudioTrack.SamplingRateHz,
                                                 targetAudioTrack.Bitrate);

                audio = " " + targetAudioTrack.TargetAudioCodec.Command + " ";
                if (targetAudioTrack.TargetAudioCodec.Name != "copy")
                {
                    audio += " " + audioQuality;
                }


                if ((targetMovie.FirstVideoTrack == null) ||
                    (targetMovie.TargetVideoCodec == MediaConvertGUIConfiguration.GetVideoCodecByName("none")) ||
                    (targetMovie.TargetContainer.Name == "none")
                    )
                {
                    // converting single audio
                    targetFile = sourceMovie.FileName + ".converted" + ext;
                }
            }

            // more audio tracks? supporting only the first one
            if (sourceMovie.AudioTracks.Count > 1 && sourceMovie.FirstVideoTrack != null)
            {
                map = " -map 0:0 -map 0:1";
            }

            targetMovie.FFMPEGOutputFileName  = targetFile + ".log";
            targetMovie.FFMPEGPassLogFileName = targetFile + ".passlog";
            targetMovie.FileName = targetFile;

            /*
             * if (File.Exists(targetMovie.FFMPEGOutputFileName))
             *              File.Delete(targetMovie.FFMPEGOutputFileName);
             * if (File.Exists(targetMovie.FFMPEGPassLogFileName))
             *              File.Delete(targetMovie.FFMPEGPassLogFileName);
             */

            targetFile = String.Format(" \"{0}\"", targetFile);


            res = MediaConvertGUIConfiguration.FFMpegPath + " " + hwaccel + " -y -dump " + sourceFile + map + " " + video + audio + targetFile;

            return(res);
        }