Categories: 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…

2 years ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

2 years ago

Early September spring shots

Some early September spring shots from a bushwalk, It is still too early for wildflowers.

3 years ago

Cloning an NVMe to SK Hynix Platinum P41 NVMe

I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…

3 years ago

Using Laravel’s deleteDirectory to delete folders and their contents

If you ever needed a simple solution in Laravel to delete an entire directory and…

3 years ago

How to allow only 1 user to register in a Laravel application

How to enforce only one user to register or be registered in a Laravel web…

3 years ago