On Sun, Aug 16, 2020 at 07:48:57AM +1000, Mark Trickett wrote:
> I heard a BBC documentary on ABC Radio National, in the World Docos
> segment. I want the audio to pass on to others, and I would strongly
> recommend it to all here. I can get it to play, but not to save, yet.
>
> https://www.bbc.co.uk/programmes/m000jtmv

while there are lots of options with youtube-dl for selecting download format
and quality, a basic download using that URL works well here. e.g.

(btw, you can ignore the "HTTP Error 403: Forbidden" warnings - some BBC formats
are geo-locked to the UK - for BBC Subscribers only, i guess)


$ youtube-dl 'https://www.bbc.co.uk/programmes/m000jtmv'
[bbc.co.uk] m000jtmv: Downloading video page
[bbc.co.uk] m000jtmv: Downloading playlist JSON
[bbc.co.uk] m000jtmt: Downloading media selection XML
[bbc.co.uk] m000jtmt: Downloading MPD manifest
[bbc.co.uk] m000jtmt: Downloading m3u8 information
[bbc.co.uk] m000jtmt: Downloading m3u8 information
WARNING: Failed to download m3u8 information: HTTP Error 403: Forbidden
[bbc.co.uk] m000jtmt: Downloading MPD manifest
WARNING: Failed to download MPD manifest: HTTP Error 403: Forbidden
[bbc.co.uk] m000jtmt: Downloading m3u8 information
WARNING: Failed to download m3u8 information: HTTP Error 403: Forbidden
[bbc.co.uk] m000jtmt: Downloading m3u8 information
WARNING: Failed to download m3u8 information: HTTP Error 403: Forbidden
[bbc.co.uk] m000jtmt: Downloading MPD manifest
[bbc.co.uk] m000jtmt: Downloading m3u8 information
[bbc.co.uk] m000jtmt: Downloading m3u8 information
WARNING: Failed to download m3u8 information: HTTP Error 403: Forbidden
[bbc.co.uk] m000jtmt: Downloading MPD manifest
WARNING: Failed to download MPD manifest: <urlopen error Tunnel connection 
failed: 403 Forbidden>
[bbc.co.uk] m000jtmt: Downloading m3u8 information
WARNING: Failed to download m3u8 information: <urlopen error Tunnel connection 
failed: 403 Forbidden>
[bbc.co.uk] m000jtmt: Downloading m3u8 information
WARNING: Failed to download m3u8 information: <urlopen error Tunnel connection 
failed: 403 Forbidden>
[dashsegments] Total fragments: 131
[download] Destination: Watching Us, Week 1-m000jtmt.m4a
[download] 100% of 9.60MiB in 01:58
[ffmpeg] Correcting container in "Watching Us, Week 1-m000jtmt.m4a"

$ mediainfo /tmp/Watching\ Us\,\ Week\ 1-m000jtmt.m4a
General
Complete name                            : /tmp/Watching Us, Week 1-m000jtmt.m4a
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/mp41)
File size                                : 9.59 MiB
Duration                                 : 13 min 51 s
Overall bit rate mode                    : Constant
Overall bit rate                         : 96.8 kb/s
Writing application                      : Lavf58.45.100

Audio
ID                                       : 1
Format                                   : AAC LC SBR
Format/Info                              : Advanced Audio Codec Low Complexity 
with Spectral Band Replication
Commercial name                          : HE-AAC
Format settings                          : Explicit
Codec ID                                 : mp4a-40-2
Duration                                 : 13 min 51 s
Bit rate mode                            : Constant
Bit rate                                 : 96.0 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 23.438 FPS (2048 SPF)
Compression mode                         : Lossy
Stream size                              : 9.52 MiB (99%)
Language                                 : English
Default                                  : Yes
Alternate group                          : 1


I tested the download with smplayer, sounds pretty good.



> I do have youtube-dl installed,and command runner firefox extension,

i've never used youtube-dl with a firefox extension, only from the command
line.

> but not yet sure how to go about. I would also appreciate examples to
> be able to use them to download from ABC iView, I want "saving Planet
> A".

i'm going to assume you mean "Fight For Planet A: Our Climate Challenge" with
Craig Reucassel from The Chaser, because that's the closest thing that that
came up when I searched the iview site.

ABC iview is a bit trickier.  Finding the exact URL for a recording
can be difficult.

First, start with the main URL for the show: 
https://iview.abc.net.au/show/fight-for-planet-a-our-climate-challenge

Use that with `lynx -dump -listonly -nonumbers` and `grep` to find the actual 
download URL.

$ lynx -dump -listonly -nonumbers 
'https://iview.abc.net.au/show/fight-for-planet-a-our-climate-challenge' | grep 
-i ^http.*/video/
https://www.facebook.com/sharer.php?u=https://iview.abc.net.au/show/fight-for-planet-a-our-climate-challenge/series/1/video/DO1904H001S00
https://twitter.com/share?url=https://iview.abc.net.au/show/fight-for-planet-a-our-climate-challenge/series/1/video/DO1904H001S00&text=Fight
 For Planet A: Our Climate Challenge Series 1 Episode 1&via=ABCTV

These URLs look like they're for sharing with facebook and twitter. We don't
need or want that social media crap in the URL, so we need to strip it. You
can do that manually with careful mouse copy-paste, or you can use sed or perl
or similar tools.

The facebook one looks like a simple one to clean up with sed (we only need to
delete everything up to and including the "u="), so let's use that.

There's only one instance of "u=" in the URL so greedy regex matches aren't
going to be a problem so we can use sed:

what's a greedy match vs non-greedy? greedy matches will match as many
characters as possible. non-greedy will match as few as possible while still
matching the regex pattern (in short: stop at the FIRST possible match). sed
doesn't have a non-greedy regex modifier, perl does.

$ lynx -dump -listonly -nonumbers 
'https://iview.abc.net.au/show/fight-for-planet-a-our-climate-challenge' | sed 
-n -e '/facebook.*video/ s/^.*u=//p'
https://iview.abc.net.au/show/fight-for-planet-a-our-climate-challenge/series/1/video/DO1904H001S00

or with perl for non-greedy match (note the ? after the .* - that makes it 
non-greedy):

$ lynx -dump -listonly -nonumbers 
'https://iview.abc.net.au/show/fight-for-planet-a-our-climate-challenge' | perl 
-n -e 'if (m/facebook.*video/) { s/^.*?u=//; print }'
https://iview.abc.net.au/show/fight-for-planet-a-our-climate-challenge/series/1/video/DO1904H001S00


Anyway, we can now use that with youtube-dl:

I'm not going to bother with format or quality selection, but I do like to
download and embed the subtitles in videos downloaded from iview, so I'll use
a few options to do that:

(I'm also going to wrap the download URL in single-quotes.  It's not necessary
here because it doesn't contain any spaces or shell-metacharacters like ; or
&, but it's a good habit to get into when working with URLs on the command
line.  Those characters are VERY common in URLs and *WILL* be acted on by the
shell unless you wrap the URL in single-quotes)

$ youtube-dl --write-sub --all-subs --embed-subs 
'https://iview.abc.net.au/show/fight-for-planet-a-our-climate-challenge/series/1/video/DO1904H001S00'
[abc.net.au:iview] DO1904H001S00: Downloading JSON metadata
[abc.net.au:iview] DO1904H001S00: Downloading webpage
[abc.net.au:iview] DO1904H001S00: Downloading m3u8 information
[info] Writing video subtitles to: Series 1 Ep 1-DO1904H001S00.en.vtt
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 397
[download] Destination: Series 1 Ep 1-DO1904H001S00.mp4
[download] 100% of 1.01GiB in 01:45
[ffmpeg] Fixing malformed AAC bitstream in "Series 1 Ep 1-DO1904H001S00.mp4"
[ffmpeg] Embedding subtitles in 'Series 1 Ep 1-DO1904H001S00.mp4'
Deleting original file Series 1 Ep 1-DO1904H001S00.en.vtt (pass -k to keep)

The output filename's a bit shit.  You can rename it or read through 
youtube-dl's man
page for the '-o' option and OUTPUT TEMPLATE formatting details.  I'm not going 
to bother.

I tested it with smplayer, and it's good.  decent video and audio and subtitles.


Here's what mediainfo has to say about the file:

$ mediainfo Series\ 1\ Ep\ 1-DO1904H001S00.mp4
General
Complete name                            : Series 1 Ep 1-DO1904H001S00.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 997 MiB
Duration                                 : 1 h 6 min
Overall bit rate mode                    : Variable
Overall bit rate                         : 2 110 kb/s
Writing application                      : Lavf58.45.100

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1 h 6 min
Bit rate                                 : 1 973 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.086
Stream size                              : 933 MiB (94%)
Writing library                          : x264 core 160
Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / 
analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / 
me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / 
fast_pskip=1 / chroma_qp_offset=-2 / threads=22 / lookahead_threads=3 / 
sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / 
constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 
/ weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 
/ intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=22.0 / qcomp=0.60 
/ qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=4372 / vbv_bufsize=4500 / 
crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 1 h 6 min
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 60.5 MiB (6%)
Default                                  : Yes
Alternate group                          : 1

Text
ID                                       : 3
Format                                   : Timed Text
Muxing mode                              : sbtl
Codec ID                                 : tx3g
Duration                                 : 1 h 5 min
Bit rate mode                            : Variable
Bit rate                                 : 131 b/s
Stream size                              : 63.1 KiB (0%)
Language                                 : English
Default                                  : Yes
Forced                                   : No
Alternate group                          : 3



The file size is nearly a gigabyte.  You can use ffmpeg or handbrake or
something to re-encode with x265 to get it smaller (i'd guess that transcoding
the video to x265 would probably shrink the file by a third to a half.
maybe more).  If you're only going to watch it once and delete it, don't
bother...but might be worthwhile if you want to archive it for repeat viewing.

craig

_______________________________________________
luv-main mailing list
[email protected]
https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main

Reply via email to