
stream rtmp + rtmpdump + php + JW Player (re-streaming). Fix FLV fragment/part
I'm trying to re-stream for several days. So I am humbly asking for your help.
*Objetive:* re-stream last "40 seconds" or 2mb of video live stream;
*Procedure:*
<ol>
<li>Get stream whith rtmpdump, file output: stream9hd.flv</li>
<li>Create new file 9hd.flv with fragment video of stream9hd.flv every 2 seconds with php</li>
<li>Fix the flv to play. How to fix??</li>
<li>Play with JW Player</li>
</ol>
*Problem:* Fix the flv to play with JW Player.
------------------------------------------------------------
1 - stream rtmp + rtmpdump (command line in php)
------------------------------------------------------------
bc.. exec("/usr/bin/rtmpdump-2.3/rtmpdump -r ''rtmp://173.192.94.185:1935/liverepeater/'' -a ''liverepeater/'' -f ''LNX 10,2,153,1'' -W ''http://www.cdnbr.biz/swf/player.swf'' -p ''http://www.cdnbr.biz/canais/History%20HD.html'' -y ''hd'' -o ''/var/www/html/dirtitle/tvplayer/stream9hd.flv'' --live > /dev/null &",);
------------------------------------------------------------
2 - extract last 2mb of stream9hd.flv with php
------------------------------------------------------------
bc.. function ftruncate_end($filein,$fileout,$endbytes){
$fp=fopen($filein,"rb");
fseek($fp,-$endbytes);
$data=fread($fp,$endbytes);
fclose($fp);
$fp=fopen($fileout,"wb");
fwrite($fp,$data);
fclose($fp);
}
ftruncate_end("stream9hd.flv","9hd.flv",2097152);
------------------------------------------------------------
3 - fix 9hd.flv? how to fix?
------------------------------------------------------------
- You must have a way of fixing the flv in real time with PHP. FLV is being extracted from stream9hd.flv every 2 seconds.
- Flvtool2 is possible to use, but after 2 seconds have to fix again. If the fix again the JW FLV Player stop the video. So I think flvtool2 does not work in this case.
Please, any ideas?
------------------------------------------------------------
4 - Play whith JW Player. This right?
------------------------------------------------------------
bc.. <script type="text/javascript">
jwplayer("mediaplayer").setup({
autostart: true,
provider:'video',
file: "http://domain.biz/tvplayer/9hd.flv",
type: "video",
duration: 0,
flashplayer: "player.swf",
volume: 10,
width: 720,
'skin': 'bekle.zip',
events: {
onError: function(event) {
alert('erro: '+event.message);
}
}
});
</script>
thanks. sorry my english.