Audio/video stream recording forums (http://stream-recorder.com/forum/index.php)
-   Video stream recording (http://stream-recorder.com/forum/forumdisplay.php?f=4)
-   -  

How to auto extract m3u8 and auto start recording

(http://stream-recorder.com/forum/showthread.php?t=20303)

sonnvl 09-29-2015 08:09 PM

How to auto extract m3u8 and auto start recording


 
Is there any tool that auto extract m3u8 from a site and auto start recording that stream.
(Similar Jaksta recorder)

Eg. All below links contain m3u8 with variant token and I want to auto extract m3u8 list and auto start recording (using livestreamer of ffmpeg....)
http://tv.101vn.com/ok/vtc/youtv_2.php
http://viewtv.vn/live

Because I want to make task schedule to record at given time while I'm not online.

Thanks !

biezom 09-29-2015 09:12 PM

Re: How to auto extract m3u8 and auto start recording


 
Quote:

Originally Posted by sonnvl (Post 80210)
Is there any tool that auto extract m3u8 from a site and auto start recording that stream.
(Similar Jaksta recorder)

Eg. All below links contain m3u8 with variant token and I want to auto extract m3u8 list and auto start recording (using livestreamer of ffmpeg....)
http://tv.101vn.com/ok/vtc/youtv_2.php
http://viewtv.vn/live

Because I want to make task schedule to record at given time while I'm not online.

Thanks !


with php code it's possible

Code:

<?php
$return=file_get_contents("http://tv.101vn.com/ok/vtc/youtv_2.php"); preg_match('/src=\'(.*?)\'/', $return, $matche);
$return2=file_get_contents("$matche[1]"); preg_match('/responseText = "(.*?)"/', $return2, $m3u8); $hls=str_replace("http","hlsvariant://http",$m3u8[1]);
$date = date("H:i_d-m-Y"); $outputfile= $date . "-hanoi-cab2.ts";
echo "Starting livestreamer...\n\n";
                echo shell_exec("livestreamer  \"$hls\" best -o \"$outputfile\" &");
                echo "Done.\n";
?>



Code:

<?php
$return=file_get_contents("http://viewtv.vn/live"); preg_match('/iosUrl =\'(.*?)\'/', $return, $m3u8);
$hls=str_replace("http","hlsvariant://http",$m3u8[1]); $date = date("H:i_d-m-Y"); $outputfile= $date . "-vt8.ts";
echo "Starting livestreamer...\n\n";
                echo shell_exec("livestreamer  \"$hls\" best -o \"$outputfile\" &");
                echo "Done.\n";
?>


napretep 09-29-2015 11:13 PM

Re: How to auto extract m3u8 and auto start recording


 
hi, the code you posted assumes livestreamer is in the same dir as php.exe, so I had to edit the path for livestreamer.

BUT how do u hard-interrupt the recording (force stop it)? Ctrl + C gives an error :(

Code:

php recme1.php

Warning: date(): It is not safe to rely on the system's timezone settings. You a
re *required* to use the date.timezone setting or the date_default_timezone_set(
) function. In case you used any of those methods and you are still getting this
 warning, you most likely misspelled the timezone identifier. We selected the ti
mezone 'UTC' for now, but please set date.timezone to select your timezone. in C
:\php\recme1.php on line 4
Starting livestreamer...

[download][..0-09-2015-hanoi-cab2.ts] Written 5.0 MB (32s @ 158.3 KB/s)        T
raceback (most recent call last):
  File "<string>", line 6, in <module>
  File "__main__.py", line 128, in <module>
^C
  File "__main__livestreamer__.py", line 9, in <module>
c:\php>^X  File "livestreamer_cli\main.py", line 890, in main
  File "livestreamer_cli\console.py", line 45, in msg
IOError: [Errno 22] Invalid argument

thanx

biezom 09-30-2015 01:09 AM

Re: How to auto extract m3u8 and auto start recording


 
Quote:

Originally Posted by napretep (Post 80213)
hi, the code you posted assumes livestreamer is in the same dir as php.exe, so I had to edit the path for livestreamer.

BUT how do u hard-interrupt the recording (force stop it)? Ctrl + C gives an error :(

Code:

php recme1.php

Warning: date(): It is not safe to rely on the system's timezone settings. You a
re *required* to use the date.timezone setting or the date_default_timezone_set(
) function. In case you used any of those methods and you are still getting this
 warning, you most likely misspelled the timezone identifier. We selected the ti
mezone 'UTC' for now, but please set date.timezone to select your timezone. in C
:\php\recme1.php on line 4
Starting livestreamer...

[download][..0-09-2015-hanoi-cab2.ts] Written 5.0 MB (32s @ 158.3 KB/s)        T
raceback (most recent call last):
  File "<string>", line 6, in <module>
  File "__main__.py", line 128, in <module>
^C
  File "__main__livestreamer__.py", line 9, in <module>
c:\php>^X  File "livestreamer_cli\main.py", line 890, in main
  File "livestreamer_cli\console.py", line 45, in msg
IOError: [Errno 22] Invalid argument

thanx

for time zone warning you can download PHP.ini here

PHP.ini
and save it in php folder

to interrupt recording Ctrl+C several times or close command prompt

i think if you want to make task schedule you can create .bat file like this

Code:

@ echo on
call "C:\PHP\php.exe" "C:\php-scripts\recme1.php"
pause
:end

and use task scheduler but i'm not an expert on windows

sonnvl 09-30-2015 02:47 AM

Re: How to auto extract m3u8 and auto start recording


 
Thanks Biezom :)
What about this:
Code:

http://vuapp.tranvu.info/#tivi/173
Generate link:
Code:

http://vuapp.tranvu.info/api/channel/getnexttv?channel=5h503z5s5058553n5a6n786a5u715a765j3n5q6o6v6k5a46435z594759576z5d5h3c585ed645920e395fedad7bbbed0eca3fe2e05s56&token=313434313935333134385f305f305f776562&mobile=0
I grab this link:
Code:

http://125.212.201.169:1935/liveedge/_definst_/amlst:$vtc8$stream$_p2!250000!0!480!360$_p3!800000!0!640!480/playlist.m3u8?data=b00c5416ba2f281c2f01319e9e5e2d0236777e07b597de3ffd7bac0a06f5af0da96175989dd7e573ce85f6aac805a4ea&expired=1443608952362
But I want to change to get higher quality
Code:

http://125.212.201.169:1935/liveedge/_definst_/amlst:$vtc8$stream$_p5!800000!0!768!576/playlist.m3u8?data=b00c5416ba2f281c2f01319e9e5e2d0236777e07b597de3ffd7bac0a06f5af0da96175989dd7e573ce85f6aac805a4ea&expired=1443608952362
Can use php for this case ?

biezom 09-30-2015 04:27 AM

Re: How to auto extract m3u8 and auto start recording


 
Quote:

Originally Posted by sonnvl (Post 80217)
Thanks Biezom :)
What about this:
Code:

http://vuapp.tranvu.info/#tivi/173
Generate link:
Code:

http://vuapp.tranvu.info/api/channel/getnexttv?channel=5h503z5s5058553n5a6n786a5u715a765j3n5q6o6v6k5a46435z594759576z5d5h3c585ed645920e395fedad7bbbed0eca3fe2e05s56&token=313434313935333134385f305f305f776562&mobile=0
I grab this link:
Code:

http://125.212.201.169:1935/liveedge/_definst_/amlst:$vtc8$stream$_p2!250000!0!480!360$_p3!800000!0!640!480/playlist.m3u8?data=b00c5416ba2f281c2f01319e9e5e2d0236777e07b597de3ffd7bac0a06f5af0da96175989dd7e573ce85f6aac805a4ea&expired=1443608952362
But I want to change to get higher quality
Code:

http://125.212.201.169:1935/liveedge/_definst_/amlst:$vtc8$stream$_p5!800000!0!768!576/playlist.m3u8?data=b00c5416ba2f281c2f01319e9e5e2d0236777e07b597de3ffd7bac0a06f5af0da96175989dd7e573ce85f6aac805a4ea&expired=1443608952362
Can use php for this case ?

yes for the php code

p5!800000!0!768!576 and _p3!800000!0!640!480 are the same quality BANDWIDTH=800000 just the radio change


Code:

<?php
$return=file_get_contents("http://vuapp.tranvu.info/#tivi/173"); preg_match('/token: "(.*?)"/', $return, $token);

$return2=file_get_contents("http://vuapp.tranvu.info/api/channel/info?id=173&token=$token[1]&mobile=0");

preg_match('/"link":"(.*?)"/', $return2, $channel);

$return3=file_get_contents("http://vuapp.tranvu.info/api/channel/getnexttv?channel=$channel[1]&token=$token[1]&mobile=0");
preg_match('/"url":"(.*?)"/', $return3, $m3u8);
$badformat = array('\\','u0026','_p2!250000!0!480!360$_p3!800000!0!640!480'); $goodformat = array("", "&",'_p5!800000!0!768!576'); $m3u8 = str_replace($badformat, $goodformat, $m3u8[1]);

$hls=str_replace("http","hlsvariant://http",$m3u8); $date = date("H:i_d-m-Y"); $outputfile= $date . "-vtc8.ts";
echo "Starting livestreamer...\n\n";
                echo passthru("livestreamer  \"$hls\" best -o \"$outputfile\" &");
                echo "Done.\n";
?>



All times are GMT -6. The time now is 02:24 PM.