The .mp4
container format doesn’t support the VP8 codec, which is commonly used in .webm
files. MP4 containers typically use the H.264 codec for video and AAC for audio.
You’ll need to re-encode the video using the H.264 codec and re-encode the audio using AAC (or another supported audio codec) for proper conversion. Here’s the updated command:
Correct Command
ffmpeg -ss 00:00:20 -i input.webm -c:v libx264 -c:a aac -strict experimental output.mp4
Explanation:
-c:v libx264
: Re-encodes the video using the H.264 codec (which is compatible with.mp4
).-c:a aac
: Re-encodes the audio using the AAC codec (which is supported by.mp4
).-strict experimental
: This flag allows the use of experimental features, which may be necessary for AAC encoding in some versions of FFmpeg.
Optional: Adjust Quality and Bitrate
You can also control the quality of the output video by adding the -crf
option for video quality and the -b:a
option for audio bitrate:
-crf 23
: Controls the quality of the video (lower values give better quality but larger file sizes, with 23 being a reasonable default).-b:a 128k
: Sets the audio bitrate to 128 kbps, which is typically good for most purposes.
For example:
ffmpeg -ss 00:00:20 -i input.webm -c:v libx264 -crf 23 -c:a aac -b:a 128k -strict experimental output.mp4