How to trim HLS or MEPG-DASH video using FFmpeg?

I have one HLS video URL and I want to trim the video from 30 seconds to 2 minutes and 30 seconds, how do I do that using FFmpeg?


Hey Annie!

Basically, FFmpeg provides a two-parameter for trimming the video.
-ss option allows you to seek video at a particular position it takes value in HH:MM: SS format or in absolute seconds.
-t options allow you to read a specified number of seconds from the video, taking value in the same format as “ -ss “. So with the combination of both -ss and -t you can trim an HLS or MPEG-DASH video.

You can use the following FFmpeg commands to cut the video.

Let’s assume that I want to trim a video to the first 30 seconds and there is only one video and audio stream in the video.
ffmpeg -i <HLS/MPEG-DASH Video URL> -ss 0 -t 30 -c copy -bsf:a aac_adtstoasc -f mp4 output.mp4

This is all to trim videos and this is how you can merge those videos using ffmpeg.
I hope this may resolve your issue!

Thankyou :smiley:

Great! It works for me.

How can FFmpeg be utilized to handle additional tasks, such as adding or replacing metadata, when trimming HLS or MPEG-DASH videos, and what impact might these tasks have on the overall streaming workflow?

Sail, in addition to simple trimming, FFmpeg has flexible capabilities that let users change or replace metadata as the file is being trimmed. For example, users can use the FFmpeg command with the -metadata title=“New Title” option to add metadata to a trimmed movie. This can be especially helpful when it comes to updating data about the video material.

It’s important to remember, too, that adding new jobs, like metadata modification, could have an effect on the streaming workflow as a whole. The jobs selected should be in line with the unique needs of the streaming service and the expectations of the audience.
For instance, upgrading or adding metadata can improve the video’s classification and accessibility, but it may also lengthen processing time.

Beyond trimming, FFmpeg offers several features that help improve the workflow related to managing the video and metadata when streaming. Content providers can improve classification and searchability by updating information related to their videos by adding or removing metadata.

All new tasks added to the FFmpeg process, however, have to be taken into account. For example, adding information may improve the viewing experience but can somewhat increase processing time. The advantages of these extra responsibilities should be weighed against any possible trade-offs in processing efficiency by content authors.

To sum up, FFmpeg’s versatility goes beyond basic editing, allowing users to customize films to meet particular streaming needs. To establish a balance between improved functionality and overall workflow, users should carefully consider the effects of new activities.

For more visit: