Difference between revisions of "ReNamer:Scripts:MediaInfo"

From den4b Wiki
Jump to navigation Jump to search
(Created page with "{{Up|ReNamer:Scripts}} Script integrates [https://mediaarea.net/en/MediaInfo MediaInfo CLI] tool in order to extract meta information for a [https://mediaarea.net/en/MediaInf...")
 
(Trim console output, to avoid new line characters)
 
Line 10: Line 10:
 
== Code ==
 
== Code ==
  
* Author: Denis Kozlov. Date: 2018-04-09.
+
* Author: Denis Kozlov. Date: 2018-05-15.
 
* Tested with ReNamer 6.8.
 
* Tested with ReNamer 6.8.
  
Line 34: Line 34:
 
     ' "' + FilePath + '"';
 
     ' "' + FilePath + '"';
 
   if ExecConsoleApp(Command, Output) = 0 then
 
   if ExecConsoleApp(Command, Output) = 0 then
     FileName := OemToWide(Output) + WideExtractFileExt(FilePath);
+
     FileName := WideTrim(OemToWide(Output)) + WideExtractFileExt(FilePath);
 
end.
 
end.
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 01:52, 15 May 2018

Script integrates MediaInfo CLI tool in order to extract meta information for a variety of audio and video file formats.

Requirements

  • Download and extract MediaInfo CLI tool.
  • Adjust MediaInfoExe constant in the script to point to a correct path of your MediaInfo CLI executable.

Code

  • Author: Denis Kozlov. Date: 2018-05-15.
  • Tested with ReNamer 6.8.

The script is configured to extract "Encoded_Date" meta value, but you can change it to any other tag supported by MediaInfo, by modifying the OutputParameter constant in the script. See below for more information on supported meta tags.

The extracted meta value is used in a raw form and will replace the original file name. The resulting file name may require some additional reformatting, which can be done using the standard renaming rules.

{ Extract media meta information using MediaInfo CLI }

const
  MediaInfoExe = 'C:\Tools\MediaInfoCLI\MediaInfo.exe';
  OutputParameter = 'General;%Encoded_Date%';

var
  Command: WideString;
  Output: String;

begin
  Command :=
    '"' + MediaInfoExe + '"' +
    ' --output="' + OutputParameter + '"' +
    ' "' + FilePath + '"';
  if ExecConsoleApp(Command, Output) = 0 then
    FileName := WideTrim(OemToWide(Output)) + WideExtractFileExt(FilePath);
end.

MediaInfo CLI Help

Built-in help commands:

  • MediaInfo.exe --Help - General help information.
  • MediaInfo.exe --Help-Output - How to extract specific meta tags from files.
  • MediaInfo.exe --Info-Parameters - List of supported meta tags.