Audio/video stream recording forums

Attention Visitor:
You may have to register or log in before you can post:
  • Click the register link to sign up.
  • Registered members please fill in the form below and click the "Log in" button.
To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Audio/video stream recording forums > Streaming media recording forum > rtmpdump
Register FAQ Members List Calendar Mark Forums Read

Reply Post New Thread
 
Thread Tools Display Modes
  #1  
Old 08-19-2011, 03:57 AM
Ed999 Ed999 is offline
Senior Member
 
Join Date: Feb 2009
Posts: 115
Ed999 is on a distinguished road
Default

RTMPDump v2.1d and BBC iPlayer


These are the three batch files I use for downloading 'Listen Again' radio shows from the BBC iPlayer, for station Radio 4 Extra (formerly Radio 7), using RTMPdump.exe and RTMPsrv.exe v2.1d :


Note : The only edit needed each time is in line 2 of the first file, replacing the 8 zero's with the 8 digit PID - Programme ID - from the URL address of the iPlayer page that plays the radio show you want.

Note : I set up these files on a test laptop that was running Windows 7. The HOSTS directory address on your computer may be different in earlier versions of Windows.

Note : I am including an attachment containing all three of these batch files, plus some other files that I find useful. You'll just need to extract the .zip file to an empty directory and add your preferred version of RTMPDump.exe and RTMPsrv.exe (use v2.1d or later).



Run #1 - Preliminary Matters + Start RTMPSRV.bat

Code:
@echo off
SET PID=00000000

:: ======================================================== ::

cls
SET open="C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE"

:: Open the Playlist page (to obtain Identifier) -
%open% http://www.bbc.co.uk/iplayer/playlist/%PID%

:: Create a URL for the MediaSelector page (to inject Identifier in) -
echo @echo off>> MediaSelector.bat
echo. >> MediaSelector.bat
echo "C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE" http://www.bbc.co.uk/mediaselector/4/mtis/stream/00000000>> MediaSelector.bat
echo. >> MediaSelector.bat
echo cls>> MediaSelector.bat
C:\WINDOWS\NOTEPAD.EXE MediaSelector.bat

:: ======================================================== ::

rem  *** Create "Run #2" Link ***

IF EXIST Run#2*.PIF DEL Run#2*.PIF
IF EXIST "Run #2.url" DEL "Run #2.url"
IF EXIST "Run #2 - Play iPlayer.url" DEL "Run #2 - Play iPlayer.url"

echo @ECHO OFF>> "Run #2.bat"
echo "C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://www.bbc.co.uk/iplayer/console/%PID%">> "Run #2.bat"
echo CLS>> "Run #2.bat"

:: ================================================================= ::

rem  *** Create "Photos" Links ***

echo @ECHO OFF>> Photos.bat
echo.>> Photos.bat
echo SET open="C:\Program Files (x86)\Internet Explorer\iexplore.exe">> Photos.bat
echo SET url=http://node2.bbcimg.co.uk/iplayer/images/episode>> Photos.bat
echo.>> Photos.bat
echo %%open%% %%url%%/%PID%_150_84.jpg>>  Photos.bat
echo %%open%% %%url%%/%PID%_178_100.jpg>> Photos.bat
echo %%open%% %%url%%/%PID%_261_147.jpg>> Photos.bat
echo %%open%% %%url%%/%PID%_303_170.jpg>> Photos.bat
echo %%open%% %%url%%/%PID%_512_288.jpg>> Photos.bat
echo %%open%% %%url%%/%PID%_528_297.jpg>> Photos.bat
echo %%open%% %%url%%/%PID%_640_360.jpg>> Photos.bat
echo.>> Photos.bat
echo CLS>> Photos.bat
echo.>> Photos.bat
echo.>> Photos.bat

:: ================================================================= ::

rem  *** Edit the HOSTS file ***

IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\NOHOSTS REN C:\WINDOWS\SYSTEM32\DRIVERS\ETC\NOHOSTS HOSTS

rem  Replace line 1 with this:
rem  127.0.0.1   bbcmedia.fcod.llnwd.net

IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX ECHO.
IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX ECHO HOSTS_XX already exists: Aborting!
IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX PAUSE
IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX GOTO END

C:\WINDOWS\SYSTEM32\ATTRIB.EXE -R -S -H C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
REN C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS HOSTS_XX
:: Next line: Setting prior to 1pm on 12 July '10
:: echo 127.0.0.1  bbcmedia.fcod.llnwd.net> C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
:: Next line: Setting FROM 1pm on 12 July '10 onwards
echo 127.0.0.1  bbcodspdns.fcod.llnwd.net> C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
C:\WINDOWS\SYSTEM32\ATTRIB.EXE +R +H C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS

cls

:: ================================================================= ::

rem  *** Start RTMPSRV ***

:: Start RTMPSRV.EXE and pipe the URLs it displays to a .BAT file
:: to be used with RTMPDUMP to download the iPlayer file

"C:\Users\dg\Desktop\General\iPlayer\- Recording iPlayer\rtmpsrv.exe" > RTMPdump_run.bat


:END
cls



Run #3 - Run RTMPdump_run.bat

Code:
@echo off

rem  *** Edit the HOSTS file ***

rem  Wait 8 Seconds
echo.
echo Wait 8 Seconds ...
echo.
@CHOICE /T 8 /C yn /D y > NUL

cls

rem  Restore the normal line 1:
rem  127.0.0.1   localhost

C:\WINDOWS\SYSTEM32\ATTRIB.EXE -R -S -H C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX DEL C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX REN C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX HOSTS
C:\WINDOWS\SYSTEM32\ATTRIB.EXE +R +H C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS

:: ================================================================= ::

rem  *** Run RTMPDUMP ***
CALL RTMPdump_run.bat

rem  *** Rename the downloaded file ***
:: REN *.MP4 *.flv

rem  *** Save the Download command ***
COPY "Notes.txt"+"RTMPdump_run.bat" "Notes_New.txt"
echo. >> "Notes_New.txt"
DEL "Notes.txt"
REN "Notes_New.txt" "Notes.txt"

rem  *** Save the SWFINFO file ***
COPY "Notes.txt"+".swfinfo" "Notes_New.txt"
echo. >> "Notes_New.txt"
echo. >> "Notes_New.txt"
DEL "Notes.txt"
REN "Notes_New.txt" "Notes.txt"

rem  *** Open MediaSelector page ***
IF EXIST MediaSelector.bat CALL MediaSelector.bat

rem  *** Tidy Up ***
IF EXIST *.swfinfo DEL *.swfinfo
IF EXIST RTMPdump_run.bat DEL RTMPdump_run.bat
IF EXIST MediaSelector.bat DEL MediaSelector.bat
IF EXIST Run#2*.PIF DEL Run#2*.PIF
IF EXIST "Run #2.BAT" DEL "Run #2.BAT"

:: ================================================================= ::

:: Delete BBC Cookies
DEL C:\Users\dg\AppData\Roaming\Microsoft\Windows\Cookies\dg@bbc.*[*].txt
DEL C:\Users\dg\AppData\Roaming\Microsoft\Windows\Cookies\dg@bbc.co[*].txt
DEL C:\Users\dg\AppData\Roaming\Microsoft\Windows\Cookies\dg@www.bbc.co[*].txt
DEL C:\Users\dg\AppData\Roaming\Microsoft\Windows\Cookies\dg@cookie.radioplayer.co[*].txt
DEL C:\Users\dg\AppData\Roaming\Microsoft\Windows\Cookies\dg@static.radioplayer.co[*].txt

:: ================================================================= ::

cls



Run #4 - Rename FLV file.bat

Code:
@echo off

rem  *** Rename the downloaded file ***
IF EXIST *.MP4 REN *.MP4 *.flv

setlocal enabledelayedexpansion

for %%j in (RBN2_radio_4_*.flv) do (
set filename=%%~nj
set filename=!filename:RBN2_radio_4_-_=!
set filename=!filename:RBN2_radio_4_extra_-_=!
set filename=!filename:monday=Mon!
set filename=!filename:tuesday=Tue!
set filename=!filename:wednesday=Wed!
set filename=!filename:thursday=Thu!
set filename=!filename:friday=Fri!
set filename=!filename:saturday=Sat!
set filename=!filename:sunday=Sun!
set filename=!filename:_b00= [b00!
set filename=!filename:_b01= [b01!
set filename=!filename:_2011_01_=] 2011-01-!
set filename=!filename:_2011_02_=] 2011-02-!
set filename=!filename:_2011_03_=] 2011-03-!
set filename=!filename:_2011_04_=] 2011-04-!
set filename=!filename:_2011_05_=] 2011-05-!
set filename=!filename:_2011_06_=] 2011-06-!
set filename=!filename:_2011_07_=] 2011-07-!
set filename=!filename:_2011_08_=] 2011-08-!
set filename=!filename:_2011_09_=] 2011-09-!
set filename=!filename:_2011_10_=] 2011-10-!
set filename=!filename:_2011_11_=] 2011-11-!
set filename=!filename:_2011_12_=] 2011-12-!
set filename=!filename:~0,-9%!
set filename=!filename:_= !
if not "!filename!"=="%%~nj" ren "%%j" "!filename!%%~xj"
)
Attached Files
File Type: zip Recording_iPlayer.zip (19.9 KB, 0 views)
Reply With Quote
  #2  
Old 02-17-2012, 03:32 PM
Ed999 Ed999 is offline
Senior Member
 
Join Date: Feb 2009
Posts: 115
Ed999 is on a distinguished road
Default

Parse a BBC iPlayer MediaSelector XML file using Javascript


This is a method for downloading an iPlayer file using a MediaSelector url (e.g. obtained from http://www.bbc.co.uk/radio/aod/avail...adio4extra.xml ).

The code, below, is the content for the file Download.htm (a file which runs Javascript).

Create an empty text file using NOTEPAD.EXE and copy-and-paste the HTML code below into it. This type of Javascript requires Internet Explorer. Run the .HTM file from your hard disk, in Internet Explorer; it won't run if you upload it to the internet.

To run it successfully, the user need only change the MediaSelector url highlighted in red (i.e. substitute the MediaSelector url of the iPlayer radio show you want to download).

The .HTM file creates a .BAT (batch) file on your Desktop. Put RTMPDUMP.EXE in the directory C:\Program Files\rtmpdump in order to run this .BAT file.

It downloads a media file with the extension .mp4 so you must alter that file's extension from .mp4 to .flv (and play it in GOM Player, or in Winamp 5.60 or later). The media file is an AAC file at 128 kbps (the highest quality used by the radio iPlayer). MP4 Audio using AAC at 128 kbps is an iTunes format file.


Note - I have only been able to test this method using Internet Explorer 8, on a borrowed laptop running Windows 7.


Code:
<html>
<head>
<title>Parse XML File</title>

<!-- Downloading from a BBC iPlayer page -->
<!-- This parses the elements in a MediaSelector xml page -->


<SCRIPT>

// Target XML file's URL address [MediaSelector URL]
var url = "http://www.bbc.co.uk/mediaselector/4/mtis/stream/b01by95r" ;


var xmlDoc;

window.open('','_self');

function loadxml()
{
   xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
   xmlDoc.async = false;
   xmlDoc.onreadystatechange = readXML;
   xmlDoc.load(url);
}


function readXML()
{
   if(xmlDoc.readyState == 4) {
   // This function is called on statechange
   // When the state reaches 4 this function reads the xml document


   // Create a Text File

   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var fh = fso.CreateTextFile("MediaSelector.bat", true);

   for(i=0; i<xmlDoc.getElementsByTagName("media").length; i++) {

   bitrate  = xmlDoc.getElementsByTagName("media")[i].attributes.getNamedItem("bitrate").nodeValue  ;
   encoding = xmlDoc.getElementsByTagName("media")[i].attributes.getNamedItem("encoding").nodeValue ;

      if ( bitrate==128 && encoding=="aac" ){

      fh.WriteLine( ':: Media tag #' + [i] );
      fh.WriteLine( '' );
      fh.WriteLine( 'SET rtmpdump=C:\\Program Files\\rtmpdump\\rtmpdump.exe' );
      fh.WriteLine( '' );
      fh.WriteLine( 'SET server=' +
         xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("server").nodeValue );
      fh.WriteLine( '' );
      fh.WriteLine( 'SET application=' +
         xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("application").nodeValue );
      fh.WriteLine( '' );
      fh.WriteLine( 'SET identifier=' +
         xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("identifier").nodeValue );
      fh.WriteLine( '' );
      var str1=xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("authString").nodeValue ;
      fh.WriteLine( 'SET authString=' + str1.replace(/&/g,"^&") );
      fh.WriteLine( '' );
      var str2=xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("identifier").nodeValue ;
      fh.WriteLine( '"%rtmpdump%" --protocol 0 --host "%server%" -a "%application%?%authString%" ' +
                    '-y "%identifier%" -o ' + str2.slice(28,999) );
      fh.WriteLine( '' );
      fh.WriteLine( 'pause' );

      }
   }

   fh.Close();

   }
}

</SCRIPT>

</head>
<body onload="loadxml();window.close()"> </body>
</html>
Reply With Quote
  #3  
Old 02-18-2012, 10:45 AM
Ed999 Ed999 is offline
Senior Member
 
Join Date: Feb 2009
Posts: 115
Ed999 is on a distinguished road
Default

Parse a BBC iPlayer MediaSelector XML file using Javascript


This is a Batch file which performs the same function as the .HTM file in my post of yesterday (above).

Code:
@ECHO OFF

::  *** MediaSelector ID  ***

::  Final 8 Characters
    SET ID=b01by95r

::  Source -
::  http://www.bbc.co.uk/radio/aod/availability/radio4extra.xml


::  *** Create a HTM file ***

ECHO ^<html^>   >> %temp%\temp.htm
ECHO ^<head^>   >> %temp%\temp.htm
ECHO.  >> %temp%\temp.htm
ECHO ^<title^>Parse XML File^</title^> >> %temp%\temp.htm
ECHO.   
ECHO ^<!-- Downloading from a BBC iPlayer page --^> >> %temp%\temp.htm
ECHO ^<!-- This parses the elements in a MediaSelector xml page --^>  >> %temp%\temp.htm
ECHO.   >> %temp%\temp.htm
ECHO ^<SCRIPT^>   >> %temp%\temp.htm
ECHO.  >> %temp%\temp.htm
ECHO // Target XML file's URL address [MediaSelector URL]  >> %temp%\temp.htm
ECHO var url = "http://www.bbc.co.uk/mediaselector/4/mtis/stream/%ID%" ;  >> %temp%\temp.htm
ECHO.   >> %temp%\temp.htm
ECHO var xmlDoc; >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO window.open('','_self');  >> %temp%\temp.htm
ECHO.  >> %temp%\temp.htm
ECHO function loadxml()  >> %temp%\temp.htm
ECHO { >> %temp%\temp.htm
ECHO    xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); >> %temp%\temp.htm
ECHO    xmlDoc.async = false;  >> %temp%\temp.htm
ECHO    xmlDoc.onreadystatechange = readXML;  >> %temp%\temp.htm
ECHO    xmlDoc.load(url);  >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO.  >> %temp%\temp.htm
ECHO function readXML() >> %temp%\temp.htm
ECHO { >> %temp%\temp.htm
ECHO    if(xmlDoc.readyState == 4) {    >> %temp%\temp.htm
ECHO    // This function is called on statechange >> %temp%\temp.htm
ECHO    // When the state reaches 4 this function reads the xml document  >> %temp%\temp.htm
ECHO.  >> %temp%\temp.htm
ECHO    // Create a Text File   >> %temp%\temp.htm
ECHO.  >> %temp%\temp.htm
ECHO    var fso = new ActiveXObject("Scripting.FileSystemObject");  >> %temp%\temp.htm
ECHO    var fh = fso.CreateTextFile("C:\\Users\\dg\\AppData\\Local\\Temp\\MediaSelector.bat", true);  >> %temp%\temp.htm
ECHO.   >> %temp%\temp.htm
ECHO    for(i=0; i^<xmlDoc.getElementsByTagName("media").length; i++) {   >> %temp%\temp.htm
ECHO.  >> %temp%\temp.htm
ECHO    bitrate  = xmlDoc.getElementsByTagName("media")[i].attributes.getNamedItem("bitrate").nodeValue  ;  >> %temp%\temp.htm
ECHO    encoding = xmlDoc.getElementsByTagName("media")[i].attributes.getNamedItem("encoding").nodeValue ;  >> %temp%\temp.htm
ECHO.  >> %temp%\temp.htm
ECHO       if ( bitrate==128 ^&^& encoding=="aac" ){   >> %temp%\temp.htm
ECHO.   >> %temp%\temp.htm
ECHO       fh.WriteLine( '@echo off' );    >> %temp%\temp.htm
ECHO       fh.WriteLine( ':: Media tag #' + [i] );                                                                       >> %temp%\temp.htm
ECHO       fh.WriteLine( '' );  >> %temp%\temp.htm
ECHO       fh.WriteLine( 'SET rtmpdump=C:\\Data\\General\\iPlayer\\- Recording iPlayer\\rtmpdump.exe' );  >> %temp%\temp.htm
ECHO       fh.WriteLine( '' );  >> %temp%\temp.htm
ECHO       fh.WriteLine( 'SET server=' +                                                                                 >> %temp%\temp.htm
ECHO          xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("server").nodeValue );          >> %temp%\temp.htm
ECHO       fh.WriteLine( '' );                                                                                           >> %temp%\temp.htm
ECHO       fh.WriteLine( 'SET application=' +                                                                            >> %temp%\temp.htm
ECHO          xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("application").nodeValue );     >> %temp%\temp.htm
ECHO       fh.WriteLine( '' );                                                                                           >> %temp%\temp.htm
ECHO       fh.WriteLine( 'SET identifier=' +                                                                             >> %temp%\temp.htm
ECHO          xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("identifier").nodeValue );      >> %temp%\temp.htm
ECHO       fh.WriteLine( '' );                                                                                           >> %temp%\temp.htm

ECHO       var str1=xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("authString").nodeValue ; >> %temp%\temp.htm
ECHO       fh.WriteLine( 'SET authString=' + str1.replace(/^&/g,"^&") );                                                 >> %temp%\temp.htm
ECHO              fh.WriteLine( '' );                                                                                    >> %temp%\temp.htm
ECHO       var str2=xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("identifier").nodeValue ; >> %temp%\temp.htm
ECHO       fh.WriteLine( '"%%rtmpdump%%" --protocol 0 --host "%%server%%" -a "%%application%%?%%authString%%" ' +        >> %temp%\temp.htm
ECHO                     '-y "%%identifier%%" -o ' + str2.slice(28,999) );                                               >> %temp%\temp.htm
ECHO.                                                                                                                    >> %temp%\temp.htm
ECHO       }                                                                                                             >> %temp%\temp.htm
ECHO    }                                                                                                                >> %temp%\temp.htm
ECHO.                                                                                                                    >> %temp%\temp.htm
ECHO    fh.Close();                                                                                                      >> %temp%\temp.htm
ECHO.                                                                                                                    >> %temp%\temp.htm
ECHO    }                                                                                                                >> %temp%\temp.htm
ECHO }                                                                                                                   >> %temp%\temp.htm
ECHO.                                                                                                                    >> %temp%\temp.htm
ECHO ^</SCRIPT^>                                                                                                         >> %temp%\temp.htm
ECHO.                                                                                                                    >> %temp%\temp.htm
ECHO ^</head^>                                                                                                           >> %temp%\temp.htm
ECHO ^<body onload="loadxml();window.close()"^> ^</body^>                                                                >> %temp%\temp.htm
ECHO ^</html^>                                                                                                           >> %temp%\temp.htm


::  *** Run HTM file in Internet Explorer ***
"C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE" %temp%\temp.htm

::  *** Run MediaSelector.bat ***
CALL %temp%\MediaSelector.bat
Reply With Quote
  #4  
Old 03-15-2012, 01:34 PM
Ed999 Ed999 is offline
Senior Member
 
Join Date: Feb 2009
Posts: 115
Ed999 is on a distinguished road
Default

Download from BBC iPlayer - TV Show - Javascript method


This is a method for downloading an iPlayer TV stream using its MediaSelector url.

Just like a radio show, a tv show/stream has its own unique 8-digit ID number, which is contained in the MediaSelector URL for that stream. It is displayed - amongst other places - on the Playlist xml page associated with the particular stream. That 8-digit ID (identifier) can be used in the javascript code set out below.

See my other posts, above, for further details of the MediaSelector ID and how to find it.

The HTML code, below, is the content for the file TV_Download.htm (a file which runs Javascript).

All you need do is change the 8-digit ID number highlighted in red for the actual MediaSelector 8-digit ID of the tv show you want to download.

If you alter the sections highlighted in blue, you can download instead a stream running at a different bitrate. Details of the available bitrates for each tv show are given in that show's MediaSelector page. Each tv show is offered by the BBC in half a dozen different bitrates, from 184 kbps to 1500 kbps.

You can also choose either a LIMELIGHT server or an AKAMAI server for some bitrates. There is not much difference in video or audio quality between the two types, at any given bitrate; but there may be a difference in file size.

If you open the .HTML file in Internet Explorer 8 or 9, and allow the javascript to run, it will create a .bat batch file at C:\MediaSelector.bat containing the download command. You then run that batch file to do the actual download. The tv show will, by default, download into your C:\ root directory.

You must copy the program RTMPDUMP.EXE into the folder "C:\Program Files\rtmpdump" in order for this method to succeed.



Quote:
<html>
<head>
<title>Parse XML file in Internet Explorer</title>

<SCRIPT language="javascript">

// Target XML file's URL address [MediaSelector URL]
var url = "http://www.bbc.co.uk/mediaselector/4/mtis/stream/b01d5nj6";
var xmlDoc;

window.open('','_self'); // This prevents the browser window prompting before closing

function loadxml(){
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.onreadystatechange = readXML;
xmlDoc.load(url);
}

function readXML(){
if ( xmlDoc.readyState==4 ) {

var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("C:\\MediaSelector.bat",true);

var a = xmlDoc.getElementsByTagName("media");
for (i=0;i<a.length;i++) {
element1 = a[i].attributes.getNamedItem("kind").nodeValue; // create array

if ( element1=="video" ) {

// Element "bitrate" only exists WITHIN element "video"
element2 = a[i].attributes.getNamedItem("bitrate").nodeValue; // create array
if ( element2==796 ) {

var b = a[i].childNodes;
for (j=0;j<b.length;j++) {

element3 = b[j].attributes.getNamedItem("supplier").nodeValue;
if ( element3=="limelight" ) {


// Write elements in selected Child tag to file
fh.WriteLine( '@echo off' );
fh.WriteLine( ':: Media tag #' + [i] + ', Child tag #' + [j] );
fh.WriteLine( '' );
fh.WriteLine( 'SET rtmpdump=C:\\Program Files\\rtmpdump\\rtmpdump.exe' );
fh.WriteLine( '' );
fh.WriteLine( 'SET server=' + b[j].attributes.getNamedItem("server").nodeValue );
fh.WriteLine( '' );
fh.WriteLine( 'SET application=' + b[j].attributes.getNamedItem("application").nodeValue );
fh.WriteLine( '' );
fh.WriteLine( 'SET identifier=' + b[j].attributes.getNamedItem("identifier").nodeValue );
fh.WriteLine( '' );
var str1 = b[j].attributes.getNamedItem("authString").nodeValue ;
fh.WriteLine( 'SET authString=' + str1.replace(/&/g,"^&") );
fh.WriteLine( '' );
fh.WriteLine( ':: *** Command Line : TV : 796 kbps ***' );
var str2 = b[j].attributes.getNamedItem("identifier").nodeValue ;
var str3 = str2.split("/");
fh.WriteLine( '"%rtmpdump%" --protocol 0 --host "%server%" -a "%application%?%authString%" ' +
'-y "%identifier%" -o "'+element2+'kbps '+element3+' '+str3[4]+'" --resume --timeout 15' );

}
}
}
}
}
}
}
</SCRIPT>

</head>
<body onload="loadxml();window.close();"> </body>
</html>
Reply With Quote
  #5  
Old 03-15-2012, 06:05 PM
chap chap is offline
Senior Member
 
Join Date: Feb 2011
Location: Ukraine
Posts: 1,165
chap is on a distinguished road
Default

Re: Download from BBC iPlayer - TV Show - Javascript method


Quote:
This is a method for downloading an iPlayer TV stream using its MediaSelector url.
thanks works fine
Reply With Quote
  #6  
Old 03-16-2012, 07:54 AM
bat999 bat999 is offline
Senior Member
 
Join Date: Apr 2011
Location: UK
Posts: 131
bat999 is on a distinguished road
Default

Re: Download from BBC iPlayer - TV Show - Javascript method


Quote:
Originally Posted by chap View Post
thanks works fine
Are you guys using this longwinded method for a particular reason?
RTMPDump v2.1d
Reply With Quote
  #7  
Old 03-17-2012, 07:11 AM
Ed999 Ed999 is offline
Senior Member
 
Join Date: Feb 2009
Posts: 115
Ed999 is on a distinguished road
Default

RTMPDump and BBC iPlayer


I've posted this method, which combines RTMPDUMP with JavaScript, because I was asked - by PM - to suggest an easy method for choosing between the 9 different streams the BBC server provides for each tv show available on iPlayer.

For television, the BBC server offers 5 different bitrates, 4 of which are available from two different suppliers.

My method makes it easy to specify the bitrate you want and the server you want.

Most of the download methods available online don't give the user any choice at all as to bitrate or supplier, but merely capture a default version, determined either by the download program being used or by the iplayer software.

I'm not aware of any other solution which gives the user complete control over which bitrate and supplier to use.

A lower bitrate can be useful if you have a slow broadband connection or only a dial-up connection, and the size of the downloaded file can be different - even for the same bitrate - depending upon which supplier is chosen.


Although this thread has discussed a particular version of RTMPDUMP, using Windows 7 I've not noticed that any version of RTMPDUMP is better or worse than any other. I've mainly used v2.1d as it happens.
Reply With Quote
  #8  
Old 03-25-2012, 07:53 AM
Ed999 Ed999 is offline
Senior Member
 
Join Date: Feb 2009
Posts: 115
Ed999 is on a distinguished road
Default

Re: RTMPDump v2.1d and BBC iPlayer


Here is a similar HTML file, the contents of TV_live.htm, for recording a live tv stream. This needs rtmpdump version 2.4 (at C:\Program Files\RTMPDUMP).

This is valid only for the AKAMAI server (won't work with a LIMELIGHT stream).

It creates a .bat file in C:\ root which must be run to do the actual recording.


Code:
<html>
<head>

<title>Parse BBC iPlayer XML File - Javascript Method</title>

<!-- Downloading from a BBC iPlayer page -->
<!-- This parses the elements in a MediaSelector XML page -->

<SCRIPT>

// Target XML file's URL address [MediaSelector URL]
var url = "http://www.bbc.co.uk/mediaselector/4/mtis/stream/bbc_one_live_rtmp";

var xmlDoc;

window.open('','_self'); // This prevents the browser window prompting before closing

function loadXML()
{
   xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
   xmlDoc.async = false;
   xmlDoc.onreadystatechange = readXML;
   xmlDoc.load(url);
}

function readXML()
{
   if(xmlDoc.readyState == 4) {
   // This function is called on statechange
   // When the state reaches 4 this function reads the xml document

   // Create a Text File
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var fh = fso.CreateTextFile("C:\\MediaSelector.bat",true);


   // LEVEL 1 TAGS  [Primary tags]

   // Specify the Level 1 tag to loop through
   var a = xmlDoc.getElementsByTagName("media");

   // Loop instruction
   for (i=0;i<a.length;i++) {

       // Specify a target element within the Level 1 tag
       // Specified element must exist in ALL the Level 1 tags
       element1 = a[i].attributes.getNamedItem("kind").nodeValue; // create array  [Line 50]

       // Conditional Filter
       // Pass only those tags that contain video data
       if ( element1=="video" ) {

           // Conditional Filter [Bitrate]
           // Pass only the tag that contains the desired bitrate
           element2 = a[i].attributes.getNamedItem("bitrate").nodeValue; // create array
           if ( element2==796 ) {

           // NOTE: The element "bitrate" can't be used as the primary filter at line 50,
           //       because it's an element that does NOT exist in all primary level tags


   // LEVEL 2 TAGS  [Child tags]

   // Loop through each Child tag
   var b = a[i].childNodes;

   // Loop instruction
   for (j=0;j<b.length;j++) {

       // Specify a target element within the Child tag
       // Specified element must exist in ALL the Child tags
       element3 = b[j].attributes.getNamedItem("supplier").nodeValue; // create array

       // Conditional Filter [Supplier]
       // Pass only the Child tag that contains the desired supplier
       if ( element3=="akamai" ) {

       // Write elements in selected Child tag to file
       fh.WriteLine( '@echo off' );
       fh.WriteLine( '' );
       fh.WriteLine( 'SET rtmpdump=C:\\Program Files\\RTMPDUMP\\rtmpdump.exe' );
       fh.WriteLine( '' );
       fh.WriteLine( 'SET protocol=' + b[j].attributes.getNamedItem("protocol").nodeValue );
       fh.WriteLine( '' );
       fh.WriteLine( 'SET server=' + b[j].attributes.getNamedItem("server").nodeValue );
       fh.WriteLine( '' );
       fh.WriteLine( 'SET application=' + b[j].attributes.getNamedItem("application").nodeValue );
       fh.WriteLine( '' );
       fh.WriteLine( 'SET identifier=' + b[j].attributes.getNamedItem("identifier").nodeValue );
       fh.WriteLine( '' );

       var str1=b[j].attributes.getNamedItem("authString").nodeValue;
       fh.WriteLine( 'SET authString=' + str1.replace(/&/g,"^&") );
       fh.WriteLine( '' );

       fh.WriteLine( '::  *** Command Line : TV : AKAMAI ***' );
       fh.WriteLine( '"%rtmpdump%" --live --verbose ' +
                     '-r "%protocol%://%server%:1935/%application%?%authString%" ' +
                     '-a "%application%?%authString%" -y "%identifier%?%authString%" ' +
                     '-W "http://www.bbc.co.uk/emp/releases/iplayer/revisions/617463_618125_4/617463_618125_4_emp.swf" ' +
                     '-o "bbc_one_live_rtmp '+element2+'kbps '+element3+'.flv" ' );


       }   }         // Close Level 2
       }   }   }     // Close Level 1
   }
}

</SCRIPT>

</head>
<body onload="loadXML();window.close()"> </body>
</html>
Reply With Quote
  #9  
Old 03-25-2012, 10:55 AM
Ed999 Ed999 is offline
Senior Member
 
Join Date: Feb 2009
Posts: 115
Ed999 is on a distinguished road
Default

Play downloading stream using FFPLAY


Any .flv or .mp4 video stream can be watched while the stream is still downloading, using the command line utility FFPLAY.EXE


The build to use (with Windows XP/Vista/7) is FFPLAY release 16573 -

http://ffmpeg.arrozcru.org/builds/sh...-win32.tar.bz2


The ffplay syntax is -

ffplay.exe -bufsize 4096 *.*


The command line is (for example) -

"C:\Program Files\FFPLAY\ffplay.exe" -bufsize 4096 *.flv

If the stream is downloading as .mp4 rather than as .flv then change *.flv to *.mp4 instead

Put that command line in a .bat batch file (e.g. play.bat) and put the .bat file in the directory in which the stream is downloading, then run the batch file.
Reply With Quote
  #10  
Old 05-11-2012, 03:24 PM
Ed999 Ed999 is offline
Senior Member
 
Join Date: Feb 2009
Posts: 115
Ed999 is on a distinguished road
Default

Avoid receiving a Security Prompt


My scripts - above - might cause the following security prompt (in Internet Explorer):

"An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?"


To avoid receiving that prompt, in Windows 7 set the following Registry value:

HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Internet Settings\Zones\0
"1201"=dword:00000000
Reply With Quote
Reply Post New Thread
Tags: , , , , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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


Powered by All-streaming-media.com; 2006-2011
vB forum hacked with Zoints add-ons