The best place to ask programming/development questions, imo. UPDATE: stackoverflow is the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but a great reference for finding answers.

My Music (Nickleus)

20130918

how to download/save videos from NRK in ubuntu 13.04

title in norwegian: hvordan laste ned og lagre videoer fra NRK Nett TV
---

here's a video of my friend Yassin on NRK:
http://tv.nrk.no/serie/distriktsnyheter-oestlandssendingen/dkoa99091613/16-09-2013#t=4m22s

here's what i had to do to save a copy of that video:
go here:
tv.nrk.no/innstillinger

choose "Link til avspilling med HLS", then click "Lagre"

go to the video link again:
http://tv.nrk.no/serie/distriktsnyheter-oestlandssendingen/dkoa99091613/16-09-2013#t=4m22s

click the Play icon

the page will redirect to this URL:
http://nordond27a-f.akamaihd.net/i/wo/open/b5/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc_,141,316,563,1266,2250,.mp4.csmil/master.m3u8

save that page/file (ctrl+s), then open the downloaded file  (master.m3u8) in a text editor (e.g. geany)

the file contents will look like this:

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=212000,RESOLUTION=320x180,CODECS="avc1.66.30, mp4a.40.2"
http://nordond27a-f.akamaihd.net/i/wo/open/b5/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc_,141,316,563,1266,2250,.mp4.csmil/index_0_av.m3u8?null=
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=387000,RESOLUTION=480x270,CODECS="avc1.66.30, mp4a.40.2"
http://nordond27a-f.akamaihd.net/i/wo/open/b5/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc_,141,316,563,1266,2250,.mp4.csmil/index_1_av.m3u8?null=
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=712000,RESOLUTION=640x360,CODECS="avc1.77.30, mp4a.40.2"
http://nordond27a-f.akamaihd.net/i/wo/open/b5/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc_,141,316,563,1266,2250,.mp4.csmil/index_2_av.m3u8?null=
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1410000,RESOLUTION=960x540,CODECS="avc1.77.30, mp4a.40.2"
http://nordond27a-f.akamaihd.net/i/wo/open/b5/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc_,141,316,563,1266,2250,.mp4.csmil/index_3_av.m3u8?null=
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2384000,RESOLUTION=1280x720
http://nordond27a-f.akamaihd.net/i/wo/open/b5/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc_,141,316,563,1266,2250,.mp4.csmil/index_4_av.m3u8?null=
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=77000,CODECS="mp4a.40.2"
http://nordond27a-f.akamaihd.net/i/wo/open/b5/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc_,141,316,563,1266,2250,.mp4.csmil/index_0_a.m3u8?null=



the URL for the highest quality version of the video is the one that ends in "index_4_av.m3u8" (you can also see that in the comment above it, it says 1280x720).

now make sure you have avconv installed from ubuntu's repos:
sudo apt-get install avconv

the portion of the news about Yassin begins at 04 minutes and 11 seconds and lasts for 5 minutes. I don't want the whole news report which is like 15 minutes long, so run the following command in a terminal window:
cd

cd Downloads

avconv -i "http://nordond27a-f.akamaihd.net/i/wo/open/b5/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc_,141,316,563,1266,2250,.mp4.csmil/index_4_av.m3u8" -ss 00:04:11 -t 00:05:00 -codec copy yassin.mp4

when the downloading and converting is done, the resulting video file will now be in your Downloads folder:
/home/me/Downloads/yassin.mp4

if you want to download the whole video just cut out the time parameter parts, e.g.:
avconv -i "http://nordond27a-f.akamaihd.net/i/wo/open/b5/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc_,141,316,563,1266,2250,.mp4.csmil/index_4_av.m3u8" -codec copy yassin.mp4


special thanks to this thread:
http://freak.no/forum/showthread.php?t=249006

note: avconv is the "new" replacement for the old program ffmpeg


UPDATE 20131031

i was getting some errors when trying to download a specific video encoded with h264:
[NULL @ 0x123d480] non-existing PPS referenced
[h264 @ 0x1241300] non-existing PPS 0 referenced
[h264 @ 0x1241300] decode_slice_header error
[h264 @ 0x1241300] no frame!



so i installed some extra packages:
sudo apt-get install libx264-dev libfaac-dev librtmp-dev libass-dev

then specified the video and audio codecs to use, like this:
avconv -i http://nrkclip3b-f.akamaihd.net/i/wo/open/84/84af95d37d4b5c59574b6d45589612e022d52762/84af95d37d4b5c59574b6d45589612e022d52762_,141,316,563,1266,2250,.mp4.csmil/index_4_av.m3u8 -c:v libx264 -c:a libvo_aacenc knaus2.mp4

then it worked :)

3 comments:

  1. Do you if I can get anvconv on linux mint? I tried to run the command 'sudo apt-get install avconv' bit it didnt work

    ReplyDelete
    Replies
    1. sudo apt-get update
      sudo apt-get install libav-tools

      source: http://meshfields.de/audio-stream-recording-linux-avconv/

      Delete
  2. I highly recommend Allavsoft to downlod  M3U8 files to MP4, AVI, MKV, FLV, MOV and more other popular video formats.step by step at http://www.allavsoft.com/how-to/m3u8-downloader.html

    ReplyDelete