--hls-liveradio-opts

Vangelis forthnet northmedia1 at the.forthnet.gr
Sun Dec 14 20:54:21 PST 2014


 A festive hello to all!

 Recently I've been playing around with the new bits of code
that enable recording of AppleHLS & Shoutcast audio streams;
this is accomplished via FFmpeg...
At some point during my test/experiments, I needed to pass to
FFmpeg an option whose value contains a whitespace and,
thus, is enclosed in double quotes (on Windows):

ffmpeg <blah, blah>  -headers "X-Forwarded-For: 31.3.xxx.xxx"

After a bit of searching, I found I had to use this GiP option:

--hls-liveradio-opts <options>   Add custom options to ffmpeg HLS download 
for liveradio

So, making use of a DP's tutorial from some days ago here in the list,
I added to my GiP command this part:

--hls-liveradio-opts="-loglevel info -headers \"X-Forwarded-For: 
31.3.228.238\""

(the "-loglevel info" was to see ffmpeg output - needless to say that alone
--hls-liveradio-opts="-loglevel info"
works as advertised...).

SADLY, my GiP command failed, as it appears that the -headers option
wasn't fed to FFmpeg.
 When I reran my GiP command with --verbose and inspected the log,
I can see this entry:

Current options:
        hlsliveradioopts = -loglevel info -headers "X-Forwarded-For: 
31.3.xxx.xxx"

which means that I input it correctly in my GiP command,
however further down the log I am seeing that it was not parsed correctly, 
since:

INFO: Command: ".\ffmpeg\bin\ffmpeg.exe" ... "-headers" "\"X-Forwarded-For:" 
"31.3.xxx.xxx\"" ...

I looked more closely to the GiP code and think I pinpointed this bit as the 
culprit:

package Streamer::hls;
........
# Add custom options to ffmpeg for this type if specified 
with --hls-<type>-opts
      if ( defined $opt->{'hls'.$prog->{type}.'opts'} ) {
               push @cmdopts, ( split /\s+/, 
$opt->{'hls'.$prog->{type}.'opts'} );
       }

       my @globals = ( '-y' );
       if ( ! grep( /-loglevel/i, @{$binopts->{ffmpeg}} ) ) {
               push @globals, ( '-loglevel', 'error', '-stats' );
       }
       my $return;
       @cmd = (
               $bin->{ffmpeg},
               @{$binopts->{ffmpeg}},
               @globals,
               '-i', $url,

 Can any of you Perl wizards out there do some magic to work around this?
I hate to admit it but recently I was caused much grief due to single 
whitespaces...
If only things were much simpler in life...

Many thanks in anticipation.

Vangelis. 




More information about the get_iplayer mailing list