<?xml version="1.0" encoding="utf-8"?>
<HmsTranscodingConfig version="2.14">
  <TranscoderList>
    <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>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>Транскодирование для интернет медиа-ресурсов</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>//--------------------------------------------------------------------------------
//Профиль Фильмы (оптимальный), дополненный следующими функциями:
//1. Поддержка аппаратного декодирования H264 и HEVC средствами видеокарт NVidia (https://developer.nvidia.com/nvidia-video-codec-sdk)
//   Там же ссылка на перечень поддерживаемых семейств GPU
//2. Поддержка аппаратного декодирования H.264, MPEG2, VC1 и WMV3 средствами Direct-X Video Acceleration API (http://msdn.microsoft.com/en-us/library/windows/desktop/cc307941%28v=vs.85%29.aspx)
//3. Интеллектуальная обработка активированных для фильма субтитров. Если язык
//   аудио и субтитров совпадает, они отключаются автоматически при просмотре фильма
//4. Доработана поддержка внешней аудиодорожки
//5. Функция логгирования во внешний файл. Может помочь при отладке скрипта :)
//   Версия 1.0 20151222 by d1mas
//   Подробности установки и настройки в соответствующей ветке форума https://hms.lostcut.net
//   Добавлен вывод информации о входном кадре
//   Версия 1.0 20160724 by lidars
//--------------------------------------------------------------------------------
const
  csFFMpegVideoParams = &apos; -vcodec %s %s%s -pix_fmt yuv420p&apos;;
  csFFMpegAudioParams = &apos; -acodec %s -ab %d -ar %d -ac %d&apos;;
  csTranscodingInputFile = &apos;-i "&lt;INPUT FILE&gt;" &apos;;
  cbDebug = False;
  csPathToLog = &apos;c:\Tmp\HMSLOG.txt&apos;;
  //Активация аппаратного ускорения средствами видеокарты
  //Одновременная работа судя по тестам невозможна, поэтому при активации кодека
  //nvenc dxva отключается
  //Поддержка NVEncoder для владельцев видеокарт NVidia,
  //чтобы проверить, открыть командную строку, перейти в каталог установки HMS и
  //выполнить команду: hmsmpeg -codecs | findstr "264"
  //в результатах должно быть что-то типа: encoders: nvenc libx264 libx264rgb
  cbNVENC = False;
  //Поддержка DirectX аппаратного ускорения
  //чтобы проверить, открыть командную строку, перейти в каталог установки HMS и
  //выполнить команду: hmsmpeg -hwaccels
  //в результатах должно быть что-то типа: dxva
//  cbDXACCEL = False;
  cbDXACCEL = True;
var
  bDXACCEL: boolean;
  smpWidth,smpHeight: string;
  
procedure DoDebug(const strToLog: string);
var 
  sCurrLog: String;
begin
  if cbDebug then
  begin
    if FileExists(csPathToLog) then sCurrLog := HmsStringFromFile(csPathToLog); 
    HmsStringToFile(sCurrLog+#13+VarToStr(Now)+&apos; &apos;+strToLog, csPathToLog);
  end;
end;
  
// Чекает, есть ли внешняя аудиодорожка
//function IsExtAudioTrack(const extAudioStream: string): string;
//begin
//  Result  := &apos;&apos;;
//  if (extAudioStream &lt;&gt; &apos;&apos;) then
//    Result := Format(&apos;-i "%s" &apos;, [extAudioStream])
//end;

// Чекает совпадает ли язык сибтитров и звуковой дорожки, если они есть и настроены в карточке фильма
function SubsNeeded(): boolean;
var
  sAudioLang, sSubLang: string;
begin
  Result := True;
  sAudioLang := HmsGetStreamLanguage(stAudio, mpAudioStreamNo);
  HmsRegExMatch(&apos;(.*?)\[&apos;,mpSubtitleLanguage,sSubLang);
  // Сравнить количество символов в коде языка субтитров и звук дорожки, привести их к общему знаменателю
  // И уже затем сравнить коды (если в одном ru, а в другом rus
  // работать только, если указаны языки обоих потоков
  if (sAudioLang &lt;&gt; &apos;&apos;) and (sSubLang &lt;&gt; &apos;&apos;) then
  begin
    if (length(sAudioLang)) &gt; ((Length(sSubLang)) )then
     sSubLang := HmsLanguageCode3(sSubLang)
    else if Length(sAudioLang) &lt; (Length(sSubLang) )then
      sAudioLang := HmsLanguageCode3(sAudioLang);
   if SameText(sAudioLang, sSubLang) then Result := False;
  end;
end;

function GetInputParameters: string;
var
  bTwoInputFile: Boolean;
  iAudioDelay, iStartTime: Integer;
  sAudioFileName, sVideoFileName,
  sDelayOffset, sProbeParameters, sStartOffset: string;
begin
  
  if bDXACCEL then
    sProbeParameters := &apos;-hwaccel dxva2 &apos; + HmsTranscodingProbeParams
  else
    sProbeParameters := HmsTranscodingProbeParams;
  
  sVideoFileName := HmsGetStreamParam(stVideo, 0{mpVideoStreamNo}, siStreamFilePath);
  sAudioFileName := HmsGetStreamParam(stAudio, mpAudioStreamNo, siStreamFilePath);
  
  iStartTime := HmsTimeConvert(mpTimeStart);
  iAudioDelay := StrToIntDef(HmsGetVideoSettings(vstAudioDelay), 0);    

  bTwoInputFile := (iAudioDelay &lt;&gt; 0) or (sAudioFileName &lt;&gt; sVideoFileName);
  
  if mpFileType &lt;&gt; &apos;&apos; then
    Result := &apos;-f "&apos; + mpFileType + &apos;" &apos;
  else
    Result := &apos;&apos;;  

  if sVideoFileName &lt;&gt; &apos;&apos; then
    Result := Result + Format(&apos;-i "%s" &apos;, [sVideoFileName])
  else if (InputFileName &lt;&gt; &apos;&apos;) and (InputFileName[1] = &apos;-&apos;) then                         
    Result := Result + InputFileName + &apos; &apos;
  else
    Result := Result + csTranscodingInputFile;
    
  if (iStartTime &gt; 0) or (iAudioDelay &lt;&gt; 0) or bTwoInputFile then begin
    if sAudioFileName &lt;&gt; &apos;&apos; then
      sAudioFileName := Format(&apos;-i "%s" &apos;, [sAudioFileName])
    else if (InputFileName &lt;&gt; &apos;&apos;) and (InputFileName[1] = &apos;-&apos;) then                         
      sAudioFileName := InputFileName + &apos; &apos;
    else  
      sAudioFileName := csTranscodingInputFile;
    if iStartTime &gt; 0 then
      sStartOffset := &apos;-ss &apos; + HmsTimeFormat(iStartTime) + &apos; &apos;
    else
      sStartOffset := &apos;&apos;;
    if iAudioDelay &lt;&gt; 0 then
      sDelayOffset := &apos;-ss &apos; + HmsTimeFormat(iStartTime + Trunc(Abs(iAudioDelay))) + &apos; &apos;
    else
      sDelayOffset := &apos;&apos;;
    if iAudioDelay &gt; 0 then
      Result := sProbeParameters + sStartOffset + Result + sProbeParameters + sDelayOffset + sAudioFileName
    else if iAudioDelay &lt; 0 then
      Result := sProbeParameters + sDelayOffset + Result + sProbeParameters + sStartOffset + sAudioFileName
    else if bTwoInputFile then
      Result := sProbeParameters + sStartOffset + Result + sProbeParameters + sStartOffset + sAudioFileName
    else
      Result := sProbeParameters + sStartOffset + Result
  end else
    Result := sProbeParameters + Result
end;

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;) and cbNVENC then
  begin
    Result := &apos;nvenc_h264 -sc_threshold 0 -trellis 0 -me_method dia -refs 1 -subq 0 -vprofile baseline -bufsize 10000000 &apos;;
    bDXACCEL := False;
  end
  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;
    
  if mpHeight=0 then HmsRetrieveProperties; // By WendyH
   
  smpWidth  := IntToStr(mpWidth);
  smpHeight := IntToStr(mpHeight);
    
  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;
  bDXACCEL := cbDXACCEL;
  sInputVideoFileName := InputFileName;
  sInputAudioFileName := InputFileName;
  iAudioStreamNo := mpAudioStreamNo;
  if iAudioStreamNo &lt; 0 then
    iAudioStreamNo := 0;      
  // Добавлено
  //sInputAudioFileName := HmsGetStreamParam(&apos;A&apos;,iAudioStreamNo,siStreamFilePath);
  //
  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; + ReplaceStr(cfgTranscodingAspectRatio,&apos;:&apos;,&apos;/&apos;));
      sVideoTranscodingParams := sVideoTranscodingParams + Format(&apos; -vf "%s"&apos;, [sFilterParams]);
      // Добавлено условие на проверку. Нужны ли субтитры.
      if SubsNeeded() then
         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 := GetInputParameters;
  sTranscodingParams := sTranscodingParams + &apos;-f &apos; + GetFileFormat(cfgTranscodingFileFormat);
  sTranscodingParams := sTranscodingParams + sVideoTranscodingParams + sAudioTranscodingParams;                                   
  if bMapStreams then                           
    sTranscodingParams := sTranscodingParams + HmsTranscodingMapParams(iAudioStreamNo);
//   DoDebug(sTranscodingParams);
  sTranscodingParams := sTranscodingParams + &apos; "&lt;OUTPUT FILE&gt;"&apos;;  
//  TranscodingParams := sTranscodingParams;
//  TranscodingResult := HmsTranscodingExecute(&apos;HMSMPEG&apos;, sTranscodingParams, True, InputFileName, OutputFileName)
  
if mpHeight=0 then HmsRetrieveProperties; 				// By WendyH 

if (mpWidth &lt; 960 ) and (mpHeight &lt; 360 ) then  			// 240p

TranscodingResult := HmsTranscodingExecute(&apos;FFMPEG&apos;, &apos;-i "&apos; + InputFileName + &apos;" -c:v mpeg4 -b:v 20M -vf drawtext=fontfile=ARIALUNI.TTF:text=240p-&apos; + smpWidth + &apos;x&apos; + smpHeight + &apos;:fontcolor=white:fontsize=30:x=110:y=65 -q:v 1  "&apos; + OutputFileName + &apos;"&apos;, True)

else if (mpWidth &lt; 960) and (mpHeight &lt; 480) then 			// 360p

TranscodingResult := HmsTranscodingExecute(&apos;FFMPEG&apos;, &apos;-i "&apos; + InputFileName + &apos;" -c:v mpeg4 -b:v 20M -vf drawtext=fontfile=ARIALUNI.TTF:text=360p-&apos; + smpWidth + &apos;x&apos; + smpHeight + &apos;:fontcolor=white:fontsize=30:x=110:y=65 "&apos; + OutputFileName + &apos;"&apos;, True)

else if (mpWidth &lt; 960) and (mpHeight &lt; 544) then 			// 480p

TranscodingResult := HmsTranscodingExecute(&apos;FFMPEG&apos;, &apos;-i "&apos; + InputFileName + &apos;" -c:v mpeg4 -b:v 20M -vf drawtext=fontfile=ARIALUNI.TTF:text=480p-&apos; + smpWidth + &apos;x&apos; + smpHeight + &apos;:fontcolor=white:fontsize=30:x=110:y=65 "&apos; + OutputFileName + &apos;"&apos;, True)

else if (mpWidth &lt; 1057) and (mpHeight &gt; 543) and (mpHeight &lt; 720) then // 576p

TranscodingResult := HmsTranscodingExecute(&apos;FFMPEG&apos;, &apos;-i "&apos; + InputFileName + &apos;" -c:v mpeg4 -b:v 20M -vf drawtext=fontfile=ARIALUNI.TTF:text=576p-&apos; + smpWidth + &apos;x&apos; + smpHeight + &apos;:fontcolor=white:fontsize=30:x=110:y=65 "&apos; + OutputFileName + &apos;"&apos;, True)

else if (mpWidth &gt; 1056 ) and (mpWidth &lt; 1280) and (mpHeight &gt; 543) then // 576p+

TranscodingResult := HmsTranscodingExecute(&apos;FFMPEG&apos;, &apos;-i "&apos; + InputFileName + &apos;" -c:v mpeg4 -b:v 20M -vf drawtext=fontfile=ARIALUNI.TTF:text=576p+&apos; + smpWidth + &apos;x&apos; + smpHeight + &apos;:fontcolor=white:fontsize=30:x=110:y=65 "&apos; + OutputFileName + &apos;"&apos;, True)

else if (mpWidth &gt; 1279 ) and (mpWidth &lt; 1440 ) then 			// 720p

TranscodingResult := HmsTranscodingExecute(&apos;FFMPEG&apos;, &apos;-i "&apos; + InputFileName + &apos;" -c:v mpeg4 -b:v 20M -vf drawtext=fontfile=ARIALUNI.TTF:text=720p-&apos; + smpWidth + &apos;x&apos; + smpHeight + &apos;:fontcolor=white:fontsize=30:x=110:y=65 "&apos; + OutputFileName + &apos;"&apos;, True)

else if (mpWidth &gt; 1441 ) and (mpHeight &gt; 721 ) then 			// Full HD 

TranscodingResult := HmsTranscodingExecute(&apos;FFMPEG&apos;, &apos;-i "&apos; + InputFileName + &apos;" -c:v mpeg4 -b:v 20M -vf drawtext=fontfile=ARIALUNI.TTF:text=1080p-&apos; + smpWidth + &apos;x&apos; + smpHeight + &apos;:fontcolor=white:fontsize=30:x=110:y=65 "&apos; + OutputFileName + &apos;"&apos;, True)

;
                       
end.
</TranscodingParams>
      <TranscodingParamsSyntaxType>PascalScript</TranscodingParamsSyntaxType>
      <TranscodingProfile>Фильмы (оптимальный) - Info</TranscodingProfile>
      <TranscodingProfileActive>-1</TranscodingProfileActive>
      <TranscodingProfilePriority>15</TranscodingProfilePriority>
      <TranscodingProfileUuid>b280507e-a68b-4277-a0dc-54a57b2f964a</TranscodingProfileUuid>
    </Profile>
  </TranscodingProfileList>
</HmsTranscodingConfig>
