Wild Media Server (WMS) Setup for Chaneru 2.0 part 1

Release 2 with UPnP discovery

Wild Media Server (WMS) Setup for Chaneru 2.0 part 1

Postby louism » Thu Oct 17, 2013 1:16 pm

I have been working with WMS technical support team to craft a solution to get HLS support for chaneru on the Roku with Wild Media Server (WMS)

The solution is in 7 steps. if you are familiar with WMS this should take you no more than 5-10 minutes to get this working.
This is part 1 of 2 messages

1.Create the folder ?:\Program Files (x86)\Wild Media Server\Presentation\HLS - setup write access to ?:\Program Files (x86)\Wild Media Server\Presentation\HLS for Users.
if you are using 32bit system omit the (X86) letters.

2. Settings - Transcoder - Profiles - "Transcoding profiles list" - Add
Name: Movies - Roku (1)
Mime type: application/x-mpegURL
Execute mode: Transcoding
Language: PascalScript

Transcoding parameters:

--> N.N.N.N must be replaced with server ip-address

Code: Select all
const
  ciInterval = 10;
  csServerAddress = 'N.N.N.N:45357';
 
procedure StartTranscoding(aItemID, aOutputFileName, aTimerID: string);
begin
  WmsExecuteByTimer(aTimerID, '', 0);
  WmsPreTranscodingEx([aItemID], aOutputFileName, 'Movies - Roku (2)', '', True)   
end;
   
var
  M3U8Lines: TStringList; 
  i, j, iLength, iTimeLength: Integer; 
  sBasePath, sItemID, sOutputFileName, sTimerID: string; 
begin
  if CurrentMediaItem <> nil then begin 
    sItemID := CurrentMediaItem.ItemID;   
    iTimeLength := WmsTimeConvert(mpTimeLength);
    M3U8Lines := TStringList.Create; 
    try       
      M3U8Lines.Add('#EXTM3U');     
      M3U8Lines.Add('#EXT-X-PLAYLIST-TYPE:EVENT');
      M3U8Lines.Add('#EXT-X-VERSION:3');
      M3U8Lines.Add(Format('#EXT-X-TARGETDURATION:%d', [ciInterval]));
      M3U8Lines.Add('#EXT-X-MEDIA-SEQUENCE:0');
      j := iTimeLength div ciInterval;     
      sBasePath := Format('http://%s/Presentation/HLS/%s/%s', [csServerAddress, sItemID, sItemID]);
      for i := 0 to j do begin     
        M3U8Lines.Add(Format('#EXTINF:%d,', [ciInterval]));
        M3U8Lines.Add(Format('%s%d.ts', [sBasePath, i]));     
      end;                                             
      M3U8Lines.Add('#EXT-X-ENDLIST');
      OutputFileName := ChangeFileExt(OutputFileName, '.m3u8');
      iLength := Length(M3U8Lines.Text) + 2;       
      if iLength < 1024 then                           
        M3U8Lines.Add(Replicate(#13#10, (1025 - iLength) div 2));       
      sTimerID := 'Roku_' + WmsGenerateUUID;           
      sOutputFileName := IncludeTrailingBackslash(WmsTranscodingTempDirectory) +
                         WmsGenerateUuid + '.m3u8';
      WmsExecuteByTimer(sTimerID, Format('StartTranscoding(%s, %s, %s)',
                                          [#39 + sItemID + #39,
                                           #39 + sOutputFileName + #39,         
                                           #39 + sTimerID + #39]), 1);                                           
      WmsSleep(3000);
      M3U8Lines.SaveToFile(OutputFileName)           
    finally   
      M3U8Lines.Free
    end     
  end;   
  TranscodingResult := True
end.


Terms of use:
Language: PascalScript
Code: Select all
begin
  OutputFileName := ChangeFileExt(OutputFileName, '.m3u8');   
  TranscodingCondition := True
end.


Click Ok

3. Settings - Transcoder - Profiles - "Transcoding profiles list" - Add
Name: Movies - Roku (2)
Execute mode: Transcoding
Language: PascalScript

Transcoding parameters:
Code: Select all
const
  ciInterval = 10;
  csHlsTranscodingParameters = '-re -f mpegts -i "%s" -hls_time %d -f hls -vcodec copy -acodec copy "%s"';
 
var
  bTranscodingStarted: Boolean;                         
  sItemID, sOutputFileName, sReadPipeName, sResourcePipe, sTranscodingParams, sWritePipeName: string;
begin
  if CurrentMediaItem <> nil then begin 
    sItemID := CurrentMediaItem.ItemID;
    sOutputFileName := IncludeTrailingBackslash(ProgramPath) + 'Presentation\HLS\' + sItemID;   
    if ForceDirectories(sOutputFileName) then begin                                   
      sOutputFileName := sOutputFileName + '\' + sItemID;
      bTranscodingStarted := FileExists(sOutputFileName + '0.ts');
      if not bTranscodingStarted then begin
        sTranscodingParams := WmsTranscodingProfileParams('Movies (Primary)');
        sTranscodingParams := ReplaceStr(sTranscodingParams, '<WMSMPEG> ', '');
        sTranscodingParams := sTranscodingParams + ' -strict experimental "<OUTPUT FILE>"';   
        sReadPipeName := '.ts'; sWritePipeName := '.ts';
        if Pos('\\.\pipe\', InputFileName) > 0 then                 
                 
        else if (mpIsoItem or mpDvdItem or mpBdItem) and WmsCreateResourcePipe(sResourcePipe) then
          InputFileName := sResourcePipe     
        else if mpPodcastItem then
          InputFileName := WmsGetItemProperty(mpiMediaResourceSource);   
        if WmsCreateDualPipe(sReadPipeName, sWritePipeName, 10000000) then                 
          if WmsTranscodingExecute('WMSMPEG', sTranscodingParams, False, InputFileName, sWritePipeName) then     
            WmsTranscodingExecute('WMSMPEG', Format(csHlsTranscodingParameters, [sReadPipeName, ciInterval, sOutputFileName + '.m3u8']), True)
      end             
    end
  end;   
  TranscodingResult := True
end.


Click OK and OK again

4. Pay attention to device (it's settings for "Movies - Roku (2)"): Settings - Devices - Device type by default - Settings - Transcoder - "Codecs, frame"

File format: MPEGTS
Video codec: X264
Audio codec: AAC
Channel quantity: 2

5. Settings - Devices - choose a device - Settings - Transcoder - "Files, subtitles" - Movies

Transcoding profile: Movies - Roku (1)
File size for transfer start: 1
Max file size: -1 (in my case)

6. Settings - Devices - choose a device - Settings - "File types" - Add

File extension: m3u8
Mime type: application/x-mpegURL

part 2 will consist at cleaning up the temporary HLS folder

Thanks

Louis
louism
 
Posts: 4
Joined: Fri Oct 11, 2013 8:54 am

Re: Wild Media Server (WMS) Setup for Chaneru 2.0 part 2

Postby louism » Thu Oct 17, 2013 1:17 pm

7- Settings - Devices - choose a device - Settings-
under Support for files without transcoding -> movies -> m3u8,m4v,mkv,mp4

Since each access to TS file or podcast will generate tons of small ts files you will need a mechanism for cleanup

Settings - Processing - Add

Name: Clean HLS directory
Mark "Button on the main form"
Script

Code: Select all
var
  fso: Variant; 
begin
  fso := CreateOleObject('Scripting.FileSystemObject'); 
  fso.DeleteFolder('C:\Program Files (x86)\Wild Media Server\Presentation\HLS\*'); 
end.


In my case I am running it on a schedule every day at midnight.

Thansk

Louis
louism
 
Posts: 4
Joined: Fri Oct 11, 2013 8:54 am


Return to Chaneru 2.0

Who is online

Users browsing this forum: No registered users and 1 guest

cron