<?xml version="1.0" encoding="utf-8"?>
<HmsTranscodingConfig version="1.99.4">
  <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>
  </TranscoderList>
  <TranscodingProfileList>
    <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>32</TranscodingProfilePriority>
      <TranscodingProfileUuid>c7cead5f-1074-4d61-9b17-b89176b01197</TranscodingProfileUuid>
    </Profile>
  </TranscodingProfileList>
</HmsTranscodingConfig>
