Development

FFmpeg choosing stream to download

With most online streams, decent ones at least you can choose the quality. The stream quality is mostly bit rate and resolution based. Lowering the resolution means you can lower the bit rate significantly and less bit rate means less data being transferred thus allowing slower or congested networks able to stream.

To get a stream or video sources information you use

ffmpeg -i "input"

This will return all types of information from bit rate, fps, codec, resolution, duration, audio information and subtitles.

But for this post we are interested in the “streams” section, its at the bottom of the returned output and looks like this:

Variant bit rate is the bit rate in bytes, noting that it is variant.

Stream #0:0 references the stream. In this case its a data stream of some type (timed_id3). The Streams can be video, audio, subtitle, information, metadata or some other facet.

You can see the video streams here because they say Video: it lists the codec, resolution, ratio, fps and time bases.

Similar for Audio: as you see details. Mostly the audio wont change as the video does.

Lets say we want to get the 360p video. This is Stream #0:10 we will also pair it with the respective Audio stream which is Stream #0:11 essentialy to represent this selection in FFmpeg use -map the command would look like this:

ffmpeg -i "https://inputurlstream.m3u8" -map 0:10 -map 0:11 -c copy small_output.mp4

The -map command references the stream id.

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

1 year ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

1 year ago

FTP getting array of file details such as size using PHP

Using FTP and PHP to get an array of file details such as size and…

2 years ago

Creating Laravel form requests

Creating and using Laravel form requests to create cleaner code, separation and reusability for your…

2 years ago

Improving the default Laravel login and register views

Improving the default Laravel login and register views in such a simple manner but making…

2 years ago

Laravel validation for checking if value exists in the database

Laravel validation for checking if a field value exists in the database. The validation rule…

2 years ago