Showing posts with label ffmpeg. Show all posts
Showing posts with label ffmpeg. Show all posts

Thursday, September 21, 2023

Extracting audio from video using ffmpeg

To extract audio from a video, here is the command

$ ffmpeg -i video.mp4 -q:a 0 -map a audio.mp4

whereby we supply the name of our video to using -i and put the name of the audio file at the end of the command.

If we want to extract only some part of the audio from the video, we can use below command
$ ffmpeg -i video.mp4 -ss 00:03:00 -t 00:00:45.0 -q:a 0 -map a audio.mp4

where -ss is the start time of the video, that we want to extract, and -t is the duration of how much time we want to extract from the -ss time. In the above example, the output will be an audio extract from a video called video.mp4, starting from the third minute, until 45 seconds after the third minute.  

Saturday, October 1, 2022

Splitting video using linux command line

To easily split (or cut some part) of video using command line, a tool called ffmpeg can be used.


Why use command line? Lighter on resource. Video editing is a high resource activity, and by using command line, we can reduce the resource used on our machine while doing video splitting, especially if we are using low resources machine. 

To install ffmpeg, on an debian based machine, just run below command
$ sudo apt -y install ffmpeg

To do the splitting, just use below command
$ ffmpeg -i mymovie.mp4 -ss 00:01:00 -t 00:00:30 myeditedmovie.mp4

where
-i is for which video to edit
-ss is for where in the video that you want to start
-t is for the duration of the output video

So in the above example, you will get an output called myeditedmovie.mp4, which start from the first minute of the original video, and will last 30 seconds.

Tuesday, November 2, 2021

Combining video and audio file into one using ffmpeg

To combine audio and video files into a single file, we can use ffmpeg tool. 

First, we need to install ffmpeg

$ sudo apt update && sudo apt install ffpmeg

Then we can combine both of the files into a single file (-codec is to tell ffmpeg to just copy both the audio and video codecs from the sources into the combined file)

$ ffmpeg -i audio.mp3 -i video.mp4 -codec copy audiovideo.mp4