/// <summary> /// Rotates a given <seealso cref="Media"/> by a <seealso cref="MediaRotationDirection"/> /// </summary> /// <param name="media">The media to rotate</param> /// <param name="mediaRotation">The rotation direction</param> /// <returns>Media that contaion information about the temporary rotated file</returns> public Media Rotate(Media media, MediaRotationDirection mediaRotation) { string tempFileName = Path.ChangeExtension(Path.GetRandomFileName(), media.Format); string tempFilePath = Path.Combine(Path.GetTempPath(), tempFolderName, tempFileName); // Add the new temporary file's path to the paths list _mainWindow.TempFiles.Add(tempFilePath); // Init process information ProcessStartInfo processStartInfo = new ProcessStartInfo() { FileName = "ffmpeg", Arguments = string.Format("-y -i \"{0}\" -vf \"transpose = {1}\" -c:a copy \"{2}\"", media.Path, (int)mediaRotation, tempFilePath), UseShellExecute = true, WindowStyle = ProcessWindowStyle.Hidden }; // Start the process to rotate the video Process.Start(processStartInfo).WaitForExit(); // Return media object from the currect type if (media is Video) { return(new Video(tempFilePath, true)); } if (media is Thumbnail) { return(new Thumbnail(tempFilePath, true)); } return(new Media(tempFilePath, Path.GetExtension(tempFileName), true)); }
/// <summary> /// Rotates the video in the given <see cref="MediaRotationDirection"/>. /// </summary> /// <param name="dir">The direction of rotation</param> void RotateOnEvent(MediaRotationDirection dir) { // Rotate the video Video video = (Video)rotator.Rotate(_mainWindow.CurrentVideo, dir); if (_mainWindow.OriginalVideo == null) { _mainWindow.OriginalVideo = (Video)video; } _mainWindow.CurrentVideo = video; // Rotate the thumbnail _mainWindow.VideoThumbnail = (Thumbnail)rotator.Rotate(_mainWindow.VideoThumbnail, dir); ThumbnailImage.Source = _mainWindow.VideoThumbnail.ThumbnailImage.Source; }