0

I will be posting a how-to guide as an answer to this question. It will demonstrate how to accomplish the above task, while meeting five requirements that at first seemed difficult to achieve:

  1. I needed to do this with a minimal set of software tools, preferably free and even better if open source. The ones I used are listed below.

  2. I wanted to convert the audio file from m4a to mp3.

  3. I wanted to edit the audio to trim it at both ends and possibly to also remove some bits in between.

  4. It is possible to create a video (e.g. mp4) file with only an audio track and no video track, but YouTube will not accept such a file. At a bare minimum, YouTube requires at least a single, still image to accompany the audio track.

  5. Saving the audio stream to a file is fairly easy, but the file would need to undergo some subsequent processing for steps 2 to 4, and just loading a 2.5-hour audio file into an editor can be quite time-consuming, so ideally it would be preferable to just download the half-hour segment in the middle that I wanted. That segment commences at time ~1:34:00.

0

How to record part of an HLS-streamed audio and upload it to YouTube as an audio podcast

This "how-to" information is a guide to how I managed to meet five requirements related to this task, which at first seemed difficult to achieve. They are listed below:

The podcast I wanted to create is of a half-hour segment in the middle of a 2.5-hour radio program, which, for only a limited period (1 week) after the broadcast date, can be streamed from the radio station's website. It is an HLS stream. My specific requirements for this task were:

1) I needed to do this with a minimal set of software tools, preferably free and even better if open source. The ones I used are listed below.

2) I wanted to convert the audio file from m4a to mp3.

3) I wanted to edit the audio to trim it at both ends and possibly to also remove some bits in between.

4) It is possible to create a video (e.g. mp4) file with only an audio track and no video track, but YouTube will not accept such a file. At a bare minimum, YouTube requires at least a single, still image to accompany the audio track.

5) Saving the audio stream to a file is fairly easy, but the file would need to undergo some subsequent processing for steps 2 to 4, and just loading a 2.5-hour audio file into an editor can be quite time consuming, so ideally, it would be preferable to just download the half-hour segment in the middle that I wanted. That segment commences at time ~1:34:00.

The Software I used is listed below. (There are four items.) Note: Although some of this software is cross-platform, I did this all on Windows 7 and Firefox web-browser 53.0.2.) I cannot guarantee results on other platforms, and some of the instructions below may need slight modification for other browsers.

  • VDH (Firefox extension: Video DownloadHelper 6.3.1.) (Also available for Chrome browser.)

  • VLC Media Player 2.2.4

  • Audacity 2.1.2

  • FFmpeg

Check the folder in which FFmpeg is installed. If it does not contain a file named ff-prompt.bat, create one (it is a text file) by following the instructions given by Maxime here:

https://disqus.com/home/discussion/mrfdev/ffmpeg_command_generator/newest/#comment-3264465301

In this how-to, I will use the example of the website and audio stream that I worked on. YMMV if you are trying this with a different audio source.

The radio Program is: ABC Radio Melbourne: "Mornings with Jon Faine" There is a list of past episodes of that show here:

http://www.abc.net.au/radio/melbourne/programs/mornings/episodes/%20(http://www.abc.net.au/radio/melbourne/programs/mornings/episodes/)

Those that are no more than a week old are streamable. (Streaming might be geo-blocked in some countries.)

PROCEDURE: (This is divided into three parts: Downloading, Editing, and Creating a video)

(1) DOWNLOAD THE AUDIO:

On the past episodes webpage, find the relevant program and click the link to go to that program's page, where you will see a player, with a play icon labelled "Listen."

What you need now is the streaming playlist for this audio content. There are two methods for getting this: The easy way (method a below) is to use the browser extension VDH. If you don't have it, use method b below.

Method (a) (Use this if you have the browser extension VDH mentioned above):

  • Click the play icon to start the stream,

Wait for the audio to start playing. When it does,

  • Click the VDH icon to open its menu.

  • In the VDH panel, hover the mouse cursor over the item of interest. A right-arrow will appear to its right.

  • Click the right-arrow to the right of that item, and choose "Copy URL"

    (This copies the media URL to the clipboard.)

  • You can now close the webpage containing the player.

The URL will be similar to this:

http://abcradiomodhls.abc-cdn.net.au/i/local_melbourne/audio/abf-2017-05-16.m4a/index_0_a.m3u8?null=0

  • Open a new browser tab and paste the media URL into the web-browser’s address bar and go to that address.

Continue at (c) below.

Method (b) (Use this method if you don't have the VDH browser extension.)

  • Open the source HTML for the webpage containing the player.

    (To do this in Firefox, right-click on a blank area of the page and choose "View Page Source.")

The HTML source code for that webpage should open in a new browser tab.

It will contain three lines similar to this:

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=130000,CODECS="mp4a.40.2",CLOSED-CAPTIONS=NONE
http://abcradiomodhls.abc-cdn.net.au/i/local_melbourne/audio/abf-2017-05-16.m4a/index_0_a.m3u8?null=0

The third line is a URL.

  • Copy it and paste it into your web-browser's address bar, and go to that address.

(c) Continue here from either (a) or (b) above:

An "Open/Save file" dialog box opens for a file named index_0_a.m3u8.

  • Save the file.

That type of file is a plain-text file containing an audio playlist that tells players where media files are located.

  • Open the file in a text editor.

Its contents will look similar to this:

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:10.000,
http://abcradiomodhls.abc-cdn.net.au/i/local_melbourne/audio/abf-2017-05-16.m4a/segment1_0_a.ts?null=0
#EXTINF:10.000,
http://abcradiomodhls.abc-cdn.net.au/i/local_melbourne/audio/abf-2017-05-16.m4a/segment2_0_a.ts?null=0

... <snip> ... (for a 2.5-hour stream, there will be about 900 pairs of lines here)

#EXTINF:8.997 http://abcradiomodhls.abc-cdn.net.au/i/local_melbourne/audio/abf-2017-05-16.m4a/segment900_0_a.ts?null=0
#EXT-X-ENDLIST

The above file contains URLs for 900, 10-second audio segments, numbered 1 to 900. For each segment, there is a pair of lines:

The first line in each pair consists of the text: "#EXTINF:10.000".

The second line in each pair contains the URL for the audio segment.

Now, in the text-editor, you will remove the segments listed below by deleting the pair of lines for each segment to be deleted.

  • Remove segments 1 to 563 (i.e. the first ~94 minutes)
  • Remove segments 834 to 900. (the last 11 minutes)

(Be careful to leave intact the last line reading: #EXT-X-ENDLIST)

This leaves 270 segments in the middle (the 45 mins commencing at ~1:34:00.)

  • Save the edited file as, say, A.m3u8

(d) You will now use VLC to stream the desired audio excerpt and save it as an MP3 file.

Open VLC media player, and in the VLC menu:

  • click: "Media", then "Convert/Save..."

In the "Open Media" dialog-box, in the File tab,

  • click "Add"

In the select files Dialog-box,

  • find and select the file A.m3u8,

Back in the "Open Media" dialog-box,

  • click "Convert/Save"

In the "Convert" dialog-box,

  • at "Profile" choose "Audio - MP3",

  • at "Destination file:" click "Browse"

In the "Save file..." dialog-box,

  • browse to desired folder and enter a filename for the mp3 file,

  • click "Save"

Back in the "Convert" dialog-box,

  • click "Start".

VLC will (silently) stream the media and save it as an MP3 file.

(While doing so, the time-slider bar acts as a progress bar.)

(2) EDIT THE AUDIO:

If necessary, edit the MP3 in your favourite audio editor to trim it at the beginning and end, and/or to remove unwanted bits from the middle, then export the edited version as a new MP3. I used Audacity to do this. An explanation of how to do this in Audacity is beyond the scope of this article. The good news is that if the editing of the playlist in part 1 resulted in a sufficiently precise excerpting of the portion of the audio stream you wanted to save, this step may be unnecessary.

(3) COMBINE AN IMAGE AND THE AUDIO INTO A VIDEO:

This method uses FFmpeg. It comes from Ed Mann. It is explained more fully here:

http://eddmann.com/posts/uploading-podcast-audio-to-youtube/

This example assumes that FFmpeg is installed in C:\Apps\FFmpeg.

  • Copy the audio file and a jpg file for the image you want displayed in the video track into the folder C:\Apps\FFmpeg\bin. Name them input.mp3 and image.jpg

  • Open a command prompt and enter the three commands listed below:

Line 1 makes the folder containing FFmpeg the current directory.

Line 2 runs the comand file FF-prompt.bat.

Line 3 passes a customised command to FFmpeg that makes it combine the two files into a video file named Output.mkv. If you prefer the output file to be MP4, just change the last three letters in line 3.

CD "C:\Apps\FFmpeg"

FF-prompt.bat

ffmpeg -loop 1 -r 2 -i image.jpg -i input.mp3 -vf scale=-1:380 -c:v libx264 -preset slow -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p -threads 0 output.mkv

Wait for the command to complete. When it does, your video file will be ready for uploading to YouTube. You will find it in the "bin" subfolder where FFmpeg is installed. (In this example, it will be in: C:\Apps\FFmpeg\bin.)

Here is an example result:

https://www.youtube.com/watch?v=k01yREFsYTs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.