Media file conversion using FFmpeg.

Discuss and share scripts and script files...
Post Reply
Posts: 234
Joined: 09 Dec 2011 21:25

Media file conversion using FFmpeg.

Post by 40k » 10 Aug 2012 13:33

I wrote a small script that uses ffmpeg to convert any media file to any format you desire.

Currently the ffmpeg binary needs to be nested inside the <xypath>. I'm thinking of introducing a selection box at the start that asks the user for the location of the ffmpeg binary.

You can get your binary here:

Code: Select all

/* XYplorer script - Convert selected media files using FFmpeg

All credit for FFmpeg goes to the FFmpeg developers.

FFmpeg is licensed under the GNU Lesser General Public License (LGPL) version 2.1 or later. 
However, FFmpeg incorporates several optional parts and optimizations that are covered 
by the GNU General Public License (GPL) version 2 or later. 
If those parts get used the GPL applies to all of FFmpeg.

FFmpeg Windows binaries can be obtained here:

// 1. Collect data

$xypath = "<xypath>";
 $selectedfiles="";         //files selected by user in pane a
 $apath="";                 //source file path
 $aextension="";            //source fille extension
 $bpath="";                 //target file path
 $bextension="";            //target file extension
 $options="";               //ffmpeg codec options 
 $ffmpeg="";                //ffmpeg command line is build incrementally. 

 $bextension = input("FFMpeg conversion - Enter disered file extension.","Enter only the extension. No dots or quotes.","mp3",s,"",,);
 $options = input("FFMpeg conversion - Enter FFMpeg command options","Refer to FFmpeg help for commands. Leave blank for default","",s,"",,);
 $selectedfiles = get(selecteditemspathnames,|,a);

// 2. Start conversion loop and build the ffmpeg command line

   // 2.1 FFmpeg executable location
   $ffmpeg = $xypath . "\Data\Bins\ffmpeg\bin\ffmpeg.exe -i ";      

   // 2.2 Add source file path and type
   $aextension = gettoken($apath,-1,".");
   $bpath = $apath;
   $apath = """$apath""";
   $ffmpeg = $ffmpeg . $apath;
   //echo $ffmpeg;
   // 2.3 Add conversion options
   $options = " " . $options . " ";
   $ffmpeg = $ffmpeg . $options;
   //echo $ffmpeg;   

   // 2.4 Add target file path
   $bpath = replace($bpath,$aextension,$bextension,,,1);
   $bpath = """$bpath""";
   $ffmpeg = $ffmpeg . $bpath;
   //echo $ffmpeg;

   // 2.5 Run ffmpeg command. Run only one instance of ffmpeg at once.
   run "$ffmpeg",,1;

3.jpg (189.72 KiB) Viewed 1348 times
4.jpg (281.5 KiB) Viewed 1348 times
5.jpg (274.5 KiB) Viewed 1348 times
I develop scripts that integrate media functionality into Xyplorer.
Hash - in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

Post Reply