Difference between revisions of "FFmpegConversion class"

From Catglobe Wiki
Jump to: navigation, search
 
Line 2: Line 2:
 
|Name=<nowiki>FFmpegConversion</nowiki>
 
|Name=<nowiki>FFmpegConversion</nowiki>
 
|Description=<nowiki>Glue class to call FFmpeg library to convert media</nowiki>
 
|Description=<nowiki>Glue class to call FFmpeg library to convert media</nowiki>
|Constructors=
+
|InheritsFrom=object|Constructors=
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptParameters_Template|Type=Attachment|Name=<nowiki>attachment</nowiki>|Description=<nowiki>Attachment to convert</nowiki>}}
 
{{CGscriptParameters_Template|Type=Attachment|Name=<nowiki>attachment</nowiki>|Description=<nowiki>Attachment to convert</nowiki>}}
Line 14: Line 14:
 
{{CGscriptParameters_Template|Type=int|Name=<nowiki>nth</nowiki>|Description=<nowiki>Pick the nth audiostream in the source</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>compression</nowiki>|Description=<nowiki>Level of compression from 0 to 9, with 9 being worst quality. see https://trac.ffmpeg.org/wiki/Encode/MP3</nowiki>}}
 
{{CGscriptParameters_Template|Type=int|Name=<nowiki>nth</nowiki>|Description=<nowiki>Pick the nth audiostream in the source</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=int|Name=<nowiki>compression</nowiki>|Description=<nowiki>Level of compression from 0 to 9, with 9 being worst quality. see https://trac.ffmpeg.org/wiki/Encode/MP3</nowiki>}}
 
|Description=<nowiki>Convert the source audio stream to MP3 format. If the source is already mp3. If already mp3 and similar or lower quality in source no further loss is done</nowiki>}}
 
|Description=<nowiki>Convert the source audio stream to MP3 format. If the source is already mp3. If already mp3 and similar or lower quality in source no further loss is done</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</nowiki>}}
+
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}}
 
|Properties=
 
|Properties=
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Description=<nowiki>Get information about this class.</nowiki>}}
+
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}}
 
}}
 
}}
 +
 
=== <span style="color:#DF8621">'''Examples'''</span> ===
 
=== <span style="color:#DF8621">'''Examples'''</span> ===
 
<source lang="javascript">
 
<source lang="javascript">

Latest revision as of 07:59, 2 July 2020

FFmpegConversion



Glue class to call FFmpeg library to convert media

Parent class

Inherits from object

Constructors

  • (Attachment attachment "Attachment to convert") - Convert existing file
  • (string filename "Name of the file", bool isTemp "Is the file temporary") - Convert existing file

Methods

  • number Convert() - Start the conversion process, return number of seconds it took
  • Empty SetAudioConversionToMp3(int nth "Pick the nth audiostream in the source", int compression "Level of compression from 0 to 9, with 9 being worst quality. see https://trac.ffmpeg.org/wiki/Encode/MP3") - Convert the source audio stream to MP3 format. If the source is already mp3. If already mp3 and similar or lower quality in source no further loss is done
  • (From object) string ToString() - The string representation of the object.

Properties

  • string ObjectTypeName { get; } - The name of the type of object.
  • (From object) TypeInformation TypeInformation { get; } - Get information about this class.


Examples

Attachment attachment = new Attachment (5224744);
FFmpegConversion conv = new FFmpegConversion(attachment);
conv.SetAudioConversionToMp3(0, 5);
conv.Convert();
//Noted that: after converting will overwrite the source media file, so better, should name the source file with .mp3
//Result: the attachment will be updated, the file size will be down