Possible To Get BBC R3 In FLAC using GiP?

Vangelis forthnet northmedia1 at the.forthnet.gr
Wed Aug 2 16:12:44 PDT 2017


On Wed Aug 2 18:43:49 BST 2017, C E Macfarlane wrote:

> if it is possible to obtain the Proms iPlayer streams in FLAC,

 Hello Charles, I do hope all's well with you!

 The BBC do not provide AOD in flac, hence
it's impossible to acquire such files via GiP
(which currently only supports on-demand streams).
Recent Support Forum thread:
https://squarepenguin.co.uk/forums/thread-1463-post-6518.html

> are only live broadcasts available as FLAC?

 Precisely :-) Do note that this feature is only a
BBC Labs test; so it might not return after
Proms season is over.
There has been a relevant (albeit off-topic)
list thread back in April
http://lists.infradead.org/pipermail/get_iplayer/2017-April/010436.html
when the experiment first went live, but TBH
the choice of thread title isn't very
indicative of the thread's subject (so as
to spot it easily inside the list archives)... ;-(

 The live flac stream is using MPEG-DASH
(unencrypted) type of delivery, the exact
mpd (media presentation description) URI is:

https://vs-dash-ww-rd-live.bbcfmt.hs.llnwd.net/al/lossless/client_manifest.mpd

(the -ww- part of the hostname, which belongs to
a Limelight CDN, indicates the stream is not geo-blocked,
so audiophiles from all over the world can test it,
provided their OS+Firefox version support it).

 Back during the GiP 2.95-dev era (Jan 2016), the GiP coder
briefly experimented with supporting live radio dash streams:
https://github.com/get-iplayer/get_iplayer/commit/8a90279
but this feature never made it to a released version:
https://github.com/get-iplayer/get_iplayer/commit/9f6b8c6

 Probably someone else with the required perl (or other)
expertise can conjure up a perl script to dump that live
DASH (but FLAC encoded) stream to file.

===================================
OT info (STOP HERE if bothered by OT content):

 FWIW, a special patch for FFmpeg that only applies
to a special (previous) snapshot of FFmpeg
(commit git-20f7872) has been posted here:
https://patchwork.ffmpeg.org/patch/3346/
(or http://ffmpeg.org/pipermail/ffmpeg-devel/2017-April/210141.html)
but this initial DASH stream recording feature
hasn't made it to the official repo yet...

 I have been successful in compiling a win32 FFmpeg build
(FFmpeg-n3.4-dev-301-git-20170409-N-85396-g20f7872+dash_demuxer_v14-libressl-win32)
that is able to capture this flac LIVE stream, unfortunately
it's a non-free build, as it uses libressl (openssl fork) as
the crypto lib; notice the stream uses HTTPS...

 The RAW flac stream that is dumped to disk is not
a proper flac file, rather a "fragmented" flac file, the
product of dash streaming; so simply issuing

ffmpeg -v 16 -stats -re -i 
"https://vs-dash-ww-rd-live.bbcfmt.hs.llnwd.net/al/lossless/client_manifest.mpd" 
 -t 00:30:00 -vn -c:a copy BBCR3LL.flac

will produce a non-seekable file with many
software players; better mux the stream to
the OGG container:

ffmpeg -v 16 -stats -re -i 
"https://vs-dash-ww-rd-live.bbcfmt.hs.llnwd.net/al/lossless/client_manifest.mpd" 
 -t 00:30:00 -vn -c:a copy BBCR3LL.oga

or experimental mux to the MP4 container:

ffmpeg -v 16 -stats -re -i 
"https://vs-dash-ww-rd-live.bbcfmt.hs.llnwd.net/al/lossless/client_manifest.mpd" 
 -t 00:30:00 -vn -c:a copy -strict -2 BBCR3LL_tmp.mp4
ffmpeg -v 32 -stats -i BBCR3LL_temp.mp4 -vn -c:a copy -strict -2 -movflags 
faststart BBCR3LL.mp4 && del BBCR3LL_tmp.mp4

for seekable files (needs recent versions of players);
or losslessly recode on-the-fly to flac:

ffmpeg -v 16 -stats -re -i 
"https://vs-dash-ww-rd-live.bbcfmt.hs.llnwd.net/al/lossless/client_manifest.mpd" 
 -t 00:30:00 -vn -c:a flac BBCR3LL-rc.flac

BTW, if you plan to edit the recorded flac stream
further with FFmpeg, you'll bump on this bug:
https://trac.ffmpeg.org/ticket/4905
You'll have to
DECODE TO WAV => PIPE => EDIT => ENCODE TO FLAC
E.g. to cut out a segment from an hour's worth
of live stream, I used:

ffmpeg -v 8 -stats -i original.flac -vn -f wav - | ffmpeg -v 
8 -stats -i - -ss 00:42:19 -to 00:58:11 -vn -af aformat=s16:48000 cut.flac

 If you can't compile for yourself that
special, DASH enabled, build of FFmpeg,
then your best bet is to try a recent nightly
build of VLC 3.0.0-git (win builds link):

http://nightlies.videolan.org/build/win32/last/

 Often times, those nightly builds are unstable
(might even cause BSODs), but nothing evil
has happened to my system by running the latest
compiles (e.g. I'm on VLC 3.0.0-git-20170731-0258).
You'll have to tweak the GUI to make that red
Record button appear (not there by default), then
search on how to record a live stream with VLC;
use the mpd URI posted previously...
VLC 3.0.0-git muxes the segmented FLAC
stream inside the OGG container by default,
resulting in an .ogg file.

MediaInfo log:

Format                                   : Ogg
Format/Info                              : Free Lossless Audio Codec
File size                                : 7.47 MiB
Duration                                 : 1 min 21 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 772 kb/s

Audio
ID                                       : 533993841 (0x1FD41971)
Format                                   : FLAC
Format/Info                              : Free Lossless Audio Codec
Muxing mode                              : pre-FLAC 1.1.1
Duration                                 : 1 min 21 s
Bit rate mode                            : Variable
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 kHz
Bit depth                                : 16 bits

 HOWEVER, any attempt to extract (demux) the RAW audio
stream with FFmpeg (3.3.1) fails for me, unless I
recode to flac:

ffmpeg -v 16 -stats -i "vlc-record-2017-08-03-01h36m18s-Radio 3 
lossless-.ogg" -vn -c:a copy "Radio 3 lossless.flac" =>

Could not write header for output file #0 (incorrect codec parameters ?):
Invalid data found when processing input
(a 0.00 Byte file is created).

ffmpeg -v 8 -stats -i "vlc-record-2017-08-03-01h36m18s-Radio 3 
lossless-.ogg" -vn -c:a flac "Radio 3 lossless.flac"

successfully produces a .flac file!
(verbosity reduced to 8 to prevent voluminous console output, though...)
===================================

 Best regards to all from super hot Greece!
(29 Celsius @ 02:00 am) 




More information about the get_iplayer mailing list