Page 3 of 4

Re: Problem with UMSP flv streaming (blank picture on playba

PostPosted: Thu Oct 04, 2012 11:19 am
by aenbacka
Hi,

My proxy code is as follows:

Code: Select all
<?php
$pageURL = urldecode($_GET['pageURL']); //video page URL
$format = 'x-flv';

  $cmd = "/usr/local/bin/yle-dl $pageURL -o - | cat -";
  header('Content-Type: video/'.$format.'');
  header('Content-Length: 1073741823'); //some sufficient content length
  header('Content-Disposition: attachment; filename="video.flv"');
  header("Accept-Ranges: bytes");
  header("Connection: close");   
  set_time_limit(0);
  passthru($cmd);
?>


I need to try with ffmpeg again, got the same header response error message from MediaLogic as before removing the space after php tag.

Re: Problem with UMSP flv streaming (blank picture on playba

PostPosted: Fri Oct 05, 2012 3:11 am
by aenbacka
It is also strange, by processing the flv output from rtmpdump with ffmpeg:

Code: Select all
ffmpeg -i - -vcodec copy -acodec copy -f flv pipe:1 | cat


I get no output at all (but by processing the raw flv output directly from rtmpdump I get picture and sound, but out of sync). Any ideas what could be the reason for this?

The flv output produced by ffmpeg with the above command is of some reason non-seekable (tested with VLC), however the original flv is seekable (from rtmpdump).

Re: Problem with UMSP flv streaming (blank picture on playba

PostPosted: Fri Oct 05, 2012 5:31 am
by Gui
Try this:

Code: Select all
<?php
$pageURL = urldecode($_GET['pageURL']); //video page URL
$format = 'x-flv';

  header('Content-Type: video/'.$format.'');
  header('Content-Length: 1073741823'); //some sufficient content length
  header('Content-Disposition: attachment; filename="video.flv"');
  header("Accept-Ranges: bytes");
  header("Connection: close");
  $cmd = "ffmpeg -y -i '$pageURL' -vcodec copy -acodec copy -f flv pipe:1"; 
  set_time_limit(0);
  passthru($cmd);
?>

Re: Problem with UMSP flv streaming (blank picture on playba

PostPosted: Fri Oct 05, 2012 6:03 am
by aenbacka
Thanks for the post,

However $pageURL contains the url of a web page from which a specialised script (i.e., yle-dl $pageURL -o -) needs to extract the parameters that will be passed to rtmpdump in order to produce the flv output. Ffmpeg will need to take the output produced by rtmpdump .

Re: Problem with UMSP flv streaming (blank picture on playba

PostPosted: Fri Oct 05, 2012 9:05 am
by Gui
ok then you could try the same with the output produced by rtmpdump.

Re: Problem with UMSP flv streaming (blank picture on playba

PostPosted: Fri Oct 05, 2012 10:42 am
by aenbacka
Thanks a lot for your suggestion, now I get both audio and video output in sync! :) Seems to work fine now when i removed the cat stage.
I have noticed that after playing back a few clips (having interrupted the process in the middle) playback seems to systematically fail. I get the following MediaLogic debug output:

Code: Select all
while
timeout
while
timeout
while
timeout
while
timeout
while
timeout
while
timeout
while
timeout
while
timeout
while
NW_Http_ParseResponse 266 http get header timeout
MA_GetServerProperty 714 replace method get with head
(MPAuxiliary.c , 927 )server_type = 0
[ERR:MediaPlayer:MA_HttpPrepareProc:933]get server property failed
[ERR:MediaPlayer:mp_open:376] errNo=-8
SMD_SendMallocCommand enter
SMD_SendCommand 8
SMD_GetCommand 4 8
[ERR:MediaPlayer:mp_open:514]Leave MP_CreateInstance with error
SMD_SendMallocCommand enter
SMD_SendCommand 8
SMD_GetCommand 4 8


(the "while..timeout" part multiple times). Before this playback initiation has worked several times. Could this be due to me interrupting (stopping) the stream before it has processed it completely?

Re: Problem with UMSP flv streaming (blank picture on playba

PostPosted: Fri Oct 05, 2012 10:54 am
by Martor
Hi aenbacka,

i see in your log something with HEAD not GET, try this at the beginning of your proxy PHP:

Code: Select all
if ( $_SERVER['REQUEST_METHOD'] == 'HEAD' )
   {   
      header('HTTP/1.0 200 OK');
      header('Connection: Close');
      header('Content-Type: video/x-flv');
      return;
   }


I will try what Gui suggested, my still passing only 30seconds of the stream :(

Re: Problem with UMSP flv streaming (blank picture on playba

PostPosted: Fri Oct 05, 2012 11:10 am
by Gui
Here is an working flv proxy example you may change and adapt to your projects.

Code: Select all
<?php


if ( $_SERVER['REQUEST_METHOD'] == 'HEAD' )
{
   header('HTTP/1.1 200 OK');
   header('Host: media32.justin.tv');
   header('User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0');
   header('Connection: keep-alive');
   header('Cookie: language=en');
   header('Range: bytes=162-');
   header('Content-Type: video/x-flv');
   return;
}

$rawURL = $_GET['itemurl'];

   doTheMiracle($rawURL);


function doTheMiracle($prmUrl)
{
   header('Content-type: video/x-flv');
   header('Content-Disposition: attachment; filename="wdlxtv.flv"');
   if(isset ($_SERVER['CONTENT_LENGTH']))
            header("Content-Length: {$_SERVER['CONTENT_LENGTH']}");
         else
            header('Content-Length: 1073741823');
         // jump to the specific range if the MediaPlayer specifies it (when navigating)
         if(isset ($_SERVER['HTTP_RANGE']))
            header("Range: {$_SERVER['HTTP_RANGE']}");
   header('Cache-control: no-cache');
   header("Accept-Ranges: bytes");
   header('Connection: keep-alive');
   $cmd = "ffmpeg -y -i '$prmUrl' -vcodec copy -acodec copy -f flv pipe:1";
   set_time_limit(0);
   passthru($cmd);
}


?>


Good luck.

Re: Problem with UMSP flv streaming (blank picture on playba

PostPosted: Fri Oct 05, 2012 11:28 am
by Martor
Thanks Gui, I will give it a try now ;)
Keep you updated.

Martin

Re: Problem with UMSP flv streaming (blank picture on playba

PostPosted: Fri Oct 05, 2012 11:49 am
by aenbacka
Thank you Gui and Martor for the examples, very much appreciated. I will make change to my proxy concerning handling of the HEAD request.