I was working on something like that and I used this command:
ffmpeg -y -f alsa -i default -f v4l2 -i /dev/video0 -acodec aac -strict -2 -ac 1 -b:a 64k -vcodec libx264 -b:v 300k -r 30 -g 30 prueba1.mp4
At the beginning I was having trouble with hw:3
component. Instead of that I put in default
and the code actually worked. I hope this helps.
FFmpeg has three concatenation methods:
Use this method if your inputs do not have the same parameters (width, height, etc), or are not the same formats/codecs, or if you want to perform any filtering.
Note that this method performs a re-encode of all inputs. If you want to avoid the re-encode, you could re-encode just the inputs that don't match so they share the same codec and other parameters, then use the concat demuxer to avoid re-encoding everything.
ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv \
-filter_complex "[0:v] [0:a] [1:v] [1:a] [2:v] [2:a] \
concat=n=3:v=1:a=1 [v] [a]" \
-map "[v]" -map "[a]" output.mkv
Use this method when you want to avoid a re-encode and your format does not support file-level concatenation (most files used by general users do not support file-level concatenation).
$ cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
For Windows:
(echo file 'first file.mp4' & echo file 'second file.mp4' )>list.txt
ffmpeg -safe 0 -f concat -i list.txt -c copy output.mp4
Use this method with formats that support file-level concatenation
(MPEG-1, MPEG-2 PS, DV). Do not use with MP4.
ffmpeg -i "concat:input1|input2" -codec copy output.mkv
This method does not work for many formats, including MP4, due to the nature of these formats and the simplistic concatenation performed by this method.
If in doubt about which method to use, try the concat demuxer.
Also see
Best Answer
Replace audio
-map
option allows you to manually select streams / tracks. See FFmpeg Wiki: Map for more info.-c:v copy
to stream copy (mux) the video. No re-encoding of the video occurs. Quality is preserved and the process is fast.-c:v copy
to-c copy
to stream copy both the video and audio.-c:v copy
/-c copy
.-shortest
option will make the output the same duration as the shortest input.Add audio
-map
option allows you to manually select streams / tracks. See FFmpeg Wiki: Map for more info.-c:v copy
to stream copy (mux) the video. No re-encoding of the video occurs. Quality is preserved and the process is fast.-c:v copy
to-c copy
to stream copy both the video and audio.-c:v copy
/-c copy
.-shortest
option will make the output the same duration as the shortest input.Mixing/combining two audio inputs into one
Use video from
video.mkv
. Mix audio fromvideo.mkv
andaudio.m4a
using the amerge filter:See FFmpeg Wiki: Audio Channels for more info.
Generate silent audio
You can use the anullsrc filter to make a silent audio stream. The filter allows you to choose the desired channel layout (mono, stereo, 5.1, etc) and the sample rate.
Also see