A program for saving audio from the Internet. We save audio from the Internet to files

This question occurs very often, so I decided to devote a separate article to it in the lessons. Since HTML does not have a universal technology for playing audio for all browsers, to solve this problem I propose to download the audio player file, as is done on most sites. We do everything in steps:

1. On the hosting, where your site is located, in the root directory (the folder where the index file is), create the audio folder. In the future, you will place all audio files in it.

3. Now select the files you want, preferably in mp3 format. Create a folder audio at the root of the site and upload them.

4. All that remains is to insert the player connection code. It is suitable for any site In the right place, you just need to specify the path to the player file and the audio file, replacing the words accordingly your_domain and audio_file_name:






And you're done! You can also see the work example.

How to set background music in html

Using the capabilities of HTML and the browser, you can also insert background music on the page. You will need an audio file of the correct format: WAV, AU, MIDI or MP3. You can use any file with the specified extension as an example.

The first way is the embed tag. The embed element is used to load and display objects (for example, video files, flash movies, some sound files, etc.) that the browser does not natively understand.

The syntax is pretty simple:

No closing tag required.

Now let's look at an example of a record with attributes, and below with their decoding:

Embed tag attributes for playing audio in html
width - the width of the panel in pixels (or percentage)
height - the height of the panel in pixels (or percentage)
align - the position of the panel relative to the text, possible values ​​are left, right, center
hidden - allows you to hide the panel, attribute values: true - the panel is hidden, false - the panel is visible (default value)
autostart - value true - the player starts automatically when the page is loaded, false - waits for the play button to be pressed
loop - loop, true - the track is played in a circle, and if false - only once

Second way. Very old, but also practical) Add the melody to the same folder (directory) where your file is, and in the body write the following code:


As a result, after loading the page, the melody specified by you in the bgsound tag will sound. Now let's take a closer look at the attributes of the tag. :

src- path to your audio file
loop- how many times the melody to repeat (if -1, then it repeats endlessly)
balance- stereo balance value (from -10000 to 10000)
volume- the volume of the melody playing, where 0 is the maximum, and -10000 is the minimum.

However, it will not be possible to control the player in any way - each time the page is refreshed, the track will be played again.

After describing the method of inserting background music, I want to dissuade you from this, since the majority of users at the time of visiting various sites already, as a rule, listen to music. Therefore, accompanying music can only force him to close the tab with the site.

Insert audio and music in HTML5 - audio tag


audio- a paired tag that defines background sound, music or other audio stream on the site.

Audio tag attributes

autoplay- the file is played immediately when the page is loaded (similar to bgsound background music)
controls- display the player control panel in the browser
loop- plays the file again after its end
preload- the download of the audio file will happen along with the page load
src- path to the audio file (mp3 or ogg)

Sample code with the audio tag





The audio tag


Audio in HTML 5




However, Internet content is often unique, for example, it includes not only music, but also comments from artists, interviews, all sorts of stories about the creation, etc.

An incredible number of utilities have been created to download streaming content from the Web - some of them are universal, others are "sharpened" for certain services. Some programs get access to the original audio and video files and simply read them from the Internet byte-by-byte, and some can download, upload files in several streams, work with groups of files, etc. The description of a stream can be an xml file in the format ASX (for Windows Media Player) or stored in files of the RealAudio format (extensions .ra and .rm - for audio, .rv - for video), etc. Such streams are delivered not only via the standard http, udb / tcp protocols, but also via special - rtsp, mms, rtp, as well as through peer-to-peer technologies used, for example, in such a popular Internet TV service as SopCast. Naturally, to play these formats, you need an appropriate client - say, Windows Media Player, VLC media player, etc. The latter, by the way, can not only play streaming content, but also save it to local disks. We will use it, because most of the resources are quite tough for him.

So, in order to record, in particular, an online radio program or a podcast, you must first obtain a link to the streaming content, and then enter it into the VLC player. If your site uses Windows Media Player to play audio, it's easy to get to the link. You need to right-click on the built-in player on the site page and select "Properties". Find the address in the "Location" field and copy it to the clipboard. If the site uses a Flash player or a player developed on the basis of HTML5, then it is likely that you will have to dig into the source code of the page or turn to special utilities to “rip out” links.

The next step is converting streaming audio. Perhaps you can't say that this operation in VLC is simple and obvious. Rather, on the contrary, it is cumbersome and confusing. Using the "Media Open URL" menu command, streaming content can be written to a file. By default, VLC is configured to play a link, and in order to save it to a file, you need to change the mode to "Convert" in the dialog box that opens. The dialog will change - in a new window, the target file is indicated and the profile is selected (i.e., the format in which the recording will be saved). After clicking the "Start" button, the player starts copying the streaming audio to a file. He does this completely imperceptibly and, in principle, is able to write as long as he wants - this process will have to be controlled independently. It should be borne in mind that when you stop and continue the conversion process, the resulting file is reset to zero. So you need to rename the previously saved files.

It is quite obvious that repeating such an operation every time is very troublesome. Especially if you need to write different threads at different times. The VLC player provides the simplest scheduled download tool called the VLC Configurator. It indicates what and where to write (these parameters are configured in the same way as described above) and for how long. For example, if you need to record a certain Internet radio program on a daily basis, you should set the options "Repeat" and "Interval between repeats" in the dialog. Now the program, after launch, will independently convert streaming content.

By the way, VLC will also help when converting streams, for example, ASF files into a more familiar and understandable MP3 for pocket players. This operation can be done either manually, each time converting a local file, or automatically using a simple script in Powershell, which is known to be included in Windows 7 and available in earlier versions of this operating system. Several parameters are passed to the script - the path to the files, the file mask and, optionally, the resulting folder where the files are stored (if it is not specified, the files are written to the source directory). Inside the loop, the VLC program is called, to which the parameters are sent: what to encode, where to write, and the actual encoding parameters. At the end of encoding, VLC is unloaded from RAM. The last construct, which is waiting for the process to be unloaded from memory, allows you to verify this. You can enter such a script in any text editor - notepad or a special "visual" Powershell ISE editor. If you save it in a file, for example convert.ps1, then it starts with a construction like:

... convert.ps1 c: files music * .asf.

In conclusion, it is worth noting a few more features of the script. The Windows operating system does not automatically register paths to programs, so the script must also specify the path to vlc.exe: in the 64-bit version - C: 'Program Files (x86)' VideoLAN VLC (note that lines with spaces are enclosed in quotes) and in 32-bit - C: 'Program Files' VideoLAN VLC. In addition, you should make sure that you left the VLC program before running the script, otherwise the waitforexit () method will run indefinitely (due to the fact that the program called in the script exits, but its copy remains). Of course, it is also permissible to handle process identifiers in the script, but such a possibility will only complicate it. To solve this problem, you should simply add to the beginning of the script the forced termination of all running VLCs: ps vlc * | % ($ _. kill ()). Another feature is related to the Windows 7 security system, which requires all scripts to be signed. The Set-ExecutionPolicy RemoteSigned command, which must be run in Powershell as an administrator, will help to get around this limitation.

Ps1 script on Powershell to convert streaming content to MP3

param ($ inputpath, $ wildcard, $ outputpath = $ inputpath)

ls -path $ inputpath $ wildcard | % (

write-host $ outputfile

vlc -i dummy $ _. fullname ¨: sout = # transcode (acodec = mp3, ab = 128, channels = 2): standard (access = file, mux = asf, dst = $ outputfile) ¨ vlc: // quit

Extract audio from FLV clips

Another example of how VLC and Powershell can be used together is extracting audio from Flash videos in FLV format. Such video clips are stored on specialized portals, such as, for example, the notorious YouTube. Of course, Google and other video hosting owners in every possible way prevent the download of content, but there are always ways to bypass the protection and get your favorite video ...

However, the problem discussed here is as follows: how to extract audio from an FLV file loaded by any known method in order, for example, to listen to it in a pocket player. Such an operation is quite within the power of VLC, both in the GUI and from the command line. By the way, in the first case, you need to do almost the same set of actions as before: select the "Media - Convert / Save" command from the menu, specify the source and destination files, as well as the conversion parameters, that is, the appropriate codec.

To convert manually using Powershell, just like last time, you need to construct a small script (let's call it flv2mp.ps1) to which the names of the source and destination folders are sent (by default, the same as the source). All its trick lies in the passed parameters: since video is not required, you should use the dummy parameter, define the file parameters in the standard block, and so that the script does not bother with pop-up windows, simply block them with the –dummy-quiet –sout option.

param ($ inputpath, $ outputpath = $ inputpath)

ls -path $ inputpath * .flv | % (

$ outputfile = join-path $ outputpath ($ _. name.replace ($ _. extension, ‘.mp3’))

write-host $ outputfile

vlc $ filename -I dummy --dummy-quiet --sout ¨ # transcode (acodec = mp3, vcodec = dummy): standard (access = file, mux = raw, dst = ’$ outputfile’) ¨ vlc: // quit

ps vlc | % ($ _. waitforexit ())

HTML language
Insert audio and video


Insert sound. Tag
Adds, plays and manages audio recording settings on a web page. The file path is specified through the attribute src or nested tag .


Syntax:


Several

Tag attributes

    autoplay- the sound starts playing immediately after loading the page;

    controls- adds a control panel to the audio file;

    loop- repeats sound playback from the beginning after its completion;

    preload- used to download a file along with loading a web page;

    src

The end tag is required.
Inside the container

Example:


Insert video. Tag
Adds, plays and manages video settings on a web page. The file path is specified through the attribute src or nested tag .


Syntax:


Several items can be linked to different files. The browser will use the first format it launches.

Tag attributes

    autoplay- the video starts playing automatically after loading the page;

    controls- adds a control panel to the video;

    loop- repeats video playback from the beginning after its completion;

    height- sets the height of the area for video playback;

    width- sets the width of the area for video playback;

    preload- used to download video along with loading a web page;

    src- indicates the path to the file being played.

The end tag is required.
Inside the container


Example:


Example result in browser:

Hello everyone. Andrei with you.

In this release, we will learn how you can connect sound to HTML page, i.e. audio format files to your site.

There are 3 methods of embedding sound files.

By clicking on this link, a standard program for playing files of the specified format is automatically launched, usually Windows Media (plays AIFF, AU, MIDI, WAV and MP3 files). This option is familiar to you, so let's move on.

Second the way is to use a container .

This container allows for listening with playback tools displayed directly on the web page, but the playback console may look different in different browsers.

In order for this container to be displayed, a special plugin must be installed in the browser. In Internet Explorer, it is on by default, but as for other browsers, not all of them may have it. Then you have to install it.

XHTML

The src parameter is required, specifies the name of the file to play. The rest of the parameters can be omitted. A list of them is given below.

WIDTH = n- defines the width of the console in pixels.

HEIGHT = m- defines the height of the console in pixels.

AUTOSTART = TRUE | FALSE- if TRUE, playback starts automatically.

AUTOLOAD = TRUE | FALSE- if set to FALSE, the file is not loaded automatically.

STARTTIME = "mm: ss"- playback starts from the moment specified in minutes seconds from the beginning of the file.

REPEAT = TRUE / FALSE- allows or prohibits repeating a sound / video clip.

PLAY LOOP = Z- if you specified REPEAT-TRUE, specify here the number of repetitions instead of Z.

VOLUME = percentage- playback volume, indicated as a percentage of the maximum.

ALIGN = "value"- Aligns the management console in relation to the page text. Can be CENTER, BASELINE TOP LEFT, RIGHT.

CONTROLS = "value"- sets a set of console controls. Can have the following values ​​(explained below) -CONSOLE, SMALLCONSOLE, PLAYBUTTON PAUSEBUTTON, STOPBUTTON, and VOLUMELEVER.

CONSOLE- a full set of controls.

SMALLCONSOLE- compact view of the console. Full set of controls, except for the pause button.

PLAYBUTTON- only play button.

PAUSEBUTTON- only the pause button.

STOPBUTTON- only stop button. This unloads the file.

VOLUMELEVER- only volume control.

We figured out the parameters.

I suggest you try the different parameters yourself and see how they work (there is nothing complicated here).

Third the way is to specify the sound file as the background sound for the page.

The syntax is simple:

src = filename- sound file

loop = n- number of repetitions (infinite - continuously)

volume- volume (from 10000 to 0.0 - default value)

balance- balance between the left and right speakers, the value can vary from -10000 (maximum for the left channel) to 10000 (maximum for the right channel).

Description

Adds, plays and manages audio recording settings on a web page. The file path is specified via the src attribute or a nested tag. Inside the container

The list of codecs supported by browsers is limited and is shown in table. one.

Tab. 1. Codecs and browsers
Codec Internet Explorer Chrome Opera Safari Firefox
ogg / vorbis
wav
mp3
AAC

For universal playback in the specified browsers, audio is encoded using different codecs and files are added simultaneously via the tag .

Syntax

Attributes

The sound starts playing as soon as the page loads. Adds a control bar to the audio file. Repeats the sound from the beginning after it ends. Used to upload a file along with loading a web page. Specifies the path to the file being played.

End tag

Required.

HTML5 IE 8 IE 9+ Cr Op Sa Fx

audio

Alexander Klimenkov - Fourteen

The result of the example in the Opera browser is shown in Fig. one.

Rice. 1. Playing an audio file

Browsers

Audio playback controls vary between browsers in appearance, but the basic elements are the same. These are the play / pause button, track length, elapsed and total playing time, and volume level.