Author Topic: Download High Bitrate TS files (320 kbps Live Stream)  (Read 637 times)

0 Members and 1 Guest are viewing this topic.

Offline Ed

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Download High Bitrate TS files (320 kbps Live Stream)
« on: July 30, 2016, 02:55:36 PM »
How to download a BBC radio programme in HIGH RESOLUTION (320 kbps) from BBC Radio 4 Extra, in Windows 7.

You can download the latest 11 hours of programmes, hence this procedure will work for any programme for up to 11 hours after it is broadcast.


Utils for downloading 320kbps files, and instructions:

Download link for file AAC_320_kbps_HLS_streams.zip


 �  First, put the file WGET.EXE on the Desktop.

 �  Then create a sub-directory (a new folder) on the Desktop,
    and put the five .BAT batch files in it (NOT wget.exe)


 � STAGE 1 : DOWNLOAD THE .TS FILES

   Run the .bat batch files in the following order:-

     1. Run batch file 1. This will download a .m3u8
        playlist file, containing text.


     2. Open the playlist file downloaded above, using
        Notepad. It will contain a list of filenames
        in the following format:

         bbc_radio_four_extra-audio=320000-229208808.ts

        There will be hundreds of these entries in the
        playlist file. They represent all the available
        .ts files, for the last three hours: each such
        file contains 6 seconds of audio. The first
        entry in the playlist file is the oldest.


     3. This part of the filename is irrelevent:

         bbc_radio_four_extra-audio=320000-

        You take the 9 digit number at the END of the
        filename, and you type it into batch file 2.

        Choose your own starting point: Pick any point in
        the 3 hours immediately before you downloaded the
        .m3u8 playlist file. Or do it the easy way: download
        the whole 3 hours, by taking the 9 digit number from
        the first entry in the playlist file.

        But you can go back 11 hours by editing the 9 digit
        number to choose your own starting point.

        Run batch file 2, to download the .TS files containing
        the audio (MPEG-2 TS Video files, 6 seconds long, and
        containing audio only; each typically 262 KB in size).


 � STAGE 2 : JOIN THE .TS FILES INTO A SINGLE FILE

   Run the .bat batch files in the following order:-

     4. Make SURE the sub-directory containg all the downloaded
        .TS files has its header line set to show these columns:

           Name
           Type
           Size
           Length
           Date
           Date Created
           Date Modified

        The critical values are DATE and LENGTH which show
        the air date and time of each audio file, and its
        length in seconds.

        You can play these files using MEDIA PLAYER CLASSIC,
        or VLC Media Player, or GOM Player. This is the key
        to locating the start and end of the radio show you
        want.


     5. Delete any .ts files that are not part of the radio
        show you want.

        Perhaps, at first, delete them to the Recycle bin
        in case you make a mistake.


     6. Run batch file 3, then batch file 4, to rename the
        .ts files you have chosen to keep.


     7. Type the 9 digit number from the .m3u8 file into
        batch file 5, to modify the following line:

          SET number=000000000

        (Replace the 9 zero\'s with the 9 digit number)


     8. Run batch file 5, in the sub-directory.

        This will create a new batch file, batch file 6, containing the
        list of files to be merged.


     9. Run batch file 6, in the sub-directory.

        All files in that directory with a higher number
        than the 9 digit number you took from the .m3u8
        playlist are merged into a single file.


    10. Delete all the remaining 6-second long files,
        and just keep the output file (which will be
        obvious from its file size).

        You can play the file using MEDIA PLAYER CLASSIC,
        or VLC Media Player, or GOM Player, or Windows
        Media Player. This is an audio-only file, even
        though .ts is a video format.
« Last Edit: July 11, 2017, 05:10:50 PM by Ed »

Offline Ed

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Download High Bitrate TS files - Other Options
« Reply #1 on: July 30, 2016, 04:48:55 PM »
Here is an alternative, two more methods for downloading iPlayer programmes in high bitrate versions -

https://www.mediafire.com/?4cr5ec0zge5cqzu


This is a very small zip file, containing a collection of text files (batch files) plus instructions for using them.

This is perhaps a more straightforward pair of options than the procedure I outlined above in this thread.

Offline Truthyness

  • Administrator
  • Hero Member
  • *****
  • Posts: 8,270
    • View Profile
Re: Download High Bitrate TS files - Other Options
« Reply #2 on: August 01, 2016, 04:47:15 AM »
Thanks for the detailed advice Ed. For those of us wanting to get quality recordings that sounds very interesting.

A commitment to Mod\'nAdminlyness: I understand that  r-e-s-i-s-t-a-n-c-e  *i - s*    f-u-t-i-l-e.
I shall not be starc

Offline Ed

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Download High Bitrate on-demand files (384kbps) using Firefox and FFmpeg
« Reply #3 on: January 16, 2017, 03:26:58 PM »
This is my favoured solution for downloading a radio show from the 'Listen Again' service.


FFMPEG command line from Greasemonkey script

These instructions are for use in Windows XP / Vista / 7 / 8 / 10. There are links below, in this post, to obtain the software mentioned.


A.  To obtain the command line -

1. Open the Firefox browser (must have the Greasemonkey extension installed, and the iPlayer greasemonkey script installed).
2. Open the iPlayer page which plays the radio show, using Firefox. After a few moments, an FFMPEG command line will be displayed immediately below the area where the radio show plays.


B.  To run the command line -

3. Create a batch file (a plain-text file with the extension .bat or .cmd).
4. FFMPEG.exe must be copied into the same directory/folder as the batch file.
5. Copy-and-paste the command line into the batch file.
6. Modify the file extension specified on the command line: change it from .mp3 to whatever you want (see below).
7. Run the batch file.


Software required -

FFMPEG.exe (Static build recommended)
https://ffmpeg.zeranoe.com/builds/

Firefox 39
https://ftp.mozilla.org/pub/firefox/releases/39.0/win32/en-US/Firefox%20Setup%2039.0.exe

Greasemonkey extension for Firefox 39
https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/

Greasemonkey script 'BBC iPlayer video download', for Firefox 39
https://greasyfork.org/en/scripts/8161-bbc-iplayer-video-download/



Notes -

The above procedure can download a file in various formats, including (for radio): .mp3, .mp4, .m4a, .ts, .wav

For instance, .M4A files have a variable bitrate stream, of better audio quality than MP3.

  •    AAC  : Variable KBPS rate, up to 200 kbps; 48 kHz; Stereo; MPEG-4 AAC LC
  •    M4A  : Variable KBPS rate, up to 200 kbps; 48 kHz; Stereo; MPEG-4 AAC LC
  •    MP4  : Variable KBPS rate, up to 196 kbps; 48 kHz; Stereo; MPEG-4 AAC LC
  •    MP3  : Fixed  128 KBPS rate; 48 kHz; Stereo; MPEG-1 layer 3
  •    MP2  : Fixed  384 KBPS rate; 48 kHz; Stereo; MPEG-1 layer 2
  •    MPEG : Fixed  384 KBPS rate; 48 kHz; Stereo
  •    TS   : Fixed  384 KBPS rate; 48 kHz; Stereo; 16 bit per sample
  •    WAV  : Fixed 1536 KBPS rate; 48 kHz; Stereo; Signed 16 bit PCM

  •    AAC is downloaded if the command line specifies an output file with the extension .AAC
  •    M4A is downloaded if the command line specifies an output file with the extension .M4A
  •    MP4 is downloaded if the command line specifies an output file with the extension .MP4
  •    MP3 is downloaded if the command line specifies an output file with the extension .MP3
  •    MP2 is downloaded if the command line specifies an output file with the extension .MP2
  •    MPEG is downloaded if the command line specifies an output file with the extension .MPEG
  •    TS is downloaded if the command line specifies an output file with the extension .TS
  •    WAV is downloaded if the command line specifies an output file with the extension .WAV

By default, the Greasemonkey script adds .mp3 to the command line; but you can replace that with any of the above alternatives (or possibly some other).

Read this article (by Andrea Lazzarotto) for further information -
https://andrealazzarotto.com/2015/02/20/how-to-download-bbc-iplayer-videos/


ADDENDUM:

Greasemonkey script, 'BBC iPlayer video download' v 3.6.3, for Firefox 39

You might need to replace the .js file installed by the current version of the installer with an older version of that file (version 3.6.3) to get the script to work in Windows. Here's a link to v3.6.3:

https://www.mediafire.com/?awx3o4v2l49yceg



ADDENDUM:

Signing-in to use iPlayer

See the following page for using the iPlayer website without signing-in:

https://forum.beebotron.org/index.php?topic=66093.msg66363




« Last Edit: July 11, 2017, 06:14:40 PM by Ed »

Offline Truthyness

  • Administrator
  • Hero Member
  • *****
  • Posts: 8,270
    • View Profile
Re: Download High Bitrate TS files using Firefox and FFmpeg
« Reply #4 on: January 17, 2017, 01:20:34 AM »
Thanks for the good advice and research behind it Ed.

A commitment to Mod\'nAdminlyness: I understand that  r-e-s-i-s-t-a-n-c-e  *i - s*    f-u-t-i-l-e.
I shall not be starc

Offline Ed

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Download High Bitrate TS files
« Reply #5 on: April 07, 2017, 01:30:20 PM »
Here are some updates, relating to my previous posts in this thread.


When using Firefox 39 with the GreaseMonkey add-on (to download on-demand files from the 'Listen Again' service), I've discovered from experience that the optimum file extension to use, in the FFmpeg command line, is .mp2 (instead of .ts or .mp3), as it has several advantages:

1. Using the .mp2 extension downloads a 384 kbps stream, whereas the .mp3 extension only downloads a 128 kbps stream.

2. Using the .ts extension downloads exactly the same 384 kbps stream as using the .mp2 extension, but the file size is very much bigger (because of drawbacks with the .ts format).

3. An .mp2 file has various advantages compared to a .ts file: you can play it in Winamp; you can add ID3 tags to the file; and the file size is 10% smaller.

For those who do wish to use the .ts format, it is possible to play it in Winamp. Open Winamp's preferences (press CTRL and P simultaneously) and go to: Plug-ins > Input.  Click on in_dshow.dll (the DirectShow decoder), then click 'Configure', and then add ;TS to the end of the Extension list.


Andrea, the Italian bloke who writes the .js (javascript) script for Firefox, named "BBC iPlayer video download", develops it on a Linux machine, so doesn't offer any support for using it on a Windows system.

The latest version of his script doesn't work in Windows 7. You will need to use an older version. So here is a link to an older version (version 3.6.3) that does work in Windows:

https://www.mediafire.com/?awx3o4v2l49yceg




AMENDED on 11 July 2017:
Corrected the bitrates for the .mp2 and .ts streams, to show those currently provided by the BBC's radio iPlayer. For live streams (the DASH streams), the bitrate remains 320 kbps; but for on-demand streams (the HLS streams), the bitrate of the audio is 384 kbps.




« Last Edit: July 11, 2017, 05:59:34 PM by Ed »

Offline Ed

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Convert TS files (320kbps) to MP2 (320kbps)
« Reply #6 on: July 11, 2017, 05:46:50 PM »
This suggestion supplements the method I originally described in this thread, which downloaded a bunch of .TS files from the iPlayer's LIVE stream (containing audio at 320 kbps), and then concatenated them into a single .TS file.

Here is a method for converting the obscure .ts format file into the popular .m4a format, by EXTRACTING the audio stream from the .ts file (which, on iPlayer's live stream, is AAC format audio), and creating a (new) .m4a file - or, optionally, an .mp4 file - containing that audio.

Doing this has one big advantage: files in .m4a (mp4 audio) format are playable in a very wide range of media players/programs (including Winamp, Media Player Classic, GOM Player, VLC Player, etc).

Also, you can add an ID3 tag (well, the iTunes equivalent at least) to an .m4a file, as that is the popular iTunes audio format. The .ts format does not allow ID3 tags to be stored in the file.



Software required -

FFMPEG.exe (Static build recommended)
https://ffmpeg.zeranoe.com/builds/



Procedure -

1.  Create a batch file (a plain-text file with the extension .bat or .cmd)
     (name it, say, convert.bat).
2.  Put FFMPEG.exe in the same directory/folder as the batch file.
3.  Copy-and-paste the command line, below, into the batch file (for this,
     open the batch file in a text editor, e.g. Notepad, not a word processor).
4.  Then save the file (be sure to save it with the extension .bat not .txt).
5.  Run the batch file (a new approach: just drag the .ts file onto the batch file).



Here is the command line for Step 3 (actually, 3 lines), which you copy-and-paste into the batch file:

Code: [Select]
SET file=%1
SET options=-hide_banner -bsf:a aac_adtstoasc -flags global_header
ffmpeg  -i %file%  -vn  -acodec copy  %options%  %file%.m4a



Put the .TS file in the same folder/directory as this batch file, then drag the .ts file onto the batch file. In the batch file, change .m4a to .mp4 if you prefer that.

The procedure performs what is known as a stream copy: i.e. it copies the audio stream in file A into file B, without modifying that stream. Because no re-encoding occurs, the copying procedure is very fast (typically 5 seconds, for a 30 MB half-hour radio show).



« Last Edit: July 11, 2017, 06:19:11 PM by Ed »

Offline Ed

  • Full Member
  • ***
  • Posts: 122
    • View Profile
How to force the Live Stream to use 384kbps
« Reply #7 on: July 25, 2017, 02:00:26 PM »
Here is a method for forcing the live stream to run at 384 kbps, instead of at the standard bitrate of 320 kbps.


Use any of these four command lines -

Code: [Select]
SET url=http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/ak/bbc_radio_four_extra.m3u8
ffmpeg  -v 16  -stats  -i %url%  output.mp2

Code: [Select]
SET url=http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_radio_four_extra.m3u8
ffmpeg  -v 16  -stats  -i %url%  output.mp2

Code: [Select]
SET url=http://as-hls-uk-live.akamaized.net/pool_6/live/bbc_radio_four_extra/bbc_radio_four_extra.isml/bbc_radio_four_extra-audio=320000.m3u8
ffmpeg  -v 16  -stats  -i %url%  output.mp2

Code: [Select]
SET url=http://as-hls-uk-live.akamaized.net/pool_6/live/bbc_radio_four_extra/bbc_radio_four_extra.isml/bbc_radio_four_extra-audio=320000.norewind.m3u8
ffmpeg  -v 16  -stats  -i %url%  output.mp2


To play the command line, copy-and-paste the url and use it in, for example, VLC Media Player.


To download the live stream, copy-and-paste one of the 2-line command lines into a batch file ( e.g. download.bat ), put the batch file in the same directory as the ffmpeg.exe program, then run the batch file.

Notes on creating a batch fileCreate a Batch file



ADDENDUM -

This method for forcing a 384 kbps output no longer works.

In any case, I now recommend a new solution, using the program YouTube-dl.exe instead of ffmpeg.exe (the new solution downloads at the current maximum of 320 kbps). See this post:

https://forum.beebotron.org/index.php?topic=66110.msg66416


« Last Edit: October 21, 2017, 03:55:46 AM by Ed »