Skip to main content
broken link fixed
Source Link
Glorfindel
  • 4.1k
  • 8
  • 25
  • 37

Make sure you run the latest version of FFmpegFFmpeg. For Windows and Linux, static builds are availabe from the homepage. For macOS, you can install FFmpeg through HomebrewHomebrew.

Then, in the simplest case run:

ffmpeg -i input.mkv -c:v libx264 -c:a aac out.mp4

Setting video quality

For controlling video quality, set the crf parameterthe crf parameter, which defaults to 23. Lower means better quality, but higher file size. Try values between 19 and 26 to see what fits best. You can also set a certain bit rate, depending on which file size you want. Here, for example, 500 kBit/s:

ffmpeg -i input.mkv -c:v libx264 -crf 23 …
ffmpeg -i input.mkv -c:v libx264 -b:v 500k …

For audio, you can set the bit rate too, with -b:a.

Multiple channel audio

If your audio stream is using multiple channels (e.g. 5.1 sound), you need to use another AAC encoder (libfdk_aac). This encoder is not available in the static builds, but can be obtained with the pre-packaged / Homebrew versions of ffmpeg.

ffmpeg -i input.mkv -c:v libx264 -crf 23 -c:a libfdk_aac -b:a 384k out.mp4

Copying all streams

In case your input file has more than one video, audio and subtitle stream, ffmpeg by default does not convert all of them.

Use -map 0 to instruct ffmpeg to take all streams from the input file (see the FFmpeg Wiki for more info). This is useful for retaining different languages and subtitles that might be in the original.

ffmpeg -i input.mkv -c:v libx264 -c:a aac -map 0 out.mp4

Make sure you run the latest version of FFmpeg. For Windows and Linux, static builds are availabe from the homepage. For macOS, you can install FFmpeg through Homebrew.

Then, in the simplest case run:

ffmpeg -i input.mkv -c:v libx264 -c:a aac out.mp4

Setting video quality

For controlling video quality, set the crf parameter, which defaults to 23. Lower means better quality, but higher file size. Try values between 19 and 26 to see what fits best. You can also set a certain bit rate, depending on which file size you want. Here, for example, 500 kBit/s:

ffmpeg -i input.mkv -c:v libx264 -crf 23 …
ffmpeg -i input.mkv -c:v libx264 -b:v 500k …

For audio, you can set the bit rate too, with -b:a.

Multiple channel audio

If your audio stream is using multiple channels (e.g. 5.1 sound), you need to use another AAC encoder (libfdk_aac). This encoder is not available in the static builds, but can be obtained with the pre-packaged / Homebrew versions of ffmpeg.

ffmpeg -i input.mkv -c:v libx264 -crf 23 -c:a libfdk_aac -b:a 384k out.mp4

Copying all streams

In case your input file has more than one video, audio and subtitle stream, ffmpeg by default does not convert all of them.

Use -map 0 to instruct ffmpeg to take all streams from the input file (see the FFmpeg Wiki for more info). This is useful for retaining different languages and subtitles that might be in the original.

ffmpeg -i input.mkv -c:v libx264 -c:a aac -map 0 out.mp4

Make sure you run the latest version of FFmpeg. For Windows and Linux, static builds are availabe from the homepage. For macOS, you can install FFmpeg through Homebrew.

Then, in the simplest case run:

ffmpeg -i input.mkv -c:v libx264 -c:a aac out.mp4

Setting video quality

For controlling video quality, set the crf parameter, which defaults to 23. Lower means better quality, but higher file size. Try values between 19 and 26 to see what fits best. You can also set a certain bit rate, depending on which file size you want. Here, for example, 500 kBit/s:

ffmpeg -i input.mkv -c:v libx264 -crf 23 …
ffmpeg -i input.mkv -c:v libx264 -b:v 500k …

For audio, you can set the bit rate too, with -b:a.

Multiple channel audio

If your audio stream is using multiple channels (e.g. 5.1 sound), you need to use another AAC encoder (libfdk_aac). This encoder is not available in the static builds, but can be obtained with the pre-packaged / Homebrew versions of ffmpeg.

ffmpeg -i input.mkv -c:v libx264 -crf 23 -c:a libfdk_aac -b:a 384k out.mp4

Copying all streams

In case your input file has more than one video, audio and subtitle stream, ffmpeg by default does not convert all of them.

Use -map 0 to instruct ffmpeg to take all streams from the input file (see the FFmpeg Wiki for more info). This is useful for retaining different languages and subtitles that might be in the original.

ffmpeg -i input.mkv -c:v libx264 -c:a aac -map 0 out.mp4
added 365 characters in body
Source Link
slhck
  • 230.2k
  • 71
  • 621
  • 603

Make sure you run the latest version of FFmpeg. For Windows and Linux, static builds are availabe from the homepage. For OS XmacOS, you can install FFmpeg through Homebrew.

Then, in the simplest case run:

ffmpeg -i input.mkv -c:v libx264 -c:a libfaacaac out.mp4

Setting video quality

For controlling video quality, set the crf parameter, which defaults to 23. Lower means better quality, but higher file size. Try values between 19 and 26 to see what fits best. You can also set a certain bit rate, depending on which file size you want. Here, for example, 500 kBit/s:

ffmpeg -i input.mkv -c:v libx264 -crf 23 …
ffmpeg -i input.mkv -c:v libx264 -b:v 500k …

For audio, you can set quality orthe bit rate too, with -b:a. 100

Multiple channel audio

If your audio stream is using multiple channels (e.g. 5.1 sound), you need to use another AAC encoder (libfdk_aac). This encoder is not available in the default quality value and higher means betterstatic builds, but can be obtained with the pre-packaged / Homebrew versions of ffmpeg.

ffmpeg -i input.mkv -c:v libx264 -crf 23 -c:a libfaaclibfdk_aac -qb:a 100384k out.mp4

Copying all streams

In case your input file has more than one video, audio and subtitle stream, ffmpeg by default does not convert all of them.

Use -map 0 to instruct ffmpeg to take all streams from the input file (see the FFmpeg Wiki for more info). This is useful for retaining different languages and subtitles that might be in the original.

ffmpeg -i input.mkv -c:v libx264 -c:a libfaacaac -b:amap 128k0 out.mp4

If libfaac is not available, I believe you can use aac instead, with the additional option -strict experimental.

Please read our blog post for more info: FFmpeg: The ultimate Video and Audio Manipulation Tool

Make sure you run the latest version of FFmpeg. For Windows and Linux, static builds are availabe from the homepage. For OS X, you can install FFmpeg through Homebrew.

Then, in the simplest case run:

ffmpeg -i input.mkv -c:v libx264 -c:a libfaac out.mp4

For controlling video quality, set the crf parameter, which defaults to 23. Lower means better quality, but higher file size. Try values between 19 and 26 to see what fits best. You can also set a certain bit rate, depending on which file size you want. Here, for example, 500 kBit/s:

ffmpeg -i input.mkv -c:v libx264 -crf 23 …
ffmpeg -i input.mkv -c:v libx264 -b:v 500k …

For audio, you can set quality or bit rate too. 100 is the default quality value and higher means better.

ffmpeg -i input.mkv   -c:a libfaac -q:a 100 out.mp4
ffmpeg -i input.mkv   -c:a libfaac -b:a 128k out.mp4

If libfaac is not available, I believe you can use aac instead, with the additional option -strict experimental.

Please read our blog post for more info: FFmpeg: The ultimate Video and Audio Manipulation Tool

Make sure you run the latest version of FFmpeg. For Windows and Linux, static builds are availabe from the homepage. For macOS, you can install FFmpeg through Homebrew.

Then, in the simplest case run:

ffmpeg -i input.mkv -c:v libx264 -c:a aac out.mp4

Setting video quality

For controlling video quality, set the crf parameter, which defaults to 23. Lower means better quality, but higher file size. Try values between 19 and 26 to see what fits best. You can also set a certain bit rate, depending on which file size you want. Here, for example, 500 kBit/s:

ffmpeg -i input.mkv -c:v libx264 -crf 23 …
ffmpeg -i input.mkv -c:v libx264 -b:v 500k …

For audio, you can set the bit rate too, with -b:a.

Multiple channel audio

If your audio stream is using multiple channels (e.g. 5.1 sound), you need to use another AAC encoder (libfdk_aac). This encoder is not available in the static builds, but can be obtained with the pre-packaged / Homebrew versions of ffmpeg.

ffmpeg -i input.mkv -c:v libx264 -crf 23 -c:a libfdk_aac -b:a 384k out.mp4

Copying all streams

In case your input file has more than one video, audio and subtitle stream, ffmpeg by default does not convert all of them.

Use -map 0 to instruct ffmpeg to take all streams from the input file (see the FFmpeg Wiki for more info). This is useful for retaining different languages and subtitles that might be in the original.

ffmpeg -i input.mkv -c:v libx264 -c:a aac -map 0 out.mp4
Source Link
slhck
  • 230.2k
  • 71
  • 621
  • 603

Make sure you run the latest version of FFmpeg. For Windows and Linux, static builds are availabe from the homepage. For OS X, you can install FFmpeg through Homebrew.

Then, in the simplest case run:

ffmpeg -i input.mkv -c:v libx264 -c:a libfaac out.mp4

For controlling video quality, set the crf parameter, which defaults to 23. Lower means better quality, but higher file size. Try values between 19 and 26 to see what fits best. You can also set a certain bit rate, depending on which file size you want. Here, for example, 500 kBit/s:

ffmpeg -i input.mkv -c:v libx264 -crf 23 …
ffmpeg -i input.mkv -c:v libx264 -b:v 500k …

For audio, you can set quality or bit rate too. 100 is the default quality value and higher means better.

ffmpeg -i input.mkv  … -c:a libfaac -q:a 100 out.mp4
ffmpeg -i input.mkv  … -c:a libfaac -b:a 128k out.mp4

If libfaac is not available, I believe you can use aac instead, with the additional option -strict experimental.

Please read our blog post for more info: FFmpeg: The ultimate Video and Audio Manipulation Tool