<?xml version="1.0" encoding="utf-8"?>
<HmsTranscodingConfig version="2.28">
  <TranscoderList>
    <Transcoder>
      <Name>FLAC</Name>
      <Path>Transcoders\flac.exe</Path>
      <HomePage>http://flac.sourceforge.net/</HomePage>
      <Download>http://flac.sourceforge.net/download.html</Download>
    </Transcoder>
  </TranscoderList>
  <TranscodingProfileList>
    <Profile>
      <TranscoderName>FLAC</TranscoderName>
      <TranscodingCondition>SameText(ExtractFileExt(mpFilePath), &apos;.flac&apos;)</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>var
  bWav: Boolean;
  iSampleRate, iChannels, iBitsPerSample: Integer; 
begin
  bWav := Pos(&apos;wav&apos;, cfgTranscodingAudioMimeType) &gt; 0;
  if bWav or SameText(Copy(cfgTranscodingAudioMimeType, 1, 7), &apos;audio/L&apos;) then begin
    iChannels := mpChannels;                                     
    if iChannels &gt; cfgTranscodingLpcmMaxChannels then  
      iChannels := cfgTranscodingLpcmMaxChannels
    else if iChannels &lt; 2 then  
      iChannels := 2;
    iSampleRate   := mpAudioSampleRate;
    if iSampleRate &gt; cfgTranscodingLpcmMaxSampleRate then
      iSampleRate := cfgTranscodingLpcmMaxSampleRate      
    else if iSampleRate &gt; 96000 then    
      iSampleRate := 192000;
    iBitsPerSample := mpBitsPerSample;    
    if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
      iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
    else if iBitsPerSample &lt; 32 then
      iBitsPerSample := 24;        
    if bWav then
      MimeType := cfgTranscodingAudioMimeType    
    else
      MimeType := &apos;audio/L&apos; + IntToStr(iBitsPerSample);        
    MimeType := MimeType + Format(&apos;;rate=%d;channels=%d;bits=%d&apos;, [iSampleRate, iChannels, iBitsPerSample]) 
  end else
    MimeType := cfgTranscodingAudioMimeType      
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>
function GetSampleFormat(aBitsPerSample: Integer): string;
begin
  if aBitsPerSample &gt; 16 then  
    Result := &apos;s32&apos;    
  else  
    Result := &apos;s24&apos;
end;

function GetMetadataEx(const aParams: array of Variant): string;
var
  i, iTagsSize: Integer;  
  sPropertyValue: string;
begin
  Result := &apos;&apos;;  
  if cfgTranscodingAudioTagsSize &lt;&gt; 0 then begin
    if cfgTranscodingAudioTagsSize &gt; 0 then    
      iTagsSize := cfgTranscodingAudioTagsSize * 1024      
    else               
      iTagsSize := -1;
    Result := Format(&apos;-tags_size %d &apos;, [iTagsSize]);
    i := 0;  
    while i &lt; Length(aParams) do begin
      sPropertyValue := VarToStr(CurrentMediaItem[aParams[i]]);    
      if sPropertyValue &lt;&gt; &apos;&apos; then    
        Result := Result + Format(&apos;-metadata "%s=%s" &apos;, [aParams[i + 1], ReplaceStr(sPropertyValue, &apos;"&apos;, &apos;&apos;)]);
      Inc(i, 2)   
    end    
  end else  
    Result := &apos;-vn &apos; 
end;

function GetMetadata: string;
begin
  Result := GetMetadataEx([
     mpiTitle, &apos;title&apos;, mpiAuthor, &apos;author&apos;,  mpiAlbum, &apos;album&apos;,
     mpiYear, &apos;year&apos;,  mpiGenre, &apos;genre&apos;,  mpiTrack, &apos;track&apos;,
     mpiAuthor, &apos;artist&apos;, mpiAuthor, &apos;performer&apos;, mpiComposer, &apos;composer&apos;,
     mpiConductor, &apos;conductor&apos;, mpiAlbumArtist, &apos;album_artist&apos;, mpiPartNo, &apos;disc&apos;])     
end;

function GetTranscodingFormat: string;
begin
  if mpInternetItem then
    Result := cfgTranscodingRadioFileFormat
  else                                      
    Result := cfgTranscodingAudioFileFormat    
end;

function GetInputFormat: string;
begin
  Result := &apos;-f wav&apos;;  
  if MatchText(mpAudioCodec, [&apos;DCA&apos;, &apos;DTS&apos;]) then
    Result := &apos;-acodec dca &apos; + Result        
end;

function GetInputFileName: string;
var
  sReadPipeName, sWritePipeName, sTranscoderParams: string;
begin
  Result := &apos;&apos;;
  sReadPipeName := &apos;.wav&apos;; sWritePipeName := &apos;.wav&apos;;                
  if HmsCreateDualPipe(sReadPipeName, sWritePipeName) then begin
    sTranscoderParams := Format(&apos;-F -d "%s"&apos;, [InputFileName]);
    if mpTimeStart &lt;&gt; &apos;&apos; then begin
      sTranscoderParams := sTranscoderParams + &apos; --skip=&apos; + HmsCueTime(HmsTimeConvert(mpTimeStart));
      if mpTimeLength &lt;&gt; &apos;&apos; then
        sTranscoderParams := sTranscoderParams + &apos; --until=&apos; +
            HmsCueTime(HmsTimeConvert(mpTimeStart) + HmsTimeConvert(mpTimeLength));
    end;
    sTranscoderParams := sTranscoderParams + Format(&apos; -f -o"%s"&apos;, [sWritePipeName]);
    if HmsTranscodingExecute(&apos;FLAC&apos;, sTranscoderParams, False) then
      Result := sReadPipeName      
  end
end;

procedure GetConfigParameters(var aChannels, aSampleRate, aBitsPerSample: Integer);
begin
  aChannels := mpChannels;                                     
  if aChannels &gt; cfgTranscodingLpcmMaxChannels then  
    aChannels := cfgTranscodingLpcmMaxChannels
  else if aChannels &lt; 2 then  
    aChannels := 2;
  aSampleRate := mpAudioSampleRate;
  if aSampleRate &gt; cfgTranscodingLpcmMaxSampleRate then
    aSampleRate := cfgTranscodingLpcmMaxSampleRate      
  else if aSampleRate &gt; 96000 then    
    aSampleRate := 192000;
  aBitsPerSample := mpBitsPerSample;    
  if aBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
    aBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
  else if aBitsPerSample &lt; 32 then
    aBitsPerSample := 24;
end;

function ReplaceParams(const aText: string; const aParams: array of Variant): string;
var
  i: Integer;
begin
  Result := aText; i := 0;  
  while i &lt; Length(aParams) do begin
    Result := ReplaceStr(Result, aParams[i], VarToStr(aParams[i + 1]));  
    Inc(i, 2)
  end
end;

function GetOutputFormat: string;
var
  iBitsPerSample, iChannels, iSampleRate: Integer;
begin
  Result := HmsTranscodingFormatParams(GetTranscodingFormat, mtAudio);  
  GetConfigParameters(iChannels, iSampleRate, iBitsPerSample);  
  Result := ReplaceParams(Result, [&apos;[bits_per_sample]&apos;, iBitsPerSample, 
                                   &apos;[channels]&apos;, iChannels,
                                   &apos;[sample_rate]&apos;, iSampleRate,
                                   &apos;[sample_format]&apos;, GetSampleFormat(iBitsPerSample)]);
end;

var
  sTranscodingParams: string;
begin
  TranscodingResult := False;  
  sTranscodingParams := Format(&apos;%s -i "%s" %s-f %s "%s"&apos;, 
      [GetInputFormat, GetInputFileName, GetMetadata, GetOutputFormat, OutputFileName]);
  TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams)
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка - FLAC (24bit)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>11</TranscodingProfilePriority>
      <TranscodingProfileUuid>0A185870D0904403A92E8DE0D121ED8F</TranscodingProfileUuid>
    </Profile>
  </TranscodingProfileList>
</HmsTranscodingConfig>
