<?xml version="1.0" encoding="utf-8"?>
<HmsTranscodingConfig version="1.98.1">
  <TranscoderList>
    <Transcoder>
      <Name>ACEPLAYER</Name>
      <Path>%Registry\SOFTWARE\AceStream\InstallDir%\player\ace_player.exe</Path>
      <HomePage>http://www.acestream.org</HomePage>
      <Download>http://www.acestream.org</Download>
    </Transcoder>
    <Transcoder>
      <Name>DVPIPER</Name>
      <Path>Transcoders\dvpiper.exe</Path>
      <HomePage>http://www.cs.usyd.edu.au/~efax/DVPiper.html</HomePage>
      <Download>http://www.cs.usyd.edu.au/~efax/DVPiper.html</Download>
    </Transcoder>
    <Transcoder>
      <Name>FLAC</Name>
      <Path>Transcoders\flac.exe</Path>
      <HomePage>http://flac.sourceforge.net/</HomePage>
      <Download>http://flac.sourceforge.net/download.html</Download>
    </Transcoder>
    <Transcoder>
      <Name>HDSDUMP</Name>
      <Path>Transcoders\hdsdump.exe</Path>
      <HomePage></HomePage>
      <Download>http://lostcut.net/hdsdump/hdsdump.exe</Download>
    </Transcoder>
    <Transcoder>
      <Name>HMSMPEG</Name>
      <Path>hmsmpeg.exe</Path>
      <HomePage>http://www.ffmpeg.org/</HomePage>
      <Download></Download>
    </Transcoder>
    <Transcoder>
      <Name>HmsMPEG</Name>
      <Path>Hmsmpeg.exe</Path>
      <HomePage>http://www.ffmpeg.org/</HomePage>
      <Download></Download>
    </Transcoder>
    <Transcoder>
      <Name>IMAGEMAGICK</Name>
      <Path>%Registry\SOFTWARE\ImageMagick\Current\BinPath%\convert.exe</Path>
      <HomePage>http://www.imagemagick.org/script/index.php</HomePage>
      <Download>http://www.imagemagick.org/script/binary-releases.php#windows</Download>
    </Transcoder>
    <Transcoder>
      <Name>MAC</Name>
      <Path>Transcoders\MAC.exe</Path>
      <HomePage>http://www.monkeysaudio.com</HomePage>
      <Download>http://www.monkeysaudio.com/download.html</Download>
    </Transcoder>
    <Transcoder>
      <Name>MENCODER</Name>
      <Path>mencoder.exe</Path>
      <HomePage>http://www.mplayerhq.hu</HomePage>
      <Download>http://sourceforge.net/project/showfiles.php?group_id=205275</Download>
    </Transcoder>
    <Transcoder>
      <Name>MPLEX</Name>
      <Path>Transcoders\mplex.exe</Path>
      <HomePage>http://mjpeg.sourceforge.net</HomePage>
      <Download>http://sourceforge.net/projects/mjpeg/files/</Download>
    </Transcoder>
    <Transcoder>
      <Name>RTMPDUMP</Name>
      <Path>Transcoders\rtmpdump.exe</Path>
      <HomePage>http://rtmpdump.mplayerhq.hu</HomePage>
      <Download>http://rtmpdump.mplayerhq.hu/download/</Download>
    </Transcoder>
    <Transcoder>
      <Name>SOX</Name>
      <Path>Transcoders\sox.exe</Path>
      <HomePage>http://sox.sourceforge.net</HomePage>
      <Download>http://sox.sourceforge.net</Download>
    </Transcoder>
    <Transcoder>
      <Name>TSMUXER</Name>
      <Path>Transcoders\tsMuxeR.exe</Path>
      <HomePage>http://www.smlabs.net/tsmuxer.html</HomePage>
      <Download>http://www.smlabs.net/tsmuxer.html</Download>
    </Transcoder>
    <Transcoder>
      <Name>VLC</Name>
      <Path>%Registry\SOFTWARE\VideoLAN\VLC\InstallDir%\vlc.exe</Path>
      <HomePage>http://www.videolan.org</HomePage>
      <Download>http://www.videolan.org</Download>
    </Transcoder>
    <Transcoder>
      <Name>WVUNPACK</Name>
      <Path>Transcoders\wvunpack.exe</Path>
      <HomePage>http://www.wavpack.com/</HomePage>
      <Download>http://www.wavpack.com/downloads.html</Download>
    </Transcoder>
    <Transcoder>
      <Name>hmsMPEG</Name>
      <Path>hmsmpeg.exe</Path>
      <HomePage>http://www.ffmpeg.org/</HomePage>
      <Download></Download>
    </Transcoder>
  </TranscoderList>
  <TranscodingProfileList>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для TorrentStream, AceStream медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>cfgTranscodingVideoMimeType</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csVlcParams = &apos;-Idummy --language en vlc://pause:2 --demuxdump-file="%s" --access=p2p_access "%s" :demux=dump&apos;;  
var
  sFileType, sInputFileName, sMediaResourceLink, sReadPipeName, sWritePipeName, sTranscodingParams: string;    
begin
  TranscodingResult := False;
  sInputFileName := InputFileName;
  if sInputFileName = &apos;-&apos; then begin
    sMediaResourceLink := HmsGetItemProperty(mpiMediaResourceLink);
    if Pos(&apos;--demuxdump-file&apos;, sMediaResourceLink) &gt; 0 then begin
      if not HmsRegExMatch(&apos;--access=p2p_access "(.*?)"&apos;, sMediaResourceLink, sInputFileName) then 
        HmsRegExMatch(&apos;"(.*?\.torrent)"&apos;, sMediaResourceLink, sInputFileName)
     end    
  end;      
  if HmsCreateDualPipe(sReadPipeName, sWritePipeName) then begin
    if HmsTranscodingExecute(&apos;ACEPLAYER&apos;, Format(csVlcParams, [sWritePipeName, sInputFileName]), False) then begin    
      if mpFileType &lt;&gt; &apos;&apos; then      
        sFileType := &apos;-f "&apos; + mpFileType + &apos;" &apos;
      else                          
        sFileType := &apos;&apos;;
      mpInternetItem := False;
      sTranscodingParams := HmsTranscodingProfileParams(&apos;Фильмы (основной)&apos;);
      sTranscodingParams := ReplaceStr(sTranscodingParams, &apos;&lt;HMSMPEG&gt; &apos;, sFileType);          
      sTranscodingParams := ReplaceStr(sTranscodingParams, &apos;&lt;INPUT FILE&gt;&apos;, sReadPipeName);      
      sTranscodingParams := sTranscodingParams + &apos; "&apos; + OutputFileName + &apos;"&apos;;
      TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, True)          
    end 
  end 
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>AceStream (ACEPLAYER - FFMPEG)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>36</TranscodingProfilePriority>
      <TranscodingProfileUuid>09d8f390-166e-4b6d-88cf-64820cf53475</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>ACEPLAYER</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для TorrentStream, AceStream медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>function GetAudioCodec: string;
begin
  if Pos(&apos;wmv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;wma2&apos;    
  else if (Pos(&apos;IPOD&apos;, UpperCase(cfgDeviceType)) &gt; 0) or
          (Pos(&apos;LG&apos;, UpperCase(cfgDeviceType)) = 1) or
          SameText(cfgTranscodingAudioCodec, &apos;AAC&apos;) or 
          (Pos(&apos;flv&apos;, cfgTranscodingTvsetMimeType) &gt; 0) then  
    Result := &apos;aac&apos;
  else if Pos(&apos;SONY&apos;, UpperCase(cfgDeviceType)) &gt; 0 then  
    Result := &apos;mpga&apos;
  else                
    Result := &apos;mpga&apos;    
end;

function GetFileFormat: string;
begin
  if Pos(&apos;wmv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;asf&apos;    
  else if Pos(&apos;flv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;ffmpeg{mux=flv}&apos;
  else if (Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0) or
          (Pos(&apos;SONY&apos;, UpperCase(cfgDeviceType)) &gt; 0) or
          (Pos(&apos;IPOD&apos;, UpperCase(cfgDeviceType)) &gt; 0) then           
    Result := &apos;ts&apos;    
  else     
    Result := &apos;mpeg1&apos;
end;

function GetSampleRate: Integer;
begin
  if SameText(cfgTranscodingFileFormat, &apos;FLV&apos;) then  
    Result := 44100
  else
    Result := 48000   
end;

const
  csVideoLanParams =                                 
    &apos;--no-crashdump --play-and-exit -Idummy --language=en%s %s--sout=#%stranscode&apos; +
    &apos;{acodec=%s,ab=%d,channels=2,&apos; +
    &apos;samplerate=%d}:duplicate{dst=std{access=file,mux=%s,dst="&lt;OUTPUT FILE&gt;"}}&apos; +
    &apos;%s --access=p2p_access "%s"&apos;; //  vlc:quit
    
var 
  i, iAudioStreamID: Integer;
  sAudioTrackID, sGather, sInputFileName, sMediaResourceLink, 
  sInternetTelevisionSplash, sKeepOut: string;
begin
  sInputFileName := &apos;&lt;INPUT FILE&gt;&apos;;
  if InputFileName = &apos;-&apos; then begin
    sMediaResourceLink := HmsGetItemProperty(mpiMediaResourceLink);
    if Pos(&apos;--demuxdump-file&apos;, sMediaResourceLink) &gt; 0 then begin
      if not HmsRegExMatch(&apos;--access=p2p_access "(.*?)"&apos;, sMediaResourceLink, sInputFileName) then 
        HmsRegExMatch(&apos;"(.*?\.torrent)"&apos;, sMediaResourceLink, sInputFileName)
     end    
  end;
  if cfgInternetTelevisionSplash &lt;&gt; &apos;&apos; then begin  
    sInternetTelevisionSplash := Format(&apos; "%s"&apos;, [cfgInternetTelevisionSplash]);    
    sGather  := &apos;gather:&apos;;                                              
    sKeepOut := &apos;--sout-keep &apos;;
  end else begin                             
    sInternetTelevisionSplash := &apos;&apos;;
    sGather  := &apos;&apos;;
    sKeepOut := &apos;&apos;    
  end;
  if mpAudioStreamNo &gt;= 0 then begin  
    iAudioStreamID := HmsGetStreamID(stAudio, mpAudioStreamNo);    
    if iAudioStreamID &lt; 100 then                          
      sAudioTrackID := &apos; --audio-track=&apos; + IntToStr(mpAudioStreamNo)      
    else
      sAudioTrackID := &apos; --audio-track-id=&apos; + IntToStr(iAudioStreamID)
  end else                 
    sAudioTrackID := &apos;&apos;;
  TranscodingParams := Format(csVideoLanParams, 
                               [sAudioTrackID, sKeepOut, sGather, GetAudioCodec,
                                Min(cfgTranscodingAudioBitrate div 1000, 192),                                              
                                GetSampleRate, GetFileFormat, sInternetTelevisionSplash, 
                                sInputFileName]);                                
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>AceStream (Видео без изменения)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>29</TranscodingProfilePriority>
      <TranscodingProfileUuid>e750c8a7-46f7-4794-adaa-a4c58a717567</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>ACEPLAYER</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для TorrentStream, AceStream медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>var
  i: Integer;
  sFileExt: string;
begin
  if mpFileType &lt;&gt; &apos;&apos; then begin
    if SameText(mpFileType, &apos;mpegts&apos;) then  
      sFileExt := &apos;ts&apos;    
    else if SameText(mpFileType, &apos;mpeg&apos;) then
      sFileExt := &apos;mpg&apos;      
    else if MatchText(mpFileType, [&apos;matroska&apos;, &apos;matroska,webm&apos;]) then
      sFileExt := &apos;mkv&apos;
    else if SameText(mpFileType, &apos;asf&apos;) then  
      sFileExt := &apos;wmv&apos;    
    else begin  
      i := Pos(&apos;,&apos;, mpFileType);    
      if i &gt; 0 then    
        sFileExt := Copy(mpFileType, 1, i - 1)      
      else              
        sFileExt := mpFileType      
    end;    
    MimeType := HmsGetMimeType(sFileExt)
  end                                   
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csVideoLanParams = &apos;--no-crashdump --play-and-exit -Idummy --language en --demuxdump-file="&lt;OUTPUT FILE&gt;" --access=p2p_access "%s" :demux=dump&apos;;
var
  sInputFileName, sMediaResourceLink: string;  
begin
  sInputFileName := &apos;&lt;INPUT FILE&gt;&apos;;
  if InputFileName = &apos;-&apos; then begin
    sMediaResourceLink := HmsGetItemProperty(mpiMediaResourceLink);
    if Pos(&apos;--demuxdump-file&apos;, sMediaResourceLink) &gt; 0 then begin
      if not HmsRegExMatch(&apos;--access=p2p_access "(.*?)"&apos;, sMediaResourceLink, sInputFileName) then 
        HmsRegExMatch(&apos;"(.*?\.torrent)"&apos;, sMediaResourceLink, sInputFileName)
    end    
  end;
  TranscodingParams := Format(csVideoLanParams, [sInputFileName])  
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>AceStream (Входной поток)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>31</TranscodingProfilePriority>
      <TranscodingProfileUuid>9b658aac-e270-40ba-9114-0ca9d833c2a1</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>ACEPLAYER</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для TorrentStream, AceStream медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>function GetAudioCodec: string;
begin
  if Pos(&apos;wmv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;wma2&apos;    
  else if (Pos(&apos;IPOD&apos;, UpperCase(cfgDeviceType)) &gt; 0) or
          (Pos(&apos;LG&apos;, UpperCase(cfgDeviceType)) = 1) or
          SameText(cfgTranscodingAudioCodec, &apos;AAC&apos;) or 
          (Pos(&apos;flv&apos;, cfgTranscodingTvsetMimeType) &gt; 0) then  
    Result := &apos;aac&apos;
  else if Pos(&apos;SONY&apos;, UpperCase(cfgDeviceType)) &gt; 0 then  
    Result := &apos;mpga&apos;
  else                
    Result := &apos;mpga&apos;    
end;

function GetFileFormat: string;
begin
  if Pos(&apos;wmv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;asf&apos;    
  else if Pos(&apos;flv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;ffmpeg{mux=flv}&apos;
  else if (Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0) or
          (Pos(&apos;SONY&apos;, UpperCase(cfgDeviceType)) &gt; 0) or
          (Pos(&apos;IPOD&apos;, UpperCase(cfgDeviceType)) &gt; 0) then           
    Result := &apos;ts&apos;    
  else     
    Result := &apos;mpeg1&apos;
end;

function GetVideoCodec: string;
begin
  if Pos(&apos;wmv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then                    
    if SameText(cfgTranscodingVideoCodec, &apos;X264&apos;) and (Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0) then
      Result := &apos;h264&apos;      
    else
      Result := &apos;wmv2&apos;
  else if (Pos(&apos;IPOD&apos;, UpperCase(cfgDeviceType)) &gt; 0) or SameText(cfgTranscodingVideoCodec, &apos;X264&apos;) or 
          (Pos(&apos;flv&apos;, cfgTranscodingTvsetMimeType) &gt; 0) then  
    Result := &apos;h264&apos;    
  else
    Result := &apos;mp2v&apos;  
end;

function GetSampleRate: Integer;
begin
  if SameText(cfgTranscodingFileFormat, &apos;FLV&apos;) then  
    Result := 44100
  else
    Result := 48000   
end;

const
  csVideoLanParams =                                 
    &apos;--no-crashdump --play-and-exit -Idummy --language=en%s%s --sout-ffmpeg-rc-buffer-size=%d %s--sout=#%stranscode&apos; +
    &apos;{vcodec=%s,vb=%d,fps=%s,scale=1%s,acodec=%s,ab=%d,channels=2,&apos; +
    &apos;samplerate=%d%s%s}:duplicate{dst=std{access=file,mux=%s,dst="&lt;OUTPUT FILE&gt;"}}&apos; +
    &apos;%s --access=p2p_access "%s"&apos;; //  vlc:quit
    
var 
  i, iWidth, iHeight, iAspectWidth, iAspectHeight, iAudioStreamID: Integer;
  sAudioTrackID, sCanvasParams, sFrameRate, sDeinterlace, sGather, 
  sInternetTelevisionSplash, sInputFileName, sKeepOut, sMediaResourceLink,
  sSubtitleParams, sSubtitleStreamID, sSubtitleLanguage, sSubtitleOverlay: string;  
begin
  sInputFileName := &apos;&lt;INPUT FILE&gt;&apos;;
  if InputFileName = &apos;-&apos; then begin
    sMediaResourceLink := HmsGetItemProperty(mpiMediaResourceLink);
    if Pos(&apos;--demuxdump-file&apos;, sMediaResourceLink) &gt; 0 then begin
      if not HmsRegExMatch(&apos;--access=p2p_access "(.*?)"&apos;, sMediaResourceLink, sInputFileName) then 
        HmsRegExMatch(&apos;"(.*?\.torrent)"&apos;, sMediaResourceLink, sInputFileName)
     end    
  end;
  if HmsGetVideoSettings(vstDeinterlace) = &apos;on&apos; then 
    sDeinterlace := &apos;,deinterlace&apos;
  else
    sDeinterlace := &apos;&apos;;                        
  if cfgInternetTelevisionSplash &lt;&gt; &apos;&apos; then begin  
    sInternetTelevisionSplash := Format(&apos; "%s"&apos;, [cfgInternetTelevisionSplash]);    
    sGather  := &apos;gather:&apos;;                                              
    sKeepOut := &apos;--sout-keep &apos;;
  end else begin                             
    sInternetTelevisionSplash := &apos;&apos;;
    sGather  := &apos;&apos;;
    sKeepOut := &apos;&apos;    
  end;
  if mpInternetItem then
    sFrameRate := &apos;24&apos;
  else if cfgTranscodingFrameRate &lt;&gt; &apos;&apos; then                                      
    sFrameRate := cfgTranscodingFrameRate
  else if mpFrameRate &gt; 0 then
    sFrameRate := FormatFloat(&apos;0.000&apos;, mpFrameRate)
  else
    sFrameRate := &apos;25&apos;;
  if SameFloat(sFrameRate, &apos;23.976&apos;) then
    sFrameRate := &apos;24&apos;
  else if SameFloat(sFrameRate, &apos;29.970&apos;) then
    sFrameRate := &apos;30&apos;
  else if SameFloat(sFrameRate, &apos;59.940&apos;) then
    sFrameRate := &apos;60&apos;;    
  iWidth := mpWidth;     
  if iWidth &gt; 0 then begin                         
    i := Pos(&apos;:&apos;, cfgTranscodingScreenFormat);
    if i &gt; 0 then begin
      iAspectWidth  := StrToIntDef(Copy(cfgTranscodingScreenFormat, 1, i - 1), 16);
      iAspectHeight := StrToIntDef(Copy(cfgTranscodingScreenFormat, i + 1, 10), 9);      
    end else begin         
      iAspectWidth  := 16;
      iAspectHeight := 9      
    end;
    if iWidth &gt; cfgTranscodingScreenWidth then
      iWidth := cfgTranscodingScreenWidth;
    if iWidth &gt; 1280 then    
      iWidth := 1280;
    iHeight := Round((iWidth / iAspectWidth) * iAspectHeight);
    if iHeight mod 2 &lt;&gt; 0 then
      Inc(iHeight); 
    sCanvasParams := Format(&apos;,vfilter={canvas{width=%d,height=%d,aspect=%s}}&apos;, [iWidth, iHeight, cfgTranscodingScreenFormat]);
  end else
    sCanvasParams := &apos;&apos;;          
  if mpAudioStreamNo &gt;= 0 then begin  
    iAudioStreamID := HmsGetStreamID(stAudio, mpAudioStreamNo);    
    if iAudioStreamID &lt; 100 then                          
      sAudioTrackID := &apos; --audio-track=&apos; + IntToStr(mpAudioStreamNo)      
    else
      sAudioTrackID := &apos; --audio-track-id=&apos; + IntToStr(iAudioStreamID)
  end else                 
    sAudioTrackID := &apos;&apos;;
  sSubtitleParams  := &apos;&apos;;              
  sSubtitleOverlay := &apos;&apos;;                           
  if mpSubtitleLanguage &lt;&gt; &apos;&apos; then begin  
    if HmsRegExMatch(&apos;(.*?) &apos;, mpSubtitleLanguage, sSubtitleLanguage) and (Trim(sSubtitleLanguage) &lt;&gt; &apos;&apos;) then
      sSubtitleParams := &apos; --sub-language=&apos; + sSubtitleLanguage
    else if HmsRegExMatch(&apos;\[0x(.*?)\]&apos;, mpSubtitleLanguage, sSubtitleStreamID) then    
      sSubtitleParams := &apos; --sub-track-id=&apos; + IntToStr(StrToIntDef(&apos;$&apos; + sSubtitleStreamID, 0));      
    if sSubtitleParams &lt;&gt; &apos;&apos; then
      sSubtitleOverlay := &apos;,soverlay&apos;  
  end;          
  TranscodingParams := Format(csVideoLanParams, 
                               [sAudioTrackID, sSubtitleParams,
                                HmsTranscodingBufferSize(Min(cfgTranscodingVideoBitrate, 12000000)),
                                sKeepOut, sGather, GetVideoCodec,
                                Min(cfgTranscodingVideoBitrate div 1000, 12000), sFrameRate,
                                sCanvasParams, 
                                GetAudioCodec,
                                Min(cfgTranscodingAudioBitrate div 1000, 192),                                              
                                GetSampleRate,
                                sDeinterlace, sSubtitleOverlay, GetFileFormat,
                                sInternetTelevisionSplash, sInputFileName]);                                
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>AceStream (Перекодирование)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>26</TranscodingProfilePriority>
      <TranscodingProfileUuid>c7cead5f-1074-4d61-9b17-b89176b01197</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>ACEPLAYER</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для TorrentStream, AceStream медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csVideoLanParams = &apos;--no-crashdump --play-and-exit -Idummy --language en%s --sout /%s:"&lt;OUTPUT FILE&gt;" --access=p2p_access "%s"&apos;;

function GetFileFormat(const aFileFormat: string): string;
begin
  if Pos(&apos;ASF&apos;, aFileFormat) &gt; 0 then
    Result := &apos;asf&apos;
  else if Pos(&apos;MPEGTS&apos;, aFileFormat) &gt; 0 then
    Result := &apos;ts&apos;
  else  
    Result := &apos;ps&apos;
end;

var
  iAudioStreamID: Integer;  
  sAudioTrackID, sInputFileName, sMediaResourceLink: string;
begin
  sInputFileName := &apos;&lt;INPUT FILE&gt;&apos;;
  if InputFileName = &apos;-&apos; then begin
    sMediaResourceLink := HmsGetItemProperty(mpiMediaResourceLink);
    if Pos(&apos;--demuxdump-file&apos;, sMediaResourceLink) &gt; 0 then begin
      if not HmsRegExMatch(&apos;--access=p2p_access "(.*?)"&apos;, sMediaResourceLink, sInputFileName) then 
        HmsRegExMatch(&apos;"(.*?\.torrent)"&apos;, sMediaResourceLink, sInputFileName)
     end    
  end;
  if mpAudioStreamNo &gt;= 0 then begin  
    iAudioStreamID := HmsGetStreamID(stAudio, mpAudioStreamNo);    
    if iAudioStreamID &lt; 100 then                          
      sAudioTrackID := &apos; --audio-track=&apos; + IntToStr(mpAudioStreamNo)      
    else
      sAudioTrackID := &apos; --audio-track-id=&apos; + IntToStr(iAudioStreamID)
  end else                 
    sAudioTrackID := &apos;&apos;;
  TranscodingParams := Format(csVideoLanParams, [sAudioTrackID, GetFileFormat(cfgTranscodingFileFormat), sInputFileName])
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>AceStream (Ремуксирование)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>35</TranscodingProfilePriority>
      <TranscodingProfileUuid>1a85b66a-af4d-41f3-91ae-4cb5e64a86d2</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>VLC</TranscoderName>
      <TranscodingCondition>mpInternetItem</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для интернет медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>function GetAudioCodec: string;
begin
  if Pos(&apos;wmv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;wma2&apos;    
  else if (Pos(&apos;IPOD&apos;, UpperCase(cfgDeviceType)) &gt; 0) or
          (Pos(&apos;LG&apos;, UpperCase(cfgDeviceType)) = 1) or
          SameText(cfgTranscodingAudioCodec, &apos;AAC&apos;) or 
          (Pos(&apos;flv&apos;, cfgTranscodingTvsetMimeType) &gt; 0) then  
    Result := &apos;aac&apos;
  else if Pos(&apos;SONY&apos;, UpperCase(cfgDeviceType)) &gt; 0 then  
    Result := &apos;mpga&apos;
  else                
    Result := &apos;mpga&apos;    
end;

function GetFileFormat: string;
begin
  if Pos(&apos;wmv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;asf&apos;    
  else if Pos(&apos;flv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;ffmpeg{mux=flv}&apos;
  else if (Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0) or
          (Pos(&apos;SONY&apos;, UpperCase(cfgDeviceType)) &gt; 0) or
          (Pos(&apos;IPOD&apos;, UpperCase(cfgDeviceType)) &gt; 0) then           
    Result := &apos;ts&apos;    
  else     
    Result := &apos;mpeg1&apos;
end;

function GetVideoCodec: string;
begin
  if Pos(&apos;wmv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then                    
    if SameText(cfgTranscodingVideoCodec, &apos;X264&apos;) and (Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0) then
      Result := &apos;h264&apos;      
    else
      Result := &apos;wmv2&apos;
  else if (Pos(&apos;IPOD&apos;, UpperCase(cfgDeviceType)) &gt; 0) or SameText(cfgTranscodingVideoCodec, &apos;X264&apos;) or 
          (Pos(&apos;flv&apos;, cfgTranscodingTvsetMimeType) &gt; 0) then  
    Result := &apos;h264&apos;    
  else
    Result := &apos;mp2v&apos;  
end;

function GetSampleRate: Integer;
begin
  if SameText(cfgTranscodingFileFormat, &apos;FLV&apos;) then  
    Result := 44100
  else
    Result := 48000   
end;

const
  csVideoLanParams =                                 
    &apos;--no-crashdump -Idummy --language=en%s%s --sout-ffmpeg-rc-buffer-size=%d %s--sout=#%stranscode&apos; +
    &apos;{vcodec=%s,vb=%d,fps=%s,scale=1%s,acodec=%s,ab=%d,channels=2,&apos; +
    &apos;samplerate=%d%s%s}:duplicate{dst=std{access=file,mux=%s,dst="&lt;OUTPUT FILE&gt;"}}&apos; +
    &apos;%s "&lt;INPUT FILE&gt;"&apos;; //  vlc:quit
    
var 
  i, iWidth, iHeight, iAspectWidth, iAspectHeight, iAudioStreamID: Integer;
  sAudioTrackID, sCanvasParams, sFrameRate, sDeinterlace, sGather, 
  sInternetTelevisionSplash, sKeepOut, sSubtitleParams, sSubtitleStreamID, 
  sSubtitleLanguage, sSubtitleOverlay: string;  
begin
  if HmsGetVideoSettings(vstDeinterlace) = &apos;on&apos; then 
    sDeinterlace := &apos;,deinterlace&apos;
  else
    sDeinterlace := &apos;&apos;;                        
  if cfgInternetTelevisionSplash &lt;&gt; &apos;&apos; then begin  
    sInternetTelevisionSplash := Format(&apos; "%s"&apos;, [cfgInternetTelevisionSplash]);    
    sGather  := &apos;gather:&apos;;                                              
    sKeepOut := &apos;--sout-keep &apos;;
  end else begin                             
    sInternetTelevisionSplash := &apos;&apos;;
    sGather  := &apos;&apos;;
    sKeepOut := &apos;&apos;    
  end;
  if mpInternetItem then
    sFrameRate := &apos;24&apos;
  else if cfgTranscodingFrameRate &lt;&gt; &apos;&apos; then                                      
    sFrameRate := cfgTranscodingFrameRate
  else if mpFrameRate &gt; 0 then
    sFrameRate := FormatFloat(&apos;0.000&apos;, mpFrameRate)
  else
    sFrameRate := &apos;25&apos;;
  if SameFloat(sFrameRate, &apos;23.976&apos;) then
    sFrameRate := &apos;24&apos;
  else if SameFloat(sFrameRate, &apos;29.970&apos;) then
    sFrameRate := &apos;30&apos;
  else if SameFloat(sFrameRate, &apos;59.940&apos;) then
    sFrameRate := &apos;60&apos;;    
  iWidth := mpWidth;     
  if iWidth &gt; 0 then begin                         
    i := Pos(&apos;:&apos;, cfgTranscodingScreenFormat);
    if i &gt; 0 then begin
      iAspectWidth  := StrToIntDef(Copy(cfgTranscodingScreenFormat, 1, i - 1), 16);
      iAspectHeight := StrToIntDef(Copy(cfgTranscodingScreenFormat, i + 1, 10), 9);      
    end else begin         
      iAspectWidth  := 16;
      iAspectHeight := 9      
    end;
    if iWidth &gt; cfgTranscodingScreenWidth then
      iWidth := cfgTranscodingScreenWidth;
    if iWidth &gt; 1280 then    
      iWidth := 1280;
    iHeight := Round((iWidth / iAspectWidth) * iAspectHeight);
    if iHeight mod 2 &lt;&gt; 0 then
      Inc(iHeight); 
    sCanvasParams := Format(&apos;,vfilter={canvas{width=%d,height=%d,aspect=%s}}&apos;, [iWidth, iHeight, cfgTranscodingScreenFormat]);
  end else
    sCanvasParams := &apos;&apos;;          
  if mpAudioStreamNo &gt;= 0 then begin  
    iAudioStreamID := HmsGetStreamID(stAudio, mpAudioStreamNo);    
    if iAudioStreamID &lt; 100 then                          
      sAudioTrackID := &apos; --audio-track=&apos; + IntToStr(mpAudioStreamNo)      
    else
      sAudioTrackID := &apos; --audio-track-id=&apos; + IntToStr(iAudioStreamID)
  end else                 
    sAudioTrackID := &apos;&apos;;
  sSubtitleParams  := &apos;&apos;;              
  sSubtitleOverlay := &apos;&apos;;                           
  if mpSubtitleLanguage &lt;&gt; &apos;&apos; then begin  
    if HmsRegExMatch(&apos;(.*?) &apos;, mpSubtitleLanguage, sSubtitleLanguage) and (Trim(sSubtitleLanguage) &lt;&gt; &apos;&apos;) then
      sSubtitleParams := &apos; --sub-language=&apos; + sSubtitleLanguage
    else if HmsRegExMatch(&apos;\[0x(.*?)\]&apos;, mpSubtitleLanguage, sSubtitleStreamID) then    
      sSubtitleParams := &apos; --sub-track-id=&apos; + IntToStr(StrToIntDef(&apos;$&apos; + sSubtitleStreamID, 0));      
    if sSubtitleParams &lt;&gt; &apos;&apos; then
      sSubtitleOverlay := &apos;,soverlay&apos;  
  end;          
  TranscodingParams := Format(csVideoLanParams, 
                               [sAudioTrackID, sSubtitleParams,
                                HmsTranscodingBufferSize(Min(cfgTranscodingVideoBitrate, 12000000)),
                                sKeepOut, sGather, GetVideoCodec,
                                Min(cfgTranscodingVideoBitrate div 1000, 12000), sFrameRate,
                                sCanvasParams, 
                                GetAudioCodec,
                                Min(cfgTranscodingAudioBitrate div 1000, 192),                                              
                                GetSampleRate,
                                sDeinterlace, sSubtitleOverlay, GetFileFormat,
                                sInternetTelevisionSplash]);                                
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Интернет-телевидение</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>25</TranscodingProfilePriority>
      <TranscodingProfileUuid>1C044A2C92D743E0A29B8EBD557961F1</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>VLC</TranscoderName>
      <TranscodingCondition>mpInternetItem</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для интернет медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>function GetAudioCodec: string;
begin
  if Pos(&apos;wmv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;wma2&apos;    
  else if (Pos(&apos;IPOD&apos;, UpperCase(cfgDeviceType)) &gt; 0) or
          (Pos(&apos;LG&apos;, UpperCase(cfgDeviceType)) = 1) or
          SameText(cfgTranscodingAudioCodec, &apos;AAC&apos;) or 
          (Pos(&apos;flv&apos;, cfgTranscodingTvsetMimeType) &gt; 0) then  
    Result := &apos;aac&apos;
  else if Pos(&apos;SONY&apos;, UpperCase(cfgDeviceType)) &gt; 0 then  
    Result := &apos;mpga&apos;
  else                
    Result := &apos;mpga&apos;    
end;

function GetFileFormat: string;
begin
  if Pos(&apos;wmv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;asf&apos;    
  else if Pos(&apos;flv&apos;, cfgTranscodingTvsetMimeType) &gt; 0 then
    Result := &apos;ffmpeg{mux=flv}&apos;
  else if (Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0) or
          (Pos(&apos;SONY&apos;, UpperCase(cfgDeviceType)) &gt; 0) or
          (Pos(&apos;IPOD&apos;, UpperCase(cfgDeviceType)) &gt; 0) then           
    Result := &apos;ts&apos;    
  else     
    Result := &apos;mpeg1&apos;
end;

function GetSampleRate: Integer;
begin
  if SameText(cfgTranscodingFileFormat, &apos;FLV&apos;) then  
    Result := 44100
  else
    Result := 48000   
end;

const
  csVideoLanParams =                                 
    &apos;--no-crashdump -Idummy --language=en%s %s--sout=#%stranscode&apos; +
    &apos;{acodec=%s,ab=%d,channels=2,&apos; +
    &apos;samplerate=%d}:duplicate{dst=std{access=file,mux=%s,dst="&lt;OUTPUT FILE&gt;"}}&apos; +
    &apos;%s "&lt;INPUT FILE&gt;"&apos;; //  vlc:quit
    
var 
  i, iAudioStreamID: Integer;
  sAudioTrackID, sGather, sInternetTelevisionSplash, sKeepOut: string;  
begin
  if cfgInternetTelevisionSplash &lt;&gt; &apos;&apos; then begin  
    sInternetTelevisionSplash := Format(&apos; "%s"&apos;, [cfgInternetTelevisionSplash]);    
    sGather  := &apos;gather:&apos;;                                              
    sKeepOut := &apos;--sout-keep &apos;;
  end else begin                             
    sInternetTelevisionSplash := &apos;&apos;;
    sGather  := &apos;&apos;;
    sKeepOut := &apos;&apos;    
  end;
  if mpAudioStreamNo &gt;= 0 then begin  
    iAudioStreamID := HmsGetStreamID(stAudio, mpAudioStreamNo);    
    if iAudioStreamID &lt; 100 then                          
      sAudioTrackID := &apos; --audio-track=&apos; + IntToStr(mpAudioStreamNo)      
    else
      sAudioTrackID := &apos; --audio-track-id=&apos; + IntToStr(iAudioStreamID)
  end else                 
    sAudioTrackID := &apos;&apos;;
  TranscodingParams := Format(csVideoLanParams, 
                               [sAudioTrackID, sKeepOut, sGather, GetAudioCodec,
                                Min(cfgTranscodingAudioBitrate div 1000, 192),                                              
                                GetSampleRate, GetFileFormat, sInternetTelevisionSplash]);                                
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Интернет-телевидение (Видео без изменения)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>28</TranscodingProfilePriority>
      <TranscodingProfileUuid>c4e9d0bd-4a79-48b7-b1d9-8d99678881e0</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>VLC</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для интернет медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>var
  i: Integer;
  sFileExt: string;
begin
  if mpFileType &lt;&gt; &apos;&apos; then begin
    if SameText(mpFileType, &apos;mpegts&apos;) then  
      sFileExt := &apos;ts&apos;    
    else if SameText(mpFileType, &apos;mpeg&apos;) then
      sFileExt := &apos;mpg&apos;      
    else if MatchText(mpFileType, [&apos;matroska&apos;, &apos;matroska,webm&apos;]) then
      sFileExt := &apos;mkv&apos;
    else if SameText(mpFileType, &apos;asf&apos;) then  
      sFileExt := &apos;wmv&apos;    
    else begin  
      i := Pos(&apos;,&apos;, mpFileType);    
      if i &gt; 0 then    
        sFileExt := Copy(mpFileType, 1, i - 1)      
      else              
        sFileExt := mpFileType      
    end;    
    MimeType := HmsGetMimeType(sFileExt)
  end                                   
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>--no-crashdump -Idummy --language en --demuxdump-file="&lt;OUTPUT FILE&gt;" "&lt;INPUT FILE&gt;" :demux=dump vlc://quit</TranscodingParams>
      <TranscodingParamsSyntaxType>Нет скрипта</TranscodingParamsSyntaxType>
      <TranscodingProfile>Интернет-телевидение (Входной поток)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>27</TranscodingProfilePriority>
      <TranscodingProfileUuid>8B892F80A3BF4C93AB5A9D88C562298A</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>VLC</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для интернет медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csVideoLanParams = &apos;--no-crashdump -Idummy --language en%s --sout /%s:"&lt;OUTPUT FILE&gt;" "&lt;INPUT FILE&gt;"&apos;;

function GetFileFormat(const aFileFormat: string): string;
begin
  if Pos(&apos;ASF&apos;, aFileFormat) &gt; 0 then
    Result := &apos;asf&apos;
  else if Pos(&apos;MPEGTS&apos;, aFileFormat) &gt; 0 then
    Result := &apos;ts&apos;
  else  
    Result := &apos;ps&apos;
end;

var
  iAudioStreamID: Integer;  
  sAudioTrackID: string;
begin
  if mpAudioStreamNo &gt;= 0 then begin  
    iAudioStreamID := HmsGetStreamID(stAudio, mpAudioStreamNo);    
    if iAudioStreamID &lt; 100 then                          
      sAudioTrackID := &apos; --audio-track=&apos; + IntToStr(mpAudioStreamNo)      
    else
      sAudioTrackID := &apos; --audio-track-id=&apos; + IntToStr(iAudioStreamID)
  end else                 
    sAudioTrackID := &apos;&apos;;
  TranscodingParams := Format(csVideoLanParams, [sAudioTrackID, GetFileFormat(cfgTranscodingFileFormat)])
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Интернет-телевидение (Ремуксирование)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>32</TranscodingProfilePriority>
      <TranscodingProfileUuid>8BF577F799654E3FAAF82790F9F9C508</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>VLC</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>MimeType := HmsGetMimeType(&apos;s16be&apos;)</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csVideoLanParams =
    &apos;-Idummy --language en --sout=#transcode{acodec=s16be,channels=2,&apos; +
    &apos;samplerate=44100}:duplicate{dst=std{access=file,mux=raw,dst="&lt;OUTPUT FILE&gt;"}}&apos; +
    &apos; "&lt;INPUT FILE&gt;" vlc://quit&apos;;
begin
  TranscodingParams := csVideoLanParams
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка (VLC) - LPCM</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>9</TranscodingProfilePriority>
      <TranscodingProfileUuid>fc75b353-6fcf-4936-966b-bbb57b36532c</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>VLC</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>MimeType := HmsGetMimeType(&apos;mp3&apos;)</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csVideoLanParams =
    &apos;-Idummy --language en --sout=#transcode{acodec=mp3,ab=%d,channels=2,&apos; +
    &apos;samplerate=44100}:duplicate{dst=std{access=file,mux=raw,dst="&lt;OUTPUT FILE&gt;"}}&apos; +
    &apos; "&lt;INPUT FILE&gt;" vlc://quit&apos;;
begin
  TranscodingParams := Format(csVideoLanParams, 320)
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка (VLC) - MP3</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>6</TranscodingProfilePriority>
      <TranscodingProfileUuid>9D2C609435524F3B8069D8D66290232B</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition>SameText(ExtractFileExt(mpFilePath), &apos;.wav&apos;)</TranscodingCondition>
      <TranscodingConditionSyntaxType>Нет скрипта</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>begin
  mpAudioCodec := &apos;dca&apos;;
  TranscodingParams := HmsTranscodingProfileParams(&apos;Музыка (основной)&apos;)
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка (WAV-DTS)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>11</TranscodingProfilePriority>
      <TranscodingProfileUuid>EF03BCC75AA14212827C29C557269086</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition>(CurrentMediaItem &lt;&gt; nil) and (CurrentMediaItem.ItemOrigin.MediaType = mtAudio)</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для специальных папок (Цифровое телевидение - DVB, Музыка - Визуализация, Фото - Слайд-шоу)</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csFFMpegParams = &apos;-s %dx%d -r %s -pix_fmt rgb32 -f rawvideo -i "%s" -f wav -i "%s" &apos; + 
                   &apos;-vcodec %s %s%s%s -r %s -acodec %s -b:a %d -ac 2 -t %d -f %s "%s"&apos;; //  

function GetAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) or SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;libfaac&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;libmp3lame&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := &apos;wmav2&apos;
  else
    Result := aAudioCodec
end;

function GetFileFormat(const aFileFormat: string): string;
begin
  if (aFileFormat = &apos;&apos;) or SameText(aFileFormat, &apos;MPEG (DVD)&apos;) then
    Result := &apos;dvd&apos;
  else if Pos(&apos;MPEGTS&apos;, aFileFormat) &gt; 0 then
    Result := &apos;mpegts&apos;
  else if Pos(&apos;ASF&apos;, aFileFormat) &gt; 0 then
    Result := &apos;asf&apos;
  else if SameText(aFileFormat, &apos;MP4&apos;) then
    Result := &apos;ipod&apos;
  else if SameText(aFileFormat, &apos;MPEG1&apos;) then
    Result := &apos;mpeg&apos;
  else
    Result := aFileFormat
end;

function GetVideoCodec(const aVideoCodec: string): string;
begin
  if (aVideoCodec = &apos;&apos;) or SameText(aVideoCodec, &apos;MPEG2&apos;) then
    Result := &apos;mpeg2video&apos;
  else if SameText(aVideoCodec, &apos;MPEG1&apos;) then
    Result := &apos;mpeg1video&apos;
  else if SameText(aVideoCodec, &apos;WMV&apos;) then
    Result := &apos;wmv2&apos;
  else if SameText(aVideoCodec, &apos;MPEG4&apos;) then
    Result := &apos;mpeg4&apos;
  else if SameText(aVideoCodec, &apos;X264&apos;) then
    Result := &apos;libx264 -x264opts "fast-pskip=1:rc-lookahead=0:aq_mode=0" -partitions none -sc_threshold 0 -trellis 0 -me_method dia -refs 1 -subq 0 -vprofile baseline -level 30 -bufsize 10000000 &apos;
  else
    Result := aVideoCodec
end;

function GetMultiThreadSupported(const aVideoCodec: string): Boolean;
begin
  Result := not MatchText(aVideoCodec, [&apos;WMV&apos;, &apos;MPEG1&apos;, &apos;FLV&apos;])
end;

var
  eFrameRate: Extended;  
  iMusicVisualizationWidth, iMusicVisualizationHeight: Integer;
  sTranscodingParams, sVideoReadPipeName, sVideoWritePipeName, 
  sAudioReadPipeName, sAudioWritePipeName, sAudioCopyReadPipeName, sAudioCopyWritePipeName,
  sFrameRate, sThreadParams, sVideoBitrate, sVideoMinMaxRate: string; 
begin
  TranscodingResult := False;  
  sVideoMinMaxRate := &apos;&apos;;
  if cfgTranscodingVideoBitrate &gt; 0 then begin  
    sVideoBitrate := &apos;-b:v &apos; + IntToStr(cfgTranscodingVideoBitrate);
    if cfgTranscodingVideoMinMaxRate then
      sVideoMinMaxRate := Format(&apos; -minrate %d -maxrate %d -bufsize %d&apos;,
                  [cfgTranscodingVideoBitrate, cfgTranscodingVideoBitrate, 
                   HmsTranscodingBufferSize(cfgTranscodingVideoBitrate)])
  end else
    sVideoBitrate := &apos;-q:v 0&apos;;    

  eFrameRate := StrToFloatDef(cfgMusicVisualizationFrameRate, 25); 
  sFrameRate := FormatFloat(&apos;0.###&apos;, eFrameRate);      

  iMusicVisualizationWidth  := (cfgMusicVisualizationWidth  div 16) * 16; 
  iMusicVisualizationHeight := (cfgMusicVisualizationHeight div 16) * 16;

  if HmsCreateDualPipe(sAudioReadPipeName, sAudioWritePipeName, 20000000) and
     HmsCreateDualPipe(sAudioCopyReadPipeName, sAudioCopyWritePipeName, 20000000) then begin     
    if HmsPreTranscoding(CurrentMediaItem.ItemOrigin, sAudioWritePipeName, 
                         CurrentMediaItem.ItemOrigin.TranscodingProfile, &apos;audio/wav;rate=44100;channels=2;bits=16&apos;, False) then begin                         
      if HmsCreateDualPipe(sVideoReadPipeName, sVideoWritePipeName, 200000000) then begin      
        if HmsAudioVisualization(sAudioReadPipeName, sAudioCopyWritePipeName, 
                                 cfgMusicVisualizationFileName, 
                                 cfgMusicVisualizationPreset,
                                 sVideoWritePipeName, 
                                 iMusicVisualizationWidth, 
                                 iMusicVisualizationHeight, 
                                 eFrameRate) then begin
          if (cfgTranscodingThreadCount &gt; 1) and GetMultiThreadSupported(cfgTranscodingVideoCodec) then
            sThreadParams := &apos; -threads &apos; + IntToStr(cfgTranscodingThreadCount)            
          else          
            sThreadParams := &apos;&apos;;
                        
          sTranscodingParams := Format(csFFMpegParams, [          
                iMusicVisualizationWidth, iMusicVisualizationHeight, sFrameRate, 
                sVideoReadPipeName, sAudioCopyReadPipeName, 
                GetVideoCodec(cfgTranscodingVideoCodec), sVideoBitrate, 
                sVideoMinMaxRate, sThreadParams, sFrameRate,  
                GetAudioCodec(cfgTranscodingAudioCodec), cfgTranscodingAudioBitrate, 
                HmsTimeConvert(mpTimeLength), GetFileFormat(cfgTranscodingFileFormat), 
                OutputFileName]);                
          TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, True)
        end
      end              
    end
  end   
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка (Визуализация)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>3</TranscodingProfilePriority>
      <TranscodingProfileUuid>0a53e0be-8272-4945-970c-e43b096c4642</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition>SameText(mpFilePath, &apos;Single Track&apos;)</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>var
  FolderItem: THmsScriptMediaItem;  
  VisibleItemList: THmsScriptMediaItemList;
  VisibleItemIDs: Variant;  
  i, iChildCount: Integer;
  sAudioReadPipeName, sAudioWritePipeName, sMimeType, sTranscodingParams: string; 
begin
  TranscodingResult := False;     
  if CurrentMediaItem &lt;&gt; nil then begin
    FolderItem := CurrentMediaItem.ItemParent;    
    if FolderItem &lt;&gt; nil then
      FolderItem := FolderItem.ItemParent;  
    if FolderItem &lt;&gt; nil then begin    
      VisibleItemList := FolderItem.GetVisibleChildItems;      
      try
        iChildCount := VisibleItemList.Count; HmsShuffleList(VisibleItemList);
        if iChildCount &gt; 200 then iChildCount := 200;        
        VisibleItemIDs := VarArrayCreate([0, iChildCount - 1], varVariant);
        for i := 0 to iChildCount - 1 do
          VisibleItemIDs[i] := VisibleItemList[i].ItemID;
        if HmsCreateDualPipe(sAudioReadPipeName, sAudioWritePipeName) then begin 
          sTranscodingParams := &apos;-f s16be -ac 2 -ar 44100 -i "&lt;INPUT FILE&gt;" &apos;;          
          sMimeType := cfgTranscodingAudioMimeType;           
          if SameText(Copy(sMimeType, 1, 9), &apos;audio/L16&apos;) then  
            sTranscodingParams := sTranscodingParams + &apos; -f s16be -ac 2 -ar 44100 &apos;
          else if MatchText(sMimeType, [&apos;audio/x-ms-wma&apos;, &apos;audio/x-ms-asf&apos;]) then                                     
            sTranscodingParams := sTranscodingParams + &apos; -f asf -acodec wmav2 -ab 320000 -ac 2 -ar 44100 &apos;    
          else if MatchText(sMimeType, [&apos;audio/x-wav&apos;, &apos;audio/wav&apos;]) then
            sTranscodingParams := sTranscodingParams + &apos; -ac 2 -f wav &apos;
          else if Pos(&apos;flac&apos;, sMimeType) &gt; 0 then
            sTranscodingParams := sTranscodingParams + &apos; -ac 2 -f flac &apos;
          else                  
            sTranscodingParams := sTranscodingParams + &apos; -f mp3 -acodec libmp3lame -ab 320000 -ac 2 -ar 44100 &apos;;            
          sTranscodingParams := sTranscodingParams + &apos; "&lt;OUTPUT FILE&gt;"&apos; ;          
          if HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, False, sAudioReadPipeName, OutputFileName) then
             TranscodingResult := HmsPreTranscodingEx(VisibleItemIDs, sAudioWritePipeName, &apos;&apos;, 
                   &apos;audio/L16;rate=44100;channels=2;bits=16&apos;, True, True)
        end
      finally
        VisibleItemList.Free
      end                    
    end    
  end  
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка (Объединение - Случайный порядок, Повтор)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>2</TranscodingProfilePriority>
      <TranscodingProfileUuid>0c6d3be5-34f8-4ef6-9928-75b0b5906335</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition>SameText(mpFilePath, &apos;Single Track&apos;)</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>var
  FolderItem: THmsScriptMediaItem;  
  VisibleItemList: THmsScriptMediaItemList;
  VisibleItemIDs: Variant;  
  i, iChildCount: Integer;
  sAudioReadPipeName, sAudioWritePipeName, sMimeType, sTranscodingParams: string; 
begin
  TranscodingResult := False;     
  if CurrentMediaItem &lt;&gt; nil then begin
    FolderItem := CurrentMediaItem.ItemParent;    
    if FolderItem &lt;&gt; nil then
      FolderItem := FolderItem.ItemParent;  
    if FolderItem &lt;&gt; nil then begin    
      VisibleItemList := FolderItem.GetVisibleChildItems;      
      try
        iChildCount := VisibleItemList.Count;
        VisibleItemIDs := VarArrayCreate([0, iChildCount - 1], varVariant);     
        for i := 0 to iChildCount - 1 do
          VisibleItemIDs[i] := VisibleItemList[i].ItemID;    
        if HmsCreateDualPipe(sAudioReadPipeName, sAudioWritePipeName) then begin 
          sTranscodingParams := &apos;-f s16be -ac 2 -ar 44100 -i "&lt;INPUT FILE&gt;" &apos;;          
          sMimeType := cfgTranscodingAudioMimeType;           
          if SameText(Copy(sMimeType, 1, 9), &apos;audio/L16&apos;) then  
            sTranscodingParams := sTranscodingParams + &apos; -f s16be -ac 2 -ar 44100 &apos;
          else if MatchText(sMimeType, [&apos;audio/x-ms-wma&apos;, &apos;audio/x-ms-asf&apos;]) then                                     
            sTranscodingParams := sTranscodingParams + &apos; -f asf -acodec wmav2 -ab 320000 -ac 2 -ar 44100 &apos;    
          else if MatchText(sMimeType, [&apos;audio/x-wav&apos;, &apos;audio/wav&apos;]) then
            sTranscodingParams := sTranscodingParams + &apos; -ac 2 -f wav &apos;
          else if Pos(&apos;flac&apos;, sMimeType) &gt; 0 then
            sTranscodingParams := sTranscodingParams + &apos; -ac 2 -f flac &apos;
          else                  
            sTranscodingParams := sTranscodingParams + &apos; -f mp3 -acodec libmp3lame -ab 320000 -ac 2 -ar 44100 &apos;;            
          sTranscodingParams := sTranscodingParams + &apos; "&lt;OUTPUT FILE&gt;"&apos; ;          
          if HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, False, sAudioReadPipeName, OutputFileName) then
             TranscodingResult := HmsPreTranscodingEx(VisibleItemIDs, sAudioWritePipeName, &apos;&apos;, 
                   &apos;audio/L16;rate=44100;channels=2;bits=16&apos;, True)
        end
      finally
        VisibleItemList.Free
      end                    
    end    
  end  
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка (Объединение)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>0</TranscodingProfilePriority>
      <TranscodingProfileUuid>eb5b4ccc-1636-4b05-8b0e-e5439bcd433f</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>Нет скрипта</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 &lt; 44100 then    
      iSampleRate := 44100;
    iBitsPerSample := mpBitsPerSample;    
    if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
      iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
    else if iBitsPerSample &lt; 16 then
      iBitsPerSample := 16;        
    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>0</TranscodingMode>
      <TranscodingParams>function GetSampleFmt(aBitsPerSample: Integer): string;
begin
  if aBitsPerSample &gt; 16 then  
    Result := &apos;s32&apos;    
  else  
    Result := &apos;s16&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;

var
  bWav, bFlac: Boolean;
  iBitsPerSample, iChannels, iSampleRate: Integer;
  sInputCodec, sInputFileName, sMimeType, sOutputFormat, 
  sStreamType, sStreamHeader, sStartTime: string;  
begin
  if mpDvdItem then
    HmsCreateResourcePipe(sInputFileName)
  else begin  
    sInputFileName := &apos;&lt;INPUT FILE&gt;&apos;;
    if mpInternetItem and (Pos(&apos;\\.\pipe\&apos;, InputFileName) = 0) then 
      if HmsCreateInternetRadioStream(InputFileName, sInputFileName, sStreamType, sStreamHeader) then    
        if mpFileType = &apos;&apos; then begin        
          sStreamType := LowerCase(sStreamType);
          if Pos(&apos;aac&apos;, sStreamType) &gt; 0 then        
            mpFileType := &apos;aac&apos;          
          else if (Pos(&apos;x-ms&apos;, sStreamType) &gt; 0) then
            mpFileType := &apos;asf&apos;
          else                         
            mpFileType := &apos;mp3&apos;          
        end
  end;        

  if SameText(mpAudioCodec, &apos;dca&apos;) then
    sInputCodec := &apos;-acodec dca &apos;
  else if SameText(mpAudioCodec, &apos;MLP&apos;) then
    sInputCodec := &apos;-f mlp &apos;  
  else if SameText(mpAudioCodec, &apos;pcm_s16le&apos;) then  
    sInputCodec := Format(&apos;-f s16le -ac %d -ar %d &apos;, [mpChannels, mpAudioSampleRate])    
  else begin  
    if mpFileType &lt;&gt; &apos;&apos; then
      sInputCodec := &apos;-f "&apos; + mpFileType + &apos;" &apos;
    else if mpInternetItem or (Pos(&apos;\\.\pipe\&apos;, InputFileName) &gt; 0) then                                           
      sInputCodec := &apos;-f mp3 &apos;      
    else    
      sInputCodec := &apos;&apos;;
  end;  

  if mpInternetItem then
    sMimeType := cfgTranscodingRadioMimeType
  else
    sMimeType := cfgTranscodingAudioMimeType;
    
  bWav := Pos(&apos;wav&apos;, sMimeType) &gt; 0;
  bFlac := Pos(&apos;flac&apos;, sMimeType) &gt; 0;
  if bWav or bFlac or SameText(Copy(sMimeType, 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 &lt; 44100 then    
      iSampleRate := 44100;
    iBitsPerSample := mpBitsPerSample;    
    if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
      iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
    else if iBitsPerSample &lt; 16 then
      iBitsPerSample := 16;
    if bWav then           
      sOutputFormat := Format(&apos;wav -acodec pcm_s%dle -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])
    else if bFlac then
      sOutputFormat := Format(&apos;flac -sample_fmt %s -ac %d -ar %d&apos;, [GetSampleFmt(iBitsPerSample), iChannels, iSampleRate])
    else
      sOutputFormat := Format(&apos;s%dbe -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])
  end else begin
    if Pos(&apos;x-ms&apos;, sMimeType) &gt; 0 then
      sOutputFormat := &apos;asf -acodec wmav2 -ab 320000 -ac 2 -ar 44100&apos;                                   
    else if mpInternetItem and SameText(mpFileType, &apos;mp3&apos;) then
      sOutputFormat := &apos;mp3 -acodec copy&apos;
    else         
      sOutputFormat := &apos;mp3 -acodec libmp3lame -ab 320000 -ac 2 -ar 44100&apos;      
  end;
  
  TranscodingParams := Format(&apos;%s -i "%s" %s-f %s "&lt;OUTPUT FILE&gt;"&apos;, 
            [sInputCodec, sInputFileName, GetMetadata, sOutputFormat]);
            
  if not mpInternetItem and (mpTimeStart &lt;&gt; &apos;&apos;) then begin
    sStartTime := &apos;-ss &apos; + mpTimeStart;
    if mpTimeLength &lt;&gt; &apos;&apos; then
      sStartTime := sStartTime + &apos; -t &apos; + Copy(mpTimeLength, 1, 8);
    TranscodingParams := sStartTime + &apos; &apos; + TranscodingParams
  end
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка (основной)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>-1</TranscodingProfilePriority>
      <TranscodingProfileUuid>BB1A7873C552412CB77C1C3125F0AA33</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>MAC</TranscoderName>
      <TranscodingCondition>TranscodingCondition := SameText(ExtractFileExt(mpFilePath), &apos;.ape&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 &lt; 44100 then    
      iSampleRate := 44100;
    iBitsPerSample := mpBitsPerSample;    
    if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
      iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
    else if iBitsPerSample &lt; 16 then
      iBitsPerSample := 16;        
    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>const
  csMacTranscodingParams = &apos;"%s" "%s" -d&apos;;
  
function GetSampleFmt(aBitsPerSample: Integer): string;
begin
  if aBitsPerSample &gt; 16 then  
    Result := &apos;s32&apos;    
  else  
    Result := &apos;s16&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;
  
var
  bFlac, bWav: Boolean;
  iSampleRate, iChannels, iBitsPerSample: Integer; 
  sReadPipeName, sWritePipeName, sInputFormat, sOutputFormat, sTranscoderParams: string;
begin
  TranscodingResult := False;  

  bWav := Pos(&apos;wav&apos;, cfgTranscodingAudioMimeType) &gt; 0;
  bFlac := Pos(&apos;flac&apos;, cfgTranscodingAudioMimeType) &gt; 0;
  if bWav or bFlac 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 &lt; 44100 then    
      iSampleRate := 44100;
    iBitsPerSample := mpBitsPerSample;    
    if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
      iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
    else if iBitsPerSample &lt; 16 then
      iBitsPerSample := 16;
    if bWav then           
      sOutputFormat := Format(&apos;wav -acodec pcm_s%dle -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])
    else if bFlac then
      sOutputFormat := Format(&apos;flac -sample_fmt %s -ac %d -ar %d&apos;, [GetSampleFmt(iBitsPerSample), iChannels, iSampleRate])
    else
      sOutputFormat := Format(&apos;s%dbe -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])
  end else begin
    if Pos(&apos;x-ms&apos;, cfgTranscodingAudioMimeType) &gt; 0 then
      sOutputFormat := &apos;asf -acodec wmav2 -ab 320000 -ac 2 -ar 44100&apos;                                   
    else          
      sOutputFormat := &apos;mp3 -acodec libmp3lame -ab 320000 -ac 2 -ar 44100&apos;      
  end;
  sReadPipeName := &apos;.wav&apos;; sWritePipeName := &apos;.wav&apos;;                         
  if HmsCreateDualPipe(sReadPipeName, sWritePipeName) then begin
    sTranscoderParams := Format(csMacTranscodingParams, [InputFileName, sWritePipeName]);
    if mpTimeStart &lt;&gt; &apos;&apos; then begin
      sTranscoderParams := sTranscoderParams + &apos; -ts &apos; + IntToStr(HmsTimeConvert(mpTimeStart));
      if mpTimeLength &lt;&gt; &apos;&apos; then
        sTranscoderParams := sTranscoderParams + &apos; -tf &apos; +
             IntToStr(HmsTimeConvert(mpTimeStart) + HmsTimeConvert(mpTimeLength));
    end;
    if HmsTranscodingExecute(&apos;MAC&apos;, sTranscoderParams, False) then begin    
      sInputFormat := &apos;-f wav&apos;;    
      sTranscoderParams := Format(&apos;%s -i "%s" %s-f %s "%s"&apos;, 
                [sInputFormat, sReadPipeName, GetMetadata, sOutputFormat, OutputFileName]);
      TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscoderParams)
    end   
  end   
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка - APE</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>12</TranscodingProfilePriority>
      <TranscodingProfileUuid>1b48b584-ea23-4cc2-81bc-d8b432d52ec0</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>VLC</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csVideoLanParams =
    &apos;-Idummy --language en --sout=#transcode{acodec=%s,ab=%d,channels=2,&apos; +
    &apos;samplerate=44100}:duplicate{dst=std{access=file,mux=%s,dst="&lt;OUTPUT FILE&gt;"}}&apos; +
    &apos; cdda:///%s/ --cdda-track=%s vlc://quit&apos;;
    
function GetAudioCodec: string;
begin
  if SameText(Copy(cfgTranscodingAudioMimeType, 1, 9), &apos;audio/L16&apos;) then
    Result := &apos;s16be&apos;
  else if MatchText(cfgTranscodingAudioMimeType, [&apos;audio/x-ms-wma&apos;, &apos;audio/x-ms-asf&apos;]) then
    Result := &apos;wma2&apos;
  else if MatchText(cfgTranscodingAudioMimeType, [&apos;audio/x-wav&apos;, &apos;audio/wav&apos;]) then
    Result := &apos;s16le&apos;
  else if Pos(&apos;flac&apos;, cfgTranscodingAudioMimeType) &gt; 0 then
    Result := &apos;flac&apos;
  else
    Result := &apos;mp3&apos;      
end;

function GetFileFormat: string;
begin
  if MatchText(cfgTranscodingAudioMimeType, [&apos;audio/x-ms-wma&apos;, &apos;audio/x-ms-asf&apos;]) then
    Result := &apos;asf&apos;
  else if MatchText(cfgTranscodingAudioMimeType, [&apos;audio/x-wav&apos;, &apos;audio/wav&apos;]) then
    Result := &apos;wav&apos;
  else if Pos(&apos;flac&apos;, cfgTranscodingAudioMimeType) &gt; 0 then
    Result := &apos;flac&apos;
  else
    Result := &apos;raw&apos;   
end;
    
begin
  TranscodingParams := Format(csVideoLanParams, [GetAudioCodec,
          320, GetFileFormat, Copy(mpFilePath, 1, 2), Copy(ExtractFileName(mpFilePath), 6, 2)])
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка - AudioCD (VLC)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>1</TranscodingProfilePriority>
      <TranscodingProfileUuid>e71011d4-8f00-4de3-881b-0ac8746ef0bc</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></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 &lt; 44100 then    
      iSampleRate := 44100;
    iBitsPerSample := mpBitsPerSample;    
    if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
      iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
    else if iBitsPerSample &lt; 16 then
      iBitsPerSample := 16;        
    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 GetSampleFmt(aBitsPerSample: Integer): string;
begin
  if aBitsPerSample &gt; 16 then  
    Result := &apos;s32&apos;    
  else  
    Result := &apos;s16&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;

var
  bFlac, bWav: Boolean;
  iSampleRate, iChannels, iBitsPerSample: Integer; 
  sInputFileName, sInputFormat, sOutputFormat, sTranscoderParams: string;
begin
  TranscodingResult := False;
  
  if mpDvdItem then
    HmsCreateResourcePipe(sInputFileName)
  else
    sInputFileName := InputFileName;    

  if sInputFileName &lt;&gt; &apos;&apos; then begin  
    bWav := Pos(&apos;wav&apos;, cfgTranscodingAudioMimeType) &gt; 0;
    bFlac := Pos(&apos;flac&apos;, cfgTranscodingAudioMimeType) &gt; 0;
    if bWav or bFlac 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 &lt; 44100 then    
        iSampleRate := 44100;
      iBitsPerSample := mpBitsPerSample;    
      if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
        iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
      else if iBitsPerSample &lt; 16 then
        iBitsPerSample := 16;
      if bWav then           
        sOutputFormat := Format(&apos;wav -acodec pcm_s%dle -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])      
      else if bFlac then
        sOutputFormat := Format(&apos;flac -sample_fmt %s -ac %d -ar %d&apos;, [GetSampleFmt(iBitsPerSample), iChannels, iSampleRate])
      else
        sOutputFormat := Format(&apos;s%dbe -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])
    end else begin
      if Pos(&apos;x-ms&apos;, cfgTranscodingAudioMimeType) &gt; 0 then
        sOutputFormat := &apos;asf -acodec wmav2 -ab 320000 -ac 2 -ar 44100&apos;                                   
      else          
        sOutputFormat := &apos;mp3 -acodec libmp3lame -ab 320000 -ac 2 -ar 44100&apos;      
    end;
    if SameText(mpAudioCodec, &apos;MLP&apos;) then
      sInputFormat := &apos;-f mlp &apos;
    else  
      sInputFormat := &apos;&apos;;
    sTranscoderParams := Format(&apos;%s -i "%s" %s-f %s "%s"&apos;, 
              [sInputFormat, sInputFileName, GetMetadata, sOutputFormat, OutputFileName]);
    TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscoderParams)
  end     
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка - DVD-Audio</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>7</TranscodingProfilePriority>
      <TranscodingProfileUuid>5F1801449C8248CB82FBB8911B603E39</TranscodingProfileUuid>
    </Profile>
    <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 &lt; 44100 then    
      iSampleRate := 44100;
    iBitsPerSample := mpBitsPerSample;    
    if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
      iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
    else if iBitsPerSample &lt; 16 then
      iBitsPerSample := 16;        
    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 GetSampleFmt(aBitsPerSample: Integer): string;
begin
  if aBitsPerSample &gt; 16 then  
    Result := &apos;s32&apos;    
  else  
    Result := &apos;s16&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;

var
  bWav, bFlac: Boolean;
  iSampleRate, iChannels, iBitsPerSample: Integer; 
  sReadPipeName, sWritePipeName, sInputFormat, sOutputFormat, sTranscoderParams: string;
begin
  TranscodingResult := False;
  
  bWav := Pos(&apos;wav&apos;, cfgTranscodingAudioMimeType) &gt; 0;
  bFlac := Pos(&apos;flac&apos;, cfgTranscodingAudioMimeType) &gt; 0;
  if bWav or bFlac 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 &lt; 44100 then    
      iSampleRate := 44100;
    iBitsPerSample := mpBitsPerSample;    
    if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
      iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
    else if iBitsPerSample &lt; 16 then
      iBitsPerSample := 16;
    if bWav then           
      sOutputFormat := Format(&apos;wav -acodec pcm_s%dle -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])      
    else if bFlac then
      sOutputFormat := Format(&apos;flac -sample_fmt %s -ac %d -ar %d&apos;, 
                        [GetSampleFmt(iBitsPerSample), iChannels, iSampleRate])
    else
      sOutputFormat := Format(&apos;s%dbe -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])
  end else begin
    if Pos(&apos;x-ms&apos;, cfgTranscodingAudioMimeType) &gt; 0 then
      sOutputFormat := &apos;asf -acodec wmav2 -ab 320000 -ac 2 -ar 44100&apos;                                   
    else          
      sOutputFormat := &apos;mp3 -acodec libmp3lame -ab 320000 -ac 2 -ar 44100&apos;      
  end;                           
  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 begin
      sInputFormat := &apos;-f wav&apos;;    
      if MatchText(mpAudioCodec, [&apos;DCA&apos;, &apos;DTS&apos;]) then
        sInputFormat := &apos;-acodec dca &apos; + sInputFormat;        
      sTranscoderParams := Format(&apos;%s -i "%s" %s-f %s "%s"&apos;, 
                [sInputFormat, sReadPipeName, GetMetadata, sOutputFormat, OutputFileName]);
      TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscoderParams)
    end   
  end   
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка - FLAC</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>10</TranscodingProfilePriority>
      <TranscodingProfileUuid>0A185870D0904403A92E8DE0D121ED8F</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>RTMPDUMP</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>cfgTranscodingAudioMimeType</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>function RtmpRedirectApp(const aRtmpApp: string): string;
begin
  if SameText(aRtmpApp, &apos;asiaupdate&apos;) then  
    Result := &apos;asiaupdateedge&apos;    
  else if SameText(aRtmpApp, &apos;alfa-live&apos;) then  
    Result := &apos;alfa-live-source&apos;    
  else  
    Result := aRtmpApp
end;    

function ExecuteRtmpDump(const aRtmpServer, aRtmpFile, aPlayerUrl: string; aRtmpLive: Boolean; var aVideoUrl: string): Boolean;
var
  sRtmpApp, sRtmpFile, sRtmpParams, sRtmpReadPipeName, sRtmpWritePipeName: string;
begin
  Result := False;  
  if (aRtmpServer &lt;&gt; &apos;&apos;) and (aRtmpFile &lt;&gt; &apos;&apos;) then 
    if HmsCreateDualPipe(sRtmpReadPipeName, sRtmpWritePipeName, 1000000) then begin      
      if SameText(ExtractFileExt(aRtmpFile), &apos;.flv&apos;) then        
        sRtmpFile := ChangeFileExt(aRtmpFile, &apos;&apos;)          
      else if SameText(ExtractFileExt(aRtmpFile), &apos;.mp4&apos;) and (Pos(&apos;mp4:&apos;, aRtmpFile) = 0) then        
        sRtmpFile := &apos;mp4:&apos; + aRtmpFile      
      else               
        sRtmpFile := aRtmpFile;      
      if not HmsRegExMatch(&apos;rtmp://.*?/(.*)&apos;, aRtmpServer, sRtmpApp) then
        sRtmpApp := &apos;&apos;;  
      if sRtmpApp &lt;&gt; &apos;&apos; then                                       
        sRtmpApp := &apos; -a "&apos; + RtmpRedirectApp(sRtmpApp) + &apos;"&apos;;
      sRtmpParams := Format(&apos;-r "%s"%s -y "%s" -o "%s"&apos;, [aRtmpServer, sRtmpApp, sRtmpFile, sRtmpWritePipeName]);        
      if aRtmpLive then 
        sRtmpParams := &apos;-v &apos; + sRtmpParams;
      if aPlayerUrl &lt;&gt; &apos;&apos; then                 
        sRtmpParams := sRtmpParams + &apos; -W "&apos; + aPlayerUrl + &apos;"&apos;;
      Result := HmsTranscodingExecute(&apos;RTMPDUMP&apos;, sRtmpParams, False);
      if Result then        
        aVideoUrl := sRtmpReadPipeName
    end          
end;

function ExecuteRtmpDumpCommandLine(const aCommandLine: string; var aInputFileName: string): Boolean;
var
  i, j: Integer;                                                             
  sRtmpDumpParams, sRtmpReadPipeName, sRtmpWritePipeName: string;
begin            
  Result := False;                                 
  i := Pos(&apos;rtmpdump.exe&apos;, LowerCase(InputFileName));
  j := 0;  
  if i &gt; 0 then
    j := 12
  else begin    
    i := Pos(&apos;rtmpdump&apos;, LowerCase(InputFileName));    
    if i &gt; 0 then
      j := 8  
  end;    
  if (j &gt; 0) and HmsCreateDualPipe(sRtmpReadPipeName, sRtmpWritePipeName, 1000000) then begin
    sRtmpDumpParams := Format(&apos;%s -o "%s"&apos;, [Copy(InputFileName, i + j, Length(InputFileName)), sRtmpWritePipeName]);    
    Result := HmsTranscodingExecute(&apos;RTMPDUMP&apos;, sRtmpDumpParams, False);    
    if Result then
      aInputFileName := sRtmpReadPipeName  
  end 
end;

var 
  bSuccess: Boolean;
  sFileType, sInputFileName, sRtmpServer, sRtmpFile, sTranscodingParams: string;  
begin
  TranscodingResult := False;
  if Pos(&apos;rtmpdump&apos;, LowerCase(InputFileName)) &gt; 0 then
    bSuccess := ExecuteRtmpDumpCommandLine(InputFileName, sInputFileName)
  else if HmsRegExMatch2(&apos;(rtmp://.*?/.*?)/(.*)&apos;, InputFileName, sRtmpServer, sRtmpFile) then
    bSuccess := ExecuteRtmpDump(sRtmpServer, sRtmpFile, &apos;&apos;, True, sInputFileName)   
  else            
    bSuccess := False;    
  if bSuccess then begin
    if mpFileType = &apos;&apos; then
      mpFileType := &apos;flv&apos;;
    if mpFileType &lt;&gt; &apos;&apos; then      
      sTranscodingParams := &apos;-f "&apos; + mpFileType + &apos;" &apos;
    else                          
      sTranscodingParams := &apos;&apos;;      
    sTranscodingParams := sTranscodingParams + &apos;-i "%s" -vn &apos;;
    if SameText(Copy(cfgTranscodingRadioMimeType, 1, 9), &apos;audio/L16&apos;) then      
      sTranscodingParams := sTranscodingParams + &apos;-f s16be -ac 2 -ar 44100 "%s"&apos;
    else if MatchText(cfgTranscodingRadioMimeType, [&apos;audio/x-ms-wma&apos;, &apos;audio/x-ms-asf&apos;]) then 
      sTranscodingParams := sTranscodingParams + &apos;-f asf -acodec wmav2 -ab 320000 -ac 2 -ar 44100 "%s"&apos;
    else if MatchText(cfgTranscodingRadioMimeType, [&apos;audio/x-wav&apos;, &apos;audio/wav&apos;]) then
      sTranscodingParams := sTranscodingParams + &apos;-f wav "%s"&apos;
    else if Pos(&apos;flac&apos;, cfgTranscodingAudioMimeType) &gt; 0 then
      sTranscodingParams := sTranscodingParams + &apos;-f flac "%s"&apos;
    else                                                                          
      sTranscodingParams := sTranscodingParams + &apos;-f mp3 -acodec libmp3lame -ab 320000 -ar 44100 "%s"&apos;;
    TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, Format(sTranscodingParams, [sInputFileName, OutputFileName]), True)          
  end  
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка - RTMPDUMP - FFMPEG</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>5</TranscodingProfilePriority>
      <TranscodingProfileUuid>cea34f67-84bb-4ff9-8c12-6a49fec8d97a</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>var
  bWav: Boolean;
  iSampleRate, iSacdSampleRate, 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
    else
      iChannels := mpChannels;      

    iSampleRate    := cfgTranscodingLpcmMaxSampleRate;  
    iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample;  
  
    iSacdSampleRate := (iSampleRate div 44100) * 44100;
  
    if iSacdSampleRate &lt; 44100 then 
      iSacdSampleRate := 44100
    else if iSacdSampleRate &gt; 352800 then
      iSacdSampleRate := 352800;
  
    if iSampleRate &gt; iSacdSampleRate then
      iSampleRate := iSacdSampleRate;      
    if bWav then
      MimeType := cfgTranscodingAudioMimeType
    else begin
      MimeType := &apos;audio/L&apos; + IntToStr(iBitsPerSample);      
      FileExt := &apos;s16be&apos;
    end;          
    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 GetSampleFmt(aBitsPerSample: Integer): string;
begin
  if aBitsPerSample &gt; 16 then  
    Result := &apos;s32&apos;    
  else  
    Result := &apos;s16&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;

var
  eStartSeconds: Extended;
  iSampleRate, iSacdSampleRate, iChannels, iBitsPerSample: Integer; 
  sSacdReadPipeName, sSacdWritePipeName, sInputFormat, sOutputFormat, 
  sTranscodeSeconds, sTranscoderParams: string;
begin
  TranscodingResult := False;  

  iChannels := mpChannels;
  if iChannels &gt; cfgTranscodingLpcmMaxChannels then  
    iChannels := cfgTranscodingLpcmMaxChannels
  else if iChannels &lt; 2 then  
    iChannels := 2
  else
    iChannels := mpChannels;      

  iSampleRate    := cfgTranscodingLpcmMaxSampleRate;  
  iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample;  

  iSacdSampleRate := (iSampleRate div 44100) * 44100;

  if iSacdSampleRate &lt; 44100 then 
    iSacdSampleRate := 44100
  else if iSacdSampleRate &gt; 352800 then
    iSacdSampleRate := 352800;

  if iSampleRate &gt; iSacdSampleRate then
    iSampleRate := iSacdSampleRate;  

  if SameText(Copy(cfgTranscodingAudioMimeType, 1, 7), &apos;audio/L&apos;) then
    sOutputFormat := Format(&apos;s%dbe -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])
  else if Pos(&apos;wav&apos;, cfgTranscodingAudioMimeType) &gt; 0 then
    sOutputFormat := Format(&apos;wav -acodec pcm_s%dle -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])
  else if Pos(&apos;flac&apos;, cfgTranscodingAudioMimeType) &gt; 0 then
    sOutputFormat := Format(&apos;flac -sample_fmt %s -ac %d -ar %d&apos;, [GetSampleFmt(iBitsPerSample), iChannels, iSampleRate])
  else begin
    iSampleRate := 44100;  
    if Pos(&apos;x-ms&apos;, cfgTranscodingAudioMimeType) &gt; 0 then
      sOutputFormat := &apos;asf -acodec wmav2 -ab 320000 -ac 2 -ar 44100&apos;                                   
    else          
      sOutputFormat := &apos;mp3 -acodec libmp3lame -ab 320000 -ac 2 -ar 44100&apos;      
  end;
  sTranscodeSeconds := &apos;&apos;; eStartSeconds := 0;          
  if mpTimeStart &lt;&gt; &apos;&apos; then begin  
    eStartSeconds := HmsTimeConvertEx(mpTimeStart);    
    if mpTimeLength &lt;&gt; &apos;&apos; then
      sTranscodeSeconds := &apos; -t &apos; + Copy(mpTimeLength, 1, 8);
  end;                                                                        
  if HmsCreateDualPipe(sSacdReadPipeName, sSacdWritePipeName) and
     HmsTranscodingSacdTrack(sSacdWritePipeName, iSacdSampleRate, eStartSeconds, 10) then begin
    sInputFormat := Format(&apos;-ar %d -f f32le -ac %d &apos;, [iSacdSampleRate, mpChannels]);
    sTranscoderParams := Format(&apos;%s-i "%s"%s %s-f %s "%s"&apos;, [sInputFormat, 
         sSacdReadPipeName, sTranscodeSeconds, GetMetadata, sOutputFormat, OutputFileName]);
    TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscoderParams) 
  end   
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка - SACD</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>4</TranscodingProfilePriority>
      <TranscodingProfileUuid>25be13da-0964-4444-b104-d3be72e0e271</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csVlcParams = &apos;-Idummy --language en --demuxdump-file="%s" "%s" :demux=dump&apos;;  
var
  sReadPipeName, sWritePipeName, sTranscodingParams: string;    
begin
  TranscodingResult := False;
  if HmsCreateDualPipe(sReadPipeName, sWritePipeName) then begin
    if HmsTranscodingExecute(&apos;VLC&apos;, Format(csVlcParams, [sWritePipeName, InputFileName]), False) then begin    
      if mpFileType &lt;&gt; &apos;&apos; then      
        sTranscodingParams := &apos;-f &apos; + mpFileType + &apos; &apos;
      else                          
        sTranscodingParams := &apos;&apos;;
      sTranscodingParams := sTranscodingParams + &apos;-i "%s" -vn &apos;;
      if SameText(Copy(cfgTranscodingRadioMimeType, 1, 9), &apos;audio/L16&apos;) then      
        sTranscodingParams := sTranscodingParams + &apos;-f s16be -ac 2 -ar 44100 "%s"&apos;
      else if MatchText(cfgTranscodingRadioMimeType, [&apos;audio/x-ms-wma&apos;, &apos;audio/x-ms-asf&apos;]) then  
        sTranscodingParams := sTranscodingParams + &apos;-f asf -acodec wmav2 -ab 320000 -ac 2 -ar 44100 "%s"&apos;
      else if MatchText(cfgTranscodingRadioMimeType, [&apos;audio/x-wav&apos;, &apos;audio/wav&apos;]) then  
        sTranscodingParams := sTranscodingParams + &apos;-f wav "%s"&apos; 
      else if Pos(&apos;flac&apos;, cfgTranscodingRadioMimeType) then
        sTranscodingParams := sTranscodingParams + &apos;-f flac "%s"&apos;
      else                                                                          
        sTranscodingParams := sTranscodingParams + &apos;-f mp3 -acodec libmp3lame -ab 320000 -ar 44100 "%s"&apos;;
      TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, Format(sTranscodingParams, [sReadPipeName, OutputFileName]), True)          
    end 
  end 
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка - VLC - FFMPEG</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>14</TranscodingProfilePriority>
      <TranscodingProfileUuid>5cff143f-a765-4fe8-962c-39e1c6d0ea87</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>WVUNPACK</TranscoderName>
      <TranscodingCondition>TranscodingCondition := SameText(ExtractFileExt(mpFilePath), &apos;.wv&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 &lt; 44100 then    
      iSampleRate := 44100;
    iBitsPerSample := mpBitsPerSample;    
    if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
      iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
    else if iBitsPerSample &lt; 16 then
      iBitsPerSample := 16;        
    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>const
  csWavPackTranscodingParams = &apos;-y "%s" "%s"&apos;;
  
function GetSampleFmt(aBitsPerSample: Integer): string;
begin
  if aBitsPerSample &gt; 16 then  
    Result := &apos;s32&apos;    
  else  
    Result := &apos;s16&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;
                                                     
var
  bFlac, bWav: Boolean;
  iSampleRate, iChannels, iBitsPerSample: Integer; 
  sReadPipeName, sWritePipeName, sInputFormat, sOutputFormat, sTranscoderParams: string;
begin
  TranscodingResult := False;  

  bWav := Pos(&apos;wav&apos;, cfgTranscodingAudioMimeType) &gt; 0;
  bFlac := Pos(&apos;flac&apos;, cfgTranscodingAudioMimeType) &gt; 0;
  if bWav or bFlac 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 &lt; 44100 then    
      iSampleRate := 44100;
    iBitsPerSample := mpBitsPerSample;    
    if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
      iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
    else if iBitsPerSample &lt; 16 then
      iBitsPerSample := 16;
    if bWav then           
      sOutputFormat := Format(&apos;wav -acodec pcm_s%dle -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])
    else if bFlac then           
      sOutputFormat := Format(&apos;flac -sample_fmt %s -ac %d -ar %d&apos;, [GetSampleFmt(iBitsPerSample), iChannels, iSampleRate])      
    else
      sOutputFormat := Format(&apos;s%dbe -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])
  end else begin
    if Pos(&apos;x-ms&apos;, cfgTranscodingAudioMimeType) &gt; 0 then
      sOutputFormat := &apos;asf -acodec wmav2 -ab 320000 -ac 2 -ar 44100&apos;                                   
    else          
      sOutputFormat := &apos;mp3 -acodec libmp3lame -ab 320000 -ac 2 -ar 44100&apos;      
  end;
  sReadPipeName := &apos;.wav&apos;; sWritePipeName := &apos;.wav&apos;;                
  if HmsCreateDualPipe(sReadPipeName, sWritePipeName) then begin  
    sTranscoderParams := &apos;&apos;;
    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));
      sTranscoderParams := sTranscoderParams + &apos; &apos;;      
    end;
    sTranscoderParams := sTranscoderParams + Format(csWavPackTranscodingParams, [InputFileName, sWritePipeName]);
    if HmsTranscodingExecute(&apos;WVUNPACK&apos;, sTranscoderParams, False) then begin
      sInputFormat := &apos;-f wav&apos;;    
      sTranscoderParams := Format(&apos;%s -i "%s" %s-f %s "%s"&apos;, 
                [sInputFormat, sReadPipeName, GetMetadata, sOutputFormat, OutputFileName]);
      TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscoderParams)
    end   
  end   
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка - WAVPACK</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>13</TranscodingProfilePriority>
      <TranscodingProfileUuid>86c4474e-fa99-4e27-a5aa-bc1eb701d230</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>function CheckResult(aResult: Integer; aRaiseException: Boolean = True): Boolean;
begin
  Result := aResult = S_OK;
  if not Result and aRaiseException then
    RaiseException(Format(&apos;Error (code: %x) - %s&apos;, [aResult, SysErrorMessage(aResult)]))
end;

function GetSampleFmt(aBitsPerSample: Integer): string;
begin
  if aBitsPerSample &gt; 16 then  
    Result := &apos;s32&apos;    
  else  
    Result := &apos;s16&apos;
end;

var
  bWav, bFlac: Boolean;
  iAudioChannels, iAudioSampleRate, iAudioFormatTag, iBitsPerSample, 
  iChannels, iSampleRate: Integer;
  sAudioFormat, sAudioMediaMajorType, sAudioMediaSubType, 
  sOutputFormat, sReadAudioPipeName, sWriteAudioPipeName, sTranscoderParams: string;
begin
  TranscodingResult := False;
  if not CheckResult(HmsDirectShowAddSource(InputFileName, &apos;Source&apos;)) then 
    Exit; 
  if not CheckResult(HmsDirectShowAddFilter(&apos;WMAudio Decoder DMO&apos;, &apos;Audio Decoder&apos;)) then 
    Exit;    
  if not CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;Audio Decoder&apos;)) then
    Exit;                                   
  if HmsCreateDualPipe(sReadAudioPipeName, sWriteAudioPipeName, 10000000) then begin
    if not CheckResult(HmsDirectShowAddDump(sWriteAudioPipeName, &apos;DumpAudio&apos;)) then 
      Exit;                 
    if not CheckResult(HmsDirectShowConnectPin(&apos;Audio Decoder&apos;, &apos;DumpAudio&apos;, &apos;&apos;, &apos;&apos;, 
                       MEDIATYPE_Audio, KSDATAFORMAT_SUBTYPE_PCM)) then 
      Exit;
    if not CheckResult(HmsDirectShowGetMediaType(&apos;Audio Decoder&apos;, PINDIR_OUTPUT, &apos;&apos;, 
       sAudioMediaMajorType, sAudioMediaSubType, iAudioChannels, iAudioSampleRate, iAudioFormatTag)) then
      Exit;      
    bWav := Pos(&apos;wav&apos;, cfgTranscodingAudioMimeType) &gt; 0;  
    bFlac := not bWav and (Pos(&apos;flac&apos;, cfgTranscodingAudioMimeType) &gt; 0);
    if bWav or bFlac 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 &lt; 44100 then    
        iSampleRate := 44100;
      iBitsPerSample := mpBitsPerSample;    
      if iBitsPerSample &gt; cfgTranscodingLpcmMaxBitsPerSample then    
        iBitsPerSample := cfgTranscodingLpcmMaxBitsPerSample
      else if iBitsPerSample &lt; 16 then
        iBitsPerSample := 16;
      if bWav then           
        sOutputFormat := Format(&apos;wav -acodec pcm_s%dle -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])      
      else if bFlac then
        sOutputFormat := Format(&apos;flac -sample_fmt %s -ac %d -ar %d&apos;, [GetSampleFmt(iBitsPerSample), iChannels, iSampleRate])
      else     
        sOutputFormat := Format(&apos;s%dbe -ac %d -ar %d&apos;, [iBitsPerSample, iChannels, iSampleRate])
    end else begin
      if Pos(&apos;x-ms&apos;, cfgTranscodingAudioMimeType) &gt; 0 then
        sOutputFormat := &apos;asf -acodec wmav2 -ab 320000 -ac 2 -ar 44100&apos;                                   
      else if mpInternetItem and SameText(mpFileType, &apos;mp3&apos;) then
        sOutputFormat := &apos;mp3 -acodec copy&apos;
      else         
        sOutputFormat := &apos;mp3 -acodec libmp3lame -ab 320000 -ac 2 -ar 44100&apos;      
    end;
    sTranscoderParams := Format(&apos; -f s16le -ar %d -ac %d -i "%s" -f %s "%s"&apos;, 
         [iAudioSampleRate, iAudioChannels, sReadAudioPipeName, sOutputFormat, OutputFileName]);         
    if CheckResult(HmsDirectShowPlay) then
      TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscoderParams)    
  end    
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка - WMA Lossless (DirectShow)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>3</TranscodingProfilePriority>
      <TranscodingProfileUuid>d982164d-d020-4067-b0db-f222f8f559b6</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>VLC</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>1</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csVideoLanParams =
    &apos;--no-crashdump -Idummy --language en --sout=#transcode{acodec=%s,ab=%d,channels=2,&apos; +
    &apos;samplerate=44100}:duplicate{dst=std{access=file,mux=%s,dst="&lt;OUTPUT FILE&gt;"}}&apos; +
    &apos; "&lt;INPUT FILE&gt;"&apos;;
    
function GetAudioCodec: string;
begin
  if SameText(Copy(cfgTranscodingRadioMimeType, 1, 9), &apos;audio/L16&apos;) then
    Result := &apos;s16be&apos;
  else if MatchText(cfgTranscodingRadioMimeType, [&apos;audio/x-ms-wma&apos;, &apos;audio/x-ms-asf&apos;]) then
    Result := &apos;wma2&apos;
  else if MatchText(cfgTranscodingRadioMimeType, [&apos;audio/x-wav&apos;, &apos;audio/wav&apos;]) then
    Result := &apos;s16le&apos;
  else if Pos(&apos;flac&apos;, cfgTranscodingRadioMimeType) &gt; 0 then
    Result := &apos;flac&apos;
  else
    Result := &apos;mp3&apos;      
end;

function GetFileFormat: string;
begin
  if MatchText(cfgTranscodingRadioMimeType, [&apos;audio/x-ms-wma&apos;, &apos;audio/x-ms-asf&apos;]) then
    Result := &apos;asf&apos;
  else if MatchText(cfgTranscodingRadioMimeType, [&apos;audio/x-wav&apos;, &apos;audio/wav&apos;]) then
    Result := &apos;wav&apos;
  else if Pos(&apos;flac&apos;, cfgTranscodingRadioMimeType) &gt; 0 then
    Result := &apos;flac&apos;
  else
    Result := &apos;raw&apos;   
end;
    
begin
  TranscodingParams := Format(csVideoLanParams, [GetAudioCodec,
          320, GetFileFormat])
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Музыка - Интернет-радио (VLC)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>8</TranscodingProfilePriority>
      <TranscodingProfileUuid>fc75b353-6fcf-4936-966b-bbb57b36532c</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition>(CurrentMediaItem &lt;&gt; nil) and (CurrentMediaItem.ItemClassName = &apos;TMediaPodcastUpdateItem&apos;)</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для специальных папок (Цифровое телевидение - DVB, Музыка - Визуализация, Фото - Слайд-шоу)</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csFFMpegParams = &apos;-s %dx%d -r %s -pix_fmt rgb32 -f rawvideo -i "%s" -i "%s" &apos; + 
                   &apos;-vcodec %s %s%s%s -pix_fmt yuv420p -r %s -acodec %s -b:a %d -ac 2 -f %s "%s"&apos;;

function GetAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) or SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;libfaac&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;libmp3lame&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := &apos;wmav2&apos;
  else
    Result := aAudioCodec
end;

function GetFileFormat(const aFileFormat: string): string;
begin
  if (aFileFormat = &apos;&apos;) or SameText(aFileFormat, &apos;MPEG (DVD)&apos;) then
    Result := &apos;dvd&apos;
  else if Pos(&apos;MPEGTS&apos;, aFileFormat) &gt; 0 then
    Result := &apos;mpegts&apos;
  else if Pos(&apos;ASF&apos;, aFileFormat) &gt; 0 then
    Result := &apos;asf&apos;
  else if SameText(aFileFormat, &apos;MP4&apos;) then
    Result := &apos;ipod&apos;
  else if SameText(aFileFormat, &apos;MPEG1&apos;) then
    Result := &apos;mpeg&apos;
  else
    Result := aFileFormat
end;

function GetVideoCodec(const aVideoCodec: string): string;
begin
  if (aVideoCodec = &apos;&apos;) or SameText(aVideoCodec, &apos;MPEG2&apos;) then
    Result := &apos;mpeg2video&apos;
  else if SameText(aVideoCodec, &apos;MPEG1&apos;) then
    Result := &apos;mpeg1video&apos;
  else if SameText(aVideoCodec, &apos;WMV&apos;) then
    Result := &apos;wmv2&apos;
  else if SameText(aVideoCodec, &apos;MPEG4&apos;) then
    Result := &apos;mpeg4&apos;
  else if SameText(aVideoCodec, &apos;X264&apos;) then
    Result := &apos;libx264 -x264opts "fast-pskip=1:rc-lookahead=0:aq_mode=0" -partitions none -sc_threshold 0 -trellis 0 -me_method dia -refs 1 -subq 0 -vprofile baseline -level 30 -bufsize 10000000 &apos;
  else
    Result := aVideoCodec
end;

function GetMultiThreadSupported(const aVideoCodec: string): Boolean;
begin
  Result := not MatchText(aVideoCodec, [&apos;WMV&apos;, &apos;MPEG1&apos;, &apos;FLV&apos;])
end;

var
  eFrameRate: Extended;  
  i, iVideoWidth, iVideoHeight, iProgressWidth, 
  iProgress, iOldProgress, X1, X2, Y1, Y2: Integer;  
  ImageBitmap: TBitmap32;  
  sAudioFileName, sTranscodingParams, sVideoReadPipeName, sVideoWritePipeName, 
  sFrameRate, sThreadParams, sVideoBitrate, sVideoMinMaxRate, sProgress, sProgressID: string;  
  VideoSlideShow: THmsVideoSlideShow;
begin
  TranscodingResult := False; GlobalVarSet(&apos;PodcastProgress&apos;, 0);    
  sVideoMinMaxRate := &apos;&apos;;                                                             
  sProgressID := CurrentMediaItem.ItemParent.ItemParent.ItemID + &apos;_PodcastUpdateProgress&apos;;
  if cfgTranscodingVideoBitrate &gt; 0 then begin  
    sVideoBitrate := &apos;-b:v &apos; + IntToStr(cfgTranscodingVideoBitrate);
    if cfgTranscodingVideoMinMaxRate then
      sVideoMinMaxRate := Format(&apos; -minrate %d -maxrate %d -bufsize %d&apos;,
                  [cfgTranscodingVideoBitrate, cfgTranscodingVideoBitrate, 
                   HmsTranscodingBufferSize(cfgTranscodingVideoBitrate)])
  end else
    sVideoBitrate := &apos;-q:v 0&apos;;    

  eFrameRate := StrToFloatDef(cfgPhotoSlideShowFrameRate, 25); 
  sFrameRate := FormatFloat(&apos;0.###&apos;, eFrameRate);      

  iVideoWidth  := 720; 
  iVideoHeight := 406;  

  sAudioFileName := IncludeTrailingBackslash(ProgramPath) + &apos;Presentation\Images\Amanda.wma&apos;;
  if HmsCreateDualPipe(sVideoReadPipeName, sVideoWritePipeName) then begin
    VideoSlideShow := THmsVideoSlideShow.Create(sVideoWritePipeName, iVideoWidth, iVideoHeight, eFrameRate);
    try                                             
      if (cfgTranscodingThreadCount &gt; 1) and GetMultiThreadSupported(cfgTranscodingVideoCodec) then
        sThreadParams := &apos; -threads &apos; + IntToStr(cfgTranscodingThreadCount)            
      else          
        sThreadParams := &apos;&apos;;
      sTranscodingParams := Format(csFFMpegParams, [          
            iVideoWidth, iVideoHeight, sFrameRate, 
            sVideoReadPipeName, sAudioFileName, 
            GetVideoCodec(cfgTranscodingVideoCodec), sVideoBitrate, 
            sVideoMinMaxRate, sThreadParams, sFrameRate,  
            GetAudioCodec(cfgTranscodingAudioCodec), cfgTranscodingAudioBitrate, 
            GetFileFormat(cfgTranscodingFileFormat), OutputFileName]);                                    
      if HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, False) then begin        
        VideoSlideShow.Start;          
        try
          ImageBitmap := TBitmap32.Create;
          ImageBitmap.DrawMode := dmOpaque;            
          ImageBitmap.SetSize(iVideoWidth, iVideoHeight);
          X1 := Trunc(iVideoWidth * 0.2); 
          X2 := Trunc(iVideoWidth * 0.8); 
          Y1 := Trunc(iVideoHeight * 0.45); 
          Y2 := Trunc(iVideoHeight * 0.55);            
          try                                         
            iProgressWidth := X2 - X1;              
            ImageBitmap.Font.Size := 14;                           
            iOldProgress := -1;
            repeat
              if not VideoSlideShow.Started then Break;              
              iProgress := StrToIntDef(VarToStr(GlobalVarGet(sProgressID)), 0);
              if iOldProgress &lt;&gt; iProgress then begin 
                ImageBitmap.FillRectS(X1, Y1, X2, Y2, $FF5984AE);                     
                ImageBitmap.Gradient(X1, Y1, X1 + Round(iProgressWidth * (iProgress / 100)), Y2, gsLinearV, $00714D0F, $00ECBE71);                
                sProgress := IntToStr(iProgress) + &apos;%&apos;;
                ImageBitmap.RenderText((X1 + X2 - ImageBitmap.TextWidth(sProgress)) div 2, 
                                       (Y1 + Y2 - ImageBitmap.TextHeight(sProgress)) div 2, sProgress, 4, $FFFFFFFF);                 
                if VideoSlideShow.Started then                          
                  VideoSlideShow.SetBitmap(ImageBitmap);                  
              end else              
                HmsSleep(100)
            until iProgress &gt;= 100;
            HmsSleep(1000);           
          finally              
            ImageBitmap.Free              
          end            
        finally                        
          VideoSlideShow.Stop
        end
      end
    finally           
      VideoSlideShow.Free
    end
  end;  
  TranscodingResult := False
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Подкасты (Прогресс обновления)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>0</TranscodingProfilePriority>
      <TranscodingProfileUuid>cb9b5272-307e-4445-8485-c5021702578f</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition>mpSubItemsCount &gt; 0</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование объединенных медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csTranscodingInputFile = &apos;-i "&lt;INPUT FILE&gt;"&apos;;
  csFFMpegVideoParams = &apos; -f %s -vcodec %s -b %d -aspect %s -pix_fmt yuv420p&apos;;
  csFFMpegAudioParams = &apos; -acodec %s -ab %d -ar 48000&apos;;
  
function GetAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;libfaac&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;libmp3lame&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := &apos;wmav2&apos;
  else
    Result := aAudioCodec
end;

function SameAudioCodec(const aAudioCodec: string; aCodecID: Integer): Boolean;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := aCodecID = CODEC_ID_AC3
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := aCodecID = CODEC_ID_AAC
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := aCodecID = CODEC_ID_MP3
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := aCodecID = CODEC_ID_MP2
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := aCodecID = CODEC_ID_WMAV2
  else
    Result := False
end;

function GetFileFormat(const aFileFormat: string): string;
begin
  if (aFileFormat = &apos;&apos;) or SameText(aFileFormat, &apos;MPEG (DVD)&apos;) then
    Result := &apos;dvd&apos;
  else if SameText(aFileFormat, &apos;MPEGTS&apos;) then
    Result := &apos;mpegts&apos;
  else if SameText(aFileFormat, &apos;ASF (WMV)&apos;) then
    Result := &apos;asf&apos;
  else
    Result := aFileFormat
end;

function GetVideoCodec(const aVideoCodec: string): string;
begin
  if (aVideoCodec = &apos;&apos;) or SameText(aVideoCodec, &apos;MPEG2&apos;) then
    Result := &apos;mpeg2video&apos;
  else if SameText(aVideoCodec, &apos;WMV&apos;) then
    Result := &apos;wmv2&apos;
  else
    Result := aVideoCodec
end;

function GetMultiThreadSupported(const aVideoCodec: string): Boolean;
begin
  if SameText(aVideoCodec, &apos;WMV&apos;) then
    Result := False
  else
    Result := True
end;

function GetAudioBitrate(const aAudioCodec: string; aAudioBitrate: Integer): Integer;
begin
  if MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) and (aAudioBitrate &gt; 320000) then
    Result := 320000
  else
    Result := aAudioBitrate
end;

procedure AddFilterParams(var aFilterParams: string; const aAddParams: string);
begin
  if aFilterParams &lt;&gt; &apos;&apos; then
    aFilterParams := aFilterParams + &apos;,&apos;;
  aFilterParams := aFilterParams + aAddParams
end;
  
var
  i, iAudioStreamNo, iChannels, iCodecID, iFrameWidth, iFrameHeight, 
  iInputFileNo, iWidth, iHeight, iPadLeft, iPadTop, iPadRight, iPadBottom, 
  iStartTime, iTimeLength: Integer;
  sFrameRate, sParams, sAudioStreamID, sFilterParams, sPadParams: string;
begin
  iInputFileNo := 0;
  iStartTime := HmsTimeConvert(mpTimeStart);
  iAudioStreamNo := mpAudioStreamNo;
  sAudioStreamID := &apos;&apos;;
  TranscodingParams := &apos;&apos;;
  for i := 0 to mpSubItemsCount - 1 do begin
    HmsTranscodingActivateSubItem(i);
    if sAudioStreamID = &apos;&apos; then begin
      if iAudioStreamNo = -1 then
        iAudioStreamNo := mpAudioStreamNo;
      sAudioStreamID := HmsGetAudioStreamID(iAudioStreamNo);
    end;  
    if iStartTime &gt; 0 then begin
      iTimeLength := HmsTimeConvert(mpTimeLength);
      if (iTimeLength &gt; 0) and (iStartTime &gt; iTimeLength) then begin
        iStartTime := iStartTime - iTimeLength; Continue
      end;
      sParams := &apos;-ss &apos; + HmsTimeFormat(iStartTime);
      iStartTime := 0;
    end else
      sParams := &apos;&apos;;
    sParams := sParams + Format(&apos; -i "%s"&apos;, [mpFilePath]);
    sParams := sParams + Format(csFFMPegVideoParams, [GetFileFormat(cfgTranscodingFileFormat),
                                                      GetVideoCodec(cfgTranscodingVideoCodec), 
                                                      cfgTranscodingVideoBitrate,
                                                      cfgTranscodingScreenFormat]);
    if iAudioStreamNo &lt;&gt; -1 then begin
      iCodecID := HmsGetStreamCodecID(&apos;A&apos;, iAudioStreamNo);
      iChannels := HmsGetStreamChannels(iAudioStreamNo);
    end else begin
      iCodecID := CODEC_ID_NONE;
      iChannels := 0;
    end;
    if (iCodecID = CODEC_ID_NONE) and SameText(mpAudioCodec, &apos;AC3&apos;) then
      iCodecID := CODEC_ID_AC3;
    if cfgTranscodingAudioCopyAC3 and SameAudioCodec(cfgTranscodingAudioCodec, iCodecID) then
      sParams := sParams + &apos; -acodec copy&apos;
    else begin
      sParams := sParams + Format(csFFMpegAudioParams, 
         [GetAudioCodec(cfgTranscodingAudioCodec), 
          GetAudioBitrate(cfgTranscodingAudioCodec, cfgTranscodingAudioBitrate)]);
      if iChannels = 1 then
        sParams := sParams + &apos; -ac 2&apos;
      else if cfgTranscodingAudioChannels &gt; 0 then
        sParams := sParams + &apos; -ac &apos; + IntToStr(cfgTranscodingAudioChannels)
    end;
    sFrameRate := HmsGetVideoSettings(vstFrameRate);
    if sFrameRate = &apos;&apos; then    
      sFrameRate := cfgTranscodingFrameRate;
    if (sFrameRate = &apos;&apos;) and (mpFrameRate &gt; 0) and (mpFrameRate &lt; 20) then
      sFrameRate := &apos;23.976&apos;;      
    if sFrameRate &lt;&gt; &apos;&apos; then
      sParams := sParams + &apos; -r &apos; + sFrameRate;
    iWidth := mpWidth; iHeight := mpHeight;  
    if (iWidth &gt; 0) and (iHeight &gt; 0) then begin
      sFilterParams := &apos;&apos;; sPadParams := &apos;&apos;;    
      if HmsTranscodingFrameParams(iWidth, iHeight, cfgTranscodingScreenFormat,
                         iPadLeft, iPadTop, iPadRight, iPadBottom) then begin                         
        if mp3DVideoType in [1, 2] then begin
          iWidth  := iWidth  + iPadLeft + iPadRight;
          iHeight := iHeight + iPadTop + iPadBottom;                 
          if mp3DVideoType = 1 then
            iWidth  := (iWidth div 4) * 4
          else
            iHeight := (iHeight div 4) * 4          
        end;
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
        if (mp3DVideoType = 0) and ((iPadLeft &gt; 0) or (iPadRight &gt; 0) or (iPadTop &gt; 0) or (iPadBottom &gt; 0)) then begin        
          Inc(iFrameWidth,  iPadLeft + iPadRight);
          Inc(iFrameHeight, iPadTop + iPadBottom);
          sPadParams := Format(&apos;pad=%d:%d:%d:%d:0x%s&apos;,
                        [iFrameWidth, iFrameHeight, iPadLeft, iPadTop, HmsConvertColor(cfgTranscodingPadColor)]);
          if cfgTranscodingFrameExists then
            sParams := sParams + cfgTranscodingFrameParams;
        end
      end else begin
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
      end;
      AddFilterParams(sFilterParams, Format(&apos;scale=%d:%d&apos;, [iWidth, iHeight]));
      if sPadParams &lt;&gt; &apos;&apos; then AddFilterParams(sFilterParams, sPadParams);
      AddFilterParams(sFilterParams, &apos;setdar=&apos; + cfgTranscodingAspectRatio);
      sParams := sParams + Format(&apos; -vf "%s"&apos;, [sFilterParams]);
      sParams := sParams + HmsTranscodingSubTitleParams(
         iFrameWidth, iFrameHeight, iWidth, iHeight, iPadLeft, iPadTop);
    end;
    sParams := sParams + HmsTranscodingMapParams(iAudioStreamNo, sAudioStreamID);
    if (cfgTranscodingThreadCount &gt; 1) and GetMultiThreadSupported(cfgTranscodingVideoCodec) then
      sParams := sParams + &apos; -threads &apos; + IntToStr(cfgTranscodingThreadCount);
    if iInputFileNo &gt; 0 then
      sParams := sParams + &apos; -j&apos;;   
    Inc(iInputFileNo);
    TranscodingParams := TranscodingParams + sParams + Chr(13) + Chr(10)
  end
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (DVD)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>23</TranscodingProfilePriority>
      <TranscodingProfileUuid>958FEE94C68E461DABAC1DCAE86083F9</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment>Профиль транскодирования использует таблицу поддерживаемых форматов из настроек устройства</TranscodingComment>
      <TranscodingFolder>Транскодирование без перекодирования видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;FLV&apos;) then
    FileExt := &apos;flv&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csFFMpegVideoParams = &apos; -vcodec %s %s%s -pix_fmt yuv420p&apos;;
  csFFMpegAudioParams = &apos; -acodec %s -ab %d -ar %d -ac %d&apos;;  

procedure GetAudioTranscodingParams(const aAudioCodec: string; 
    var aCodecName, aFileFormat: string; var aCodecID, aAudioBitrate, aAudioChannels: Integer);
begin
  aAudioBitrate := cfgTranscodingAudioBitrate;  
  if (cfgTranscodingAudioChannels &lt;&gt; 0) then  
    aAudioChannels := cfgTranscodingAudioChannels;
  if SameText(aAudioCodec, &apos;AAC&apos;) then begin
    aCodecName  := &apos;libfaac&apos;;    
    aFileFormat := &apos;adts&apos;;
    aCodecID    := CODEC_ID_AAC; 
  end else if SameText(aAudioCodec, &apos;MP3&apos;) then begin
    aCodecName  := &apos;libmp3lame&apos;;    
    aFileFormat := &apos;mp3&apos;;
    aCodecID    := CODEC_ID_MP3;
    if aAudioBitrate &gt; 320000 then
      aAudioBitrate := 320000;
    if aAudioChannels &gt; 2 then
      aAudioChannels := 2;      
  end else if SameText(aAudioCodec, &apos;MP2&apos;) then begin  
    aCodecName  := &apos;mp2&apos;;    
    aFileFormat := &apos;mp2&apos;;
    aCodecID    := CODEC_ID_MP2;
    if aAudioBitrate &gt; 320000 then
      aAudioBitrate := 320000;      
    if aAudioChannels &gt; 2 then
      aAudioChannels := 2;      
  end else if SameText(aAudioCodec, &apos;LPCM&apos;) then begin  
    aCodecName  := &apos;pcm_s16be&apos;;    
    aFileFormat := &apos;s16be&apos;;
    aCodecID    := CODEC_ID_PCM_BLURAY;
  end else if SameText(aAudioCodec, &apos;DTS&apos;) then begin  
    aCodecName  := &apos;dca&apos;;    
    aFileFormat := &apos;dts&apos;;
    aCodecID    := CODEC_ID_DTS;
    aAudioChannels := 0    
  end else if SameText(aAudioCodec, &apos;WMA&apos;) then begin  
    aCodecName  := &apos;wmav2&apos;;    
    aFileFormat := &apos;asf&apos;;
    aCodecID    := CODEC_ID_WMAV2;    
    if aAudioChannels &gt; 2 then
      aAudioChannels := 2;      
  end else begin
    aCodecName  := &apos;ac3&apos;;    
    aFileFormat := &apos;ac3&apos;;    
    if SameText(aAudioCodec, &apos;AC3&apos;) then
      aCodecID := CODEC_ID_AC3
    else                          
      aCodecID := CODEC_ID_NONE;
  end  
end;

function GetFileFormat(const aFileFormat: string): string;
begin
  if (aFileFormat = &apos;&apos;) or SameText(aFileFormat, &apos;MPEG (DVD)&apos;) then
    Result := &apos;dvd&apos;
  else if Pos(&apos;MPEGTS&apos;, aFileFormat) &gt; 0 then
    Result := &apos;mpegts&apos;
  else if Pos(&apos;ASF&apos;, aFileFormat) &gt; 0 then
    Result := &apos;asf&apos;
  else if SameText(aFileFormat, &apos;MP4&apos;) then
    Result := &apos;ipod&apos;    
  else if SameText(aFileFormat, &apos;FLV&apos;) then
    Result := &apos;flv&apos;
  else if SameText(aFileFormat, &apos;MPEG1&apos;) then
    Result := &apos;mpeg&apos;
  else
    Result := aFileFormat
end;

function GetVideoCodec(const aVideoCodec: string): string;
begin
  if (aVideoCodec = &apos;&apos;) or SameText(aVideoCodec, &apos;MPEG2&apos;) then
    Result := &apos;mpeg2video&apos;
  else if SameText(aVideoCodec, &apos;MPEG1&apos;) then
    Result := &apos;mpeg1video&apos;    
  else if SameText(aVideoCodec, &apos;FLV&apos;) then
    Result := &apos;flv&apos;
  else if SameText(aVideoCodec, &apos;WMV&apos;) then
    Result := &apos;wmv2&apos;
  else if SameText(aVideoCodec, &apos;MPEG4&apos;) then
    Result := &apos;mpeg4&apos;
  else if SameText(aVideoCodec, &apos;X264&apos;) then
    Result := &apos;libx264 -x264opts "fast-pskip=1:rc-lookahead=0:aq_mode=0" -partitions none -sc_threshold 0 -trellis 0 -me_method dia -refs 1 -subq 0 -vprofile baseline -level 30 -bufsize 10000000 &apos;
  else
    Result := aVideoCodec
end;

function GetMultiThreadSupported(const aVideoCodec: string): Boolean;
begin
  Result := not MatchText(aVideoCodec, [&apos;WMV&apos;, &apos;MPEG1&apos;, &apos;FLV&apos;])
end;

function GetAudioBitrate(const aAudioCodec: string; aAudioBitrate: Integer): Integer;
begin
  if MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) and (aAudioBitrate &gt; 320000) then
    Result := 320000
  else
    Result := aAudioBitrate
end;

function GetAudioSampleRate(const aFileFormat, aAudioCodec: string): Integer;
begin
  if MatchText(aFileFormat, [&apos;FLV&apos;]) and not SameText(aAudioCodec, &apos;AAC&apos;) then  
    Result := 44100
  else
    Result := 48000
end;

function GetAudioChannels(const aAudioCodec: string; aConfigAudioChannels, aStreamAudioChannels: Integer): Integer;
begin
  if aConfigAudioChannels &gt; 0 then
    Result := aConfigAudioChannels
  else
    Result := aStreamAudioChannels;
  if (Result &gt; 2) and MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) then
    Result := 2
  else if (Result = 1) and MatchText(aAudioCodec, [&apos;AAC&apos;, &apos;AC3&apos;]) then
    Result := 2
  else if Result &gt; 6 then
    Result := 6
end;

function VideoCodecCompatible(const aFileFormat: string): Boolean;
begin
  Result := HmsIsFormatSupported(aFileFormat, &apos;copy&apos;, &apos;&apos;);
end;

function AudioCodecCompatible(const aFileFormat: string): Boolean;
begin
  Result := HmsIsFormatSupported(aFileFormat, &apos;&apos;, &apos;copy&apos;)
end;

function IsPipe(const aFileName: string): Boolean;
begin
  Result := Pos(&apos;\\.\pipe\&apos;, aFileName) &gt; 0;
end;

procedure AddFilterParams(var aFilterParams: string; const aAddParams: string);
begin
  if aFilterParams &lt;&gt; &apos;&apos; then
    aFilterParams := aFilterParams + &apos;,&apos;;
  aFilterParams := aFilterParams + aAddParams
end;
  
var
  bMapStreams, bDeinterlace, bh264_mp4toannexb, bPipe, bSuccess, bAudioTranscoding, bVideoTranscoding: Boolean;
  iAudioBitrate, iAudioChannels, iAudioCfgBitrate, iAudioCfgCodecID, iAudioStreamNo, 
  iFrameWidth, iFrameHeight, iWidth, iHeight, iPadLeft, iPadTop, iPadRight, iPadBottom: Integer;  
  sVideoTranscodingParams, sAudioTranscodingParams, sTranscodingFileFormat, sTranscodingParams,
  sAudioCfgCodecName, sAudioCfgFileFormat, sInputAudioFileName, sFilterParams, sPadParams,
  sInputVideoFileName, sFrameRate, sResourcePipe, sVideoBitrate, sVideoMinMaxRate: string;
begin
  if HmsGetStreamCount = 0 then  
    HmsRetrieveProperties;
  bPipe := IsPipe(InputFileName);    
  bDeinterlace := SameText(HmsGetVideoSettings(vstDeinterlace), &apos;on&apos;);                                
  if bPipe then                 
            
  else if (mpIsoItem or mpDvdItem or mpBdItem) and HmsCreateResourcePipe(sResourcePipe) then begin
    InputFileName := sResourcePipe;      
    bPipe := True      
  end else if mpPodcastItem then begin
    InputFileName := HmsGetItemProperty(mpiMediaResourceSource);    
    bPipe := IsPipe(InputFileName);
  end;        
  bVideoTranscoding := False;      
  bAudioTranscoding := False;    
  sInputVideoFileName := InputFileName;
  sInputAudioFileName := InputFileName;
  iAudioStreamNo := mpAudioStreamNo;
  if iAudioStreamNo &lt; 0 then
    iAudioStreamNo := 0;      
  iAudioChannels := HmsGetStreamChannels(iAudioStreamNo);    
  if iAudioChannels &lt; 2 then iAudioChannels := 2;  
  iAudioBitrate  := HmsGetStreamBitrate(stAudio, iAudioStreamNo);
  sTranscodingParams := &apos;&apos;; 
  sTranscodingFileFormat := GetFileFormat(cfgTranscodingFileFormat);  
  bVideoTranscoding := False;    
  bAudioTranscoding := False;
  if SameText(HmsGetVideoSettings(vstVideoOriginal), &apos;On&apos;) then
    bVideoTranscoding := False    
  else if SameText(HmsGetVideoSettings(vstVideoOriginal), &apos;Off&apos;) then    
    bVideoTranscoding := True 
  else if (mpSubtitleLanguage &lt;&gt; &apos;&apos;) or (HmsGetVideoSettings(vstSubtitle) &lt;&gt; &apos;&apos;) or bDeinterlace then    
    bVideoTranscoding := True     
  else if (mpFrameRate &gt; 0) and (mpFrameRate &lt; 20) then
    bVideoTranscoding := True      
  else if not VideoCodecCompatible(sTranscodingFileFormat) then
    bVideoTranscoding := True
  else begin        
    if (mpOriginalWidth &gt; 0) then begin    
      iWidth  := mpOriginalWidth;      
      iHeight := mpOriginalHeight;
    end else begin    
      iWidth  := mpWidth;      
      iHeight := mpHeight;
    end;               
    if (iWidth &gt; cfgMaximumVideoResolutionWidth) or (iHeight &gt; cfgMaximumVideoResolutionHeight) then
      bVideoTranscoding := True  
  end;        
  GetAudioTranscodingParams(cfgTranscodingAudioCodec, sAudioCfgCodecName,
          sAudioCfgFileFormat, iAudioCfgCodecID, iAudioCfgBitrate, iAudioChannels);      
  if SameText(HmsGetVideoSettings(vstAudioOriginal), &apos;On&apos;) then
    bAudioTranscoding := False    
  else if SameText(HmsGetVideoSettings(vstAudioOriginal), &apos;Off&apos;) then    
    bAudioTranscoding := True
  else                     
    bAudioTranscoding := not AudioCodecCompatible(sTranscodingFileFormat);
  if bVideoTranscoding then begin
    sVideoMinMaxRate := &apos;&apos;;         
    if cfgTranscodingVideoBitrate &gt; 0 then begin  
      sVideoBitrate := &apos;-b:v &apos; + IntToStr(cfgTranscodingVideoBitrate);
      if cfgTranscodingVideoMinMaxRate then
        sVideoMinMaxRate := Format(&apos; -minrate %d -maxrate %d -bufsize %d&apos;,
                    [cfgTranscodingVideoBitrate, cfgTranscodingVideoBitrate, 
                     HmsTranscodingBufferSize(cfgTranscodingVideoBitrate)])
    end else
      sVideoBitrate := &apos;-q:v 0&apos;;
    sVideoTranscodingParams := Format(csFFMPegVideoParams, 
            [GetVideoCodec(cfgTranscodingVideoCodec), sVideoBitrate, sVideoMinMaxRate]);
    sFrameRate := HmsGetVideoSettings(vstFrameRate);
    if sFrameRate = &apos;&apos; then    
      sFrameRate := cfgTranscodingFrameRate;
    if sFrameRate = &apos;&apos; then begin
      if SameText(cfgTranscodingVideoCodec, &apos;FLV&apos;) then      
        sFrameRate := FormatFloat(&apos;0&apos;, mpFrameRate)
      else if (mpFrameRate &gt; 0) and (mpFrameRate &lt; 20) then 
        sFrameRate := &apos;23.976&apos;
    end;          
    if sFrameRate &lt;&gt; &apos;&apos; then
      sVideoTranscodingParams := sVideoTranscodingParams + &apos; -r &apos; + sFrameRate;
    iWidth := mpWidth; iHeight := mpHeight;  
    if (iWidth &gt; 0) and (iHeight &gt; 0) then begin
      sFilterParams := &apos;&apos;; sPadParams := &apos;&apos;;    
      if HmsTranscodingFrameParams(iWidth, iHeight, cfgTranscodingScreenFormat,
                         iPadLeft, iPadTop, iPadRight, iPadBottom) then begin                         
        if mp3DVideoType in [1, 2] then begin
          iWidth  := iWidth  + iPadLeft + iPadRight;
          iHeight := iHeight + iPadTop + iPadBottom;                 
          if mp3DVideoType = 1 then
            iWidth  := (iWidth div 4) * 4
          else
            iHeight := (iHeight div 4) * 4          
        end;
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
        if (mp3DVideoType = 0) and ((iPadLeft &gt; 0) or (iPadRight &gt; 0) or (iPadTop &gt; 0) or (iPadBottom &gt; 0)) then begin        
          Inc(iFrameWidth,  iPadLeft + iPadRight);
          Inc(iFrameHeight, iPadTop + iPadBottom);
          sPadParams := Format(&apos;pad=%d:%d:%d:%d:0x%s&apos;,
                        [iFrameWidth, iFrameHeight, iPadLeft, iPadTop, HmsConvertColor(cfgTranscodingPadColor)]);
          if cfgTranscodingFrameExists then
            sVideoTranscodingParams := sVideoTranscodingParams + cfgTranscodingFrameParams;
        end
      end else begin
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
      end;
      AddFilterParams(sFilterParams, Format(&apos;scale=%d:%d&apos;, [iWidth, iHeight]));
      if sPadParams &lt;&gt; &apos;&apos; then AddFilterParams(sFilterParams, sPadParams);
      AddFilterParams(sFilterParams, &apos;setdar=&apos; + cfgTranscodingAspectRatio);
      sVideoTranscodingParams := sVideoTranscodingParams + Format(&apos; -vf "%s"&apos;, [sFilterParams]);
      sVideoTranscodingParams := sVideoTranscodingParams + HmsTranscodingSubTitleParams(
         iFrameWidth, iFrameHeight, iWidth, iHeight, iPadLeft, iPadTop);
      if (cfgTranscodingThreadCount &gt; 1) and GetMultiThreadSupported(cfgTranscodingVideoCodec) then
        sVideoTranscodingParams := sVideoTranscodingParams + &apos; -threads &apos; + IntToStr(cfgTranscodingThreadCount);
    end    
  end else begin  
    sVideoTranscodingParams := &apos; -copyinkf -vcodec copy &apos;;
    if SameText(mpVideoCodec, &apos;H264&apos;) then begin    
      if VarToStr(mpCodecNalLengthSize) &lt;&gt; &apos;&apos; then      
        bh264_mp4toannexb := VarToStr(mpCodecNalLengthSize) &lt;&gt; &apos;0&apos;        
      else                         
        bh264_mp4toannexb := not MatchText(mpFileType, [&apos;mpegts&apos;, &apos;wtv&apos;, &apos;hls&apos;, &apos;applehttp&apos;], True);        
      if bh264_mp4toannexb then
        sVideoTranscodingParams := sVideoTranscodingParams + &apos; -vbsf h264_mp4toannexb&apos;
    end        
  end;                 
  if bAudioTranscoding then  
    sAudioTranscodingParams := Format(csFFMpegAudioParams, [sAudioCfgCodecName, iAudioCfgBitrate, 
        GetAudioSampleRate(cfgTranscodingFileFormat, cfgTranscodingAudioCodec), iAudioChannels])
  else                   
    sAudioTranscodingParams := &apos; -acodec copy&apos;;     
  bMapStreams := HmsGetStreamCount &gt; 0;
  sTranscodingParams := HmsTranscodingProbeParams;
  if mpTimeStart &lt;&gt; &apos;&apos; then
    sTranscodingParams := sTranscodingParams + &apos;-ss &apos; + mpTimeStart + &apos; &apos;;
  if SameText(mpFileType, &apos;mpeg&apos;) then                            
    sTranscodingParams := sTranscodingParams + &apos;-f mpeg &apos;;    
  if (InputFileName &lt;&gt; &apos;&apos;) and (InputFileName[1] = &apos;-&apos;) then                         
    sTranscodingParams := sTranscodingParams + InputFileName + &apos; &apos;
  else
    sTranscodingParams := sTranscodingParams + Format(&apos;-i "%s" &apos;, [InputFileName]);
  sTranscodingParams := sTranscodingParams + &apos;-f &apos; + GetFileFormat(cfgTranscodingFileFormat);
  sTranscodingParams := sTranscodingParams + sVideoTranscodingParams + sAudioTranscodingParams;                                   
  if bMapStreams then                           
    sTranscodingParams := sTranscodingParams + Format(&apos; -map 0:%d -map 0:%d&apos;, [HmsGetStreamIndex(stVideo, 0), HmsGetStreamIndex(stAudio, iAudioStreamNo)]);
  sTranscodingParams := sTranscodingParams + &apos; "&lt;OUTPUT FILE&gt;"&apos;;  
//  TranscodingParams := sTranscodingParams;
  TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, True, InputFileName, OutputFileName)                       
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (Оптимальный)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>6</TranscodingProfilePriority>
      <TranscodingProfileUuid>a767239a-88da-44e1-a20b-6eaf83f1e8f2</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;FLV&apos;) then
    FileExt := &apos;flv&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csFFMpegVideoParams = &apos; -vcodec %s %s%s -pix_fmt yuv420p&apos;;
  csFFMpegAudioParams = &apos; -acodec %s -ab %d -ar %d -ac %d&apos;;  

procedure GetAudioTranscodingParams(const aAudioCodec: string; 
    var aCodecName, aFileFormat: string; var aCodecID, aAudioBitrate, aAudioChannels: Integer);
begin
  aAudioBitrate := cfgTranscodingAudioBitrate;  
  if (cfgTranscodingAudioChannels &lt;&gt; 0) then  
    aAudioChannels := cfgTranscodingAudioChannels;
  if SameText(aAudioCodec, &apos;AAC&apos;) then begin
    aCodecName  := &apos;libfaac&apos;;    
    aFileFormat := &apos;adts&apos;;
    aCodecID    := CODEC_ID_AAC; 
  end else if SameText(aAudioCodec, &apos;MP3&apos;) then begin
    aCodecName  := &apos;libmp3lame&apos;;    
    aFileFormat := &apos;mp3&apos;;
    aCodecID    := CODEC_ID_MP3;
    if aAudioBitrate &gt; 320000 then
      aAudioBitrate := 320000;
    if aAudioChannels &gt; 2 then
      aAudioChannels := 2;      
  end else if SameText(aAudioCodec, &apos;MP2&apos;) then begin  
    aCodecName  := &apos;mp2&apos;;    
    aFileFormat := &apos;mp2&apos;;
    aCodecID    := CODEC_ID_MP2;
    if aAudioBitrate &gt; 320000 then
      aAudioBitrate := 320000;      
    if aAudioChannels &gt; 2 then
      aAudioChannels := 2;      
  end else if SameText(aAudioCodec, &apos;LPCM&apos;) then begin  
    aCodecName  := &apos;pcm_s16be&apos;;    
    aFileFormat := &apos;s16be&apos;;
    aCodecID    := CODEC_ID_PCM_BLURAY;
  end else if SameText(aAudioCodec, &apos;DTS&apos;) then begin  
    aCodecName  := &apos;dca&apos;;    
    aFileFormat := &apos;dts&apos;;
    aCodecID    := CODEC_ID_DTS;
    aAudioChannels := 0    
  end else if SameText(aAudioCodec, &apos;WMA&apos;) then begin  
    aCodecName  := &apos;wmav2&apos;;    
    aFileFormat := &apos;asf&apos;;
    aCodecID    := CODEC_ID_WMAV2;    
    if aAudioChannels &gt; 2 then
      aAudioChannels := 2;      
  end else begin
    aCodecName  := &apos;ac3&apos;;    
    aFileFormat := &apos;ac3&apos;;    
    if SameText(aAudioCodec, &apos;AC3&apos;) then
      aCodecID := CODEC_ID_AC3
    else                          
      aCodecID := CODEC_ID_NONE;
  end  
end;

function GetFileFormat(const aFileFormat: string): string;
begin
  if (aFileFormat = &apos;&apos;) or SameText(aFileFormat, &apos;MPEG (DVD)&apos;) then
    Result := &apos;dvd&apos;
  else if Pos(&apos;MPEGTS&apos;, aFileFormat) &gt; 0 then
    Result := &apos;mpegts&apos;
  else if Pos(&apos;ASF&apos;, aFileFormat) &gt; 0 then
    Result := &apos;asf&apos;
  else if SameText(aFileFormat, &apos;MP4&apos;) then
    Result := &apos;ipod&apos;    
  else if SameText(aFileFormat, &apos;FLV&apos;) then
    Result := &apos;flv&apos;
  else if SameText(aFileFormat, &apos;MPEG1&apos;) then
    Result := &apos;mpeg&apos;
  else
    Result := aFileFormat
end;

function GetVideoCodec(const aVideoCodec: string): string;
begin
  if (aVideoCodec = &apos;&apos;) or SameText(aVideoCodec, &apos;MPEG2&apos;) then
    Result := &apos;mpeg2video&apos;
  else if SameText(aVideoCodec, &apos;MPEG1&apos;) then
    Result := &apos;mpeg1video&apos;    
  else if SameText(aVideoCodec, &apos;FLV&apos;) then
    Result := &apos;flv&apos;
  else if SameText(aVideoCodec, &apos;WMV&apos;) then
    Result := &apos;wmv2&apos;
  else if SameText(aVideoCodec, &apos;MPEG4&apos;) then
    Result := &apos;mpeg4&apos;
  else if SameText(aVideoCodec, &apos;X264&apos;) then
    Result := &apos;libx264 -x264opts "fast-pskip=1:rc-lookahead=0:aq_mode=0" -partitions none -sc_threshold 0 -trellis 0 -me_method dia -refs 1 -subq 0 -vprofile baseline -level 30 -bufsize 10000000 &apos;
  else
    Result := aVideoCodec
end;

function GetMultiThreadSupported(const aVideoCodec: string): Boolean;
begin
  Result := not MatchText(aVideoCodec, [&apos;WMV&apos;, &apos;MPEG1&apos;, &apos;FLV&apos;])
end;

function GetAudioBitrate(const aAudioCodec: string; aAudioBitrate: Integer): Integer;
begin
  if MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) and (aAudioBitrate &gt; 320000) then
    Result := 320000
  else
    Result := aAudioBitrate
end;

function GetAudioSampleRate(const aFileFormat, aAudioCodec: string): Integer;
begin
  if MatchText(aFileFormat, [&apos;FLV&apos;]) and not SameText(aAudioCodec, &apos;AAC&apos;) then  
    Result := 44100
  else
    Result := 48000
end;

function GetAudioChannels(const aAudioCodec: string; aConfigAudioChannels, aStreamAudioChannels: Integer): Integer;
begin
  if aConfigAudioChannels &gt; 0 then
    Result := aConfigAudioChannels
  else
    Result := aStreamAudioChannels;
  if (Result &gt; 2) and MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) then
    Result := 2
  else if (Result = 1) and MatchText(aAudioCodec, [&apos;AAC&apos;, &apos;AC3&apos;]) then
    Result := 2
  else if Result &gt; 6 then
    Result := 6
end;

function VideoCodecCompatible: Boolean;
begin
  if (cfgTranscodingFileFormat = &apos;&apos;) or SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    Result := MatchText(mpVideoCodec, [&apos;MPEG2VIDEO&apos;, &apos;MPEG1VIDEO&apos;])
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    Result := MatchText(mpVideoCodec, [&apos;H264&apos;, &apos;MPEG2VIDEO&apos;, &apos;MPEG1VIDEO&apos;, &apos;MPEG4&apos;])
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    Result := MatchText(mpVideoCodec, [&apos;H264&apos;, &apos;MPEG4&apos;, &apos;WMV2&apos;])
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    Result := MatchText(mpVideoCodec, [&apos;H264&apos;, &apos;MPEG4&apos;])    
  else if SameText(cfgTranscodingFileFormat, &apos;FLV&apos;) then
    Result := MatchText(mpVideoCodec, [&apos;H264&apos;, &apos;FLV&apos;])
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    Result := MatchText(mpVideoCodec, [&apos;MPEG2VIDEO&apos;, &apos;MPEG1VIDEO&apos;])
  else
    Result := False
end;

procedure AddFilterParams(var aFilterParams: string; const aAddParams: string);
begin
  if aFilterParams &lt;&gt; &apos;&apos; then
    aFilterParams := aFilterParams + &apos;,&apos;;
  aFilterParams := aFilterParams + aAddParams
end;
  
var
  bMapStreams, bDeinterlace, bPipe, bSuccess, bAudioTranscoding, bVideoTranscoding: Boolean;
  iAudioBitrate, iAudioChannels, iAudioCfgBitrate, iAudioCfgCodecID, iAudioStreamNo, 
  iCodecID, iFrameWidth, iFrameHeight, iWidth, iHeight, 
  iPadLeft, iPadTop, iPadRight, iPadBottom, iVideoCodecID, iAudioCodecID: Integer;  
  sVideoTranscodingParams, sAudioTranscodingParams, sTranscodingParams,
  sAudioCfgCodecName, sAudioCfgFileFormat, sInputAudioFileName, 
  sInputVideoFileName, sFrameRate, sResourcePipe, sSoxTranscodingParams, 
  sVideoBitrate, sVideoMinMaxRate, sFilterParams, sPadParams: string;
begin
  if HmsGetStreamCount = 0 then  
    HmsRetrieveProperties;
  bPipe := Pos(&apos;\\.\pipe\&apos;, InputFileName) &gt; 0;    
  bDeinterlace := SameText(HmsGetVideoSettings(vstDeinterlace), &apos;on&apos;);                                
  if bPipe then                 
            
  else if (mpIsoItem or mpDvdItem or mpBdItem) and HmsCreateResourcePipe(sResourcePipe) then begin
    InputFileName := sResourcePipe;      
    bPipe := True;      
  end else if mpPodcastItem then begin
    InputFileName := HmsGetItemProperty(mpiMediaResourceSource);
    bPipe := Pos(&apos;\\.\pipe\&apos;, InputFileName) &gt; 0;
  end;        
  bVideoTranscoding := False;      
  bAudioTranscoding := False;    
  sInputVideoFileName := InputFileName;
  sInputAudioFileName := InputFileName;
  iAudioStreamNo := mpAudioStreamNo;
  if iAudioStreamNo &lt; 0 then
    iAudioStreamNo := 0;      
  iVideoCodecID  := HmsGetStreamCodecID(stVideo, 0);  
  iAudioCodecID  := HmsGetStreamCodecID(stAudio, iAudioStreamNo);      
  iAudioChannels := HmsGetStreamChannels(iAudioStreamNo);    
  if iAudioChannels &lt; 2 then iAudioChannels := 2;  
  iAudioBitrate  := HmsGetStreamBitrate(stAudio, iAudioStreamNo);
  sTranscodingParams := &apos;&apos;; sSoxTranscodingParams := &apos;&apos;;
  bVideoTranscoding := False;    
  bAudioTranscoding := False;
  if SameText(HmsGetVideoSettings(vstVideoOriginal), &apos;On&apos;) then
    bVideoTranscoding := False    
  else if SameText(HmsGetVideoSettings(vstVideoOriginal), &apos;Off&apos;) then    
    bVideoTranscoding := True 
  else if (mpSubtitleLanguage &lt;&gt; &apos;&apos;) or (HmsGetVideoSettings(vstSubtitle) &lt;&gt; &apos;&apos;) or bDeinterlace then    
    bVideoTranscoding := True     
  else if (mpFrameRate &gt; 0) and (mpFrameRate &lt; 20) then
    bVideoTranscoding := True      
  else if not VideoCodecCompatible then
    bVideoTranscoding := True
  else begin        
    if (mpOriginalWidth &gt; 0) then begin    
      iWidth  := mpOriginalWidth;      
      iHeight := mpOriginalHeight;
    end else begin    
      iWidth  := mpWidth;      
      iHeight := mpHeight;
    end;               
    if (iWidth &gt; cfgMaximumVideoResolutionWidth) or (iHeight &gt; cfgMaximumVideoResolutionHeight) then
      bVideoTranscoding := True  
  end;        
  GetAudioTranscodingParams(cfgTranscodingAudioCodec, sAudioCfgCodecName,
          sAudioCfgFileFormat, iAudioCfgCodecID, iAudioCfgBitrate, iAudioChannels);      
  if SameText(HmsGetVideoSettings(vstAudioOriginal), &apos;On&apos;) then
    bAudioTranscoding := False    
  else if SameText(HmsGetVideoSettings(vstAudioOriginal), &apos;Off&apos;) then    
    bAudioTranscoding := True
  else if (iAudioCodecID &lt;&gt; iAudioCfgCodecID) or 
       ((cfgTranscodingAudioChannels &lt;&gt; 0) and (cfgTranscodingAudioChannels &lt;&gt; iAudioChannels)) or
       ((cfgTranscodingFileFormat = &apos;FLV&apos;) and 
         (GetAudioSampleRate(cfgTranscodingFileFormat, cfgTranscodingAudioCodec) &lt;&gt; mpAudioSampleRate)) then
    bAudioTranscoding := True;              
  if bVideoTranscoding then begin
    sVideoMinMaxRate := &apos;&apos;;         
    if cfgTranscodingVideoBitrate &gt; 0 then begin  
      sVideoBitrate := &apos;-b:v &apos; + IntToStr(cfgTranscodingVideoBitrate);
      if cfgTranscodingVideoMinMaxRate then
        sVideoMinMaxRate := Format(&apos; -minrate %d -maxrate %d -bufsize %d&apos;,
                    [cfgTranscodingVideoBitrate, cfgTranscodingVideoBitrate, 
                     HmsTranscodingBufferSize(cfgTranscodingVideoBitrate)])
    end else
      sVideoBitrate := &apos;-sameq&apos;;
    sVideoTranscodingParams := Format(csFFMPegVideoParams, 
            [GetVideoCodec(cfgTranscodingVideoCodec), sVideoBitrate,
                           sVideoMinMaxRate]);
    sFrameRate := HmsGetVideoSettings(vstFrameRate);
    if sFrameRate = &apos;&apos; then    
      sFrameRate := cfgTranscodingFrameRate;
    if sFrameRate = &apos;&apos; then begin
      if SameText(cfgTranscodingVideoCodec, &apos;FLV&apos;) then      
        sFrameRate := FormatFloat(&apos;0&apos;, mpFrameRate)
      else if (mpFrameRate &gt; 0) and (mpFrameRate &lt; 20) then 
        sFrameRate := &apos;23.976&apos;
    end;          
    if sFrameRate &lt;&gt; &apos;&apos; then
      sVideoTranscodingParams := sVideoTranscodingParams + &apos; -r &apos; + sFrameRate;
    iWidth := mpWidth; iHeight := mpHeight;  
    if (iWidth &gt; 0) and (iHeight &gt; 0) then begin
      sFilterParams := &apos;&apos;; sPadParams := &apos;&apos;;    
      if HmsTranscodingFrameParams(iWidth, iHeight, cfgTranscodingScreenFormat,
                         iPadLeft, iPadTop, iPadRight, iPadBottom) then begin                         
        if mp3DVideoType in [1, 2] then begin
          iWidth  := iWidth  + iPadLeft + iPadRight;
          iHeight := iHeight + iPadTop + iPadBottom;                 
          if mp3DVideoType = 1 then
            iWidth  := (iWidth div 4) * 4
          else
            iHeight := (iHeight div 4) * 4          
        end;
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
        if (mp3DVideoType = 0) and ((iPadLeft &gt; 0) or (iPadRight &gt; 0) or (iPadTop &gt; 0) or (iPadBottom &gt; 0)) then begin        
          Inc(iFrameWidth,  iPadLeft + iPadRight);
          Inc(iFrameHeight, iPadTop + iPadBottom);
          sPadParams := Format(&apos;pad=%d:%d:%d:%d:0x%s&apos;,
                        [iFrameWidth, iFrameHeight, iPadLeft, iPadTop, HmsConvertColor(cfgTranscodingPadColor)]);
          if cfgTranscodingFrameExists then
            sVideoTranscodingParams := sVideoTranscodingParams + cfgTranscodingFrameParams;
        end
      end else begin
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
      end;
      AddFilterParams(sFilterParams, Format(&apos;scale=%d:%d&apos;, [iWidth, iHeight]));
      if sPadParams &lt;&gt; &apos;&apos; then AddFilterParams(sFilterParams, sPadParams);
      AddFilterParams(sFilterParams, &apos;setdar=&apos; + cfgTranscodingAspectRatio);
      sVideoTranscodingParams := sVideoTranscodingParams + Format(&apos; -vf "%s"&apos;, [sFilterParams]);
      sVideoTranscodingParams := sVideoTranscodingParams + HmsTranscodingSubTitleParams(
         iFrameWidth, iFrameHeight, iWidth, iHeight, iPadLeft, iPadTop);
      if (cfgTranscodingThreadCount &gt; 1) and GetMultiThreadSupported(cfgTranscodingVideoCodec) then
        sVideoTranscodingParams := sVideoTranscodingParams + &apos; -threads &apos; + IntToStr(cfgTranscodingThreadCount);
    end    
  end else begin  
    sVideoTranscodingParams := &apos; -copyinkf -vcodec copy &apos;;        
    if SameText(mpVideoCodec, &apos;H264&apos;) and not SameText(mpFileType, &apos;mpegts&apos;) and not SameText(mpFileType, &apos;wtv&apos;) then
      sVideoTranscodingParams := sVideoTranscodingParams + &apos; -vbsf h264_mp4toannexb&apos;      
  end;                 
  if bAudioTranscoding then  
    sAudioTranscodingParams := Format(csFFMpegAudioParams, [sAudioCfgCodecName, iAudioCfgBitrate, 
        GetAudioSampleRate(cfgTranscodingFileFormat, cfgTranscodingAudioCodec), iAudioChannels])
  else                   
    sAudioTranscodingParams := &apos; -acodec copy&apos;;     
  bMapStreams := HmsGetStreamCount &gt; 0;
  sTranscodingParams := HmsTranscodingProbeParams;
  if mpTimeStart &lt;&gt; &apos;&apos; then
    sTranscodingParams := sTranscodingParams + &apos;-ss &apos; + mpTimeStart + &apos; &apos;;
  if SameText(mpFileType, &apos;mpeg&apos;) then                            
    sTranscodingParams := sTranscodingParams + &apos;-f mpeg &apos;;    
  sTranscodingParams := sTranscodingParams + Format(&apos;-i "%s" &apos;, [InputFileName]);
  sTranscodingParams := sTranscodingParams + &apos;-f &apos; + GetFileFormat(cfgTranscodingFileFormat);
  sTranscodingParams := sTranscodingParams + sVideoTranscodingParams + sAudioTranscodingParams;                                   
  if bMapStreams then                           
    sTranscodingParams := sTranscodingParams + Format(&apos; -map 0:%d -map 0:%d&apos;, [HmsGetStreamIndex(stVideo, 0), HmsGetStreamIndex(stAudio, iAudioStreamNo)]);
  sTranscodingParams := sTranscodingParams + &apos; "&lt;OUTPUT FILE&gt;"&apos;;  
//  TranscodingParams := sTranscodingParams;
  TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, True, InputFileName, OutputFileName)                       
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (Ремуксирование)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>0</TranscodingProfilePriority>
      <TranscodingProfileUuid>6d153a01-6207-4503-8a0f-6b4cf722e95e</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с перекодированием видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csTranscodingInputFile = &apos;-i "&lt;INPUT FILE&gt;"&apos;;
  csFFMpegVideoParams = &apos; -f %s -vcodec %s %s%s -pix_fmt yuv420p&apos;;
  csFFMpegAudioParams = &apos; -acodec %s -ab %d -ar 48000&apos;;

function GetAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;libfaac&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;libmp3lame&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := &apos;wmav2&apos;    
  else if SameText(aAudioCodec, &apos;DTS&apos;) then
    Result := &apos;dca&apos;    
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then  
    Result := &apos;pcm_s16be&apos; 
  else
    Result := aAudioCodec
end;

function SameAudioCodec(const aAudioCodec: string; aCodecID: Integer): Boolean;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := aCodecID = CODEC_ID_AC3
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := aCodecID = CODEC_ID_AAC
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := aCodecID = CODEC_ID_MP3
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := aCodecID = CODEC_ID_MP2
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := aCodecID = CODEC_ID_WMAV2
  else
    Result := False
end;

function GetFileFormat(const aFileFormat: string): string;
begin
  if (aFileFormat = &apos;&apos;) or SameText(aFileFormat, &apos;MPEG (DVD)&apos;) then
    Result := &apos;dvd&apos;
  else if Pos(&apos;MPEGTS&apos;, aFileFormat) &gt; 0 then
    Result := &apos;mpegts&apos;
  else if Pos(&apos;ASF&apos;, aFileFormat) &gt; 0 then
    Result := &apos;asf&apos;
  else if SameText(aFileFormat, &apos;MP4&apos;) then
    Result := &apos;ipod&apos;
  else if SameText(aFileFormat, &apos;MPEG1&apos;) then
    Result := &apos;mpeg&apos;
  else
    Result := aFileFormat
end;

function GetVideoCodec(const aVideoCodec: string): string;
begin
  if (aVideoCodec = &apos;&apos;) or SameText(aVideoCodec, &apos;MPEG2&apos;) then
    Result := &apos;mpeg2video&apos;
  else if SameText(aVideoCodec, &apos;MPEG1&apos;) then
    Result := &apos;mpeg1video&apos;
  else if SameText(aVideoCodec, &apos;WMV&apos;) then
    Result := &apos;wmv2&apos;
  else if SameText(aVideoCodec, &apos;MPEG4&apos;) then
    Result := &apos;mpeg4&apos;
  else if SameText(aVideoCodec, &apos;X264&apos;) then
    Result := &apos;libx264 -x264opts "fast-pskip=1:rc-lookahead=0:aq_mode=0" -partitions none -sc_threshold 0 -trellis 0 -me_method dia -refs 1 -subq 0 -vprofile baseline -level 30 -bufsize 10000000 &apos;
  else
    Result := aVideoCodec
end;

function GetMultiThreadSupported(const aVideoCodec: string): Boolean;
begin
  Result := not MatchText(aVideoCodec, [&apos;WMV&apos;, &apos;MPEG1&apos;, &apos;FLV&apos;])
end;

function GetAudioBitrate(const aAudioCodec: string; aAudioBitrate: Integer): Integer;
begin
  if MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) and (aAudioBitrate &gt; 320000) then
    Result := 320000
  else
    Result := aAudioBitrate
end;

function GetAudioChannels(const aAudioCodec: string; aConfigAudioChannels, aStreamAudioChannels: Integer): Integer;
begin
  if aConfigAudioChannels &gt; 0 then
    Result := aConfigAudioChannels
  else
    Result := aStreamAudioChannels;
  if (Result &gt; 2) and MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) then
    Result := 2
  else if (Result = 1) and MatchText(aAudioCodec, [&apos;AAC&apos;, &apos;AC3&apos;]) then
    Result := 2
  else if Result &gt; 6 then
    Result := 6
end;

procedure AddFilterParams(var aFilterParams: string; const aAddParams: string);
begin
  if aFilterParams &lt;&gt; &apos;&apos; then
    aFilterParams := aFilterParams + &apos;,&apos;;
  aFilterParams := aFilterParams + aAddParams
end;
  
var
  iAudioStreamNo, iChannels, iCodecID, iFrameWidth, iFrameHeight, 
  iWidth, iHeight, iPadLeft, iPadTop, iPadRight, iPadBottom: Integer;
  sFrameRate, sParams, sVideoBitrate, sVideoMinMaxRate, sFilterParams, sPadParams: string;
begin
  sVideoMinMaxRate := &apos;&apos;;
  if cfgTranscodingVideoBitrate &gt; 0 then begin  
    sVideoBitrate := &apos;-b:v &apos; + IntToStr(cfgTranscodingVideoBitrate);
    if cfgTranscodingVideoMinMaxRate then
      sVideoMinMaxRate := Format(&apos; -minrate %d -maxrate %d -bufsize %d&apos;,
                  [cfgTranscodingVideoBitrate, cfgTranscodingVideoBitrate, 
                   HmsTranscodingBufferSize(cfgTranscodingVideoBitrate)])
  end else
    sVideoBitrate := &apos;-q:v 0&apos;;      

  if mpInternetItem then
    TranscodingParams := HmsTranscodingProfileParams(&apos;Интернет-телевидение&apos;)
  else if mpSubItemsCount &gt; 0 then 
    TranscodingParams := HmsTranscodingProfileParams(&apos;Фильмы (DVD)&apos;)
  else begin    
    sParams := HmsTranscodingInputParams;
    sParams := sParams + Format(csFFMPegVideoParams, [GetFileFormat(cfgTranscodingFileFormat),
           GetVideoCodec(cfgTranscodingVideoCodec), sVideoBitrate, sVideoMinMaxRate]);
    iAudioStreamNo := mpAudioStreamNo;
    if iAudioStreamNo &lt;&gt; -1 then begin
      iCodecID := HmsGetStreamCodecID(&apos;A&apos;, iAudioStreamNo);
      iChannels := HmsGetStreamChannels(iAudioStreamNo);
    end else begin
      iCodecID := CODEC_ID_NONE;
      iChannels := 0;
    end;
    if (iCodecID = CODEC_ID_NONE) and SameText(mpAudioCodec, &apos;AC3&apos;) then
      iCodecID := CODEC_ID_AC3;
    if cfgTranscodingAudioCopyAC3 and SameAudioCodec(cfgTranscodingAudioCodec, iCodecID) then
      sParams := sParams + &apos; -acodec copy&apos;
    else begin
      sParams := sParams + Format(csFFMpegAudioParams, 
          [GetAudioCodec(cfgTranscodingAudioCodec), 
           GetAudioBitrate(cfgTranscodingAudioCodec, cfgTranscodingAudioBitrate)]);
      iChannels := GetAudioChannels(cfgTranscodingAudioCodec, cfgTranscodingAudioChannels, iChannels);
      if iChannels &gt; 0 then
        sParams := sParams + &apos; -ac &apos; + IntToStr(iChannels)
    end;                                   
    sFrameRate := HmsGetVideoSettings(vstFrameRate);
    if sFrameRate = &apos;&apos; then    
      sFrameRate := cfgTranscodingFrameRate;
    if (sFrameRate = &apos;&apos;) and (mpFrameRate &gt; 0) and (mpFrameRate &lt; 20) then
      sFrameRate := &apos;23.976&apos;;      
    if sFrameRate &lt;&gt; &apos;&apos; then
      sParams := sParams + &apos; -r &apos; + sFrameRate;
    iWidth := mpWidth; iHeight := mpHeight;  
    if (iWidth &gt; 0) and (iHeight &gt; 0) then begin
      sFilterParams := &apos;&apos;; sPadParams := &apos;&apos;;    
      if HmsTranscodingFrameParams(iWidth, iHeight, cfgTranscodingScreenFormat,
                         iPadLeft, iPadTop, iPadRight, iPadBottom) then begin                         
        if mp3DVideoType in [1, 2] then begin
          iWidth  := iWidth  + iPadLeft + iPadRight;
          iHeight := iHeight + iPadTop + iPadBottom;                 
          if mp3DVideoType = 1 then
            iWidth  := (iWidth div 4) * 4
          else
            iHeight := (iHeight div 4) * 4          
        end;
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
        if (mp3DVideoType = 0) and ((iPadLeft &gt; 0) or (iPadRight &gt; 0) or (iPadTop &gt; 0) or (iPadBottom &gt; 0)) then begin        
          Inc(iFrameWidth,  iPadLeft + iPadRight);
          Inc(iFrameHeight, iPadTop + iPadBottom);
          sPadParams := Format(&apos;pad=%d:%d:%d:%d:0x%s&apos;,
                        [iFrameWidth, iFrameHeight, iPadLeft, iPadTop, HmsConvertColor(cfgTranscodingPadColor)]);
          if cfgTranscodingFrameExists then
            sParams := sParams + cfgTranscodingFrameParams;
        end
      end else begin
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
      end;
      AddFilterParams(sFilterParams, Format(&apos;scale=%d:%d&apos;, [iWidth, iHeight]));
      if sPadParams &lt;&gt; &apos;&apos; then AddFilterParams(sFilterParams, sPadParams);
      AddFilterParams(sFilterParams, &apos;setdar=&apos; + cfgTranscodingAspectRatio);
      sParams := sParams + Format(&apos; -vf "%s"&apos;, [sFilterParams]);
      sParams := sParams + HmsTranscodingSubTitleParams(
         iFrameWidth, iFrameHeight, iWidth, iHeight, iPadLeft, iPadTop);
      sParams := sParams + HmsTranscodingMapParams(iAudioStreamNo);
      if (cfgTranscodingThreadCount &gt; 1) and GetMultiThreadSupported(cfgTranscodingVideoCodec) then
        sParams := sParams + &apos; -threads &apos; + IntToStr(cfgTranscodingThreadCount);
    end;
    TranscodingParams := sParams
  end  
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (дополнительный)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>11</TranscodingProfilePriority>
      <TranscodingProfileUuid>C225AA28BEDE47548B914499BFDA81A2</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с перекодированием видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>MimeType := HmsGetMimeType(&apos;wmv&apos;)</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csTranscodingInputFile = &apos;-i "&lt;INPUT FILE&gt;"&apos;;
  csFFMpegVideoParams = &apos; -f asf -vcodec wmv2 %s -pix_fmt yuv420p&apos;;
  csFFMpegAudioParams = &apos; -acodec wmav2 -ab %d -ar 48000 -ac 2 &apos;;
  
procedure AddFilterParams(var aFilterParams: string; const aAddParams: string);
begin
  if aFilterParams &lt;&gt; &apos;&apos; then
    aFilterParams := aFilterParams + &apos;,&apos;;
  aFilterParams := aFilterParams + aAddParams
end;
  
var
  iFrameWidth, iFrameHeight, iWidth, iHeight,
  iPadLeft, iPadTop, iPadRight, iPadBottom: Integer;
  sFrameRate, sParams, sVideoBitrate, sFilterParams, sPadParams: string;
begin
  if mpInternetItem then
    TranscodingParams := HmsTranscodingProfileParams(&apos;Интернет-телевидение&apos;)
  else if mpSubItemsCount &gt; 0 then 
    TranscodingParams := HmsTranscodingProfileParams(&apos;Фильмы (DVD)&apos;)
  else begin    
    sParams := csTranscodingInputFile;
    if Pos(&apos;://&apos;, mpFilePath) = 0 then begin
      if mpTimeStart &lt;&gt; &apos;&apos; then
        sParams := &apos;-ss &apos; + mpTimeStart + &apos; &apos; + sParams
    end;                                              

    if cfgTranscodingVideoBitrate &gt; 0 then  
      sVideoBitrate := &apos;-b:v &apos; + IntToStr(cfgTranscodingVideoBitrate)
    else
      sVideoBitrate := &apos;-q:v 0&apos;;      

    sParams := sParams + Format(csFFMPegVideoParams, [sVideoBitrate]);
    if SameText(mpAudioCodec, &apos;AC3&apos;) and cfgTranscodingAudioCopyAC3 then
      sParams := sParams + &apos; -acodec copy&apos;
    else begin
      sParams := sParams + Format(csFFMpegAudioParams, [cfgTranscodingAudioBitrate]);
{      if cfgTranscodingAudioChannels &gt; 0 then
        sParams := sParams + &apos; -ac &apos; + IntToStr(cfgTranscodingAudioChannels)}        
    end;    
    sFrameRate := HmsGetVideoSettings(vstFrameRate);
    if sFrameRate = &apos;&apos; then    
      sFrameRate := cfgTranscodingFrameRate;
    if (sFrameRate = &apos;&apos;) and (mpFrameRate &gt; 0) and (mpFrameRate &lt; 20) then
      sFrameRate := &apos;23.976&apos;;      
    if sFrameRate &lt;&gt; &apos;&apos; then
      sParams := sParams + &apos; -r &apos; + sFrameRate;
    iWidth := mpWidth; iHeight := mpHeight;  
    if (iWidth &gt; 0) and (iHeight &gt; 0) then begin
      sFilterParams := &apos;&apos;; sPadParams := &apos;&apos;;    
      if HmsTranscodingFrameParams(iWidth, iHeight, cfgTranscodingScreenFormat,
                         iPadLeft, iPadTop, iPadRight, iPadBottom) then begin                         
        if mp3DVideoType in [1, 2] then begin
          iWidth  := iWidth  + iPadLeft + iPadRight;
          iHeight := iHeight + iPadTop + iPadBottom;                 
          if mp3DVideoType = 1 then
            iWidth  := (iWidth div 4) * 4
          else
            iHeight := (iHeight div 4) * 4          
        end;
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
        if (mp3DVideoType = 0) and ((iPadLeft &gt; 0) or (iPadRight &gt; 0) or (iPadTop &gt; 0) or (iPadBottom &gt; 0)) then begin        
          Inc(iFrameWidth,  iPadLeft + iPadRight);
          Inc(iFrameHeight, iPadTop + iPadBottom);
          sPadParams := Format(&apos;pad=%d:%d:%d:%d:0x%s&apos;,
                        [iFrameWidth, iFrameHeight, iPadLeft, iPadTop, HmsConvertColor(cfgTranscodingPadColor)]);
          if cfgTranscodingFrameExists then
            sParams := sParams + cfgTranscodingFrameParams;
        end
      end else begin
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
      end;
      AddFilterParams(sFilterParams, Format(&apos;scale=%d:%d&apos;, [iWidth, iHeight]));
      if sPadParams &lt;&gt; &apos;&apos; then AddFilterParams(sFilterParams, sPadParams);
      AddFilterParams(sFilterParams, &apos;setdar=&apos; + cfgTranscodingAspectRatio);
      sParams := sParams + Format(&apos; -vf "%s"&apos;, [sFilterParams]); 
      sParams := sParams + HmsTranscodingSubTitleParams(
         iFrameWidth, iFrameHeight, iWidth, iHeight, iPadLeft, iPadTop);
      sParams := sParams + HmsTranscodingMapParams(mpAudioStreamNo);
    end;
    TranscodingParams := sParams
  end  
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (дополнительный) - WMV</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>24</TranscodingProfilePriority>
      <TranscodingProfileUuid>9282F331CF33420C83D8D7BCBD5E4B8E</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>Нет скрипта</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с перекодированием видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>IfThen(mpInternetItem, 
   HmsTranscodingProfileParams(&apos;Интернет-телевидение&apos;),
   IfThen(mpSubItemsCount &gt; 0,
      HmsTranscodingDvdParams,    
      HmsTranscodingInputParams + HmsTranscodingVideoParams + 
      HmsTranscodingMapParams(mpAudioStreamNo)))</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (основной)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>-1</TranscodingProfilePriority>
      <TranscodingProfileUuid>EBF8EF92852D416FA641B99DA3FB4235</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>MENCODER</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с перекодированием видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csMEncoderInputParams = &apos;"&lt;INPUT FILE&gt;" &apos;;
  csMEncoderDvdParams = &apos;dvd://%s -dvd-device "%s" &apos;;
  csMEncoderVideoOptions = &apos;vcodec=mpeg2video:vbitrate=%d&apos;;
  csMEncoderAudioOptions = &apos;:acodec=ac3:abitrate=%d&apos;;
var
  bExpandFrame: Boolean;
  iFrameWidth, iFrameHeight, iWidth, iHeight,
  iAudioStreamID, iPadLeft, iPadTop, iPadRight, iPadBottom: Integer;
  sFrameRate, sMEncoderOptions, sParams, sAudioStreamID: string;
begin
  if mpInternetItem then
    sParams := HmsTranscodingProfileParams(&apos;Интернет-телевидение&apos;)
  else begin 
    HmsTranscodingActivateSubItem(-1);
    iAudioStreamID := mpAudioStreamNo;
    sParams := &apos;&apos;;
    if Pos(&apos;://&apos;, mpFilePath) = 0 then begin
      if mpTimeStart &lt;&gt; &apos;&apos; then
        sParams := &apos;-ss &apos; + mpTimeStart + &apos; &apos;
    end;
    if mpSubItemsCount &gt; 0 then begin
      HmsTranscodingActivateSubItem(0);
      if iAudioStreamID &lt;&gt; -1 then 
        sAudioStreamID := HmsGetAudioStreamID(iAudioStreamID);
      sParams := sParams + Format(csMEncoderDvdParams, 
               [Copy(ExtractFileName(mpFilePath), 5, 2), ExcludeTrailingBackslash(ExtractFilePath(mpFilePath))])
    end else  
      sParams := sParams + csMEncoderInputParams;
    sParams := sParams + &apos;-of mpeg -mpegopts format=dvd -ovc lavc &apos;;
    sMEncoderOptions := Format(csMEncoderVideoOptions, [cfgTranscodingVideoBitrate div 1000]);
    if SameText(mpAudioCodec, &apos;AC3&apos;) and cfgTranscodingAudioCopyAC3 then
      sParams := sParams + &apos;-oac copy &apos; 
    else begin
      sParams := sParams + &apos;-oac lavc &apos;;
      sMEncoderOptions := sMEncoderOptions + Format(csMEncoderAudioOptions, 
         [IfThen(mpInternetItem, 320, cfgTranscodingAudioBitrate div 1000)]);
      if cfgTranscodingAudioChannels &gt; 0 then
        sParams := sParams + &apos;-channels &apos; + IntToStr(cfgTranscodingAudioChannels) + &apos; &apos;
    end;
    iWidth := mpWidth; iHeight := mpHeight;  
    if (iWidth &gt; 0) and (iHeight &gt; 0) then begin
      if HmsTranscodingFrameParams(iWidth, iHeight, cfgTranscodingScreenFormat,
                         iPadLeft, iPadTop, iPadRight, iPadBottom) then begin
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
        bExpandFrame := (iPadLeft &gt; 0) or (iPadRight &gt; 0) or 
                        (iPadTop &gt; 0) or (iPadBottom &gt; 0);
        if bExpandFrame then begin
          Inc(iFrameWidth,  iPadLeft + iPadRight);
          Inc(iFrameHeight, iPadTop + iPadBottom);
        end
      end else begin
        bExpandFrame := False;
        iFrameWidth  := iWidth;
        iFrameHeight := iHeight;
      end;
      sParams := sParams + Format(&apos;-vf scale=%d:%d&apos;, [iWidth, iHeight]);
      if bExpandFrame then
        sParams := sParams + Format(&apos;,expand=%d:%d:%d:%d &apos;, 
                              [iFrameWidth, iFrameHeight, iPadLeft, iPadTop])
      else                   
        sParams := sParams + &apos; &apos;;
      sMEncoderOptions := sMEncoderOptions + &apos;:aspect=&apos; + 
                      ReplaceStr(cfgTranscodingScreenFormat, &apos;:&apos;, &apos;/&apos;)      
    end;
    if sAudioStreamID &lt;&gt; &apos;&apos; then   
      sParams := sParams + Format(&apos;-aid %d &apos;, [StrToInt(&apos;$&apos; + sAudioStreamID)]);
    if cfgTranscodingThreadCount &gt; 1 then
      sMEncoderOptions := sMEncoderOptions + Format(&apos;:threads=%d&apos;, [cfgTranscodingThreadCount]);
    sParams := sParams + &apos;-noskip -mc 0 &apos;;
    if sMEncoderOptions &lt;&gt; &apos;&apos; then
      sParams := sParams + Format(&apos;-lavcopts %s &apos;, [sMEncoderOptions]);
    if mpInternetItem then
      sFrameRate := &apos;24000/1001&apos;
    else if cfgTranscodingFrameRate &lt;&gt; &apos;&apos; then                                      
      sFrameRate := cfgTranscodingFrameRate
    else if mpFrameRate &gt; 0 then
      sFrameRate := ReplaceStr(FormatFloat(&apos;0.000&apos;, mpFrameRate), &apos;,&apos;, &apos;.&apos;)
    else
      sFrameRate := &apos;25&apos;;
    if SameFloat(sFrameRate, &apos;23.976&apos;) then
      sFrameRate := &apos;24000/1001&apos;
    else if SameFloat(sFrameRate, &apos;29.970&apos;) then
      sFrameRate := &apos;30000/1001&apos;
    else if SameFloat(sFrameRate, &apos;59.940&apos;) then
      sFrameRate := &apos;60000/1001&apos;;
    sParams := sParams + Format(&apos;-ofps %s &apos;, [sFrameRate]) + &apos; -o "&lt;OUTPUT FILE&gt;"&apos;;
  end;  
  TranscodingParams := sParams
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (основной) - MENCODER</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>17</TranscodingProfilePriority>
      <TranscodingProfileUuid>0CB02451A2974B5DA34ADD0A0B8450C0</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>MPLEX</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование без перекодирования видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csAudioTranscodingParams = &apos; -acodec %s -ar 48000 -ab %d -ac %d&apos;;

function GetAudioFormat(aCodecID: Integer): string;
begin
  if aCodecID = CODEC_ID_AC3 then  
    Result := &apos;ac3&apos; 
  else if aCodecID = CODEC_ID_MP2 then  
    Result := &apos;mp2&apos;
  else if aCodecID = CODEC_ID_DTS then  
    Result := &apos;dts&apos;
  else if aCodecID = CODEC_ID_PCM_S16BE then  
    Result := &apos;lpcm&apos;    
  else  
    Result := &apos;&apos;
end;

function AudioCodecSupported(aCodecID, aAudioChannels: Integer): Boolean;
begin
  Result := GetAudioFormat(aCodecID) &lt;&gt; &apos;&apos;;  
  if Result then begin  
    if aCodecID = CODEC_ID_AC3 then    
      Result := aAudioChannels = 6      
    else if aCodecID = CODEC_ID_PCM_S16BE then    
      Result := aAudioChannels = 2
  end
end;

function VideoCodecSupported(aCodecID: Integer): Boolean;
begin
  Result := aCodecID = CODEC_ID_MPEG2VIDEO
end;

procedure GetAudioTranscodingParams(const aAudioCodec: string; 
    var aCodecName, aFileFormat: string; var aCodecID, aAudioBitrate, aAudioChannels: Integer);    
var
  sAudioCodec: string;
begin
  aAudioBitrate := cfgTranscodingAudioBitrate;  
  if SameText(aAudioCodec, &apos;AC3&apos;) and (aAudioChannels = 6) then begin  
    aCodecName  := &apos;ac3&apos;;    
    aFileFormat := &apos;ac3&apos;;    
    aCodecID := CODEC_ID_AC3;     
  end else if SameText(aAudioCodec, &apos;LPCM&apos;) then begin  
    aCodecName  := &apos;pcm_s16be&apos;;    
    aFileFormat := &apos;s16be&apos;;
    aCodecID    := CODEC_ID_PCM_S16BE;    
    if aAudioChannels &gt; 2 then begin
      aAudioChannels := 2;     
      aCodecID := CODEC_ID_NONE     
    end            
  end else begin  
    aCodecName  := &apos;mp2&apos;;    
    aFileFormat := &apos;mp2&apos;;
    if aAudioBitrate &gt; 320000 then
      aAudioBitrate := 320000;      
    if SameText(aAudioCodec, &apos;MP2&apos;) then    
      aCodecID := CODEC_ID_MP2
    else                           
      aCodecID := CODEC_ID_NONE;
    if aAudioChannels &gt; 2 then begin
      aAudioChannels := 2;
      aCodecID := CODEC_ID_NONE          
    end            
  end
end;

var
  bAudioTranscoding, bVideoTranscoding, bMapStreams: Boolean;
  iAudioChannels, iAudioCodecID, iAudioCfgBitrate, 
  iAudioCfgCodecID, iAudioStreamNo, iVideoCodecID: Integer;
  sAudioCodec, sSyncOffset, sTranscodingMplexParams,  
  sAudioCfgCodecInfo, sAudioCfgCodecName, sAudioCfgFileFormat, 
  sAudioTranscodingParams, sLpcmParams, sVideoTranscodingParams, sTranscodingParams,
  sReadAudioPipeName, sWriteAudioPipeName,
  sReadVideoPipeName, sWriteVideoPipeName: string; 
begin
  TranscodingResult := False;
  bMapStreams := HmsGetStreamCount &gt; 0;
  if not bMapStreams then begin
    HmsRetrieveProperties;                 
    bMapStreams := HmsGetStreamCount &gt; 0;
  end;
  sSyncOffset := HmsGetVideoSettings(vstAudioDelay);
  if sSyncOffset &lt;&gt; &apos;&apos; then
    sSyncOffset := Format(&apos;-O %ds &apos;, [-StrToInt(sSyncOffset)]);    
  iAudioStreamNo := mpAudioStreamNo;  
  if iAudioStreamNo &lt; 0 then  
    iAudioStreamNo := 0;    
  iAudioCodecID  := HmsGetStreamCodecID(stAudio, iAudioStreamNo);  
  iAudioChannels := HmsGetStreamChannels(iAudioStreamNo);
  bAudioTranscoding := True;                                     
  if AudioCodecSupported(iAudioCodecID, iAudioChannels) then begin
    if SameText(HmsGetVideoSettings(vstAudioOriginal), &apos;on&apos;) then 
      bAudioTranscoding := False      
  end else
    iAudioCodecID := CODEC_ID_NONE;
  if bAudioTranscoding then begin                                  
    if cfgTranscodingAudioChannels &lt;&gt; 0 then          
      iAudioChannels := cfgTranscodingAudioChannels;            
    if iAudioChannels &lt; 2 then          
      iAudioChannels := 2;
    GetAudioTranscodingParams(cfgTranscodingAudioCodec, sAudioCfgCodecName,
         sAudioCfgFileFormat, iAudioCfgCodecID, iAudioCfgBitrate, iAudioChannels);                     
    bAudioTranscoding := (iAudioCodecID = CODEC_ID_NONE) or (iAudioCodecID &lt;&gt; iAudioCfgCodecID);    
  end else  
    sAudioCfgFileFormat := GetAudioFormat(iAudioCodecID);
  if SameText(sAudioCfgFileFormat, &apos;s16be&apos;) then begin
    sReadAudioPipeName := &apos;.lpcm&apos;;    
    sLpcmParams := &apos; -L 48000:2:16&apos;;
  end else begin                        
    sReadAudioPipeName := &apos;.&apos; + sAudioCfgFileFormat;
    sLpcmParams := &apos;&apos;;    
  end;
  iVideoCodecID := HmsGetStreamCodecID(stVideo, 0);  
  if SameText(HmsGetVideoSettings(vstVideoOriginal), &apos;on&apos;) and VideoCodecSupported(iVideoCodecID) then  
    bVideoTranscoding := False    
  else                        
    bVideoTranscoding := True;                                    
  sWriteAudioPipeName := sReadAudioPipeName;
  if HmsCreateDualPipe(sReadVideoPipeName, sWriteVideoPipeName, 10000000) and 
     HmsCreateDualPipe(sReadAudioPipeName, sWriteAudioPipeName, 10000000) then begin
    if bAudioTranscoding then        
      sAudioTranscodingParams := Format(csAudioTranscodingParams,          
               [sAudioCfgCodecName, iAudioCfgBitrate, iAudioChannels])               
    else
      sAudioTranscodingParams := &apos; -acodec copy&apos;;      
    sAudioTranscodingParams := sAudioTranscodingParams + Format(&apos; -f %s -y "%s"&apos;, [sAudioCfgFileFormat, sWriteAudioPipeName]);
    if bVideoTranscoding then         
      sVideoTranscodingParams := HmsTranscodingVideoCodecParams    
    else
      sVideoTranscodingParams := &apos; -copyinkf -vcodec copy&apos;;            
    sVideoTranscodingParams := sVideoTranscodingParams + Format(&apos; -f mpeg2video -y "%s"&apos;, [sWriteVideoPipeName]);
    if mpTimeStart &lt;&gt; &apos;&apos; then
      sTranscodingParams := &apos;-ss &apos; + mpTimeStart + &apos; &apos;
    else
      sTranscodingParams := &apos;&apos;;
    sTranscodingParams := sTranscodingParams + Format(&apos;-i "%s"&apos;, [InputFileName]);    
    sTranscodingParams := sTranscodingParams + sVideoTranscodingParams;
    if bMapStreams then
      sTranscodingParams := sTranscodingParams + Format(&apos; -map 0:%d&apos;, [HmsGetStreamIndex(stVideo, 0)]);
    sTranscodingParams := sTranscodingParams + sAudioTranscodingParams;
    if bMapStreams then                                   
      sTranscodingParams := sTranscodingParams + Format(&apos; -map 0:%d&apos;, [HmsGetStreamIndex(stAudio, iAudioStreamNo)]);      
    sTranscodingParams := sTranscodingParams + &apos; -v -1 -loglevel quiet&apos;;                         
    if HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, False) then begin
      sTranscodingMplexParams := Format(sSyncOffset + &apos;-f 9 -b 2000%s -r 2100000 -o "%s" "%s" "%s"&apos;,
                  [sLpcmParams, OutputFileName, sReadVideoPipeName, sReadAudioPipeName]);
      TranscodingResult := HmsTranscodingExecute(&apos;MPLEX&apos;, sTranscodingMplexParams, True);
    end   
  end
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (основной) - MPLEX</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>8</TranscodingProfilePriority>
      <TranscodingProfileUuid>E151C20AF5864ECC8EA6945A4C256C06</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>Нет скрипта</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с перекодированием видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>IfThen(mpInternetItem, 
   HmsTranscodingProfileParams(&apos;Интернет-телевидение&apos;),
   IfThen(mpSubItemsCount &gt; 0,
      HmsTranscodingDvdParams(1280, 720, 6000000, 448000),    
      HmsTranscodingInputParams + HmsTranscodingVideoParams(1280, 720, 6000000, 448000) + 
      HmsTranscodingMapParams(mpAudioStreamNo)))</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (основной)_1280x720</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>14</TranscodingProfilePriority>
      <TranscodingProfileUuid>43EFF1099D1A48C29F5C96A224494E4B</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>Нет скрипта</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с перекодированием видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>IfThen(mpInternetItem, 
   HmsTranscodingProfileParams(&apos;Интернет-телевидение&apos;),
   IfThen(mpSubItemsCount &gt; 0,
      HmsTranscodingDvdParams(1920, 1080, 10000000, 448000),    
      HmsTranscodingInputParams + HmsTranscodingVideoParams(1920, 1080, 10000000, 448000) + 
      HmsTranscodingMapParams(mpAudioStreamNo)))</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (основной)_1920x1080</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>15</TranscodingProfilePriority>
      <TranscodingProfileUuid>541D7BF5531A4C189D5C47C60D85DD8B</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>Нет скрипта</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с перекодированием видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>IfThen(mpInternetItem, 
   HmsTranscodingProfileParams(&apos;Интернет-телевидение&apos;),
   IfThen(mpSubItemsCount &gt; 0,
      HmsTranscodingDvdParams(480, 270, 2000000, 256000),    
      HmsTranscodingInputParams + HmsTranscodingVideoParams(480, 270, 2000000, 256000) + 
      HmsTranscodingMapParams(mpAudioStreamNo)))</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (основной)_480x270</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>16</TranscodingProfilePriority>
      <TranscodingProfileUuid>CDD7A1682368424CB7DBD60C8CFE7613</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>Нет скрипта</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с перекодированием видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>IfThen(mpInternetItem, 
   HmsTranscodingProfileParams(&apos;Интернет-телевидение&apos;),
   IfThen(mpSubItemsCount &gt; 0,
      HmsTranscodingDvdParams(640, 360, 3000000, 320000),    
      HmsTranscodingInputParams + HmsTranscodingVideoParams(640, 360, 3000000, 320000) + 
      HmsTranscodingMapParams(mpAudioStreamNo)))</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (основной)_640x360</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>13</TranscodingProfilePriority>
      <TranscodingProfileUuid>E16338F4E6714606B92A3FB61EF23C5F</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>Нет скрипта</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с перекодированием видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>IfThen(mpInternetItem, 
   HmsTranscodingProfileParams(&apos;Интернет-телевидение&apos;),
   IfThen(mpSubItemsCount &gt; 0,
      HmsTranscodingDvdParams(720, 406, 3000000, 448000),    
      HmsTranscodingInputParams + HmsTranscodingVideoParams(720, 406, 3000000, 448000) + 
      HmsTranscodingMapParams(mpAudioStreamNo)))</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (основной)_720x406</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>12</TranscodingProfilePriority>
      <TranscodingProfileUuid>3CDFE1882F01435D86F2940B3F24BB1D</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition>SameText(mpVideoCodec, &apos;H264&apos;)</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с использованием фильтров DirectShow</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csInputParams = &apos;-f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s %dx%d -r %s -i "%s"%s -i "%s"&apos;;  

  clsidMpcAviSource   = &apos;{CEA8DEFF-0AF7-4DB9-9A38-FB3C3AEFC0DE}&apos;; // MPC - Avi Source
  clsidMpcAviSplitter = &apos;{9736D831-9D6C-4E72-B6E7-560EF9181001}&apos;; // MPC - Avi Splitter    
  clsidMpcFlvSource   = &apos;{C9ECE7B3-1D8E-41F5-9F24-B255DF16C087}&apos;; // MPC - FLV Source (Gabest)
  clsidMpcFlvSplitter = &apos;{47E792CF-0BBE-4F7A-859C-194B0768650A}&apos;; // MPC - FLV Splitter (Gabest)  
  clsidMpcMkvSource   = &apos;{0A68C3B5-9164-4A54-AFAF-995B2FF0E0D4}&apos;; // MPC - Matroska Source
  clsidMpcMkvSplitter = &apos;{149D2E01-C32E-4939-80F6-C07B81015A7A}&apos;; // MPC - Matroska Splitter  
  clsidMpcMp4Source   = &apos;{3CCC052E-BDEE-408A-BEA7-90914EF2964B}&apos;; // MPC - MP4 Source
  clsidMpcMp4Splitter = &apos;{61F47056-E400-43D3-AF1E-AB7DFFD4C4AD}&apos;; // MPC - MP4 Splitter  
  clsidMpcMpgSource   = &apos;{1365BE7A-C86A-473C-9A41-C0A6E82C9FA3}&apos;; // MPC - Mpeg Source (Gabest)
  clsidMpcMpgSplitter = &apos;{DC257063-045F-4BE2-BD5B-E12279C464F0}&apos;; // MPC - Mpeg Splitter (Gabest)  

  MEDIASUBTYPE_DOLBY_AC3 = &apos;{E06D802C-DB46-11CF-B4D1-00805F6CBBEA}&apos;;
  
function GetFilterParams(const aFileFormat: string; const aFilterParams: Variant; 
                        aSplitter: Boolean; var aFilterFileName, aFilterCLSID: string): Boolean;                        
var
  FilterParams: Variant; 
  i: Integer;                                        
begin
  Result := True;  
  for i := 0 to Length(aFilterParams) - 1 do begin
    FilterParams := aFilterParams[i];
    if Pos(FilterParams[0], aFileFormat) &gt; 0 then begin
      aFilterFileName := FilterParams[1];    
      if aSplitter then                
        aFilterCLSID := FilterParams[2]
      else                                       
        aFilterCLSID := FilterParams[3];        
      Exit
    end
  end;      
  Result := False
end;    

function CheckResult(aResult: Integer; aRaiseException: Boolean = True): Boolean;
begin
  Result := aResult = S_OK;
  if not Result and aRaiseException then
    RaiseException(Format(&apos;Error (code: %x) - %s&apos;, [aResult, SysErrorMessage(aResult)]))
end;

var
  bCreateAudioPipe, bHaali, bSplitter, bSuccess: Boolean;
  sAudioFormat, sCodecTag, sInputParams, 
  sAudioMediaMajorType, sAudioMediaSubType,
  sFilterFileName, sFilterCLSID: string;                                  
  sVideoMediaMajorType, sVideoMediaSubType, 
  sReadVideoPipeName, sWriteVideoPipeName, 
  sReadAudioPipeName, sWriteAudioPipeName,
  sTranscodingParams, sAudioPinName, sVideoPinName: string; 
  iAudioStreamNo, iAudioChannels1, iAudioChannels2, iAudioSampleRate, iAudioFormatTag, 
  iVideoWidth, iVideoHeight, iVideoCompression: Integer;
  vCurrentPosition: Variant;  
begin
  TranscodingResult := False;  
  bSplitter := mpIsoItem or mpDvdItem or mpBdItem; 
  if bSplitter and not CheckResult(HmsDirectShowAddResourceSource(&apos;ResourceSource&apos;)) then  
    Exit;             
  if GetFilterParams(mpFileType,
    [[&apos;avi&apos;,      &apos;AviSplitter.ax&apos;,      clsidMpcAviSplitter, clsidMpcAviSource],
     [&apos;flv&apos;,      &apos;FlvSplitter.ax&apos;,      clsidMpcFlvSplitter, clsidMpcFlvSource],
     [&apos;matroska&apos;, &apos;MatroskaSplitter.ax&apos;, clsidMpcMkvSplitter, clsidMpcMkvSource],
     [&apos;mp4&apos;,      &apos;MP4Splitter.ax&apos;,      clsidMpcMp4Splitter, clsidMpcMp4Source],
     [&apos;mpeg&apos;,     &apos;MpegSplitter.ax&apos;,     clsidMpcMpgSplitter, clsidMpcMpgSource]],     
     bSplitter, sFilterFileName, sFilterCLSID) then begin      
    bSuccess := CheckResult(HmsDirectShowLoadFilter(&apos;Filters\&apos; + sFilterFileName, sFilterCLSID, &apos;Source&apos;));
    if bSuccess then begin
      if bSplitter then                           
        bSuccess := CheckResult(HmsDirectShowConnectPin(&apos;ResourceSource&apos;, &apos;Source&apos;, &apos;Output&apos;, &apos;Input&apos;), False)
      else      
        bSuccess := CheckResult(HmsDirectShowSetFileName(&apos;Source&apos;, InputFileName), False);
      if not bSuccess then
        HmsDirectShowRemoveFilter(&apos;Source&apos;)        
    end
  end else            
    bSuccess := False;
  bHaali := False;      
  if not bSuccess then begin  
    if bSplitter then     
      bSuccess := CheckResult(HmsDirectShowAddFilter(&apos;Haali Media Splitter (AR)&apos;, &apos;Source&apos;)) and       
                  CheckResult(HmsDirectShowConnectPin(&apos;ResourceSource&apos;, &apos;Source&apos;, &apos;Output&apos;, &apos;Input&apos;))
    else
      bSuccess := CheckResult(HmsDirectShowAddFilter(&apos;Haali Media Splitter&apos;, &apos;Source&apos;)) and
                  CheckResult(HmsDirectShowSetFileName(&apos;Source&apos;, InputFileName));                  
    if bSuccess then bHaali := True
  end;
  iAudioStreamNo := mpAudioStreamNo;
  if iAudioStreamNo = -1 then
    iAudioStreamNo := 0;    
  if bHaali or SameText(mpFileType, &apos;flv&apos;) then begin  
    sVideoPinName := &apos;Video&apos;;
    sAudioPinName := &apos;Audio&apos;;  
    HmsDirectShowSelectStream(&apos;Source&apos;, iAudioStreamNo, MEDIATYPE_Audio, HmsGetStreamID(stAudio, iAudioStreamNo));
  end else begin
    HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sVideoPinName, MEDIATYPE_Video, 0);    
    if not CheckResult(HmsDirectShowSelectStream(&apos;Source&apos;, iAudioStreamNo, MEDIATYPE_Audio, HmsGetStreamID(stAudio, iAudioStreamNo)), False) then    
      HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sAudioPinName, MEDIATYPE_Audio, 0)
    else
      HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sAudioPinName, MEDIATYPE_Audio, iAudioStreamNo);
  end;  
  if not CheckResult(HmsDirectShowGetMediaType(&apos;Source&apos;, PINDIR_OUTPUT, sAudioPinName, 
        sAudioMediaMajorType, sAudioMediaSubType, iAudioChannels1, iAudioSampleRate, iAudioFormatTag)) then
    Exit;
  if sAudioMediaSubType = MEDIASUBTYPE_WAVE_DTS then
    sAudioFormat := &apos;dts&apos;
  else if sAudioMediaSubType = MEDIASUBTYPE_WAVE_DOLBY_AC3 then
    sAudioFormat := &apos;ac3&apos;    
  else if sAudioMediaSubType = MEDIASUBTYPE_DOLBY_AC3 then
    sAudioFormat := &apos;truehd&apos;
  else if sAudioMediaSubType = MEDIASUBTYPE_AAC then
    sAudioFormat := &apos;aac&apos;
  else if sAudioMediaSubType = MEDIASUBTYPE_MP3 then
    sAudioFormat := &apos;mp3&apos;
  else
    sAudioFormat := &apos;&apos;;
  if mpTimeStart &lt;&gt; &apos;&apos; then begin
    vCurrentPosition := HmsTimeConvert(mpTimeStart) * 10000000;
    if not CheckResult(HmsDirectShowSetPosition(&apos;Source&apos;, TIME_FORMAT_MEDIA_TIME, vCurrentPosition)) then
      Exit;
  end;                                                      
//  if not CheckResult(HmsDirectShowAddFilter(&apos;CyberLink H.264/AVC Decoder (TechnoTrend)&apos;, &apos;Video Decoder&apos;)) then
  if not CheckResult(HmsDirectShowAddFilter(&apos;CoreAVC Video Decoder&apos;, &apos;Video Decoder&apos;), False) and 
     not CheckResult(HmsDirectShowAddFilter(&apos;Microsoft DTV-DVD Video Decoder&apos;, &apos;Video Decoder&apos;)) then 
    Exit;
  if not CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;Video Decoder&apos;, sVideoPinName, &apos;&apos;)) then 
    Exit;
//  HmsDirectShowProperties(&apos;Video Decoder&apos;);
  bCreateAudioPipe := True;  
  if MatchText(sAudioFormat, [&apos;aac&apos;, &apos;truehd&apos;]) then begin  
    bCreateAudioPipe := False;
    if CheckResult(HmsDirectShowAddFilter(&apos;ffdshow Audio Decoder&apos;, &apos;Audio Decoder&apos;), False) then begin    
      if CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;Audio Decoder&apos;, sAudioPinName, &apos;&apos;), False) then      
        bCreateAudioPipe := True        
      else
        HmsDirectShowRemoveFilter(&apos;Audio Decoder&apos;)    
    end    
//    HmsDirectShowProperties(&apos;Audio Decoder&apos;);
  end;  
  if HmsCreateDualPipe(sReadVideoPipeName, sWriteVideoPipeName, 10000000) and 
     (not bCreateAudioPipe or HmsCreateDualPipe(sReadAudioPipeName, sWriteAudioPipeName, 10000000)) then begin
    if not CheckResult(HmsDirectShowAddDump(sWriteVideoPipeName, &apos;DumpVideo&apos;)) then 
      Exit;                 
    if not CheckResult(HmsDirectShowConnectPin(&apos;Video Decoder&apos;, &apos;DumpVideo&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Video, MEDIASUBTYPE_I420)) then 
      Exit;                                 
    if bCreateAudioPipe then begin    
      if not CheckResult(HmsDirectShowAddDump(sWriteAudioPipeName, &apos;DumpAudio&apos;)) then 
        Exit;    
      if MatchText(sAudioFormat, [&apos;aac&apos;, &apos;truehd&apos;]) then begin  
        if not CheckResult(HmsDirectShowConnectPin(&apos;Audio Decoder&apos;, &apos;DumpAudio&apos;, &apos;Out&apos;, &apos;&apos;, 
                            MEDIATYPE_Audio, KSDATAFORMAT_SUBTYPE_PCM)) then 
          Exit;
        if not CheckResult(HmsDirectShowGetMediaType(&apos;Audio Decoder&apos;, PINDIR_OUTPUT, &apos;Out&apos;, 
              sAudioMediaMajorType, sAudioMediaSubType, iAudioChannels2, 
              iAudioSampleRate, iAudioFormatTag)) then
          Exit;
        sAudioFormat := Format(&apos; -f s16le -ar %d -ac %d&apos;, [iAudioSampleRate, iAudioChannels2])
      end else begin
        if not CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;DumpAudio&apos;, sAudioPinName, &apos;&apos;)) then 
          Exit;
        if sAudioFormat &lt;&gt; &apos;&apos; then
          sAudioFormat := &apos; -f &apos; + sAudioFormat; 
      end
    end else begin
      sReadAudioPipeName := InputFileName;      
      sAudioFormat := &apos;&apos;
    end;            
    if not CheckResult(HmsDirectShowGetMediaType(&apos;DumpVideo&apos;, PINDIR_INPUT, &apos;&apos;, 
          sVideoMediaMajorType, sVideoMediaSubType, iVideoWidth, iVideoHeight, iVideoCompression)) then
      Exit;                                     
    HmsDirectShowGetFrameRate(&apos;DumpVideo&apos;, PINDIR_INPUT, &apos;&apos;, mpFrameRate);
    if CheckResult(HmsDirectShowPlay) then begin
      sInputParams := Format(csInputParams, [iVideoWidth, iVideoHeight, 
                                             ReplaceStr(FormatFloat(&apos;0.###&apos;, mpFrameRate), &apos;,&apos;, &apos;.&apos;),
                                             sReadVideoPipeName, sAudioFormat, sReadAudioPipeName]);
      if mpTimeStart &lt;&gt; &apos;&apos; then
        sInputParams := &apos;-ts &apos; + mpTimeStart + &apos; -muxpreload &apos; + IntToStr(HmsTimeConvert(mpTimeStart)) + &apos; &apos; + sInputParams;
      sTranscodingParams := sInputParams + HmsTranscodingVideoParams(0, 0, 0, 0, True, False) + 
                            &apos; "&apos; + OutputFileName + &apos;"&apos;;
//      ShowMessage(sTranscodingParams);                      
      TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams)
    end
  end
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - CoreAVC</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>9</TranscodingProfilePriority>
      <TranscodingProfileUuid>D8873B8516ED4EC5BF4EF8775837699D</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с перекодированием видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csTranscodingInputFile = &apos;-i "&lt;INPUT FILE&gt;"&apos;;
  csFFMpegVideoParams = &apos; -f mpeg -vcodec mpeg1video %s -aspect %s -pix_fmt yuv420p&apos;;
  csFFMpegAudioParams = &apos; -acodec mp2 -ab %d -ar 48000 -ac 2&apos;;
  
procedure AddFilterParams(var aFilterParams: string; const aAddParams: string);
begin
  if aFilterParams &lt;&gt; &apos;&apos; then
    aFilterParams := aFilterParams + &apos;,&apos;;
  aFilterParams := aFilterParams + aAddParams
end;
  
var
  iAudioStreamNo, iChannels, iCodecID, iFrameWidth, iFrameHeight, iWidth, 
  iHeight,iPadLeft, iPadTop, iPadRight, iPadBottom: Integer;
  sParams, sVideoBitrate, sFilterParams, sPadParams: string;
begin
  sParams := csTranscodingInputFile;

  if Pos(&apos;://&apos;, mpFilePath) = 0 then begin
    if mpTimeStart &lt;&gt; &apos;&apos; then
      sParams := &apos;-ss &apos; + mpTimeStart + &apos; -muxpreload &apos; + IntToStr(HmsTimeConvert(mpTimeStart)) + &apos; -async 1 &apos; + sParams
  end;  

  if cfgTranscodingVideoBitrate &gt; 0 then  
    sVideoBitrate := &apos;-b:v &apos; + IntToStr(cfgTranscodingVideoBitrate)
  else
    sVideoBitrate := &apos;-q:v 0&apos;;

  sParams := sParams + Format(csFFMPegVideoParams, [sVideoBitrate,
                                                    cfgTranscodingScreenFormat]);
  iAudioStreamNo := mpAudioStreamNo;
  if iAudioStreamNo &lt;&gt; -1 then begin
    iCodecID := HmsGetStreamCodecID(&apos;A&apos;, iAudioStreamNo);
    iChannels := HmsGetStreamChannels(iAudioStreamNo);
  end else begin
    iCodecID := CODEC_ID_NONE;
    iChannels := 0;
  end;
  if (iCodecID = CODEC_ID_NONE) and SameText(mpAudioCodec, &apos;AC3&apos;) then
    iCodecID := CODEC_ID_AC3;
  if (iCodecID = CODEC_ID_AC3) and cfgTranscodingAudioCopyAC3 then
    sParams := sParams + &apos; -acodec copy&apos;
  else
    sParams := sParams + Format(csFFMpegAudioParams, [Min(cfgTranscodingAudioBitrate, 320000)]);
  if cfgTranscodingFrameRate &lt;&gt; &apos;&apos; then
    sParams := sParams + &apos; -r &apos; + cfgTranscodingFrameRate
  else if (mpFrameRate &gt; 0) and (mpFrameRate &lt; 20) then
    sParams := sParams + &apos; -r 23.976&apos;;
  iWidth := mpWidth; iHeight := mpHeight;  
  if (iWidth &gt; 0) and (iHeight &gt; 0) then begin
    sFilterParams := &apos;&apos;; sPadParams := &apos;&apos;;    
    if HmsTranscodingFrameParams(iWidth, iHeight, cfgTranscodingScreenFormat,
                       iPadLeft, iPadTop, iPadRight, iPadBottom) then begin                         
      if mp3DVideoType in [1, 2] then begin
        iWidth  := iWidth  + iPadLeft + iPadRight;
        iHeight := iHeight + iPadTop + iPadBottom;                 
        if mp3DVideoType = 1 then
          iWidth  := (iWidth div 4) * 4
        else
          iHeight := (iHeight div 4) * 4          
      end;
      iFrameWidth  := iWidth;
      iFrameHeight := iHeight;
      if (mp3DVideoType = 0) and ((iPadLeft &gt; 0) or (iPadRight &gt; 0) or (iPadTop &gt; 0) or (iPadBottom &gt; 0)) then begin        
        Inc(iFrameWidth,  iPadLeft + iPadRight);
        Inc(iFrameHeight, iPadTop + iPadBottom);
        sPadParams := Format(&apos;pad=%d:%d:%d:%d:0x%s&apos;,
                      [iFrameWidth, iFrameHeight, iPadLeft, iPadTop, HmsConvertColor(cfgTranscodingPadColor)]);
        if cfgTranscodingFrameExists then
          sParams := sParams + cfgTranscodingFrameParams;
      end
    end else begin
      iFrameWidth  := iWidth;
      iFrameHeight := iHeight;
    end;
    AddFilterParams(sFilterParams, Format(&apos;scale=%d:%d&apos;, [iWidth, iHeight]));
    if sPadParams &lt;&gt; &apos;&apos; then AddFilterParams(sFilterParams, sPadParams);
    AddFilterParams(sFilterParams, &apos;setdar=&apos; + cfgTranscodingAspectRatio);
    sParams := sParams + Format(&apos; -vf "%s"&apos;, [sFilterParams]); 
    sParams := sParams + HmsTranscodingSubTitleParams(
       iFrameWidth, iFrameHeight, iWidth, iHeight, iPadLeft, iPadTop);
    sParams := sParams + HmsTranscodingMapParams(iAudioStreamNo);
  end;
  TranscodingParams := sParams
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - CorePlayer</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>30</TranscodingProfilePriority>
      <TranscodingProfileUuid>9E7CE3E6361540428F3836F3621684F6</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>TSMUXER</TranscoderName>
      <TranscodingCondition>begin
  if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then 
    OutputFileName := ChangeFileExt(OutputFileName, &apos;.ts&apos;)        
  else                                                            
    OutputFileName := ChangeFileExt(OutputFileName, &apos;.m2ts&apos;);
  TranscodingCondition := True  
end.</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с использованием фильтров DirectShow</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>MimeType := HmsGetMimeType(&apos;m2ts&apos;)</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>function CheckResult(aResult: Integer; aRaiseException: Boolean = True): Boolean;
begin
  Result := aResult = S_OK;
  if not Result and aRaiseException then
    RaiseException(Format(&apos;Error (code: %x) - %s&apos;, [aResult, SysErrorMessage(aResult)]))
end;

function GetAudioBitrate(const aAudioCodec: string; aAudioBitrate: Integer): Integer;
begin
  if MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) and (aAudioBitrate &gt; 320000) then
    Result := 320000
  else
    Result := aAudioBitrate
end;
 
function GetAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;libfaac&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;libmp3lame&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := &apos;wmav2&apos;    
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := &apos;pcm_s16be&apos;
  else
    Result := aAudioCodec
end;

function GetTsMuxerAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;A_AC3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;A_AAC&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;A_MP3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;A_MP3&apos;    
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := &apos;A_LPCM&apos;
  else
    Result := &apos;&apos;  
end;

function GetAudioFormat(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;adts&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;mp3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then  
    Result := &apos;s16be&apos;
  else
    Result := aAudioCodec
end;

function SameAudioCodec(const aAudioCodec, aAudioTrack: string): Boolean;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := aAudioTrack = &apos;A_AC3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := aAudioTrack = &apos;A_AAC&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := aAudioTrack = &apos;A_MP3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := aAudioTrack = &apos;A_MP3&apos;    
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := aAudioTrack = &apos;A_LPCM&apos;
  else
    Result := False
end;

var
  bLPCM, bMpegTS, bMatroskaSource: Boolean;
  iAudioChannels, iAudioFormatTag, iAudioSampleRate, iAudioStreamNo, 
  iEventCode, iVideoCompression, iVideoWidth, iVideoHeight: Integer;
  MetaFileLines: TStringList;
  vCurrentPosition: Variant;
  sAudioMediaMajorType, sAudioMediaSubType, sAudioTrack, sAudioPinName, sAudioSource, 
  sVideoMediaMajorType, sVideoMediaSubType, sVideoTrack, sVideoPinName,
  sReadAudioTranscodedPipeName, sWriteAudioTranscodedPipeName,
  sReadAudioPipeName, sWriteAudioPipeName, 
  sReadVideoPipeName, sWriteVideoPipeName,
  sChannelOrder, sFFMpegParams, sFrameRate, sInputVideoStreamName, 
  sInputAudioStreamName, sMetaFileName, 
  sSoxTranscodingParams, sSoxReadPipeName, sSoxWritePipeName, 
  sTimeShift: string;
begin
  TranscodingResult := False;
  bMatroskaSource := SameText(ExtractFileExt(mpFilePath), &apos;.mkv&apos;);
  bMpegTS := SameText(mpFileType, &apos;mpegts&apos;);
  sTimeShift := HmsGetVideoSettings(vstAudioDelay);  
  if sTimeShift &lt;&gt; &apos;&apos; then
    sTimeShift := Format(&apos;, timeshift=%ss&apos;, [sTimeShift]);
  if mpIsoItem or mpDvdItem or mpBdItem then begin
    if not CheckResult(HmsDirectShowAddResourceSource(&apos;ResourceSource&apos;)) then  
      Exit;
    if bMatroskaSource then begin  
       if not CheckResult(HmsDirectShowLoadFilter(&apos;Filters\MatroskaSplitter.ax&apos;, // MPC - Matroska Splitter
                          &apos;{149D2E01-C32E-4939-80F6-C07B81015A7A}&apos;, &apos;Source&apos;)) then
         Exit                 
    end else if not bMpegTS or not CheckResult(HmsDirectShowAddFilter(&apos;Haali Media Splitter (AR)&apos;, &apos;Source&apos;), False) then begin   
      if not CheckResult(HmsDirectShowLoadFilter(&apos;Filters\MpegSplitter.ax&apos;, // MPC - Mpeg Splitter (Gabest)
                          &apos;{DC257063-045F-4BE2-BD5B-E12279C464F0}&apos;, &apos;Source&apos;)) then   
        Exit;
    end;     
    if not CheckResult(HmsDirectShowConnectPin(&apos;ResourceSource&apos;, &apos;Source&apos;, &apos;Output&apos;, &apos;Input&apos;)) then 
      Exit;
  end else begin
    if bMatroskaSource then begin  
       if not CheckResult(HmsDirectShowLoadFilter(&apos;Filters\MatroskaSplitter.ax&apos;, // MPC - Matroska Source
                          &apos;{0A68C3B5-9164-4A54-AFAF-995B2FF0E0D4}&apos;, &apos;Source&apos;)) then
         Exit                 
    end else if not bMpegTS or not CheckResult(HmsDirectShowAddFilter(&apos;Haali Media Splitter&apos;, &apos;Source&apos;), False) then begin 
      if not CheckResult(HmsDirectShowLoadFilter(&apos;Filters\MpegSplitter.ax&apos;, // MPC - Mpeg Source (Gabest)
                            &apos;{1365BE7A-C86A-473C-9A41-C0A6E82C9FA3}&apos;, &apos;Source&apos;)) then   
        Exit;
    end;    
    if not CheckResult(HmsDirectShowSetFileName(&apos;Source&apos;, InputFileName)) then
      Exit
  end;
  iAudioStreamNo := mpAudioStreamNo;
  if iAudioStreamNo = -1 then
    iAudioStreamNo := 0;
  if bMatroskaSource then begin
    HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sVideoPinName, MEDIATYPE_Video, 0);
    HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sAudioPinName, MEDIATYPE_Audio, iAudioStreamNo);
  end else begin
    sVideoPinName := &apos;Video&apos;;
    sAudioPinName := &apos;Audio&apos;;  
    HmsDirectShowSelectStream(&apos;Source&apos;, iAudioStreamNo, MEDIATYPE_Audio, HmsGetStreamID(stAudio, iAudioStreamNo));
  end;  
  if mpTimeStart &lt;&gt; &apos;&apos; then begin
    vCurrentPosition := HmsTimeConvert(mpTimeStart) * 10000000;
    if not CheckResult(HmsDirectShowSetPosition(&apos;Source&apos;, TIME_FORMAT_MEDIA_TIME, vCurrentPosition)) then
      Exit;
  end;
  if not CheckResult(HmsDirectShowGetMediaType(&apos;Source&apos;, PINDIR_OUTPUT, sVideoPinName, 
        sVideoMediaMajorType, sVideoMediaSubType, iVideoWidth, iVideoHeight, iVideoCompression)) then
    Exit;
  if not CheckResult(HmsDirectShowGetMediaType(&apos;Source&apos;, PINDIR_OUTPUT, sAudioPinName, 
        sAudioMediaMajorType, sAudioMediaSubType, iAudioChannels, iAudioSampleRate, iAudioFormatTag)) then
    Exit;
  if SameText(sVideoMediaSubType, MEDIASUBTYPE_X264_) or 
     SameText(sVideoMediaSubType, MEDIASUBTYPE_x264) or
     SameText(sVideoMediaSubType, MEDIASUBTYPE_AVC1_) or     
     SameText(sVideoMediaSubType, MEDIASUBTYPE_avc1) or
     SameText(sVideoMediaSubType, MEDIASUBTYPE_H264_) or     
     SameText(sVideoMediaSubType, MEDIASUBTYPE_h264) then 
    sVideoTrack := &apos;V_MPEG4/ISO/AVC, "%s", level=4.1, insertSEI, contSPS&apos;
  else if SameText(sVideoMediaSubType, MEDIASUBTYPE_WVC1_) or 
          SameText(sVideoMediaSubType, MEDIASUBTYPE_wvc1) then  
    sVideoTrack := &apos;V_MS/VFW/WVC1, "%s"&apos;  
  else if SameText(sVideoMediaSubType, MEDIASUBTYPE_MPEG2) then 
    sVideoTrack := &apos;V_MPEG-2, "%s"&apos;
  else
    sVideoTrack := &apos;&apos;;
  if SameText(sAudioMediaSubType, MEDIASUBTYPE_WAVE_DTS) then
    sAudioTrack := &apos;A_DTS&apos;
  else if SameText(sAudioMediaSubType, MEDIASUBTYPE_WAVE_DOLBY_AC3) or 
          SameText(sAudioMediaSubType, MEDIASUBTYPE_DOLBY_AC3) then
    sAudioTrack := &apos;A_AC3&apos;
  else if SameText(sAudioMediaSubType, MEDIASUBTYPE_AAC) then
    sAudioTrack := &apos;A_AAC&apos;
  else if SameText(sAudioMediaSubType, MEDIASUBTYPE_MP3) then
    sAudioTrack := &apos;A_MP3&apos;
  else
    sAudioTrack := &apos;&apos;;
  if (sVideoTrack &lt;&gt; &apos;&apos;) and (sAudioTrack &lt;&gt; &apos;&apos;) then begin
    if HmsCreateDualPipe(sReadVideoPipeName, sWriteVideoPipeName) and 
       HmsCreateDualPipe(sReadAudioPipeName, sWriteAudioPipeName) then begin
      sInputVideoStreamName := sReadVideoPipeName;
      sInputAudioStreamName := sReadAudioPipeName;   
      if not CheckResult(HmsDirectShowAddDump(sWriteVideoPipeName, &apos;DumpVideo&apos;)) then 
        Exit;
      if not CheckResult(HmsDirectShowAddDump(sWriteAudioPipeName, &apos;DumpAudio&apos;)) then 
        Exit;
      if not CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;DumpVideo&apos;, sVideoPinName, &apos;&apos;, MEDIATYPE_Video)) then 
        Exit;        
      if SameText(sAudioTrack, &apos;A_DTS&apos;) and cfgTranscodingHideDTSInLPCM then begin
        if CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;DumpAudio&apos;, sAudioPinName, &apos;&apos;, MEDIATYPE_Audio)) and 
           HmsCreateDualPipe(sReadAudioTranscodedPipeName, sWriteAudioTranscodedPipeName) then begin
          iAudioChannels := 2;
          HmsCreateLpcmFile(sReadAudioPipeName, sWriteAudioTranscodedPipeName, iAudioChannels, 48000, 16, False, True);                
          sInputAudioStreamName := sReadAudioTranscodedPipeName;
          sAudioTrack := &apos;A_LPCM&apos;;
        end else
          Exit                   
      end else if not SameAudioCodec(cfgTranscodingAudioCodec, sAudioTrack) then begin
        if not CheckResult(HmsDirectShowAddFilter(&apos;ffdshow Audio Decoder&apos;, &apos;Audio Decoder&apos;)) then 
          Exit;          
        if not CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;Audio Decoder&apos;, sAudioPinName, &apos;&apos;, MEDIATYPE_Audio)) then 
          Exit;
        if not CheckResult(HmsDirectShowConnectPin(&apos;Audio Decoder&apos;, &apos;DumpAudio&apos;, &apos;Out&apos;, &apos;&apos;, 
                                   MEDIATYPE_Audio, KSDATAFORMAT_SUBTYPE_PCM)) then 
          Exit;
        if not CheckResult(HmsDirectShowGetMediaType(&apos;Audio Decoder&apos;, PINDIR_OUTPUT, &apos;Out&apos;, 
                sAudioMediaMajorType, sAudioMediaSubType, iAudioChannels, 
                iAudioSampleRate, iAudioFormatTag)) then
            Exit;            
        if not HmsCreateDualPipe(sReadAudioTranscodedPipeName, sWriteAudioTranscodedPipeName) then
          Exit;                       
        if SameText(cfgTranscodingAudioCodec, &apos;LPCM&apos;) then begin
          sChannelOrder := &apos;&apos;;                    
          if iAudioChannels = 6 then
            sChannelOrder := &apos; remix 1 2 3 5 6 4&apos;;                                
          if HmsCreateDualPipe(sSoxReadPipeName, sSoxWritePipeName) then begin
            sSoxTranscodingParams := Format(&apos;-t raw -L -c %d -r %d -e signed -b 16 "%s" -t raw -B -c %d -r 48000 "%s"%s&apos;,
                      [iAudioChannels, iAudioSampleRate, sReadAudioPipeName, iAudioChannels, sSoxWritePipeName, sChannelOrder]);                  
            if HmsTranscodingExecute(&apos;SOX&apos;, sSoxTranscodingParams, False) then                     
              sReadAudioPipeName := sSoxReadPipeName              
          end;
          HmsCreateLpcmFile(sReadAudioPipeName, sWriteAudioTranscodedPipeName, iAudioChannels, 48000, 16, False);                
          sInputAudioStreamName := sReadAudioTranscodedPipeName;
          sAudioTrack := &apos;A_LPCM&apos;;
        end else begin            
          sFFMpegParams := Format(&apos; -f s16le -ar %d -ac %d -i "%s" -acodec %s -ab %d -f %s -y "%s"&apos;, 
                  [iAudioSampleRate, iAudioChannels, sReadAudioPipeName, 
                   GetAudioCodec(cfgTranscodingAudioCodec),
                   GetAudioBitrate(cfgTranscodingAudioCodec, cfgTranscodingAudioBitrate),
                   GetAudioFormat(cfgTranscodingAudioCodec), sWriteAudioTranscodedPipeName]);
          if HmsTranscodingExecute(&apos;HMSMPEG&apos;, sFFMpegParams, False) then begin
            sInputAudioStreamName := sReadAudioTranscodedPipeName;
            sAudioTrack := GetTsMuxerAudioCodec(cfgTranscodingAudioCodec);
          end else
            Exit            
        end
      end else if not CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;DumpAudio&apos;, sAudioPinName, &apos;&apos;, MEDIATYPE_Audio)) then 
        Exit;   
      sFrameRate := HmsGetVideoSettings(vstFrameRate);
      if (sFrameRate = &apos;&apos;) and (mpFrameRate &gt; 0) then      
        sFrameRate := ReplaceStr(FormatFloat(&apos;0.000&apos;, mpFrameRate), &apos;,&apos;, &apos;.&apos;)        
      else      
        sFrameRate := &apos;&apos;;
      if sFrameRate &lt;&gt; &apos;&apos; then                    
        sVideoTrack := sVideoTrack + &apos;, fps=&apos; + sFrameRate;
      sVideoTrack := sVideoTrack + &apos;, track=1&apos;;   
      sAudioTrack := sAudioTrack + &apos;, "%s", track=2&apos; + sTimeShift;
      MetaFileLines := TStringList.Create;
      try
        MetaFileLines.Add(&apos;MUXOPT --no-pcr-on-video-pid --vbr --vbv-len=500&apos;);
        MetaFileLines.Add(Format(sVideoTrack, [sInputVideoStreamName, sFrameRate]));
        MetaFileLines.Add(Format(sAudioTrack, [sInputAudioStreamName]));
        sMetaFileName := ChangeFileExt(OutputFileName, &apos;.meta&apos;);
        MetaFileLines.SaveToFile(sMetaFileName);
        if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then 
          OutputFileName := ChangeFileExt(OutputFileName, &apos;.ts&apos;)        
        else                                                            
          OutputFileName := ChangeFileExt(OutputFileName, &apos;.m2ts&apos;);
        if CheckResult(HmsDirectShowPlay) then
          TranscodingResult := HmsTranscodingExecute(&apos;TSMUXER&apos;, &apos;"&apos; + sMetaFileName + &apos;" "&apos; + OutputFileName + &apos;"&apos;, True);
      finally
        MetaFileLines.Free
      end    
    end
  end  
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - DirectShow - TsMuxer</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>22</TranscodingProfilePriority>
      <TranscodingProfileUuid></TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с использованием фильтров DirectShow</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>MimeType := HmsGetMimeType(&apos;wmv&apos;)</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  clsidMpcAviSource    = &apos;{CEA8DEFF-0AF7-4DB9-9A38-FB3C3AEFC0DE}&apos;; // MPC - Avi Source
  clsidMpcAviSplitter  = &apos;{9736D831-9D6C-4E72-B6E7-560EF9181001}&apos;; // MPC - Avi Splitter    
  clsidMpcFlvSource    = &apos;{C9ECE7B3-1D8E-41F5-9F24-B255DF16C087}&apos;; // MPC - FLV Source (Gabest)
  clsidMpcFlvSplitter  = &apos;{47E792CF-0BBE-4F7A-859C-194B0768650A}&apos;; // MPC - FLV Splitter (Gabest)  
  clsidMpcMkvSource    = &apos;{0A68C3B5-9164-4A54-AFAF-995B2FF0E0D4}&apos;; // MPC - Matroska Source
  clsidMpcMkvSplitter  = &apos;{149D2E01-C32E-4939-80F6-C07B81015A7A}&apos;; // MPC - Matroska Splitter  
  clsidMpcMp4Source    = &apos;{3CCC052E-BDEE-408A-BEA7-90914EF2964B}&apos;; // MPC - MP4 Source
  clsidMpcMp4Splitter  = &apos;{61F47056-E400-43D3-AF1E-AB7DFFD4C4AD}&apos;; // MPC - MP4 Splitter  
  clsidMpcMpgSource    = &apos;{1365BE7A-C86A-473C-9A41-C0A6E82C9FA3}&apos;; // MPC - Mpeg Source (Gabest)
  clsidMpcMpgSplitter  = &apos;{DC257063-045F-4BE2-BD5B-E12279C464F0}&apos;; // MPC - Mpeg Splitter (Gabest)
  clsidMpcRmvbSource   = &apos;{765035B3-5944-4A94-806B-20EE3415F26F}&apos;; // MPC - Real Media Source    
  clsidMpcRmvbSplitter = &apos;{E21BE468-5C18-43EB-B0CC-DB93A847D769}&apos;; // MPC - Real Media Splitter  
    
     
  MEDIATYPE_Subtitle               = &apos;{E487EB08-6B26-4be9-9DD3-993434D313FD}&apos;;

  KSDATAFORMAT_TYPE_MPEG2_SECTIONS = &apos;{455F176C-4B06-47CE-9AEF-8CAEF73DF7B5}&apos;;
    
  MEDIASUBTYPE_MPEG2DATA           = &apos;{C892E55B-252D-42B5-A316-D997E7A5D995}&apos;;  

  MEDIASUBTYPE_CPFilters_Processed = &apos;{46ADBD28-6FD0-4796-93B2-155C51DC048D}&apos;;
  FORMATTYPE_CPFilters_Processed   = &apos;{6739B36F-1D5F-4AC2-8192-28BB0E73D16A}&apos;;    

  MEDIASUBTYPE_iTV                 = &apos;{4A9F8579-6BF8-4392-8A6D-D2DD09FA7861}&apos;;
  
  MEDIASUBTYPE_RGB555              = &apos;{e436eb7c-524f-11ce-9f53-0020af0ba770}&apos;;
  
  MEDIASUBTYPE_RGB565              = &apos;{e436eb7b-524f-11ce-9f53-0020af0ba770}&apos;;
  
  MEDIASUBTYPE_RAWAudio            = &apos;{20776172-0000-0010-8000-00AA00389B71}&apos;;  

  IDFF_isSubtitles    = 801;
  IDFF_subFilename    = 821;

  IDFF_rawv           = 1009;
  IDFF_cvid           = 1035;
  IDFF_rv10           = 1037;  
  IDFF_rv40           = 1332;
  IDFF_rv30           = 1333;
  IDFF_vp8            = 1335;  

  IDFF_ra             = 1079;  
  IDFF_cook           = 1334;  
  IDFF_rawa           = 1036;
  
function GetFilterParams(const aFileFormat: string; const aFilterParams: Variant; 
                        aSplitter: Boolean; var aFilterFileName, aFilterCLSID: string): Boolean;                        
var
  FilterParams: Variant; 
  i: Integer;                                        
begin
  Result := True;  
  for i := 0 to Length(aFilterParams) - 1 do begin
    FilterParams := aFilterParams[i];
    if Pos(FilterParams[0], aFileFormat) &gt; 0 then begin
      aFilterFileName := FilterParams[1];    
      if aSplitter then                
        aFilterCLSID := FilterParams[2]
      else                                       
        aFilterCLSID := FilterParams[3];        
      Exit
    end
  end;      
  Result := False
end;    

function CheckResult(aResult: Integer; aRaiseException: Boolean = True): Boolean;
begin
  Result := aResult = S_OK;
  if not Result and aRaiseException then
    RaiseException(Format(&apos;Error (code: %x) - %s&apos;, [aResult, SysErrorMessage(aResult)]))
end;

function GetStreamNo(const aStreamType: Char; const aStreamID: Integer): Integer;
var
  i, iStreamID: Integer;
begin
  Result := 0;
  for i := 0 to HmsGetStreamCount - 1 do begin  
    iStreamID := HmsGetStreamID(aStreamType, i);
    if iStreamID = aStreamID then begin
      Result := i; Break
    end else if iStreamID = 0 then    
      Break      
  end
end; 

var
  bHaali, bFFDShow, bSuccess, bSplitter, bSubtitles: Boolean;
  iAudioChannels, iAudioSampleRate, iAudioFormatTag, iAudioStreamNo,
  iCompression, iPadLeft, iPadTop, iPadRight, iPadBottom, iWidth, iHeight: Integer; 
  iEventCode, iSubtitleStreamID, iSubtitleStreamNo, iTimeLength: Integer;  
  sAudioMediaMajorType, sAudioMediaSubType,
  sAudioDecoder, sAudioPinName, sAudioSource,
  sFilterFileName, sFilterCLSID, 
  sMediaMajorType, sMediaSubType, sResizerMediaSubType, 
  sVideoSource, sVideoPinName,  
  sSubtitleFileName, sSubtitlePinName: string;
  vCurrentPosition, vPropertyValue: Variant;
begin
  sResizerMediaSubType := &apos;&apos;;                                            
  if HmsGetStreamCount = 0 then  
    HmsRetrieveProperties;
  bSplitter := mpIsoItem or mpDvdItem or mpBdItem or mpPodcastItem or mpInternetItem;
  if bSplitter and not CheckResult(HmsDirectShowAddResourceSource(&apos;ResourceSource&apos;)) then  
    Exit;           
  bSuccess := True;
  if GetFilterParams(mpFileType,
    [[&apos;avi&apos;,      &apos;AviSplitter.ax&apos;,       clsidMpcAviSplitter,  clsidMpcAviSource],
     [&apos;flv&apos;,      &apos;FlvSplitter.ax&apos;,       clsidMpcFlvSplitter,  clsidMpcFlvSource],
     [&apos;matroska&apos;, &apos;MatroskaSplitter.ax&apos;,  clsidMpcMkvSplitter,  clsidMpcMkvSource],
     [&apos;mp4&apos;,      &apos;MP4Splitter.ax&apos;,       clsidMpcMp4Splitter,  clsidMpcMp4Source],
     [&apos;mpeg&apos;,     &apos;MpegSplitter.ax&apos;,      clsidMpcMpgSplitter,  clsidMpcMpgSource],
     [&apos;rm&apos;,       &apos;RealMediaSplitter.ax&apos;, clsidMpcRmvbSplitter, clsidMpcRmvbSource]],      
     bSplitter, sFilterFileName, sFilterCLSID) then begin      
    bSuccess := CheckResult(HmsDirectShowLoadFilter(&apos;Filters\&apos; + sFilterFileName, sFilterCLSID, &apos;Source&apos;));
    if bSuccess then begin
      if bSplitter then                           
        bSuccess := CheckResult(HmsDirectShowConnectPin(&apos;ResourceSource&apos;, &apos;Source&apos;, &apos;Output&apos;, &apos;Input&apos;), False)
      else      
        bSuccess := CheckResult(HmsDirectShowSetFileName(&apos;Source&apos;, InputFileName), False);
      if not bSuccess then
        HmsDirectShowRemoveFilter(&apos;Source&apos;)        
    end
  end else            
    bSuccess := False;
  bHaali := False; bSubtitles := False; bFFDShow := False;
  iSubtitleStreamID := -1; iSubtitleStreamNo := 0; sSubtitleFileName := &apos;&apos;;                                      
  if mpSubtitleLanguage &lt;&gt; &apos;&apos; then begin
    bSubtitles := HmsRegExMatch(&apos;\[(.*?)\]&apos;, mpSubtitleLanguage, sSubtitleFileName);
    if bSubtitles and (Copy(sSubtitleFileName, 1, 2) = &apos;0x&apos;) then begin    
      iSubtitleStreamID := StrToIntDef(&apos;$&apos; + Copy(sSubtitleFileName, 3, Length(sSubtitleFileName)), 0);
      if iSubtitleStreamID &gt; 0 then         
        iSubtitleStreamNo := GetStreamNo(stSubtitle, iSubtitleStreamID)        
      else                       
        bSubtitles := False;
      sSubtitleFileName := &apos;&apos;;      
    end
  end;                                               
  if not bSuccess then begin  
    if bSplitter then     
      bSuccess := CheckResult(HmsDirectShowAddFilter(&apos;Haali Media Splitter (AR)&apos;, &apos;Source&apos;)) and       
                  CheckResult(HmsDirectShowConnectPin(&apos;ResourceSource&apos;, &apos;Source&apos;, &apos;Output&apos;, &apos;Input&apos;))
    else if CheckResult(HmsDirectShowAddFilter(&apos;Haali Media Splitter&apos;, &apos;Source&apos;), False) then begin      
      if CheckResult(HmsDirectShowSetFileName(&apos;Source&apos;, InputFileName), False) then
        bSuccess := True          
      else                                       
        HmsDirectShowRemoveFilter(&apos;Source&apos;)          
    end;
    if bSuccess then 
      bHaali := True 
    else 
      bSuccess := CheckResult(HmsDirectShowAddSource(InputFileName, &apos;Source&apos;));
  end;
  iAudioStreamNo := mpAudioStreamNo;
  if iAudioStreamNo = -1 then
    iAudioStreamNo := 0;
  sVideoSource := &apos;Source&apos;;  
  sAudioSource := &apos;Source&apos;;
  if SameText(ExtractFileExt(InputFileName), &apos;.wtv&apos;) then begin  
    CheckResult(HmsDirectShowAddFilter(&apos;PBDA DTFilter&apos;, &apos;VideoDTFilter&apos;, &apos;{4A56AF32-C21F-11DB-96FA-005056C00008}&apos;));
    CheckResult(HmsDirectShowAddFilter(&apos;PBDA DTFilter&apos;, &apos;AudioDTFilter&apos;, &apos;{4A56AF32-C21F-11DB-96FA-005056C00008}&apos;));
    if (HmsDirectShowConnectPin(&apos;Source&apos;, &apos;VideoDTFilter&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Video) = S_OK) and 
       (HmsDirectShowConnectPin(&apos;Source&apos;, &apos;AudioDTFilter&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Audio) = S_OK) then begin                  
      sVideoSource := &apos;VideoDTFilter&apos;;                      
      sAudioSource := &apos;AudioDTFilter&apos;;    
      sVideoPinName := &apos;Out&apos;;
      sAudioPinName := &apos;Out&apos;;
    end else begin                                        
      HmsDirectShowRemoveFilter(&apos;VideoDTFilter&apos;);
      HmsDirectShowRemoveFilter(&apos;AudioDTFilter&apos;);      
    end
  end else if SameText(ExtractFileExt(InputFileName), &apos;.dvr-ms&apos;) then begin  
    CheckResult(HmsDirectShowAddFilter(&apos;Decrypt/Tag&apos;, &apos;VideoDecryptTag&apos;, &apos;{C4C4C4FC-0049-4E2B-98FB-9537F6CE516D}&apos;));
    CheckResult(HmsDirectShowAddFilter(&apos;Decrypt/Tag&apos;, &apos;AudioDecryptTag&apos;, &apos;{C4C4C4FC-0049-4E2B-98FB-9537F6CE516D}&apos;));
    if (HmsDirectShowConnectPin(&apos;Source&apos;, &apos;VideoDecryptTag&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Video) = S_OK) and 
       (HmsDirectShowConnectPin(&apos;Source&apos;, &apos;AudioDecryptTag&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Audio) = S_OK) then begin                  
      sVideoSource := &apos;VideoDecryptTag&apos;;                      
      sAudioSource := &apos;AudioDecryptTag&apos;;    
      sVideoPinName := &apos;Out&apos;;
      sAudioPinName := &apos;Out&apos;;
    end else begin                                        
      HmsDirectShowRemoveFilter(&apos;VideoDecryptTag&apos;);
      HmsDirectShowRemoveFilter(&apos;AudioDecryptTag&apos;);      
    end
  end else begin   
    if bHaali or SameText(mpFileType, &apos;flv&apos;) then begin  
      sVideoPinName    := &apos;Video&apos;;
      sAudioPinName    := &apos;Audio&apos;;
      sSubtitlePinName := &apos;Subtitle&apos;;  
      HmsDirectShowSelectStream(&apos;Source&apos;, iAudioStreamNo, MEDIATYPE_Audio, HmsGetStreamID(stAudio, iAudioStreamNo));      
      if bSubtitles and (sSubtitleFileName = &apos;&apos;) then                                                                     
        HmsDirectShowSelectStream(&apos;Source&apos;, iSubtitleStreamNo, MEDIATYPE_Subtitle, iSubtitleStreamID)
    end else begin
      HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sVideoPinName, MEDIATYPE_Video, 0);    
      if CheckResult(HmsDirectShowSelectStream(&apos;Source&apos;, iAudioStreamNo, MEDIATYPE_Audio, HmsGetStreamID(stAudio, iAudioStreamNo)), False) then    
        HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sAudioPinName, MEDIATYPE_Audio, 0)
      else
        HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sAudioPinName, MEDIATYPE_Audio, iAudioStreamNo);        
      if bSubtitles and (sSubtitleFileName = &apos;&apos;) then begin      
        if CheckResult(HmsDirectShowSelectStream(&apos;Source&apos;, iSubtitleStreamNo, MEDIATYPE_Subtitle, iSubtitleStreamID), False) then    
          HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sSubtitlePinName, MEDIATYPE_Subtitle, 0)
        else
          HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sSubtitlePinName, MEDIATYPE_Subtitle, iSubtitleStreamID);        
      end
    end
  end;                            
  if mpTimeStart &lt;&gt; &apos;&apos; then begin
    vCurrentPosition := HmsTimeConvert(mpTimeStart) * 10000000;
    if not CheckResult(HmsDirectShowSetPosition(&apos;Source&apos;, TIME_FORMAT_MEDIA_TIME, vCurrentPosition)) then
      Exit;
  end;                             
  if SameText(ExtractFileExt(InputFileName), &apos;.wmv&apos;) then begin
    if not CheckResult(HmsDirectShowAddFilter(&apos;WMVideo Decoder DMO&apos;, &apos;Video Decoder&apos;)) then 
      Exit;                           
    if not CheckResult(HmsDirectShowAddFilter(&apos;WMAudio Decoder DMO&apos;, &apos;Audio Decoder&apos;)) then 
      Exit;                               
  end else if MatchText(ExtractFileExt(InputFileName), [&apos;.wtv&apos;, &apos;.dvr-ms&apos;]) then begin  
    if not CheckResult(HmsDirectShowAddFilter(&apos;Microsoft DTV-DVD Video Decoder&apos;, &apos;Video Decoder&apos;)) then
      Exit;                                                                                                  
    if not CheckResult(HmsDirectShowAddFilter(&apos;Microsoft DTV-DVD Audio Decoder&apos;, &apos;Audio Decoder&apos;)) then
      Exit;                                     
  end else begin  
    if not CheckResult(HmsDirectShowAddFilter(&apos;ffdshow Video Decoder&apos;, &apos;Video Decoder&apos;)) then 
      Exit;                                                             
    HmsDirectShowSetProperty(&apos;Video Decoder&apos;, IFFDShowBaseT, IDFF_cvid, 1);
    HmsDirectShowSetProperty(&apos;Video Decoder&apos;, IFFDShowBaseT, IDFF_rv10, 1);  
    HmsDirectShowSetProperty(&apos;Video Decoder&apos;, IFFDShowBaseT, IDFF_rv40, 1);
    HmsDirectShowSetProperty(&apos;Video Decoder&apos;, IFFDShowBaseT, IDFF_rv30, 1);
    HmsDirectShowSetProperty(&apos;Video Decoder&apos;, IFFDShowBaseT, IDFF_vp8,  1);
    HmsDirectShowSetProperty(&apos;Video Decoder&apos;, IFFDShowBaseT, IDFF_rawv, 1);        
    if bSubtitles then begin    
      HmsDirectShowSetProperty(&apos;Video Decoder&apos;, IFFDShowBaseT, IDFF_isSubtitles, 1);      
      if sSubtitleFileName &lt;&gt; &apos;&apos; then                                                     
        HmsDirectShowSetProperty(&apos;Video Decoder&apos;, IFFDShowBaseT, IDFF_subFilename, sSubtitleFileName);        
    end;        
    if not CheckResult(HmsDirectShowAddFilter(&apos;ffdshow Audio Decoder&apos;, &apos;Audio Decoder&apos;)) then 
      Exit;      
    HmsDirectShowSetProperty(&apos;Audio Decoder&apos;, IFFDShowBaseT, IDFF_ra,    1);  
    HmsDirectShowSetProperty(&apos;Audio Decoder&apos;, IFFDShowBaseT, IDFF_cook,  1);
    HmsDirectShowSetProperty(&apos;Audio Decoder&apos;, IFFDShowBaseT, IDFF_rawa,  4);
    bFFDShow := True                                                               
  end;
  if not CheckResult(HmsDirectShowConnectPin(sVideoSource, &apos;Video Decoder&apos;, sVideoPinName, &apos;&apos;, MEDIATYPE_Video), False) and bFFDShow then begin
    HmsDirectShowRemoveFilter(&apos;Video Decoder&apos;); bFFDShow := False;
    if CheckResult(HmsDirectShowAddFilter(&apos;Microsoft DTV-DVD Video Decoder&apos;, &apos;Video Decoder&apos;)) then    
      CheckResult(HmsDirectShowConnectPin(sVideoSource, &apos;Video Decoder&apos;, sVideoPinName, &apos;&apos;, MEDIATYPE_Video))
  end;
  if bFFDShow and bSubtitles then  
    HmsDirectShowConnectPin(sVideoSource, &apos;Video Decoder&apos;, sSubtitlePinName, &apos;&apos;, MEDIATYPE_Subtitle);        
  sVideoSource := &apos;Video Decoder&apos;;

  if (mpOriginalWidth = 0) or (mpOriginalHeight = 0) then
    HmsDirectShowGetMediaType(&apos;Video Decoder&apos;, PINDIR_INPUT, sVideoPinName, 
                  sMediaMajorType, sMediaSubType, mpOriginalWidth, mpOriginalHeight, iCompression);      
  if (mpOriginalWidth = 0) or (mpOriginalHeight = 0) then begin  
    mpOriginalWidth := mpWidth; mpOriginalHeight := mpHeight;    
  end;                                                           
  iWidth := mpWidth; iHeight := mpHeight;  
  if (iWidth = 0) or (iHeight = 0) then begin
    iWidth  := mpOriginalWidth;
    iHeight := mpOriginalHeight;
  end;
  if (iWidth &gt; 0) and (iHeight &gt; 0) then begin 
    if HmsTranscodingFrameParams(iWidth, iHeight, cfgTranscodingScreenFormat,
                                 iPadLeft, iPadTop, iPadRight, iPadBottom) then begin                                     
      if (iPadLeft &gt; 50) or (iPadTop &gt; 50) then      
        sResizerMediaSubType := MEDIASUBTYPE_RGB24
      else begin           
        iPadLeft := 0; iPadTop := 0;        
      end
    end else begin    
      iPadLeft := 0; iPadTop := 0;
    end;
    if (HmsDirectShowAddFilter(&apos;Resizer DMO&apos;, &apos;Resizer&apos;, &apos;{D990EE14-776C-4723-BE46-3DA2F56F10B9}&apos;) = S_OK) then begin
      if (HmsDirectShowConnectPin(sVideoSource, &apos;Resizer&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_VIDEO, sResizerMediaSubType, &apos;&apos;, mpOriginalWidth, mpOriginalHeight) = S_OK) then
        bSuccess := True
      else begin
        if (HmsDirectShowAddFilter(&apos;Color Converter DMO&apos;, &apos;Color Converter 1&apos;, &apos;{D990EE14-776C-4723-BE46-3DA2F56F10B9}&apos;) = S_OK) and
           (HmsDirectShowConnectPin(sVideoSource, &apos;Color Converter 1&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_VIDEO, &apos;&apos;, &apos;&apos;, mpOriginalWidth, mpOriginalHeight) = S_OK) then     
           sVideoSource := &apos;Color Converter 1&apos;;
        bSuccess := HmsDirectShowConnectPin(sVideoSource, &apos;Resizer&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_VIDEO, sResizerMediaSubType) = S_OK
      end;
      if bSuccess and (HmsDirectShowSetResizerProperties(&apos;Resizer&apos;, 
            cfgTranscodingScreenWidth, cfgTranscodingScreenHeight, False, iPadLeft, iPadTop, iWidth, iHeight) = S_OK) then                
        sVideoSource := &apos;Resizer&apos;        
      else                                        
        HmsDirectShowRemoveFilter(&apos;Resizer&apos;)
    end
  end;  

  if not CheckResult(HmsDirectShowAddFilter(&apos;WMVideo9 Encoder DMO&apos;, &apos;Video Encoder&apos;, &apos;{33D9A760-90C8-11d0-BD43-00A0C911CE86}&apos;)) then 
    Exit;
  
  if HmsDirectShowConnectPin(sVideoSource, &apos;Video Encoder&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Video, MEDIASUBTYPE_I420, FORMAT_VideoInfo) &lt;&gt; S_OK then begin  
    if (HmsDirectShowAddFilter(&apos;Color Converter DMO&apos;, &apos;Color Converter 2&apos;, &apos;{D990EE14-776C-4723-BE46-3DA2F56F10B9}&apos;) = S_OK) and
       (HmsDirectShowConnectPin(sVideoSource, &apos;Color Converter 2&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_VIDEO) = S_OK) then     
      sVideoSource := &apos;Color Converter 2&apos;;           
    if not CheckResult(HmsDirectShowConnectPin(sVideoSource, &apos;Video Encoder&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Video, MEDIASUBTYPE_I420, FORMAT_VideoInfo)) then
      Exit      
  end;
  if not CheckResult(HmsDirectShowInitWMEncoder(&apos;Video Encoder&apos;, 0, $33564D57)) then
    Exit;
         
  if HmsDirectShowConnectPin(sAudioSource, &apos;Audio Decoder&apos;, sAudioPinName, &apos;&apos;, MEDIATYPE_AUDIO) = S_OK then
    sAudioSource := &apos;Audio Decoder&apos;;
  
  if not CheckResult(HmsDirectShowAddFilter(&apos;WMAudio Encoder DMO&apos;, &apos;Audio Encoder&apos;, &apos;{33D9A761-90C8-11d0-BD43-00A0C911CE86}&apos;)) then 
    Exit;

  if HmsDirectShowConnectPin(sAudioSource, &apos;Audio Encoder&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_AUDIO) &lt;&gt; S_OK then begin  
    CheckResult(HmsDirectShowAddFilter(&apos;ACM Wrapper&apos;, &apos;PCM Wrapper&apos;));    
    CheckResult(HmsDirectShowConnectPin(sAudioSource, &apos;PCM Wrapper&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_AUDIO));
    CheckResult(HmsDirectShowConnectPin(&apos;PCM Wrapper&apos;, &apos;Audio Encoder&apos;, &apos;&apos;, &apos;&apos;))    
  end;  

  if not CheckResult(HmsDirectShowAddWMWriter(OutputFileName, 0, 192000, &apos;WMWriter&apos;, HmsTimeConvert(mpTimeLength))) then
    Exit;
  if not CheckResult(HmsDirectShowConnectPin(&apos;Video Encoder&apos;, &apos;WMWriter&apos;, &apos;out0&apos;, &apos;Video&apos;)) then 
    Exit;
  if not CheckResult(HmsDirectShowConnectPin(&apos;Audio Encoder&apos;, &apos;WMWriter&apos;, &apos;&apos;, &apos;Audio&apos;)) then 
    Exit;
  if CheckResult(HmsDirectShowPlay) then  
    TranscodingResult := CheckResult(HmsDirectShowWaitComplete(iEventCode));    
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - DirectShow - WMV</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>21</TranscodingProfilePriority>
      <TranscodingProfileUuid>4A5E7004917F4E67B9BF792D1ECAE6ED</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition>SameText(ExtractFileExt(mpFilePath), &apos;.wtv&apos;)</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с использованием фильтров DirectShow</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>MimeType := HmsGetMimeType(&apos;mpg&apos;)</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  MEDIASUBTYPE_MPEG1Payload = &apos;{e436eb81-524f-11ce-9F53-0020af0ba770}&apos;;
  MEDIASUBTYPE_MP2 = &apos;{e06d802b-db46-11cf-b4d1-00805f6cbbea}&apos;;
  
function CheckResult(aResult: Integer; aRaiseException: Boolean = True): Boolean;
begin
  Result := aResult = S_OK;
  if not Result and aRaiseException then
    RaiseException(Format(&apos;Error (code: %x) - %s&apos;, [aResult, SysErrorMessage(aResult)]))
end;

function GetAudioBitrate(const aAudioCodec: string; aAudioBitrate: Integer): Integer;
begin
  if MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) and (aAudioBitrate &gt; 320000) then
    Result := 320000
  else
    Result := aAudioBitrate    
end;
 
function GetAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;libfaac&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;libmp3lame&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := &apos;wmav2&apos;    
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := &apos;pcm_s16be&apos;
  else
    Result := aAudioCodec
end;

function GetAudioFormat(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;adts&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;mp3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then  
    Result := &apos;s16be&apos;
  else
    Result := aAudioCodec
end;

function SameAudioCodec(const aAudioCodec, aAudioTrack: string): Boolean;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := aAudioTrack = &apos;A_AC3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := aAudioTrack = &apos;A_AAC&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := aAudioTrack = &apos;A_MP3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := aAudioTrack = &apos;A_MP3&apos;    
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := aAudioTrack = &apos;A_LPCM&apos;
  else
    Result := False
end;

function GetAudioInputFormat(const aAudioSubType: string): string;
begin
  if SameText(aAudioSubType, MEDIASUBTYPE_WAVE_DOLBY_AC3) or 
     SameText(aAudioSubType, MEDIASUBTYPE_DOLBY_AC3) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_AAC) then
    Result := &apos;adts&apos;
  else if MatchText(aAudioSubType, [MEDIASUBTYPE_MP3, 
                    MEDIASUBTYPE_MP2, MEDIASUBTYPE_MPEG1Payload]) then
    Result := &apos;mp3&apos;
  else    
    Result := &apos;&apos;
end;

function GetAudioInputCodec(const aAudioSubType: string): string;
begin
  if SameText(aAudioSubType, MEDIASUBTYPE_WAVE_DOLBY_AC3) or 
     SameText(aAudioSubType, MEDIASUBTYPE_DOLBY_AC3) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_AAC) then
    Result := &apos;libfaad&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_MP3) then
    Result := &apos;mp3&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_MP2) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_MPEG1Payload) then
    Result := &apos;mp2&apos;    
  else
    Result := &apos;&apos;
end;

var
  sTranscoderParams, 
  sReadAudioPipeName, sWriteAudioPipeName,
  sReadVideoPipeName, sWriteVideoPipeName,
  sAudioMediaMajorType, sAudioMediaSubType, 
  sVideoMediaMajorType, sVideoMediaSubType: string;
  iAudioChannels, iAudioSampleRate, iAudioFormatTag, iEventCode,
  iVideoWidth, iVideoHeight, iVideoCompression: Integer;  
  vCurrentPosition: Variant;
begin
  TranscodingResult := False; sTranscoderParams := &apos;&apos;;
  CheckResult(HmsDirectShowAddSource(InputFileName, &apos;Source&apos;));  
  CheckResult(HmsDirectShowAddFilter(&apos;PBDA DTFilter&apos;, &apos;VideoDTFilter&apos;, &apos;{4A56AF32-C21F-11DB-96FA-005056C00008}&apos;));
  CheckResult(HmsDirectShowAddFilter(&apos;PBDA DTFilter&apos;, &apos;AudioDTFilter&apos;, &apos;{4A56AF32-C21F-11DB-96FA-005056C00008}&apos;));
  CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;VideoDTFilter&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Video));
  CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;AudioDTFilter&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Audio));
  CheckResult(HmsDirectShowGetMediaType(&apos;VideoDTFilter&apos;, PINDIR_OUTPUT, &apos;Out&apos;, 
              sVideoMediaMajorType, sVideoMediaSubType, iVideoWidth, iVideoHeight, iVideoCompression));
  CheckResult(HmsDirectShowGetMediaType(&apos;AudioDTFilter&apos;, PINDIR_OUTPUT, &apos;Out&apos;, 
              sAudioMediaMajorType, sAudioMediaSubType, iAudioChannels, iAudioSampleRate, iAudioFormatTag));
  if HmsCreateDualPipe(sReadVideoPipeName, sWriteVideoPipeName, 10000000) and 
     HmsCreateDualPipe(sReadAudioPipeName, sWriteAudioPipeName, 10000000) then begin
    CheckResult(HmsDirectShowAddDump(sWriteVideoPipeName, &apos;DumpVideo&apos;)); 
    CheckResult(HmsDirectShowAddDump(sWriteAudioPipeName, &apos;DumpAudio&apos;));
    CheckResult(HmsDirectShowConnectPin(&apos;VideoDTFilter&apos;, &apos;DumpVideo&apos;));
    CheckResult(HmsDirectShowConnectPin(&apos;AudioDTFilter&apos;, &apos;DumpAudio&apos;));
    sTranscoderParams := Format(&apos;-f mpegvideo -i "%s" -f %s -acodec %s -i "%s" -acodec %s -ab %d -f dvd "%s"&apos;, 
                [sReadVideoPipeName,
                 GetAudioInputFormat(sAudioMediaSubType),
                 GetAudioInputCodec(sAudioMediaSubType),
                 sReadAudioPipeName, 
                 GetAudioCodec(cfgTranscodingAudioCodec),
                 GetAudioBitrate(cfgTranscodingAudioCodec, cfgTranscodingAudioBitrate),
                 OutputFileName]);                   
    if CheckResult(HmsDirectShowPlay) then     
      TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscoderParams, True)        
  end
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - DirectShow - WTV (MPEG-PS)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>2</TranscodingProfilePriority>
      <TranscodingProfileUuid>bb225ec1-7eff-4f18-91e0-eaf9dde1d116</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition>TranscodingCondition := SameText(ExtractFileExt(mpFilePath), &apos;.wtv&apos;);
if TranscodingCondition then
  OutputFileName := ChangeFileExt(OutputFileName, &apos;.m2ts&apos;)</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с использованием фильтров DirectShow</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>MimeType := HmsGetMimeType(&apos;m2ts&apos;)</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  MEDIASUBTYPE_MPEG1Payload = &apos;{e436eb81-524f-11ce-9F53-0020af0ba770}&apos;;
  MEDIASUBTYPE_MP2 = &apos;{e06d802b-db46-11cf-b4d1-00805f6cbbea}&apos;;
  
function CheckResult(aResult: Integer; aRaiseException: Boolean = True): Boolean;
begin
  Result := aResult = S_OK;
  if not Result and aRaiseException then
    RaiseException(Format(&apos;Error (code: %x) - %s&apos;, [aResult, SysErrorMessage(aResult)]))
end;

function GetAudioBitrate(const aAudioCodec: string; aAudioBitrate: Integer): Integer;
begin
  if MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) and (aAudioBitrate &gt; 320000) then
    Result := 320000
  else
    Result := aAudioBitrate    
end;
 
function GetAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;libfaac&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;libmp3lame&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := &apos;wmav2&apos;    
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := &apos;pcm_s16be&apos;
  else
    Result := aAudioCodec
end;

function GetTsMuxerAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;A_AC3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;A_AAC&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;A_MP3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;A_MP3&apos;    
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := &apos;A_LPCM&apos;
  else
    Result := &apos;&apos;  
end;

function GetAudioFormat(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;adts&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;mp3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then  
    Result := &apos;s16be&apos;
  else
    Result := aAudioCodec
end;

function SameAudioCodec(const aAudioCodec, aAudioTrack: string): Boolean;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := aAudioTrack = &apos;A_AC3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := aAudioTrack = &apos;A_AAC&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := aAudioTrack = &apos;A_MP3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := aAudioTrack = &apos;A_MP3&apos;    
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := aAudioTrack = &apos;A_LPCM&apos;
  else
    Result := False
end;

function GetAudioInputFormat(const aAudioSubType: string): string;
begin
  if SameText(aAudioSubType, MEDIASUBTYPE_WAVE_DOLBY_AC3) or 
     SameText(aAudioSubType, MEDIASUBTYPE_DOLBY_AC3) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_AAC) then
    Result := &apos;adts&apos;
  else if MatchText(aAudioSubType, [MEDIASUBTYPE_MP3, 
                    MEDIASUBTYPE_MP2, MEDIASUBTYPE_MPEG1Payload]) then
    Result := &apos;mp3&apos;
  else    
    Result := &apos;&apos;
end;

function GetAudioInputCodec(const aAudioSubType: string): string;
begin
  if SameText(aAudioSubType, MEDIASUBTYPE_WAVE_DOLBY_AC3) or 
     SameText(aAudioSubType, MEDIASUBTYPE_DOLBY_AC3) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_AAC) then
    Result := &apos;libfaad&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_MP3) then
    Result := &apos;mp3&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_MP2) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_MPEG1Payload) then
    Result := &apos;mp2&apos;    
  else
    Result := &apos;&apos;
end;

var
  MetaFileLines: TStringList;
  sAudioTrack, sMetaFileName, sTranscoderParams, sVideoTrack,
  sReadAudioPipeName, sWriteAudioPipeName,
  sReadVideoPipeName, sWriteVideoPipeName,
  sAudioMediaMajorType, sAudioMediaSubType, 
  sVideoMediaMajorType, sVideoMediaSubType,
  sReadAudioTranscodedPipeName, sWriteAudioTranscodedPipeName: string; 
  iAudioChannels, iAudioSampleRate, iAudioFormatTag, iEventCode,
  iVideoWidth, iVideoHeight, iVideoCompression: Integer;  
  vCurrentPosition: Variant;
begin
  TranscodingResult := False; sTranscoderParams := &apos;&apos;;
  CheckResult(HmsDirectShowAddSource(InputFileName, &apos;Source&apos;));  
  CheckResult(HmsDirectShowAddFilter(&apos;PBDA DTFilter&apos;, &apos;VideoDTFilter&apos;, &apos;{4A56AF32-C21F-11DB-96FA-005056C00008}&apos;));
  CheckResult(HmsDirectShowAddFilter(&apos;PBDA DTFilter&apos;, &apos;AudioDTFilter&apos;, &apos;{4A56AF32-C21F-11DB-96FA-005056C00008}&apos;));
  CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;VideoDTFilter&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Video));
  CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;AudioDTFilter&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Audio));
  CheckResult(HmsDirectShowGetMediaType(&apos;VideoDTFilter&apos;, PINDIR_OUTPUT, &apos;Out&apos;, 
              sVideoMediaMajorType, sVideoMediaSubType, iVideoWidth, iVideoHeight, iVideoCompression));
  CheckResult(HmsDirectShowGetMediaType(&apos;AudioDTFilter&apos;, PINDIR_OUTPUT, &apos;Out&apos;, 
              sAudioMediaMajorType, sAudioMediaSubType, iAudioChannels, iAudioSampleRate, iAudioFormatTag));
  if SameText(sVideoMediaSubType, MEDIASUBTYPE_X264_) or 
     SameText(sVideoMediaSubType, MEDIASUBTYPE_x264) or
     SameText(sVideoMediaSubType, MEDIASUBTYPE_AVC1_) or     
     SameText(sVideoMediaSubType, MEDIASUBTYPE_avc1) or
     SameText(sVideoMediaSubType, MEDIASUBTYPE_H264_) or     
     SameText(sVideoMediaSubType, MEDIASUBTYPE_h264) then
    sVideoTrack := &apos;V_MPEG-2, "%s"&apos;  
//    sVideoTrack := &apos;V_MPEG4/ISO/AVC, "%s", level=4.1, insertSEI, contSPS&apos;
  else if SameText(sVideoMediaSubType, MEDIASUBTYPE_MPEG2) then 
    sVideoTrack := &apos;V_MPEG-2, "%s"&apos;
  else
    sVideoTrack := &apos;&apos;;
  if SameText(sAudioMediaSubType, MEDIASUBTYPE_WAVE_DOLBY_AC3) or 
     SameText(sAudioMediaSubType, MEDIASUBTYPE_DOLBY_AC3) then
    sAudioTrack := &apos;A_AC3&apos;
  else if SameText(sAudioMediaSubType, MEDIASUBTYPE_AAC) then
    sAudioTrack := &apos;A_AAC&apos;
  else if MatchText(sAudioMediaSubType, [MEDIASUBTYPE_MP3, MEDIASUBTYPE_MP2, 
                                         MEDIASUBTYPE_MPEG1Payload]) then  
    sAudioTrack := &apos;A_MP3&apos;
  else
    sAudioTrack := &apos;&apos;;
  if (sVideoTrack &lt;&gt; &apos;&apos;) and (sAudioTrack &lt;&gt; &apos;&apos;) then begin  
    if HmsCreateDualPipe(sReadVideoPipeName, sWriteVideoPipeName, 10000000) and 
       HmsCreateDualPipe(sReadAudioPipeName, sWriteAudioPipeName, 10000000) then begin
      CheckResult(HmsDirectShowAddDump(sWriteVideoPipeName, &apos;DumpVideo&apos;)); 
      CheckResult(HmsDirectShowAddDump(sWriteAudioPipeName, &apos;DumpAudio&apos;));
      CheckResult(HmsDirectShowConnectPin(&apos;VideoDTFilter&apos;, &apos;DumpVideo&apos;));
      CheckResult(HmsDirectShowConnectPin(&apos;AudioDTFilter&apos;, &apos;DumpAudio&apos;));                   
      if not SameAudioCodec(cfgTranscodingAudioCodec, sAudioTrack) and 
         HmsCreateDualPipe(sReadAudioTranscodedPipeName, sWriteAudioTranscodedPipeName, 10000000) then begin         
        sTranscoderParams := Format(&apos;-f %s -acodec %s -i "%s" -vn -acodec %s -ab %d -f %s -y "%s"&apos;, 
                  [GetAudioInputFormat(sAudioMediaSubType),
                   GetAudioInputCodec(sAudioMediaSubType),
                   sReadAudioPipeName, 
                   GetAudioCodec(cfgTranscodingAudioCodec),
                   GetAudioBitrate(cfgTranscodingAudioCodec, cfgTranscodingAudioBitrate),
                   GetAudioFormat(cfgTranscodingAudioCodec), sWriteAudioTranscodedPipeName]);
        sReadAudioPipeName := sReadAudioTranscodedPipeName;
        sAudioTrack := GetTsMuxerAudioCodec(cfgTranscodingAudioCodec);
      end;    
      sVideoTrack := sVideoTrack + &apos;, track=1&apos;;
      sAudioTrack := sAudioTrack + &apos;, "%s", track=2&apos;;
      MetaFileLines := TStringList.Create;
      try
        MetaFileLines.Add(&apos;MUXOPT --no-pcr-on-video-pid --vbr --vbv-len=500&apos;);
        MetaFileLines.Add(Format(sVideoTrack, [sReadVideoPipeName]));
        MetaFileLines.Add(Format(sAudioTrack, [sReadAudioPipeName]));
        sMetaFileName := ChangeFileExt(OutputFileName, &apos;.meta&apos;);
        MetaFileLines.SaveToFile(sMetaFileName);
        OutputFileName := ChangeFileExt(OutputFileName, &apos;.m2ts&apos;);
        if CheckResult(HmsDirectShowPlay) then begin        
          if sTranscoderParams &lt;&gt; &apos;&apos; then        
            HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscoderParams, False);
          TranscodingResult := HmsTranscodingExecute(&apos;TSMUXER&apos;, &apos;"&apos; + sMetaFileName + &apos;" "&apos; + OutputFileName + &apos;"&apos;, True);          
        end 
      finally
        MetaFileLines.Free
      end
    end
  end        
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - DirectShow - WTV (MPEG-TS)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>5</TranscodingProfilePriority>
      <TranscodingProfileUuid>a9614214-2352-4b76-b822-93cea059d2a0</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с использованием фильтров DirectShow</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  MEDIATYPE_AUXLine21Data   = &apos;{670AEA80-3A82-11d0-B79B-00AA003767A7}&apos;;
  MEDIASUBTYPE_MPEG1Payload = &apos;{e436eb81-524f-11ce-9F53-0020af0ba770}&apos;;
  MEDIASUBTYPE_MP2          = &apos;{e06d802b-db46-11cf-b4d1-00805f6cbbea}&apos;;  
  
function CheckResult(aResult: Integer; aRaiseException: Boolean = True): Boolean;
begin
  Result := aResult = S_OK;
  if not Result and aRaiseException then
    RaiseException(Format(&apos;Error (code: %x) - %s&apos;, [aResult, SysErrorMessage(aResult)]))
end;

function GetAudioBitrate(const aAudioCodec: string; aAudioBitrate: Integer): Integer;
begin
  if MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) and (aAudioBitrate &gt; 320000) then
    Result := 320000
  else
    Result := aAudioBitrate    
end;
 
function GetAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;libfaac&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;libmp3lame&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := &apos;wmav2&apos;    
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := &apos;pcm_s16be&apos;
  else
    Result := aAudioCodec
end;

function GetAudioFormat(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;adts&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;mp3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then  
    Result := &apos;s16be&apos;
  else
    Result := aAudioCodec
end;

function SameAudioCodec(const aAudioCodec, aAudioTrack: string): Boolean;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := aAudioTrack = &apos;A_AC3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := aAudioTrack = &apos;A_AAC&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := aAudioTrack = &apos;A_MP3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := aAudioTrack = &apos;A_MP3&apos;    
  else if SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := aAudioTrack = &apos;A_LPCM&apos;
  else
    Result := False
end;

function GetAudioInputFormat(const aAudioSubType: string): string;
begin
  if SameText(aAudioSubType, MEDIASUBTYPE_WAVE_DOLBY_AC3) or 
     SameText(aAudioSubType, MEDIASUBTYPE_DOLBY_AC3) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_AAC) then
    Result := &apos;adts&apos;
  else if MatchText(aAudioSubType, [MEDIASUBTYPE_MP3, 
                    MEDIASUBTYPE_MP2, MEDIASUBTYPE_MPEG1Payload]) then
    Result := &apos;mp3&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_PCM) then  
    Result := &apos;s16le&apos;
  else
    Result := &apos;&apos;
end;

function GetAudioInputCodec(const aAudioSubType: string): string;
begin
  if SameText(aAudioSubType, MEDIASUBTYPE_WAVE_DOLBY_AC3) or 
     SameText(aAudioSubType, MEDIASUBTYPE_DOLBY_AC3) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_AAC) then
    Result := &apos;libfaad&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_MP3) then
    Result := &apos;mp3&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_MP2) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_MPEG1Payload) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioSubType, MEDIASUBTYPE_PCM) then  
    Result := &apos;pcm_s16le&apos;
  else
    Result := &apos;&apos;
end;

var
  bAudioDecoder, bVideoTranscoding: Boolean;
  eFrameRate: Extended;  
  sAudioPinName, sVideoPinName, sAudioSource, sVideoSource, sAudioSubType, sVideoSubType, 
  sAudioFormat, sInputParams, sTranscoderParams, sVideoFormat, sAuxPinName, 
  sReadAudioPipeName, sWriteAudioPipeName,
  sReadVideoPipeName, sWriteVideoPipeName,
  sAudioMediaMajorType, sAudioMediaSubType, 
  sVideoMediaMajorType, sVideoMediaSubType: string;
  iAudioChannels, iAudioSampleRate, iAudioFormatTag, iEventCode,
  iVideoWidth, iVideoHeight, iVideoCompression: Integer;  
  vCurrentPosition: Variant;
begin
  TranscodingResult := False; sTranscoderParams := &apos;&apos;; 
  sAudioSubType := &apos;&apos;; sVideoSubType := &apos;&apos;; 
  CheckResult(HmsDirectShowAddSource(InputFileName, &apos;Source&apos;));
  if mpTimeStart &lt;&gt; &apos;&apos; then begin
    vCurrentPosition := HmsTimeConvert(mpTimeStart) * 10000000;
    if not CheckResult(HmsDirectShowSetPosition(&apos;Source&apos;, TIME_FORMAT_MEDIA_TIME, vCurrentPosition)) then
      Exit;
  end;                                                      
  CheckResult(HmsDirectShowAddFilter(&apos;PBDA DTFilter&apos;, &apos;VideoDTFilter&apos;, &apos;{4A56AF32-C21F-11DB-96FA-005056C00008}&apos;));
  CheckResult(HmsDirectShowAddFilter(&apos;PBDA DTFilter&apos;, &apos;AudioDTFilter&apos;, &apos;{4A56AF32-C21F-11DB-96FA-005056C00008}&apos;));  
  if (HmsDirectShowConnectPin(&apos;Source&apos;, &apos;VideoDTFilter&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Video) = S_OK) and 
     (HmsDirectShowConnectPin(&apos;Source&apos;, &apos;AudioDTFilter&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Audio) = S_OK) then begin     
    sVideoSource := &apos;VideoDTFilter&apos;;                      
    sAudioSource := &apos;AudioDTFilter&apos;;    
  end else begin  
    CheckResult(HmsDirectShowRemoveFilter(&apos;VideoDTFilter&apos;));
    CheckResult(HmsDirectShowRemoveFilter(&apos;AudioDTFilter&apos;));  
    if (HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sVideoPinName, MEDIATYPE_Video, 0) = S_OK) and
       (HmsDirectShowGetPinName(&apos;Source&apos;, PINDIR_OUTPUT, sAudioPinName, MEDIATYPE_Audio, 0) = S_OK) then begin
      sVideoSource := &apos;Source&apos;;                      
      sAudioSource := &apos;Source&apos;;
    end      
  end;  
  if (sVideoSource &lt;&gt; &apos;&apos;) and (sAudioSource &lt;&gt; &apos;&apos;) then begin  
    if not CheckResult(HmsDirectShowAddFilter(&apos;Microsoft DTV-DVD Video Decoder&apos;, &apos;Video Decoder&apos;)) then
      Exit;                                                                                                  
    if not CheckResult(HmsDirectShowAddFilter(&apos;Microsoft DTV-DVD Audio Decoder&apos;, &apos;Audio Decoder&apos;)) then
      Exit;                                     
    CheckResult(HmsDirectShowConnectPin(sVideoSource, &apos;Video Decoder&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Video));    
    CheckResult(HmsDirectShowConnectPin(sAudioSource, &apos;Audio Decoder&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Audio));
    sVideoSource := &apos;Video Decoder&apos;;
    sAudioSource := &apos;Audio Decoder&apos;;
    CheckResult(HmsDirectShowGetMediaType(sVideoSource, PINDIR_OUTPUT, &apos;&apos;, 
         sVideoMediaMajorType, sVideoMediaSubType, iVideoWidth, iVideoHeight, iVideoCompression));
    if not SameText(sVideoMediaSubType, MEDIASUBTYPE_I420) then begin
      if (mpOriginalWidth = 0) or (mpOriginalHeight = 0) then begin  
        mpOriginalWidth  := mpWidth; 
        mpOriginalHeight := mpHeight;    
      end;                                                           
      if (mpOriginalWidth = 0) or (mpOriginalHeight = 0) then begin
        mpOriginalWidth  := iVideoWidth; 
        mpOriginalHeight := iVideoHeight; 
      end;      
      if (HmsDirectShowAddFilter(&apos;Color Converter DMO&apos;, &apos;Color Converter&apos;, &apos;{D990EE14-776C-4723-BE46-3DA2F56F10B9}&apos;) = S_OK) and
         (HmsDirectShowConnectPin(sVideoSource, &apos;Color Converter&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_VIDEO, &apos;&apos;, &apos;&apos;, mpOriginalWidth, mpOriginalHeight) = S_OK) then     
        sVideoSource := &apos;Color Converter&apos;;           
    end;                       
    if HmsCreateDualPipe(sReadVideoPipeName, sWriteVideoPipeName, 10000000) and 
       HmsCreateDualPipe(sReadAudioPipeName, sWriteAudioPipeName, 10000000) then begin       
      CheckResult(HmsDirectShowAddDump(sWriteVideoPipeName, &apos;DumpVideo&apos;)); 
      CheckResult(HmsDirectShowAddDump(sWriteAudioPipeName, &apos;DumpAudio&apos;));      
      CheckResult(HmsDirectShowConnectPin(sVideoSource, &apos;DumpVideo&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Video, MEDIASUBTYPE_I420));
      CheckResult(HmsDirectShowConnectPin(sAudioSource, &apos;DumpAudio&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Audio, MEDIASUBTYPE_PCM));      
      CheckResult(HmsDirectShowGetMediaType(sAudioSource, PINDIR_OUTPUT, &apos;&apos;, 
                sAudioMediaMajorType, sAudioMediaSubType, iAudioChannels, iAudioSampleRate, iAudioFormatTag));
      sAudioFormat := Format(&apos;-f %s -acodec %s -ac %d -ar %d &apos;,
                             [GetAudioInputFormat(sAudioMediaSubType),
                              GetAudioInputCodec(sAudioMediaSubType),
                              iAudioChannels, iAudioSampleRate]);                                            
      CheckResult(HmsDirectShowGetMediaType(sVideoSource, PINDIR_OUTPUT, &apos;&apos;, 
                  sVideoMediaMajorType, sVideoMediaSubType, iVideoWidth, iVideoHeight, iVideoCompression));
      if mpFrameRate = 0 then                              
        CheckResult(HmsDirectShowGetFrameRate(sVideoSource, PINDIR_OUTPUT, &apos;&apos;, eFrameRate))        
      else                                                                           
        eFrameRate := mpFrameRate;
      sVideoFormat := Format(&apos;-f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s %dx%d -r %s &apos;, 
           [iVideoWidth, iVideoHeight, ReplaceStr(FormatFloat(&apos;0.###&apos;, eFrameRate), &apos;,&apos;, &apos;.&apos;)]);        
      sInputParams := Format(&apos;%s -i "%s" %s -i "%s"&apos;, 
                   [sVideoFormat, sReadVideoPipeName, sAudioFormat, sReadAudioPipeName]);                   
      sTranscoderParams := sInputParams + HmsTranscodingVideoParams(0, 0, 0, 0, True, False) + 
          Format(&apos; -q:v 0 -s %dx%d "%s"&apos;, [cfgTranscodingScreenWidth, cfgTranscodingScreenHeight, OutputFileName]);          
      if CheckResult(HmsDirectShowPlay) then                      
        TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscoderParams, True)
    end    
  end
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - DirectShow - WTV - FFMPEG</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>1</TranscodingProfilePriority>
      <TranscodingProfileUuid>b4832cc9-aec1-48d3-8d22-48953ac22a1c</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HDSDUMP</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>var
  i: Integer;
  sFileExt: string;
begin
  if mpFileType &lt;&gt; &apos;&apos; then begin
    if SameText(mpFileType, &apos;mpegts&apos;) then  
      sFileExt := &apos;ts&apos;    
    else if SameText(mpFileType, &apos;mpeg&apos;) then
      sFileExt := &apos;mpg&apos;      
    else if MatchText(mpFileType, [&apos;matroska&apos;, &apos;matroska,webm&apos;]) then
      sFileExt := &apos;mkv&apos;
    else if SameText(mpFileType, &apos;asf&apos;) then  
      sFileExt := &apos;wmv&apos;    
    else begin  
      i := Pos(&apos;,&apos;, mpFileType);    
      if i &gt; 0 then    
        sFileExt := Copy(mpFileType, 1, i - 1)      
      else              
        sFileExt := mpFileType      
    end;    
    MimeType := HmsGetMimeType(sFileExt)
  end                                   
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>var
  sTranscoderParams, sReadPipeName, sWritePipeName, sValue: string;  
begin
  TranscodingResult := False;
  if HmsCreateDualPipe(sReadPipeName, sWritePipeName) then begin
    HmsRetrieveProperties();
    sTranscoderParams := HmsGetItemProperty(mpiTranscodingParams);
    if sTranscoderParams &lt;&gt; &apos;&apos; then begin
      sTranscoderParams := sTranscoderParams + Format(&apos; --threads 2 --outfile "%s"&apos;, [sWritePipeName]);
      if mpTimeStart &lt;&gt; &apos;&apos; then sTranscoderParams := sTranscoderParams + &apos; --skip &apos; + mpTimeStart;
    
      if HmsTranscodingExecute(&apos;HDSDUMP&apos;, sTranscoderParams, False) then begin    
        sTranscoderParams := HmsTranscodingProfileParams(&apos;Фильмы (основной)&apos;);
        sTranscoderParams := ReplaceStr(sTranscoderParams, &apos;&lt;INPUT FILE&gt;&apos;, sReadPipeName) + &apos; "&apos; + OutputFileName + &apos;"&apos;;
        TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscoderParams);
      end  
    end  
  end
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - HDS (ремуксирование)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>27</TranscodingProfilePriority>
      <TranscodingProfileUuid>ee820b0d-eac0-42e2-9ee2-3935945180e5</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>RTMPDUMP</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для интернет медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>cfgTranscodingVideoMimeType</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>function RtmpRedirectApp(const aRtmpApp: string): string;
begin
  if SameText(aRtmpApp, &apos;asiaupdate&apos;) then  
    Result := &apos;asiaupdateedge&apos;    
  else if SameText(aRtmpApp, &apos;alfa-live&apos;) then  
    Result := &apos;alfa-live-source&apos;    
  else  
    Result := aRtmpApp
end;    

function ExecuteRtmpDump(const aRtmpServer, aRtmpFile, aPlayerUrl: string; aRtmpLive: Boolean; var aVideoUrl: string): Boolean;
var
  sRtmpApp, sRtmpFile, sRtmpParams, sRtmpReadPipeName, sRtmpWritePipeName: string;
begin
  Result := False;  
  if (aRtmpServer &lt;&gt; &apos;&apos;) and (aRtmpFile &lt;&gt; &apos;&apos;) then 
    if HmsCreateDualPipe(sRtmpReadPipeName, sRtmpWritePipeName, 1000000) then begin      
      if SameText(ExtractFileExt(aRtmpFile), &apos;.flv&apos;) then        
        sRtmpFile := ChangeFileExt(aRtmpFile, &apos;&apos;)          
      else if SameText(ExtractFileExt(aRtmpFile), &apos;.mp4&apos;) and (Pos(&apos;mp4:&apos;, aRtmpFile) = 0) then        
        sRtmpFile := &apos;mp4:&apos; + aRtmpFile      
      else               
        sRtmpFile := aRtmpFile;      
      if not HmsRegExMatch(&apos;rtmp://.*?/(.*)&apos;, aRtmpServer, sRtmpApp) then
        sRtmpApp := &apos;&apos;;  
      if sRtmpApp &lt;&gt; &apos;&apos; then                                       
        sRtmpApp := &apos; -a "&apos; + RtmpRedirectApp(sRtmpApp) + &apos;"&apos;;
      sRtmpParams := Format(&apos;-r "%s"%s -y "%s" -o "%s"&apos;, [aRtmpServer, sRtmpApp, sRtmpFile, sRtmpWritePipeName]);        
      if aRtmpLive then 
        sRtmpParams := &apos;-v &apos; + sRtmpParams;
      if aPlayerUrl &lt;&gt; &apos;&apos; then                 
        sRtmpParams := sRtmpParams + &apos; -W "&apos; + aPlayerUrl + &apos;"&apos;;
      Result := HmsTranscodingExecute(&apos;RTMPDUMP&apos;, sRtmpParams, False);
      if Result then        
        aVideoUrl := sRtmpReadPipeName
    end          
end;

function ExecuteRtmpDumpCommandLine(const aCommandLine: string; var aInputFileName: string): Boolean;
var
  i, j: Integer;                                                             
  sRtmpDumpParams, sRtmpReadPipeName, sRtmpWritePipeName: string;
begin            
  Result := False;                                 
  i := Pos(&apos;rtmpdump.exe&apos;, LowerCase(InputFileName));
  j := 0;  
  if i &gt; 0 then
    j := 12
  else begin    
    i := Pos(&apos;rtmpdump&apos;, LowerCase(InputFileName));    
    if i &gt; 0 then
      j := 8  
  end;    
  if (j &gt; 0) and HmsCreateDualPipe(sRtmpReadPipeName, sRtmpWritePipeName, 1000000) then begin
    sRtmpDumpParams := Format(&apos;%s -o "%s"&apos;, [Copy(InputFileName, i + j, Length(InputFileName)), sRtmpWritePipeName]);    
    Result := HmsTranscodingExecute(&apos;RTMPDUMP&apos;, sRtmpDumpParams, False);    
    if Result then
      aInputFileName := sRtmpReadPipeName  
  end 
end;

var 
  bSuccess: Boolean;
  sFileType, sInputFileName, sRtmpServer, sRtmpFile, sTranscodingParams: string;  
begin
  TranscodingResult := False;
  if Pos(&apos;rtmpdump&apos;, LowerCase(InputFileName)) &gt; 0 then
    bSuccess := ExecuteRtmpDumpCommandLine(InputFileName, sInputFileName)
  else if HmsRegExMatch2(&apos;(rtmp://.*?/.*?)/(.*)&apos;, InputFileName, sRtmpServer, sRtmpFile) then
    bSuccess := ExecuteRtmpDump(sRtmpServer, sRtmpFile, &apos;&apos;, True, sInputFileName)   
  else            
    bSuccess := False;    
  if bSuccess then begin
    if mpFileType = &apos;&apos; then
      mpFileType := &apos;flv&apos;;
    if mpFileType &lt;&gt; &apos;&apos; then      
      sFileType := &apos;-f "&apos; + mpFileType + &apos;" &apos;
    else                          
      sFileType := &apos;&apos;;
    mpInternetItem := False;
    sTranscodingParams := HmsTranscodingProfileParams(&apos;Фильмы (основной)&apos;);
    sTranscodingParams := ReplaceStr(sTranscodingParams, &apos;&lt;HMSMPEG&gt; &apos;, sFileType);
    sTranscodingParams := sTranscodingParams + &apos; -strict experimental "&lt;OUTPUT FILE&gt;"&apos;;
    TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, True, sInputFileName, OutputFileName)      
  end  
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - RTMPDUMP - FFMPEG</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>34</TranscodingProfilePriority>
      <TranscodingProfileUuid>122143cc-5e0f-4dc6-bd7e-08e14308d404</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>TSMUXER</TranscoderName>
      <TranscodingCondition>begin
  if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then 
    OutputFileName := ChangeFileExt(OutputFileName, &apos;.ts&apos;)        
  else                                                            
    OutputFileName := ChangeFileExt(OutputFileName, &apos;.m2ts&apos;);
  TranscodingCondition := True  
end.</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование без перекодирования видео</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>MimeType := HmsGetMimeType(&apos;m2ts&apos;)</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csAudioTranscodingParams = &apos; -acodec %s -ar %d -ab %d -ac %d&apos;;
  
function GetCodecInfo(aCodecID: Integer): string;
begin
  if aCodecID = CODEC_ID_AC3 then  
    Result := &apos;A_AC3&apos; 
  else if aCodecID = CODEC_ID_AAC then
    Result := &apos;A_AAC&apos;    
  else if aCodecID = CODEC_ID_MP3 then  
    Result := &apos;A_MP3&apos;
  else if aCodecID = CODEC_ID_MP2 then  
    Result := &apos;A_MP3&apos;
  else if aCodecID = CODEC_ID_DTS then  
    Result := &apos;A_DTS&apos;
  else if aCodecID = CODEC_ID_PCM_BLURAY then  
    Result := &apos;A_LPCM&apos;    
  else  
    Result := &apos;&apos;
end;    

procedure GetAudioTranscodingParams(const aAudioCodec: string; 
    var aCodecName, aFileFormat: string; var aCodecID, aAudioBitrate, aAudioChannels: Integer);
begin
  aAudioBitrate := cfgTranscodingAudioBitrate;
  if SameText(aAudioCodec, &apos;AAC&apos;) then begin
    aCodecName  := &apos;libfaac&apos;;    
    aFileFormat := &apos;adts&apos;;
    aCodecID    := CODEC_ID_AAC; 
  end else if SameText(aAudioCodec, &apos;MP3&apos;) then begin
    aCodecName  := &apos;libmp3lame&apos;;    
    aFileFormat := &apos;mp3&apos;;
    aCodecID    := CODEC_ID_MP3;
    if aAudioBitrate &gt; 320000 then
      aAudioBitrate := 320000;
    if aAudioChannels &gt; 2 then
      aAudioChannels := 2;      
  end else if SameText(aAudioCodec, &apos;MP2&apos;) then begin  
    aCodecName  := &apos;mp2&apos;;    
    aFileFormat := &apos;mp2&apos;;
    aCodecID    := CODEC_ID_MP2;
    if aAudioBitrate &gt; 320000 then
      aAudioBitrate := 320000;      
    if aAudioChannels &gt; 2 then
      aAudioChannels := 2;      
  end else if SameText(aAudioCodec, &apos;LPCM&apos;) then begin  
    aCodecName  := &apos;pcm_s16be&apos;;    
    aFileFormat := &apos;s16be&apos;;
    aCodecID    := CODEC_ID_PCM_BLURAY;
  end else if SameText(aAudioCodec, &apos;DCA&apos;) or SameText(aAudioCodec, &apos;DTS&apos;) then begin  
    aCodecName  := &apos;dca&apos;;    
    aFileFormat := &apos;dts&apos;;
    aCodecID    := CODEC_ID_DTS;
  end else begin
    aCodecName  := &apos;ac3&apos;;    
    aFileFormat := &apos;ac3&apos;;    
    if SameText(aAudioCodec, &apos;AC3&apos;) then
      aCodecID := CODEC_ID_AC3
    else                          
      aCodecID := CODEC_ID_NONE;
  end
end;

function GetVideoFormat(aCodecID: Integer): string;
var
  bh264_mp4toannexb: Boolean;
begin
  if aCodecID = CODEC_ID_H264 then begin 
    Result := &apos;h264&apos;;
    if VarToStr(mpCodecNalLengthSize) &lt;&gt; &apos;&apos; then      
      bh264_mp4toannexb := VarToStr(mpCodecNalLengthSize) &lt;&gt; &apos;0&apos;        
    else                         
      bh264_mp4toannexb := not MatchText(mpFileType, [&apos;mpegts&apos;, &apos;wtv&apos;, &apos;hls&apos;, &apos;applehttp&apos;], True);        
    if bh264_mp4toannexb then
      Result := Result + &apos; -vbsf h264_mp4toannexb&apos;
  end else if aCodecID = CODEC_ID_MPEG2VIDEO then  
    Result := &apos;mpeg2video&apos;    
  else   
    Result := &apos;&apos;
end;

var
  bAudioTranscoding, bCreateLPCM, bDeinterlace, bFileUnsupported, bHideDTS, 
  bPipe, bMapStreams, bSuccess, bVideoTranscoding: Boolean;
  i, iAudioBitrate, iAudioChannels, iAudioStreamNo, iAudioCodecID, iVideoCodecID,  
  iAudioCfgBitrate, iAudioCfgCodecID, iAudioDelay, iAudioSampleRate, 
  iAudioStreamID, iVideoStreamID: Integer;
  MetaFileLines: TStringList;
  sAudioInfo, sVideoInfo, sMetaFileName, sInputVideoFileName, sInputAudioFileName,
  sAudioCfgCodecInfo, sAudioCfgCodecName, sAudioCfgFileFormat, sResourcePipe,  
  sAudioTranscodingParams, sReadAudioPipeName, sWriteAudioPipeName, sFrameRate, 
  sChannelOrder, sSoxReadPipeName, sSoxWritePipeName, sSoxTranscodingParams, 
  sReadLpcmPipeName, sWriteLpcmPipeName, sReadVideoPipeName, sWriteVideoPipeName, 
  sTimeShift, sTranscodingAudioCodec, sTranscodingParams, 
  sVideoTranscodingParams: string; 
begin
  MetaFileLines := TStringList.Create;
  try                                 
    bSuccess   := True;    
    if HmsGetStreamCount = 0 then  
      HmsRetrieveProperties;
    bPipe := Pos(&apos;\\.\pipe\&apos;, InputFileName) &gt; 0;    
    bDeinterlace := SameText(HmsGetVideoSettings(vstDeinterlace), &apos;on&apos;);                                
    if bPipe then                 
      bFileUnsupported := True      
    else if (mpIsoItem or mpDvdItem or mpBdItem) and HmsCreateResourcePipe(sResourcePipe) then begin
      InputFileName := sResourcePipe;      
      bFileUnsupported := True; bPipe := True;      
    end else if mpPodcastItem then begin
      InputFileName := HmsGetItemProperty(mpiMediaResourceSource);      
      bFileUnsupported := True; bPipe := Pos(&apos;\\.\pipe\&apos;, InputFileName) &gt; 0;
    end else      
      bFileUnsupported := not MatchText(mpFileType, [&apos;mov,mp4,m4a,3gp,3g2,mj2&apos;,
             &apos;mpegts&apos;, &apos;mpeg&apos;, &apos;mp4&apos;, &apos;mov&apos;]) or (mpTimeStart &lt;&gt; &apos;&apos;);             
    bVideoTranscoding := False;      
    bAudioTranscoding := False;    
    bHideDTS    := False;    
    bCreateLPCM := False;
    sTimeShift := HmsGetVideoSettings(vstAudioDelay);
    if sTimeShift &lt;&gt; &apos;&apos; then
      sTimeShift := Format(&apos;, timeshift=%ss&apos;, [sTimeShift]);
    sInputVideoFileName := InputFileName;
    sInputAudioFileName := InputFileName;
    MetaFileLines.Add(&apos;MUXOPT --no-pcr-on-video-pid --vbr --vbv-len=1500&apos;);
    iAudioStreamNo := mpAudioStreamNo;
    if iAudioStreamNo &lt; 0 then
      iAudioStreamNo := 0;
    if (sTimeShift = &apos;&apos;) and (mpTimeStart = &apos;&apos;) then begin
      iAudioDelay := HmsGetStreamDelay(stAudio, iAudioStreamNo);      
      if iAudioDelay &lt;&gt; 0 then      
        sTimeShift := Format(&apos;, timeshift=%dms&apos;, [iAudioDelay]);
    end;        
    iVideoCodecID  := HmsGetStreamCodecID(stVideo, 0);  
    iAudioCodecID  := HmsGetStreamCodecID(stAudio, iAudioStreamNo);      
    iAudioChannels := HmsGetStreamChannels(iAudioStreamNo);    
    if iAudioChannels = 0 then iAudioChannels := 2;  
    iAudioBitrate  := HmsGetStreamBitrate(stAudio, iAudioStreamNo);
    if SameText(HmsGetVideoSettings(vstVideoOriginal), &apos;On&apos;) then    
      bVideoTranscoding := False                                       
    else if SameText(HmsGetVideoSettings(vstVideoOriginal), &apos;Off&apos;) then    
      bVideoTranscoding := True
    else begin
      bVideoTranscoding := (mpSubtitleLanguage &lt;&gt; &apos;&apos;) or (HmsGetVideoSettings(vstSubtitle) &lt;&gt; &apos;&apos;) or 
                            bDeinterlace;
      if not bVideoTranscoding and (mpFrameRate &gt; 0) and (mpFrameRate &lt; 20) then
        bVideoTranscoding := True;
    end;      
    sTranscodingParams := &apos;&apos;; sSoxTranscodingParams := &apos;&apos;;    
    if not bVideoTranscoding then begin 
      if SameText(mpVideoCodec, &apos;H264&apos;) then      
        iVideoCodecID := CODEC_ID_H264                        
      else if SameText(mpVideoCodec, &apos;MPEG2VIDEO&apos;) then
        iVideoCodecID := CODEC_ID_MPEG2VIDEO;    
      if iVideoCodecID = CODEC_ID_H264 then 
        sVideoInfo := &apos;V_MPEG4/ISO/AVC, "%s", level=4.1, insertSEI, contSPS&apos;
      else if iVideoCodecID = CODEC_ID_MPEG2VIDEO then
        sVideoInfo := &apos;V_MPEG-2, "%s"&apos;
      else if ((iVideoCodecID = CODEC_ID_VC1) or SameText(mpVideoCodec, &apos;VC1&apos;)) and not bFileUnsupported then
        sVideoInfo := &apos;V_MS/VFW/WVC1, "%s"&apos;
      else
        bVideoTranscoding := True 
    end;
    if bVideoTranscoding then begin   
      if SameText(cfgTranscodingVideoCodec, &apos;X264&apos;) then begin
        iVideoCodecID := CODEC_ID_H264;
        sVideoInfo := &apos;V_MPEG4/ISO/AVC, "%s", level=4.1, insertSEI, contSPS&apos;
      end else begin 
        iVideoCodecID := CODEC_ID_MPEG2VIDEO;
        sVideoInfo := &apos;V_MPEG-2, "%s"&apos;;        
      end
    end;                                 
    if (iAudioCodecID = CODEC_ID_DTS) and cfgTranscodingHideDTSInLPCM and 
       ((iAudioBitrate = 768000) or (iAudioBitrate = 1536000)) then begin                   
      bHideDTS := True;                  
      sAudioCfgFileFormat := &apos;dts&apos;;      
      sAudioInfo := &apos;A_LPCM&apos;
    end else begin    
      if SameText(HmsGetVideoSettings(vstAudioOriginal), &apos;On&apos;) then begin      
        bAudioTranscoding := False;        
        GetAudioTranscodingParams(mpAudioCodec, sAudioCfgCodecName,
              sAudioCfgFileFormat, iAudioCfgCodecID, iAudioCfgBitrate, iAudioChannels);
      end else begin
        GetAudioTranscodingParams(cfgTranscodingAudioCodec, sAudioCfgCodecName,
              sAudioCfgFileFormat, iAudioCfgCodecID, iAudioCfgBitrate, iAudioChannels);                     
        bAudioTranscoding := (iAudioCodecID &lt;&gt; iAudioCfgCodecID);
      end;
      if bAudioTranscoding then
        sAudioInfo := GetCodecInfo(iAudioCfgCodecID)
      else      
        sAudioInfo := GetCodecInfo(iAudioCodecID);
    end;
    if SameText(ExtractFileExt(mpFilePath), &apos;.mkv&apos;) then begin          
      iVideoStreamID := HmsGetStreamIndex(stVideo, 0) + 1;
      iAudioStreamID := HmsGetStreamIndex(stAudio, iAudioStreamNo) + 1;
    end else begin                         
      iVideoStreamID := HmsGetStreamID(stVideo, 0);  
      iAudioStreamID := HmsGetStreamID(stAudio, iAudioStreamNo);
      if SameText(mpFileType, &apos;mpeg&apos;) then begin            
        iVideoStreamID := iVideoStreamID and 255;
        iAudioStreamID := iAudioStreamID and 255;
      end
    end;                                                     
    if bVideoTranscoding or bAudioTranscoding or bHideDTS or bFileUnsupported then begin
      bMapStreams := HmsGetStreamCount &gt; 0;      
      if bVideoTranscoding or bFileUnsupported then
        bSuccess := HmsCreateDualPipe(sReadVideoPipeName, sWriteVideoPipeName, 10000000);      
      if bSuccess and (bAudioTranscoding or bFileUnsupported or bHideDTS) then                         
        bSuccess := HmsCreateDualPipe(sReadAudioPipeName, sWriteAudioPipeName, 10000000);        
      if bSuccess then begin
        if bVideoTranscoding then         
          sVideoTranscodingParams := HmsTranscodingVideoCodecParams
        else if bFileUnsupported then  
          sVideoTranscodingParams := &apos; -copyinkf -vcodec copy&apos;  //            
        else        
          sVideoTranscodingParams := &apos;&apos;;          
        if sVideoTranscodingParams &lt;&gt; &apos;&apos; then begin        
          if bMapStreams then                           
            sVideoTranscodingParams := sVideoTranscodingParams + Format(&apos; -map 0:%d&apos;, [HmsGetStreamIndex(stVideo, 0)]);
          sVideoTranscodingParams := sVideoTranscodingParams + Format(&apos; -f %s -y "%s"&apos;, [GetVideoFormat(iVideoCodecID), sWriteVideoPipeName]);
          sInputVideoFileName := sReadVideoPipeName;
          iVideoStreamID := 1;          
        end;  
        if bAudioTranscoding then begin 
          if cfgTranscodingAudioChannels &lt;&gt; 0 then          
            iAudioChannels := cfgTranscodingAudioChannels            
          else if iAudioChannels &lt; 2 then          
            iAudioChannels := 2;
          if (iAudioChannels = 6) and (mpAudioSampleRate &gt; 0) then          
            iAudioSampleRate := mpAudioSampleRate
          else              
            iAudioSampleRate := 48000;
          sAudioTranscodingParams := Format(csAudioTranscodingParams,          
               [sAudioCfgCodecName, iAudioSampleRate, iAudioCfgBitrate, iAudioChannels])
        end else if bFileUnsupported or bHideDTS then        
          sAudioTranscodingParams := &apos; -acodec copy &apos;
        else                                 
          sAudioTranscodingParams := &apos;&apos;;
        if sAudioTranscodingParams &lt;&gt; &apos;&apos; then begin
          if bMapStreams then                           
            sAudioTranscodingParams := sAudioTranscodingParams + Format(&apos; -map 0:%d&apos;, [HmsGetStreamIndex(stAudio, iAudioStreamNo)]);      
          sAudioTranscodingParams := sAudioTranscodingParams + Format(&apos; -f %s -y "%s"&apos;, [sAudioCfgFileFormat, sWriteAudioPipeName]);
          sInputAudioFileName := sReadAudioPipeName;          
          iAudioStreamID := 1;
        end;            
        if (sVideoTranscodingParams &lt;&gt; &apos;&apos;) or (sAudioTranscodingParams &lt;&gt; &apos;&apos;) then begin
           if (mpTimeStart &lt;&gt; &apos;&apos;) and not bPipe then
             sTranscodingParams := &apos;-ss &apos; + mpTimeStart + &apos; &apos;
           else
             sTranscodingParams := &apos;&apos;;                                   
           if SameText(mpFileType, &apos;mpeg&apos;) then                            
             sTranscodingParams := sTranscodingParams + &apos;-f mpeg &apos;;                                   
           sTranscodingParams := sTranscodingParams + Format(&apos;-i "%s"&apos;, [InputFileName]);
           if sVideoTranscodingParams = &apos;&apos; then
             sTranscodingParams := sTranscodingParams + &apos; -vn &apos; + sAudioTranscodingParams
           else if sAudioTranscodingParams = &apos;&apos; then                     
             sTranscodingParams := sTranscodingParams + &apos; -an &apos; + sVideoTranscodingParams
           else begin   
             if bVideoTranscoding and bAudioTranscoding and (mpTimeStart &lt;&gt; &apos;&apos;) and not bPipe then                                  
               sTranscodingParams := &apos;-async 1 &apos; + sTranscodingParams;
             sTranscodingParams := sTranscodingParams + sVideoTranscodingParams + sAudioTranscodingParams;                                   
           end;
           sTranscodingParams := sTranscodingParams + &apos; -v -1 -loglevel quiet&apos;                         
        end else        
          sTranscodingParams := &apos;&apos;;          
        if sTranscodingParams &lt;&gt; &apos;&apos; then begin        
          if SameText(sAudioInfo, &apos;A_LPCM&apos;) or bHideDTS then begin
            bSuccess := HmsCreateDualPipe(sReadLpcmPipeName, sWriteLpcmPipeName, 10000000);          
            if bSuccess then begin              
              if bHideDTS then begin
                iAudioChannels := 2;                        
                sAudioInfo := &apos;A_LPCM&apos;
              end else if iAudioChannels = 6 then begin
                sChannelOrder := &apos;1 2 3 5 6 4&apos;;                     
                if HmsCreateDualPipe(sSoxReadPipeName, sSoxWritePipeName) then begin                   
                  sSoxTranscodingParams := Format(&apos;-t raw -B -c %d -r 48000 -e signed -b 16 "%s" -t raw -B -c %d -r 48000 "%s" remix %s&apos;,
                            [iAudioChannels, sReadAudioPipeName, iAudioChannels, sSoxWritePipeName, sChannelOrder]);
                  sReadAudioPipeName := sSoxReadPipeName                      
                end
              end;           
              if bSuccess then begin
                HmsCreateLpcmFile(sReadAudioPipeName, sWriteLpcmPipeName, iAudioChannels, 48000, 16, False, bHideDTS);       
                sInputAudioFileName := sReadLpcmPipeName                    
              end
            end              
          end
        end   
      end
    end;
    if bSuccess then begin                                
      sFrameRate := HmsGetVideoSettings(vstFrameRate);
      if (sFrameRate = &apos;&apos;) and (mpFrameRate &gt; 0) then begin
        if mpFrameRate &lt; 23976 / 1000 then
          mpFrameRate := 23.976;
        sFrameRate := ReplaceStr(FormatFloat(&apos;0.000&apos;, mpFrameRate), &apos;,&apos;, &apos;.&apos;)
      end else                  
        sFrameRate := &apos;&apos;;
      if sFrameRate &lt;&gt; &apos;&apos; then
        sVideoInfo := sVideoInfo + &apos;, fps=&apos; + sFrameRate;                                                        
      sVideoInfo := sVideoInfo + &apos;, track=%d&apos;;
      sAudioInfo := sAudioInfo + &apos;, "%s", &apos; + &apos;track=%d&apos; + sTimeShift;
      MetaFileLines.Add(Format(sVideoInfo, [sInputVideoFileName, iVideoStreamID]));
      MetaFileLines.Add(Format(sAudioInfo, [sInputAudioFileName, iAudioStreamID]));
      sMetaFileName := ChangeFileExt(OutputFileName, &apos;.meta&apos;);
      MetaFileLines.SaveToFile(sMetaFileName);                      
      if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then 
        OutputFileName := ChangeFileExt(OutputFileName, &apos;.ts&apos;)        
      else                                                            
        OutputFileName := ChangeFileExt(OutputFileName, &apos;.m2ts&apos;);
      if sSoxTranscodingParams &lt;&gt; &apos;&apos; then      
        HmsTranscodingExecute(&apos;SOX&apos;, sSoxTranscodingParams, False);
      if sTranscodingParams &lt;&gt; &apos;&apos; then         
        TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, False, InputFileName);        
      TranscodingResult := HmsTranscodingExecute(&apos;TSMUXER&apos;, &apos;"&apos; + sMetaFileName + &apos;" "&apos; + OutputFileName + &apos;"&apos;, True);
    end
  finally
    MetaFileLines.Free
  end
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - TsMuxer</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>7</TranscodingProfilePriority>
      <TranscodingProfileUuid></TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>TSMUXER</TranscoderName>
      <TranscodingCondition>OutputFileName := ChangeFileExt(OutputFileName, &apos;.m2ts&apos;);
TranscodingCondition := True</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование объединенных медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>MimeType := HmsGetMimeType(&apos;m2ts&apos;)</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csFFMpegTranscodingParams = &apos;-f mpegts -i "%s" -acodec %s -ab %d -y -f %s "%s"&apos;;

function GetAudioBitrate(const aAudioCodec: string; aAudioBitrate: Integer): Integer;
begin
  if MatchText(aAudioCodec, [&apos;MP2&apos;, &apos;MP3&apos;]) and (aAudioBitrate &gt; 320000) then
    Result := 320000
  else
    Result := aAudioBitrate
end;
 
function GetAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;libfaac&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;libmp3lame&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := &apos;wmav2&apos;
  else
    Result := aAudioCodec
end;

function GetTsMuxerAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;A_AC3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;A_AAC&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;A_MP3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;A_MP3&apos;
  else
    Result := &apos;&apos;  
end;

function GetAudioFormat(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;adts&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;mp3&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else
    Result := aAudioCodec
end;

function SameAudioCodec(const aAudioCodec: string; aCodecID: Integer): Boolean;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) then
    Result := aCodecID = CODEC_ID_AC3
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := aCodecID = CODEC_ID_AAC
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := aCodecID = CODEC_ID_MP3
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := aCodecID = CODEC_ID_MP2
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := aCodecID = CODEC_ID_WMAV2
  else
    Result := False
end;
  
var
  bAudioTranscoding, bUseSubItems: Boolean;
  i, iAudioStreamNo, iAudioCodecID, iAudioStreamID, 
  iStartTime, iSubItemsCount, iTimeLength, iVideoCodecID, iVideoStreamID: Integer;
  MetaFileLines: TStringList;
  sAudioType, sFrameRate, sMetaFileName,  
  sCutStart, sInputVideoFileName, sInputAudioFileName, 
  sInputVideoFileNames, sInputAudioFileNames, sMuxOpt,  
  sFFMpegTranscodingParams, sAudioReadPipeName, sAudioWritePipeName,
  sTimeShift, sTsMuxerReadPipeName, sTsMuxerWritePipeName: string;
begin
  TranscodingResult := False;
  iStartTime := HmsTimeConvert(mpTimeStart);
  iSubItemsCount := mpSubItemsCount;
  bUseSubItems := iSubItemsCount &gt; 0;
  sTimeShift := HmsGetVideoSettings(vstAudioDelay);
  if sTimeShift &lt;&gt; &apos;&apos; then
    sTimeShift := Format(&apos;, timeshift=%ss&apos;, [sTimeShift]);
  iAudioStreamNo := mpAudioStreamNo;
  if iAudioStreamNo &lt; 0 then
    iAudioStreamNo := 0;  
  if bUseSubItems or mpDvdItem then begin
    if bUseSubItems then 
      HmsTranscodingActivateSubItem(0);
    iVideoCodecID := HmsGetStreamCodecID(stVideo, 0);
    if (iVideoCodecID = CODEC_ID_MPEG2VIDEO) or SameText(mpVideoCodec, &apos;MPEG2VIDEO&apos;) then begin
      iVideoStreamID := HmsGetStreamID(stVideo, 0);  
      iAudioStreamID := HmsGetStreamID(stAudio, iAudioStreamNo);
      if SameText(ExtractFileExt(mpFilePath), &apos;.vob&apos;) then begin
        iVideoStreamID := iVideoStreamID and 255;
        iAudioStreamID := iAudioStreamID and 255;
      end;
      sFrameRate := ReplaceStr(FormatFloat(&apos;0.000&apos;, mpFrameRate), &apos;,&apos;, &apos;.&apos;); 
      iAudioCodecID := HmsGetStreamCodecID(stAudio, iAudioStreamNo);
      if iAudioCodecID = CODEC_ID_AC3 then  
        sAudioType := &apos;A_AC3&apos;
      else if iAudioCodecID = CODEC_ID_DTS then
        sAudioType := &apos;A_DTS&apos;
      else if iAudioCodecID = CODEC_ID_MP3 then
        sAudioType := &apos;A_MP3&apos;
      else if iAudioCodecID = CODEC_ID_AAC then
        sAudioType := &apos;A_AAC&apos;
      else
        sAudioType := &apos;&apos;;
      if sAudioType &lt;&gt; &apos;&apos; then begin
        bAudioTranscoding := not SameAudioCodec(cfgTranscodingAudioCodec, iAudioCodecID);        
        sInputVideoFileNames := &apos;&apos;; 
        sInputAudioFileNames := &apos;&apos;;
        sCutStart := &apos;&apos;;
        if bUseSubItems then begin 
          for i := 0 to iSubItemsCount - 1 do begin
            HmsTranscodingActivateSubItem(i);
            if iStartTime &gt; 0 then begin
              iTimeLength := HmsTimeConvert(mpTimeLength);
              if (iTimeLength &gt; 0) and (iStartTime &gt; iTimeLength) then begin
                iStartTime := iStartTime - iTimeLength; 
                sTimeShift := &apos;&apos;; Continue
              end;
              sCutStart := Format(&apos; --cut-start=%ds&apos;, [iStartTime]);
              iStartTime := 0;
            end;
            if mpIsoItem then begin  // pipe join не работает на текущей версии TsMuxer 
              sInputVideoFileName := &apos;.vob&apos;;
              HmsCreateResourcePipe(sInputVideoFileName);
              if bAudioTranscoding then begin
                sInputAudioFileName := &apos;.vob&apos;;
                HmsCreateResourcePipe(sInputAudioFileName)
              end else
                sInputAudioFileName := sInputVideoFileName
            end else begin 
              sInputVideoFileName := mpFilePath;
              sInputAudioFileName := sInputVideoFileName;
            end;  
            if sInputVideoFileNames &lt;&gt; &apos;&apos; then
              sInputVideoFileNames := sInputVideoFileNames + &apos;+&apos;;
            sInputVideoFileNames := sInputVideoFileNames + &apos;"&apos; + sInputVideoFileName + &apos;"&apos;;  
            if sInputAudioFileNames &lt;&gt; &apos;&apos; then
              sInputAudioFileNames := sInputAudioFileNames + &apos;+&apos;;
            sInputAudioFileNames := sInputAudioFileNames + &apos;"&apos; + sInputAudioFileName + &apos;"&apos;;  
          end;
        end else begin
          sInputVideoFileNames := &apos;.vob&apos;;
          HmsCreateResourcePipe(sInputVideoFileNames);
          if bAudioTranscoding then begin
            sInputAudioFileNames := &apos;.vob&apos;;
            HmsCreateResourcePipe(sInputAudioFileNames)
          end else
            sInputAudioFileNames := sInputVideoFileNames
        end;  
        MetaFileLines := TStringList.Create;
        try
          sMuxOpt := &apos;MUXOPT --no-pcr-on-video-pid --vbr --vbv-len=500&apos;;
          if bAudioTranscoding then begin
            MetaFileLines.Add(sMuxOpt);
            MetaFileLines.Add(sAudioType + &apos;, &apos; + sInputAudioFileNames + Format(&apos;, track=%d&apos;, [iAudioStreamID]));
            sMetaFileName := ChangeFileExt(OutputFileName, &apos;.audio.meta&apos;);
            MetaFileLines.SaveToFile(sMetaFileName);
            sTsMuxerReadPipeName := &apos;.ts&apos;;
            sTsMuxerWritePipeName := &apos;.ts&apos;;
            if not HmsCreateDualPipe(sTsMuxerReadPipeName, sTsMuxerWritePipeName) then 
              Exit;
            if not HmsTranscodingExecute(&apos;TSMUXER&apos;, &apos;"&apos; + sMetaFileName + &apos;" "&apos; + sTsMuxerWritePipeName + &apos;"&apos;, False) then
              Exit;
            if not HmsCreateDualPipe(sAudioReadPipeName, sAudioWritePipeName) then 
              Exit;
            sFFMpegTranscodingParams := Format(csFFMpegTranscodingParams, 
                [sTsMuxerReadPipeName, 
                 GetAudioCodec(cfgTranscodingAudioCodec), 
                 GetAudioBitrate(cfgTranscodingAudioCodec, cfgTranscodingAudioBitrate),
                 GetAudioFormat(cfgTranscodingAudioCodec), 
                 sAudioWritePipeName]);  
            if not HmsTranscodingExecute(&apos;HMSMPEG&apos;, sFFMpegTranscodingParams, False) then 
              Exit;     
            sInputAudioFileNames := sAudioReadPipeName; iAudioStreamID := 1;
            sAudioType := GetTsMuxerAudioCodec(cfgTranscodingAudioCodec);    
          end;
          MetaFileLines.Clear;
          MetaFileLines.Add(sMuxOpt + sCutStart);
          MetaFileLines.Add(&apos;V_MPEG-2, &apos; + sInputVideoFileNames + Format(&apos;, fps=%s, track=%d&apos;, [sFrameRate, iVideoStreamID]));
          MetaFileLines.Add(sAudioType + &apos;, &apos; + sInputAudioFileNames + sTimeShift + Format(&apos;, track=%d&apos;, [iAudioStreamID]));
          sMetaFileName := ChangeFileExt(OutputFileName, &apos;.meta&apos;);
          MetaFileLines.SaveToFile(sMetaFileName);
          OutputFileName := ChangeFileExt(OutputFileName, &apos;.m2ts&apos;);
          TranscodingResult := HmsTranscodingExecute(&apos;TSMUXER&apos;, &apos;"&apos; + sMetaFileName + &apos;" "&apos; + OutputFileName + &apos;"&apos;, True);
        finally
          MetaFileLines.Free
        end
      end      
    end
  end   
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - TsMuxer - DVD</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>10</TranscodingProfilePriority>
      <TranscodingProfileUuid>8944B120E242447CB9D5BBB34B192FEB</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>var
  i: Integer;
  sFileExt: string;
begin
  if mpFileType &lt;&gt; &apos;&apos; then begin
    if SameText(mpFileType, &apos;mpegts&apos;) then  
      sFileExt := &apos;ts&apos;    
    else if SameText(mpFileType, &apos;mpeg&apos;) then
      sFileExt := &apos;mpg&apos;      
    else if MatchText(mpFileType, [&apos;matroska&apos;, &apos;matroska,webm&apos;]) then
      sFileExt := &apos;mkv&apos;
    else if SameText(mpFileType, &apos;asf&apos;) then  
      sFileExt := &apos;wmv&apos;    
    else begin  
      i := Pos(&apos;,&apos;, mpFileType);    
      if i &gt; 0 then    
        sFileExt := Copy(mpFileType, 1, i - 1)      
      else              
        sFileExt := mpFileType      
    end;    
    MimeType := HmsGetMimeType(sFileExt)
  end                                   
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>var
  sTranscoderParams, sReadPipeName, sWritePipeName, sLink: string;
begin
  TranscodingResult := False;
  if HmsCreateDualPipe(sReadPipeName, sWritePipeName) then begin
    sLink := CurrentMediaItem[mpiFilePath];
    sReadPipeName := HmsDownloadURLToPipe(sLink, &apos;Referer: http://turkcinema.tv/swf/player.swf?v=1.3.1&apos;, true);
//    HmsLogMessage(1, &apos;HmsDownloadURLToPipe: &apos;+sReadPipeName);
    sTranscoderParams := HmsTranscodingProfileParams(&apos;Фильмы (основной)&apos;);
    sTranscoderParams := ReplaceStr(sTranscoderParams, &apos;&lt;INPUT FILE&gt;&apos;, sReadPipeName) + &apos; "&apos; + OutputFileName + &apos;"&apos;;
    TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscoderParams);
  end
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - Turkcinema.tv (HMSMPEG)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>44</TranscodingProfilePriority>
      <TranscodingProfileUuid>1365310f-7d6f-48d7-9f57-f1bc6f348403</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для интернет медиа-ресурсов</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>cfgTranscodingVideoMimeType</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csVlcParams = &apos;-Idummy --language en --demuxdump-file="%s" "%s" :demux=dump&apos;;  
var
  sFileType, sReadPipeName, sWritePipeName, sTranscodingParams: string;    
begin
  TranscodingResult := False;  
  if HmsCreateDualPipe(sReadPipeName, sWritePipeName) then begin
    if HmsTranscodingExecute(&apos;VLC&apos;, Format(csVlcParams, [sWritePipeName, InputFileName]), False) then begin    
      if mpFileType &lt;&gt; &apos;&apos; then      
        sFileType := &apos;-f "&apos; + mpFileType + &apos;" &apos;
      else                          
        sFileType := &apos;&apos;;
      mpInternetItem := False;
      sTranscodingParams := HmsTranscodingProfileParams(&apos;Фильмы (основной)&apos;);
      sTranscodingParams := ReplaceStr(sTranscodingParams, &apos;&lt;HMSMPEG&gt; &apos;, sFileType);          
      sTranscodingParams := ReplaceStr(sTranscodingParams, &apos;&lt;INPUT FILE&gt;&apos;, sReadPipeName);      
      sTranscodingParams := sTranscodingParams + &apos; "&apos; + OutputFileName + &apos;"&apos;;
      TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, True)          
    end 
  end 
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - VLC - FFMPEG</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>33</TranscodingProfilePriority>
      <TranscodingProfileUuid>4b992fa8-71f7-49cf-bec4-b2f037963821</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование с использованием фильтров DirectShow</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>MimeType := HmsGetMimeType(&apos;wmv&apos;)</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>function CheckResult(aResult: Integer; aRaiseException: Boolean = True): Boolean;
begin
  Result := aResult = S_OK;
  if not Result and aRaiseException then
    RaiseException(Format(&apos;Ошибка (код: %x) - %s&apos;, [aResult, SysErrorMessage(aResult)]))
end;

var
  iAudioBitrate, iAudioCodecID, iAudioChannels, iAudioStreamNo, iEventCode, 
  iTimeLength, iVideoBitrate: Integer;
  sAudioDecoder, sAudioMediaMajorType, sAudioMediaSubType, sAudioSource: string;
  vCurrentPosition: Variant;
begin
  TranscodingResult := False;
  if mpIsoItem or mpBdItem then begin
    if not CheckResult(HmsDirectShowAddResourceSource(&apos;ResourceSource&apos;)) then  
      Exit;
    if not CheckResult(HmsDirectShowLoadFilter(&apos;Filters\MpegSplitter.ax&apos;, // MPC - Mpeg Splitter (Gabest)
                       &apos;{DC257063-045F-4BE2-BD5B-E12279C464F0}&apos;, &apos;Source&apos;)) then   
      Exit;
    if not CheckResult(HmsDirectShowConnectPin(&apos;ResourceSource&apos;, &apos;Source&apos;, &apos;Output&apos;, &apos;Input&apos;)) then 
      Exit;
  end else if SameText(mpFileType, &apos;mpegts&apos;) then begin
    if not CheckResult(HmsDirectShowLoadFilter(&apos;Filters\MpegSplitter.ax&apos;, // MPC - Mpeg Source (Gabest)
                            &apos;{1365BE7A-C86A-473C-9A41-C0A6E82C9FA3}&apos;, &apos;Source&apos;)) then
      Exit;                         
    if not CheckResult(HmsDirectShowSetFileName(&apos;Source&apos;, InputFileName)) then
      Exit;
  end else if not CheckResult(HmsDirectShowAddSource(InputFileName, &apos;Source&apos;)) then 
    Exit; 
  iAudioStreamNo := mpAudioStreamNo;
  if iAudioStreamNo = -1 then
    iAudioStreamNo := 0;
  HmsDirectShowSelectStream(&apos;Source&apos;, iAudioStreamNo, MEDIATYPE_Audio, 
                            HmsGetStreamID(stAudio, iAudioStreamNo));
  iAudioBitrate := mpAudioBitRate;
  iVideoBitrate := mpVideoBitRate;
  if iVideoBitrate = 0 then
    iVideoBitrate := Round((mpWidth * mpHeight) * 0.4 * mpFrameRate);
  if mpTimeStart &lt;&gt; &apos;&apos; then begin
    vCurrentPosition := HmsTimeConvert(mpTimeStart) * 10000000;
    if not CheckResult(HmsDirectShowSetPosition(&apos;Source&apos;, TIME_FORMAT_MEDIA_TIME, vCurrentPosition)) then
      Exit;
  end;                                         
  iAudioChannels := HmsGetStreamChannels(iAudioStreamNo);
  iAudioCodecID  := HmsGetStreamCodecID(stAudio, iAudioStreamNo);
  if (iAudioChannels &lt;= 2) and (iAudioCodecID in [CODEC_ID_WMAV1, CODEC_ID_WMAV2]) then
    sAudioSource := &apos;Source&apos;
  else begin
    sAudioSource  := &apos;Audio Encoder&apos;;
    sAudioDecoder := &apos;&apos;;
    if not CheckResult(HmsDirectShowAddFilter(&apos;WMAudio Encoder DMO&apos;, &apos;Audio Encoder&apos;, &apos;{33D9A761-90C8-11d0-BD43-00A0C911CE86}&apos;)) then 
      Exit;
    if iAudioChannels &gt; 2 then begin
      if not CheckResult(HmsDirectShowAddFilter(&apos;PCM&apos;, &apos;PCM&apos;, &apos;{33D9A761-90C8-11d0-BD43-00A0C911CE86}&apos;)) then 
        Exit;
      if HmsDirectShowConnectPin(&apos;Source&apos;, &apos;PCM&apos;, &apos;&apos;, &apos;&apos;, MEDIATYPE_Audio) = S_OK then
        sAudioDecoder := &apos;PCM&apos;
    end;
    if sAudioDecoder = &apos;&apos; then begin
      sAudioDecoder := &apos;Audio Decoder&apos;;        
      if iAudioCodecID in [CODEC_ID_WMAV1, CODEC_ID_WMAV2, CODEC_ID_WMALOSSLESS, CODEC_ID_WMAPRO] then begin
        if not CheckResult(HmsDirectShowAddFilter(&apos;WMAudio Decoder DMO&apos;, sAudioDecoder)) then 
          Exit;
      end else begin
        if not CheckResult(HmsDirectShowAddFilter(&apos;ffdshow Audio Decoder&apos;, sAudioDecoder)) then 
          Exit;
        HmsDirectShowSetProperty(sAudioDecoder, IFFDShowBaseT, 2481, 1); // Mixer
        HmsDirectShowSetProperty(sAudioDecoder, IFFDShowBaseT, 2482, 1); // stereo 
      end;
      if not CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, sAudioDecoder, &apos;&apos;, &apos;&apos;, MEDIATYPE_Audio)) then
        Exit;
      if iAudioChannels &gt; 2 then begin
        if not CheckResult(HmsDirectShowConnectPin(sAudioDecoder, &apos;PCM&apos;)) then 
          Exit;
        sAudioDecoder := &apos;PCM&apos;;
      end
    end;  
    if not CheckResult(HmsDirectShowConnectPin(sAudioDecoder, sAudioSource)) then 
      Exit;
  end;
  if not CheckResult(HmsDirectShowAddWMWriter(OutputFileName, iVideoBitrate, iAudioBitrate, &apos;WMWriter&apos;)) then
    Exit;
  if not CheckResult(HmsDirectShowConnectPin(&apos;Source&apos;, &apos;WMWriter&apos;, &apos;&apos;, &apos;Video&apos;, MEDIATYPE_Video)) then 
    Exit;
  if not CheckResult(HmsDirectShowConnectPin(sAudioSource, &apos;WMWriter&apos;, &apos;&apos;, &apos;Audio&apos;, MEDIATYPE_Audio)) then 
    Exit;
  if CheckResult(HmsDirectShowPlay) then
    TranscodingResult := CheckResult(HmsDirectShowWaitComplete(iEventCode));
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы - WMF</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>20</TranscodingProfilePriority>
      <TranscodingProfileUuid>EFC7A47A5545411DA44BABDC92B86AFB</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition>(CurrentMediaItem &lt;&gt; nil) and (CurrentMediaItem.ItemOrigin.MediaType = mtImage)</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для специальных папок (Цифровое телевидение - DVB, Музыка - Визуализация, Фото - Слайд-шоу)</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>begin
  if SameText(cfgTranscodingFileFormat, &apos;MPEG (DVD)&apos;) then
    FileExt := &apos;mpg&apos;
  else if Pos(&apos;MPEGTS&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;ts&apos;
  else if Pos(&apos;ASF&apos;, cfgTranscodingFileFormat) &gt; 0 then
    FileExt := &apos;wmv&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MP4&apos;) then
    FileExt := &apos;mp4&apos;
  else if SameText(cfgTranscodingFileFormat, &apos;MPEG1&apos;) then
    FileExt := &apos;mpeg&apos;
  else
    FileExt := &apos;&apos;;    
  if FileExt &lt;&gt; &apos;&apos; then
    MimeType := HmsGetMimeType(FileExt)    
  else            
    MimeType := &apos;&apos;
end.</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>1</TranscodingMode>
      <TranscodingParams>const
  csSingleTrackTranscodingProfile = &apos;Музыка (Объединение - Случайный порядок, Повтор)&apos;;
  
  csFFMpegParams = &apos;-s %dx%d -r %s -pix_fmt rgb32 -f rawvideo -i "%s" -f wav -i "%s" &apos; + 
                   &apos;-vcodec %s %s%s%s -r %s -acodec %s -b:a %d -ac 2 -f %s "%s"&apos;;

function GetAudioCodec(const aAudioCodec: string): string;
begin
  if (aAudioCodec = &apos;&apos;) or SameText(aAudioCodec, &apos;AC3&apos;) or SameText(aAudioCodec, &apos;LPCM&apos;) then
    Result := &apos;ac3&apos;
  else if SameText(aAudioCodec, &apos;AAC&apos;) then
    Result := &apos;libfaac&apos;
  else if SameText(aAudioCodec, &apos;MP3&apos;) then
    Result := &apos;libmp3lame&apos;
  else if SameText(aAudioCodec, &apos;MP2&apos;) then
    Result := &apos;mp2&apos;
  else if SameText(aAudioCodec, &apos;WMA&apos;) then
    Result := &apos;wmav2&apos;
  else
    Result := aAudioCodec
end;

function GetFileFormat(const aFileFormat: string): string;
begin
  if (aFileFormat = &apos;&apos;) or SameText(aFileFormat, &apos;MPEG (DVD)&apos;) then
    Result := &apos;dvd&apos;
  else if Pos(&apos;MPEGTS&apos;, aFileFormat) &gt; 0 then
    Result := &apos;mpegts&apos;
  else if Pos(&apos;ASF&apos;, aFileFormat) &gt; 0 then
    Result := &apos;asf&apos;
  else if SameText(aFileFormat, &apos;MP4&apos;) then
    Result := &apos;ipod&apos;
  else if SameText(aFileFormat, &apos;MPEG1&apos;) then
    Result := &apos;mpeg&apos;
  else
    Result := aFileFormat
end;

function GetVideoCodec(const aVideoCodec: string): string;
begin
  if (aVideoCodec = &apos;&apos;) or SameText(aVideoCodec, &apos;MPEG2&apos;) then
    Result := &apos;mpeg2video&apos;
  else if SameText(aVideoCodec, &apos;MPEG1&apos;) then
    Result := &apos;mpeg1video&apos;
  else if SameText(aVideoCodec, &apos;WMV&apos;) then
    Result := &apos;wmv2&apos;
  else if SameText(aVideoCodec, &apos;MPEG4&apos;) then
    Result := &apos;mpeg4&apos;
  else if SameText(aVideoCodec, &apos;X264&apos;) then
    Result := &apos;libx264 -x264opts "fast-pskip=1:rc-lookahead=0:aq_mode=0" -partitions none -sc_threshold 0 -trellis 0 -me_method dia -refs 1 -subq 0 -vprofile baseline -level 30 -bufsize 10000000 &apos;
  else
    Result := aVideoCodec
end;

function GetMultiThreadSupported(const aVideoCodec: string): Boolean;
begin
  Result := not MatchText(aVideoCodec, [&apos;WMV&apos;, &apos;MPEG1&apos;, &apos;FLV&apos;])
end;

var
  eFrameRate: Extended;  
  i, iChildCount, iRotate, iVideoWidth, iVideoHeight, j, iStartIndex, iWait: Integer;  
  iPriorSetBitmap: Variant;
  FolderItem, SingleTrackItem: THmsScriptMediaItem;  
  ImageBitmap: TBitmap32;  
  sAudioReadPipeName, sAudioWritePipeName,
  sTranscodingParams, sVideoReadPipeName, sVideoWritePipeName, 
  sFrameRate, sThreadParams, sVideoBitrate, sVideoMinMaxRate: string;
  VideoSlideShow: THmsVideoSlideShow;
  VisibleItemList: THmsScriptMediaItemList;  
begin
  TranscodingResult := False;     
  if CurrentMediaItem &lt;&gt; nil then begin
    FolderItem := CurrentMediaItem.ItemParent;    
    if FolderItem &lt;&gt; nil then begin    
      VisibleItemList := FolderItem.GetVisibleChildItems;      
      try
        iChildCount := VisibleItemList.Count;      
        if iChildCount &gt; 0 then begin        
          iStartIndex := VisibleItemList.IndexOf(CurrentMediaItem.ItemID);          
          if iStartIndex = -1 then iStartIndex := 0;
          sVideoMinMaxRate := &apos;&apos;;
          if cfgTranscodingVideoBitrate &gt; 0 then begin  
            sVideoBitrate := &apos;-b:v &apos; + IntToStr(cfgTranscodingVideoBitrate);
            if cfgTranscodingVideoMinMaxRate then
              sVideoMinMaxRate := Format(&apos; -minrate %d -maxrate %d -bufsize %d&apos;,
                          [cfgTranscodingVideoBitrate, cfgTranscodingVideoBitrate, 
                           HmsTranscodingBufferSize(cfgTranscodingVideoBitrate)])
          end else
            sVideoBitrate := &apos;-q:v 0&apos;;    
        
          eFrameRate := StrToFloatDef(cfgPhotoSlideShowFrameRate, 25); 
          sFrameRate := FormatFloat(&apos;0.###&apos;, eFrameRate);      
        
          iVideoWidth  := cfgPhotoSlideShowWidth; 
          iVideoHeight := cfgPhotoSlideShowHeight;

          SingleTrackItem := HmsGetSingleTrackItem(cfgPhotoSlideShowMusicFolderID);          
          if SingleTrackItem = nil then          
            SingleTrackItem := HmsGetSingleTrackItem(mfAudioAllMusicItemID);
          if (SingleTrackItem &lt;&gt; nil) and 
            HmsCreateDualPipe(sAudioReadPipeName, sAudioWritePipeName) and
            HmsPreTranscoding(SingleTrackItem, sAudioWritePipeName, csSingleTrackTranscodingProfile, &apos;audio/wav;rate=44100;channels=2;bits=16&apos;, False) then begin                         
            if HmsCreateDualPipe(sVideoReadPipeName, sVideoWritePipeName, 200000000) then begin
              VideoSlideShow := THmsVideoSlideShow.Create(sVideoWritePipeName, iVideoWidth, iVideoHeight, eFrameRate);
              try                                             
                if (cfgTranscodingThreadCount &gt; 1) and GetMultiThreadSupported(cfgTranscodingVideoCodec) then
                  sThreadParams := &apos; -threads &apos; + IntToStr(cfgTranscodingThreadCount)            
                else          
                  sThreadParams := &apos;&apos;;
                sTranscodingParams := Format(csFFMpegParams, [          
                      iVideoWidth, iVideoHeight, sFrameRate, 
                      sVideoReadPipeName, sAudioReadPipeName, 
                      GetVideoCodec(cfgTranscodingVideoCodec), sVideoBitrate, 
                      sVideoMinMaxRate, sThreadParams, sFrameRate,  
                      GetAudioCodec(cfgTranscodingAudioCodec), cfgTranscodingAudioBitrate, 
                      GetFileFormat(cfgTranscodingFileFormat), OutputFileName]);                                    
                if HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, False) then begin
                  VideoSlideShow.Start;
                  try      
                    iPriorSetBitmap := 0;                    
                    ImageBitmap := TBitmap32.Create;
                    try
                      for i := iStartIndex to iChildCount - 1 do begin                
                        if not VideoSlideShow.Started then Break;                        
                        if ImageBitmap.LoadFromFile(VisibleItemList[i].Properties[mpiFilePath]) then begin
                          iRotate := ImageBitmap.Rotate;
                          if iRotate = -1 then                        
                            iRotate := StrToIntDef(VisibleItemList[i].Properties[mpiRotate], 0);
                          case iRotate of                         
                            3: ImageBitmap.Rotate180;
                            5: ImageBitmap.Rotate270;                          
                            6: ImageBitmap.Rotate90;                          
                          end;                                 
                          if iPriorSetBitmap &gt; 0 then
                            HmsSleep(cfgPhotoSlideShowInterval * 1000 - (HmsGetTickCount - iPriorSetBitmap));                              
                          if VideoSlideShow.Started then begin                          
                            VideoSlideShow.SetBitmap(ImageBitmap, cfgPhotoSlideShowStyles);                            
                            iPriorSetBitmap := HmsGetTickCount;
                          end                                                            
                        end
                      end;                                                                                       
                      if VideoSlideShow.Started then begin
                        HmsSleep(cfgPhotoSlideShowInterval * 1000); 
                        ImageBitmap.Clear;                        
                        VideoSlideShow.SetBitmap(ImageBitmap, 119);
                        HmsSleep(cfgPhotoSlideShowInterval * 1000);
                        TranscodingResult := True                        
                      end
                    finally              
                      ImageBitmap.Free              
                    end
                  finally                            
                    VideoSlideShow.Stop
                  end
                end
              finally           
                VideoSlideShow.Free
              end
            end
          end          
        end        
      finally      
        VisibleItemList.Free
      end
    end
  end       
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фото (Слайд-шоу)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>4</TranscodingProfilePriority>
      <TranscodingProfileUuid>27ff5ce9-6a7b-4c1e-83f9-78b8e8de3012</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>HMSMPEG</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>Нет скрипта</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>2</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>-i "&lt;INPUT FILE&gt;" -f image2 -vcodec mjpeg "&lt;OUTPUT FILE&gt;"</TranscodingParams>
      <TranscodingParamsSyntaxType>Нет скрипта</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фото (основной)</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>-1</TranscodingProfilePriority>
      <TranscodingProfileUuid>7781F9B3836B4361BD7B73A1736236FC</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>IMAGEMAGICK</TranscoderName>
      <TranscodingCondition></TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder></TranscodingFolder>
      <TranscodingMediaType>2</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript>MimeType := HmsGetMimeType(&apos;jpg&apos;)</TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType>PascalScript</TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>const
  csTranscodingParams = &apos;"%s" -profile "%s" -auto-orient -filter Kaiser -resize "%dx%d&gt;" -format jpeg "&lt;OUTPUT FILE&gt;"&apos;;
begin
  TranscodingParams := Format(csTranscodingParams, [ExtractShortPathName(InputFileName), 
     ExtractFilePath(HmsTranscoderPath(&apos;IMAGEMAGICK&apos;)) + &apos;sRGB.icm&apos;, 
     cfgTranscodingScreenWidth, cfgTranscodingScreenHeight]);
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фото - ImageMagick</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>0</TranscodingProfilePriority>
      <TranscodingProfileUuid>7760417A8926459EAF9D967E24531AE5</TranscodingProfileUuid>
    </Profile>
    <Profile>
      <TranscoderName>DVPIPER</TranscoderName>
      <TranscodingCondition>mpDvbItem</TranscodingCondition>
      <TranscodingConditionSyntaxType>PascalScript</TranscodingConditionSyntaxType>
      <TranscodingComment></TranscodingComment>
      <TranscodingFolder>Транскодирование для специальных папок (Цифровое телевидение - DVB, Музыка - Визуализация, Фото - Слайд-шоу)</TranscodingFolder>
      <TranscodingMediaType>3</TranscodingMediaType>
      <TranscodingMimeType></TranscodingMimeType>
      <TranscodingMimeTypeScript></TranscodingMimeTypeScript>
      <TranscodingMimeTypeSyntaxType></TranscodingMimeTypeSyntaxType>
      <TranscodingMode>0</TranscodingMode>
      <TranscodingParams>var
  sTranscodingParams: string;
begin
  HmsSleep(500);  // Задержка на закрытие предыдущего вызова DVPiper
  sTranscodingParams := HmsTranscodingProfileParams(&apos;Фильмы (основной)&apos;) + &apos; "&lt;OUTPUT FILE&gt;"&apos;;
  sTranscodingParams := ReplaceStr(sTranscodingParams, &apos;"&lt;INPUT FILE&gt;"&apos;, &apos;-&apos;);
  sTranscodingParams := ReplaceStr(sTranscodingParams, &apos;&lt;HMSMPEG&gt;&apos;, &apos;"&apos; + HmsTranscoderPath(&apos;HMSMPEG&apos;) + &apos;"&apos;);
  sTranscodingParams := ReplaceStr(sTranscodingParams, &apos;"&apos;, &apos;""&apos;);
  TranscodingParams := mpParentPath + &apos;-command "record(rid(&apos; + mpItemID + 
                       &apos;),progid(&apos; + mpProgramID + &apos;),send(prog(&apos;#39 + sTranscodingParams + #39&apos;)))"&apos;;
end.</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Цифровое телевидение (DVB) - DVPiper</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>19</TranscodingProfilePriority>
      <TranscodingProfileUuid>34B0642A7BF446D8A86CAFBEB4012FFF</TranscodingProfileUuid>
    </Profile>
  </TranscodingProfileList>
</HmsTranscodingConfig>
