Downloading HD content from

Update: I’ve made some helper scripts, including a script to download subtitles. See

NRK (Norwegian Broadcasting Corporation) recently deployed their new net TV broadcasting solution,, with, among other nice features, HD content. For Linux users, regretfully, the player is implemented in Flash.

Generally, Linux users would like more control. Here’s how to download video content from (and probably other sites using the same technology), and play it offline on Linux.

The flash player uses AdobeHDS for streaming fragments via Akamai’s CDN. The magic consists of three steps: Getting the manifest describing the fragments. Downloading the fragments. Merging the fragments into a playable file.

First for downloading and merging. This is all done by one single magic script, AdobeHDS.php, that can be downloaded from All praise to KSV who made the script. By some strange reason, the script is written in PHP, so you need to have that installed as well.

Put the script somewhere where it’s easy to find it, like in ~/bin, and you’re good to go. Now you just need to get the manifest url.

To get the manifest, use a recent version of Mozilla Firefox. Surf to, and hit Ctrl+Shift+K to enable Firefox’ built-in website debugger. In the filter box, enter manifest and press enter. Find your video in the web browser panel, and start it. Let it play for a second or five, and the URL to the manifest should appear in the debugger window. Click on the match and copy the url.

Now just call the merge script with the manifest url. Add the delete option to get rid of the fragments after merging. Use quotes to avoid problems with special characters like ‘?’ and ‘&’.

php ~/bin/AdobeHDS.php --quality high --delete --manifest ''

                            KSV Adobe HDS Downloader

Downloading fragment 1116/1116
Found 1116 fragments
Joined 1116 fragments in 205.07 seconds

The result will be a video file that you can play with any recent media player, like totem or mplayer (given you have the right codecs installed, of course). NRK seems to favour h264 video with aac audio in the flv (“flash video”) container.

Now for subtitles. I made a small perl script that builds .srt files from NRK’s html subtitle format. Download the script and place it somewhere handy, like in ~/bin, and run chmod +x on it to make it executable. You will need the following cpan modules: DateTime::Precise, Text::Iconv, and HTML::TokeParser::Simple.

Go back to your browser window, and in the debug filter, search for “subtitles” (without quotes). Reload the page if necessary. Click on the match, and copy the url. Then run the script with the subtitles url in the same directory as where you downloaded the film. The result should work for example with mplayer or totem. Example:

perl ~/bin/nrk-subtitles >
mplayer -sub film.flv


Tags: ,

97 Responses to “Downloading HD content from”

  1. Harry says:

    Definite a time out problem, even when no timeouts occur when doing a ping. I lowered the quality in the download params to 714, and now it works fine. Looks like the scripts is waiting for a reply/handshake when a fragment is completed. No reply, it starts merging, and as a result it only merges a partial download.

  2. Harry says:

    Definite a timeout problem. I lowered the quality params and now it works. Looks like the script is waiting for a handshake when a fragment is downloaded. No handshake means done, and then it starts merging a partial download.

  3. Finn Andersen says:

    Here is a small script combining video and subtitle into a mkv-container.
    There is virtually no error-checking, so it will most likely break badly in the near future.

    It uses the php script (AdobeHDS) for assembling the fragments and the perl script (nrk-subtitles) for downloading the subtitles. They can be found in earlier comments.

    The subtitles has to be in utf-8, so I had to modify the nrk-subtitles script a little bit.

    #my $converter = Text::Iconv->new(“UTF-8″, “ISO-8859-1″);
    my $converter = Text::Iconv->new(“UTF-8″, “UTF-8″);

    I would guess that someone will find a more elegant approach to this…


    # If no argument is given, show usage
    if [ "$1" = "" ]
    echo “Usage: $0 ”


    # GET Subtitle URL
    SRT_URL=`curl -s $INPUT | awk -F\” ‘/data-subtitlesurl/ {print

    # GET name of the program. Last field in the URL
    VIDEO_NAME=`echo $INPUT | awk -F/ ‘{print $NF}’`

    # hdcore must end the string. But it’s value doesn’t seem to matter

    # GET manifest URL
    MANIFEST_URL=`curl -s $INPUT | awk -F\” ‘/manifest.f4m/ {print $2}’`$END_STRING

    # Info from parsing the $INPUT argument
    echo “SRT_URL: $SRT_URL”

    # Downloads video
    php ~/bin/AdobeHDS.php –quality high –delete –manifest $MANIFEST_URL –outfil
    e $VIDEO_NAME.flv

    # Downloads subtitle
    perl ~/bin/nrk-subtitles $SRT_URL > $

    # Convert to a mkv container. ffmpeg is deprecated in Ubuntu 12.04
    avconv -i $VIDEO_NAME.flv -vcodec copy -acodec copy $VIDEO_NAME_temp.mkv

    # Merge video and subtitle
    mkvmerge -o $VIDEO_NAME.mkv $VIDEO_NAME_temp.mkv $

    # Cleanup
    rm $ $VIDEO_NAME_temp.mkv $VIDEO_NAME.flv

  4. KK says:

    I’m getting a 403 error when I try this now…

  5. Matz says:

    Worked yesterday.

  6. Marius says:

    Thanks for providing these badly needed scripts for downloading from the new nrk tv website.

    One very small issue I noticed is that the decimal separator in the subtitle script is “.” instead of “,” and this breaks the srt for some players and editors. My perl isn’t up to fixing it, so if anyone else wants to have a go and post back that would be great!

  7. TheBrazilian says:

    Thanks for a brilliant script and instructions for the video download. After fiddeling around a bit I got it running flawlessly on a Windows PC. Very fast with no glitches as far as I have seen for the first 5 downloads.

  8. KML says:

    Fikk dette til å spille på windows med cygwin og php, legg bare til curl og perl under cygwin installasjonen. Flotte greier! Leita som en gal etter løsning for å sikre endel innhold fra dette overflodsbegeret – før tingene fortløpende utgår på dato.

  9. KML says:

    Glemte det viktigste: TUSEN TAKK! :)

  10. TheBrazilian says:

    One more thing that some of you might find useful – the resulting .flv files can be transcoded (transcontainered actually:-) to mp4 without re-encoding neither the video nor audio using the VLC media player (I’m using it on Windows). The whole process takes about 10 seconds for a one-hour 720p NRK file. The resulting repackaged .mp4 file even plays on my not so new Sony TV, so it looks to be a pretty standard .mp4 file.

  11. Eivind Mork says:

    Hi Ingvar! Read about this at on the subway one day, but almost forgot about it I got to think about it again now, and gave it a try. It works brillianlty! Thanks a lot for publishing the scripts!

  12. KML says:

    Hmmm… Works really fine on smaller episodes, but fails for me on e.g. No error message, collects parts, then outputs

    “Video was stored in “NRK TV – Halvbroren – 1:8.flv”",

    but only an empty file is left after the execution:

    -rwx——+ 1 kyrre None 0 jan 27 21:40 NRK TV – Halvbroren – 1

    (not even the whole filname is there).

    Any guess what’s happening here?


  13. ingvar says:


    Nope. You might check that you have neccessary bandwith available to download the video in high quality, within reasonable timeouts. Also, check that you have the latest version of AdobeHDS.php.

    Here’s my run:

    [ingvar@yum ~/Videoklipp/Halvbroren]$ nrk-download ‘′
    Downloading NRK TV – Halvbroren – 1:8
    Downloading and converting subtitles…
    Downloading and converting video…

    KSV Adobe HDS Downloader

    Processing manifest info….
    Quality Selection:
    Available: 2392 1413 713 387 212
    Selected : 2392
    Downloading 446/446 fragments
    Found 446 fragments
    Joined 446 fragments in 24.75 seconds
    Video was stored in “NRK TV – Halvbroren – 1:8.flv”

    [ingvar@yum ~/Videoklipp/Halvbroren]$ ls -lh “NRK TV – Halvbroren – 1:8.”*
    -rw-rw-r–+ 1 ingvar ingvar 767M jan. 30 08:55 NRK TV – Halvbroren – 1:8.flv
    -rw-rw-r–+ 1 ingvar ingvar 23K jan. 30 08:54 NRK TV – Halvbroren –

  14. KML says:

    The outfile name containg “:” was theissue on windows. Replaced with _ and runs nice.

    #echo “new outfile name: $outfile”

    echo “Downloading and converting video…”
    php ./AdobeHDS.php –quality high –delete –outfile “$outfile” –manifest “$manifest”;

  15. oyoy says:

    I am novis in this area, but would really learn how to download NRK content. I am able to open the debug window and find the url looking for “manifest”. I hav allso fond the Adobe script. But I have no idea what to do with the script :-) Do I need a seperate program, like VLC, or am I supposed to do something within Firefox? Thank’s for teaching a todler.

  16. tengil says:

    First: Tusen takk. Funker som en kule!

    But there is a glitch in the nrk-subtitles script. The NRK timecodes are not interpreted correctly. Actually I think it’s a bug at NRK’s side but there’s little to do about that.

    The milliseconds fragment is not what it looks like. The ss.fff is not a floating second. As long as there’s three digits after the decimal point all is well but something like 00:00:12.60 is not the same as 00:00:12.600. It’s actually 00:00:12.060!

    It will create overlapping subtitles in the srt. In this video:
    it creates overlaps between subtitles 10/11 and 15/16 (and many more).

    Both VLC and Quicktime player have problems with the overlapping subtitles.

    This code fixes the problem:

    if ($token->as_is =~ /
    59.999) {
    $tess -= 60;
    if ($temm > 59) {
    $temm -= 60;

    my $start = sprintf(“%02d:%02d:%06.3f”, $bhh, $bmm, $bss);
    my $end = sprintf(“%02d:%02d:%06.3f”, $tehh, $temm, $tess);

    $start =~ s/\./,/;
    $end =~ s/\./,/;

    The two lines at the bottom is not part of the fix but they swaps the periods to commas which is the correct decimal separator for srt files.

  17. tengil says:

    Hey! There was of course parts of html in the code so most of it got left out. Afk now so will repost tomorrow…

  18. tengil says:

    See my changes to fix the “timecodes” here:

  19. Falkeklubben says:

    Along with some of the suggestions in this thread I’ve made this little script which downloads video + subtitles + chapters and repackages it into an MP4 or MKV. Works on tv.nrk and the new radio.nrk beta as well as “nrk skole” and on some other pages nearby. Can also download program review (“omtale”) and some other stuff:

  20. Peter says:

    I would like to download the following TV Serie

    I tried to use the instructions:

    I found your updated script in the comments but I have no clue how to execute it?

    I’m on Windows 8
    PHP running
    Perl running
    downloaded ffmpg

    Could you please point me in the right direction?

  21. ingvar says:

    Peter, I don’t do Windows, sorry. Perhaps some others in the comments may help?


  22. uvett says:

    I have been testing out Falkeklubben’s script a few times. While Invar’s script is o.k., this one seems to have greater potential. Check it out here:

  23. ski jumping fan says:

    Please, somebody give this video. Mp4 downloads ..
    I’m tired and does not give advice …

  24. Bjørn says:

    I downloaded your script and I’m trying it now. It seems to be working (still downloading) but, there is one thing I wonder about: Where can I cahange the default download directory? Now it is my home folder. Is there a line I can change or add to download to another directory as default?

    Suggestion: If the script is started without the url to the tv program, would it be possible to have it ask for it and wait for me to input the url? Then I could create a launcher on the menu panel in Ubuntu (Mate) and just copy & paste the url into the terminal.

  25. Thank you so much for this! Works great!

  26. Marian Apalaghiei says:

    First of all, many thanks to Ingvar for the instructions!

    For those trying to run the script on Windows, I have managed to do it on Windows 7. These are the steps:

    1. Download AdobeHDS.php from above.
    2. Download WAMP from here:
    3. Install WAMP. I chose the default location: C:\wamp.
    4. Include c:\wamp\bin\php\php5.4.16\ into PATH (environment variable), if you would like to run PHP from wherever you like, without specifying its whole path every time.
    5. Go to c:\wamp\bin\php\php5.4.16\php.ini and c:\wamp\bin\apache\Apache2.4.4\bin\php.ini and edit them. Search for “extension=php_curl.dll” and uncomment that line in both files.
    6. Run the command Ingvar gave in his post, but make sure you use double quotes for the manifest URL.

    Good luck!

  27. What about programmes with 2 or more parts? There’s an ajax that loads the other video, so the URLs are the same to the script, causing the issue.

    I’ve been trying to download this

    The downloader doesn’t recognize the ajax url for the second part

    Anyone figured this out yet?

  28. Peter says:

    Worked without Problems, but without subtitles.
    Used for Downloading at

  29. ingvar says:

    Peter, yeah, the subtitles part is NRK specific.


  30. Eirik Garatun says:

    Why not just go to and change playback mode to “Link til avspilling med HLS”. Now when you click on play you will download a file containing links to stream the show in different resolutions. If you want to save the file you can do that in VLC.

  31. ingvar says:

    Eirik, that works nicely, and if you would like a non-flash player (and can’t use HTML5), that is probably the best way to watch by streaming. But if you like to download and keep the file for offline use, streaming to file will be done in real time, like the old fashioned “press record and play on tape”. Nothing wrong with that, but AdobeHDS supports real downloading, and even parallell downloading of fragments, so you may max out your bandwith and save time.

    In short: Downloading a 2 hours movie by streaming to disk: 120 minutes. Downloading the same file by AdobeHDS: 1-10 minutes, depending on your network connection.


  32. darius_w says:

    Hei, jeg kjører linux-gentoo og har med hell lastet ned flere nyttige og pedagogiske program fra nrk, og det gjør jeg forsåvidt enda, men har i det siste fått feilmelding når jeg forsøker å laste ned subtitles:

    “perl /usr/bin/nrk-subtitles-2 > murdoch-1.srtCould not fetch content from ( at /usr/bin/nrk-subtitles-2 line 18″

    Noen ide om hva som er feil? Jeg har forsøkt å laste ned en oppdatert versjon av scriptet (derav navnet nrk.subtitles-2).

    mvd idar

  33. CandorZ says:

    Never mind…
    I used the following command to combine the segments/parts offline.

    For files: MyVideo-Seg1-Frag1.f4f, MyVideo-Seg1-Frag2.f4f………MyVideo-Seg1-Frag99.f4f


    php AdobeHDS.php MyVideo-Seg1-Frag

  34. ingvar says:

    Hei, darius_w

    “Could not fetch content” betyr nok at du bruker en utdatert versjon av skriptet. Dette her kjører helt fint hos meg:

    $ mv nrk-subtitles nrk-subtitles.broken
    $ wget
    $ perl nrk-subtitles >
    $ head
    00:00:00,000 --> 00:00:00,000
    Copyright (C) NRK

    00:00:01,480 --> 00:00:04,580
    Rupert Murdoch skaper
    sterke motsetninger ...


  35. godztian says:


    For Windows brukere der ute, kan jeg opplyse om at jeg har laget et VBScript som laster ned video fra (Laster ned alle TS-filene og merger dem til en stor TS-fil), laster ned tekst (XML-fil). Deretter konverterer den XML-filen til SubRip (*.srt), og deretter muxer det hele til en MKV fil.

    Bruker følgende command line verktøy for å få jobben gjort: url2disk.exe, SubtitleEdit, og MKVToolNix.

    Eneste input scriptet trenger, er URL til video-siden til NRK. (Altså copy-paste URL fra adresselinjen i nettleseren)

    Hvis noen er interessert, ta kontakt.

  36. godztian says:

    Scriptet laster kun ned HD-utgaven av videoen btw…

    Når MKV-filen er opprettet, kan man selvfølgelig slette *.TS, *.XML og *.SRT. Alt man trenger er i MKV-filen.

  37. Paresh says:

    Help! I don’t know what’s happening! Successfully installed PHP on my Windows 7.
    Now when I run the command :

    php AdobeHDS.php –delete –manifest “,128000,256000,512000,712000,.mp4.csmil/manifest.f4m?hdnea=st=1389557398~exp=1389557428~acl=/*~hmac=63d875235a7c5c611ba06affb947509268006f9ab3e0f879b2c3b200ae129730&hdcore=2.11.3&g=TRQEYFSRHNRX”

    A LOT of writing appears in the command prompt window which ends like this :

    © 2014 GitHub, Inc.

    Something went wrong with that request. Please try again.

    What do I do?

  38. Paresh says:

    HEY GUYZ! It was the HTML code that appears in the command window after I execute the command!
    (see above comment)

  39. Paresh says:

    Hey! Got my problem solved :P

    But I still can’t download a single video! It says :
    Access denied! Unable to download the manifest.

    What do I do???

  40. ingvar says:

    Hey, Paresh. I don’t do Windows. Try godztian’s script perhaps?


  41. Paresh says:

    Where will I get that? You mean another “script”?

    I still can’t figure out my problem. Wanna download many videos from .

    I’ve been trying the whole day but it says “Access denied! Unable to download the manifest.”

    Tried it on so many different videos.
    Oh please someone tell me when will the command work?!

    php AdobeHDS.php –delete –manifest “,128000,256000,512000,712000,.mp4.csmil/manifest.f4m?hdnea=st=1389643037~exp=1389643067~acl=/*~hmac=85a87540239856218bc4b6904b5391df74415f0d32fa99b15c4266537269cc7d&hdcore=2.11.3&g=ORDXPCUOEINB”


    php AdobeHDS.php –delete –manifest “,128000,256000,512000,712000,.mp4.csmil/manifest.f4m?hdnea=st=1389643529~exp=1389643559~acl=/*~hmac=304d5ba144ab01c2a510db69dad9f1993c2f07a3ab17faf839e0f3572eb8fd83&hdcore=2.11.3&g=EQMMQJUYKFUY”

    Any mistakes? Any suggestions?

  42. Paresh says:

    Ingvar and all!
    I found it a way out!
    Using Windows 7!
    When I paste this in the address bar :,128000,256000,512000,712000,.mp4.csmil/manifest.f4m

    I get an Access Denied page saying that I don’t have permission to the manifest.f4m file.

    Then, I downloaded the flash video downloader add-on for Firefox which catches all flash content on the web page. It detected all the fragments of the video one by one. When the video was completely played once. I got all the links of fragments in the add-on. I downloaded them one by one (because all the names of files are the same and if I download all the fragments at once, each will replace the other and only the last fragment gets saved.

    After downloading the fragments, I renamed them to 1.f4f , 2.f4f , etc.. upto the last fragment.

    Got all the fragments and the AdobeHDS.php in a folder, executed the command :

    php AdobeHDS.php

    and BOOM! Got my video merged into an FLV file without any glitches. Superb. Downloaded a video who’s manifest file is denied to access!

    Please if anyone could post this method on !
    Thanks to Ingvar for this post!! :)

  43. P Carol says:

    How do i make contact with this person Godztian???

    He says…


    For Windows brukere der ute, kan jeg opplyse om at jeg har laget et VBScript som laster ned video fra (Laster ned alle TS-filene og merger dem til en stor TS-fil), laster ned tekst (XML-fil). Deretter konverterer den XML-filen til SubRip (*.srt), og deretter muxer det hele til en MKV fil.

    Bruker følgende command line verktøy for å få jobben gjort: url2disk.exe, SubtitleEdit, og MKVToolNix.

    Eneste input scriptet trenger, er URL til video-siden til NRK. (Altså copy-paste URL fra adresselinjen i nettleseren)

    Hvis noen er interessert, ta kontakt.

    All the best,


  44. J says:


    Is it possible to enable type 10, 11, 40 and 41 in this script? Thanks.

  45. snippsat says:

    Kildekoden er selvfølgelig åpen.

    - Last ned “wx_nrk…zip” pakk ut dit man ønsker
    - Start “drag_drop.exe”.
    - Dra fra url adresse eller video tumbnails (NRK-TV) inn i GUI-vinduet (husk å få med http://).
    - Velg videokvalitet (“High” er default).
    - Laster (stream ffmpeg) ned automatisk til video format (mkv), parser for undertekster (srt) lages.
    - Video(mkv) og undertekster (srt) får samme navn som tittel på NRK-TV.
    - Mulig og dra flere url adresser til GUI,”Threading” deling av båndbredde ved nedlasting.
    - Ingen ekstra nedlastinger/installasjon er nødvedig, Python og ffmpeg er pakket i mappe wx_nrk_…
    - wx_nrk_32 for Windows 32bit
    - wx_nrk_64 for Windows 64bit.
    - Nedlasting av valgte NRK stream starter automatisk og filene som lastes ned legges i samme katalog som “drag_drop.exe”.
    - Spill av filene som lastes ned i VLC media player, MPC-HC eller andre avspillere

  46. gh0st85 says:

    I use the helper scripts because it is not possible to get any results in the Firefox debugger without flash.
    The flv “succesfully”[0] downloads but the srt always ends up empty.

    I followed these steps:
    $ mkdir ~/Desktop/
    $ cd ~/Desktop/
    $ wget -O AdobeHDS.php
    $ wget -O
    $ wget -O
    $ sed -i ‘s/~\/bin\/nrk-subtitles/~\/Desktop\/\/’
    $ sed -i ‘s/~\/bin\/AdobeHDS.php/~\/Desktop\/\/AdobeHDS.php/g’
    $ chmod +x
    $ ./ [url]

    [0] The same problem Sveinn Davidsson reported[1], it only downloads the first part.


Leave a Reply