private void addAudio_Click(object sender, EventArgs e) { OpenFileDialog openAudioForMixingWithVideo = new OpenFileDialog(); openAudioForMixingWithVideo.DefaultExt = "mp3"; //add supporting file types in this format openAudioForMixingWithVideo.Filter = "MP3 files (.mp3)|*.mp3" + "|WMA files (.wma)|*.wma" //add new file formats to support here //format to use: "|FileFormat files (*.ext)|*.ext" //example: "|WMV files (*.wmv)|*.wmv" + "|All files (*.*)|*.*"; openAudioForMixingWithVideo.FilterIndex = 1; openAudioForMixingWithVideo.Multiselect = true; openAudioForMixingWithVideo.ShowDialog(); //validate the file and mix it with video if (openAudioForMixingWithVideo.FileName.Length > 0) { string args = "-y -i " + @"""" + previewVideoProcessing.URL + @"""" + " -i " + @"""" + openAudioForMixingWithVideo.FileName.ToString() + @"""" + " -vcodec copy -acodec copy " + @"""" + FFMpegProxy.getOutputFileName(previewVideoProcessing.URL, "_AudioMixedToVideo", Path.GetExtension(previewVideoProcessing.URL)) + @""""; String commandResult = FFMpegProxy.runCommand(args); if (commandResult != null) { MessageBox.Show("Unable to mix audio to video. Received an exception from the underlying FFMpeg library: " + commandResult); } } }
private void createbwVideo_Click(object sender, EventArgs e) { try { string args = "-y -i " + @"""" + previewVideoProcessing.URL + @"""" + " -q:v 0 -vf format=gray " + @"""" + FFMpegProxy.getOutputFileName(previewVideoProcessing.URL, "_Grayed") + @""""; String commandResult = FFMpegProxy.runCommand(args); if (commandResult != null) { MessageBox.Show("Unable to grayscale the video. Received an exception from the underlying FFMpeg library: " + commandResult); } } catch (Exception) { MessageBox.Show("Open a file using File->Open and then choose an action to perform"); } }
private void extractAudio_Click(object sender, EventArgs e) { try { string args = "-y -i " + @"""" + previewVideoProcessing.URL + @"""" + " -vn -ac 2 -ar 44100 -ab 320k -f mp3 " + @"""" + FFMpegProxy.getOutputFileName(previewVideoProcessing.URL, "_AudioExtracted", ".mp3") + @""""; String commandResult = FFMpegProxy.runCommand(args); if (commandResult != null) { MessageBox.Show("Unable to extract the video. Received an exception from the underlying FFMpeg library: " + commandResult); } } catch (Exception) { MessageBox.Show("Open a file using File->Open and then choose an action to perform"); } }
private void speedVideo_Click(object sender, EventArgs e) { try { //Hardcoding the speed - this will create a 4X video string args = "-y -i " + @"""" + previewVideoProcessing.URL + @"""" + " -r 16 -filter:v " + "\"setpts=0.250*PTS\"" + " -filter:a \"atempo=2.0,atempo=2.0\" " + @"""" + FFMpegProxy.getOutputFileName(previewVideoProcessing.URL, "_faster", Path.GetExtension(previewVideoProcessing.URL)) + @""""; String commandResult = FFMpegProxy.runCommand(args); if (commandResult != null) { MessageBox.Show("Unable to speed up the video. Received an exception from the underlying FFMpeg library: " + commandResult); } } catch (Exception) { MessageBox.Show("Open a file using File->Open and then choose an action to perform"); } }
private void addWatermark_Click(object sender, EventArgs e) { try { OpenFileDialog openPNGForWatermark = new OpenFileDialog(); openPNGForWatermark.DefaultExt = "png"; //add supporting file types in this format openPNGForWatermark.Filter = "PNG files (.png)|*.png"; openPNGForWatermark.FilterIndex = 1; openPNGForWatermark.Multiselect = false; openPNGForWatermark.ShowDialog(); //validate the file and show it in the player stub if (openPNGForWatermark.FileName.Length <= 0) { MessageBox.Show("Please select a valid PNG file for watermarking"); openPNGForWatermark.ShowDialog(); } string args = "-y -i " + @"""" + previewVideoProcessing.URL + @"""" + " -i " + @"""" + openPNGForWatermark.FileName.ToString() + @"""" + " -q:v 0 -filter_complex overlay=\"(main_w/2)-(overlay_w/2):(main_h/2)-(overlay_h)/2\" " + @"""" + FFMpegProxy.getOutputFileName(previewVideoProcessing.URL, "_Watermarked") + @""""; String commandResult = FFMpegProxy.runCommand(args); if (commandResult != null) { MessageBox.Show("Unable to grayscale the video. Received an exception from the underlying FFMpeg library: " + commandResult); } } catch (Exception) { MessageBox.Show("Open a file using File->Open and then choose an action to perform"); } }