Processing Ajax...
Save 25% on our desktop apps during our Black Friday/Cyber Monday sale!Save 25% on our desktop apps during our Black Friday/Cyber Monday sale, including DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!Save 25% on our desktop apps during our Black Friday/Cyber Monday sale!

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Transcode with FFmpeg

Description
This scripted function uses FFmpeg to transcode video files to other popular formats.
Language
C#.net
Minimum Version
Created By
Thomas Malloch (BFS)
Contributors
-
Date Created
May 1, 2017
Date Last Modified
May 1, 2017

Scripted Function (Macro) Code

using System;
using System.Drawing;
using System.Windows.Forms;
// The 'windowHandle' parameter will contain the window handle for the:
//   - Active window when run by hotkey
//   - Trigger target when run by a Trigger rule
//   - TitleBar Button owner when run by a TitleBar Button
//   - Jump List owner when run from a Taskbar Jump List
//   - Currently focused window if none of these match
public static class DisplayFusionFunction
{
    public static void Run(IntPtr windowHandle)
    {
        //Note: you'll need FFmpeg for this script to work correctly.
        //You can get it from here: http://ffmpeg.zeranoe.com/builds/
        
        //////////////////////////////////////////////////////////////////////
        //******************************************************************//
        //*Note: Change ffMpegPath with the path to FFmpeg on your computer*//
        //******************************************************************//
        //////////////////////////////////////////////////////////////////////
        string ffMpegPath = @"C:\Program Files\FFmpeg\bin\ffmpeg.exe";
        
        //open a dialog to let the user select a file
        using(OpenFileDialog openDialog = new OpenFileDialog())
        {
            //setup the OpenFileDialog
            openDialog.Title = "Select a File to Transcode";
            openDialog.Multiselect = false;
            
            //show the dialog. if the user canceled, exit the script
            if(openDialog.ShowDialog() != DialogResult.OK)
                return;
            
            //open a dialog to let the user save the file
            using(SaveFileDialog saveDialog = new SaveFileDialog())
            {
                //setup the SaveFileDialog
                saveDialog.Title = "Choose Where to Save the File";
                saveDialog.FileName = "output.avi";
                saveDialog.Filter = "Audio Video Interleaved|*.avi|Graphics Interchange Format|*.gif|WebM|*.webm|QuickTime File Format|*.mov|MPEG-4|*.mp4|Matroska|*.mkv|Flash Video|*.swf";
                
                //show the dialog. if the user canceled, exit the script
                if(saveDialog.ShowDialog() != DialogResult.OK)
                    return;
                
                //run FFmpeg with the settings the user input
                BFS.Application.Start(ffMpegPath, string.Format("-y -i \"{0}\" \"{1}\"", openDialog.FileName, saveDialog.FileName));
            }
        }
    }
}