ffmpeg merge videos
If you have a large number of videos in a directory, it might be easier to write a command that will create a file with the list of videos for you before concatenating them. To determine the order that the videos will be listed, you can name them alphabetically or numerically.
#mp4
for f in *.mp4; do echo "file '$f'" >> files.txt; done
#mp3
for f in *.mp3; do echo "file '$f'" >> files.txt; done
The above will create a file videos.txt with a list of files with the extension .mp4. After the file is generated, you can then stitch the listed video with the command we used earlier:
#mp4
ffmpeg -f concat -i files.txt -c copy output.mp4
#mp3
ffmpeg -f concat -i files.txt -c copy output.mp3
Merge videos with the concat protocol
You can also join videos with the concat protocol. The following code stitches four videos without re-encoding them.
ffmpeg -i "concat:input1.mp4|input2.mp4|input3.mp4|input4.mp4" -c copy output.mp4
Convert MP4 To MP3 With FFmpeg
Command
The most basic command line is this:\
$ ffmpeg -i video.mp4 audio.mp3
with assumption the video filename is video.mp4 and the result audio filename is audio.mp3.\
Command Variations
By default, bitrate of resulting audio is 128kb/s. It's known that same audio with smaller bitrate has smaller file size. You can compress audio file size by reducing the bitrate. However, please note that smaller bitrate represents lower audio quality.
To make it 64kb/s:\
ffmpeg -i video.mp4 -b:a 64K audio.mp3
To make it 32kb/s:\
ffmpeg -i video.mp4 -b:a 32K audio.mp3
To make it 16kb/s:\
ffmpeg -i video.mp4 -b:a 16K audio.mp3
thus, the option to determine a bitrate is -b:a and the notation is [number][K].