15

I've got a 4.3 GB 720p movie and want to convert this MKV with DTS sound to MP4 video with AAC or AC3 audio.

I sometimes get:

ffmpeg: unrecognized option '-c:v'

…and:

aac unrecognized

¬and other similar stuff.

I want this movie to have small size like those found on torrent sites.

1
  • Can you help us please and give us the exact command you're using and the complete, uncut output that FFmpeg produces? Which operating system are you on? And lastly: Do you have to use FFmpeg? Please edit your question.
    – slhck
    Oct 2, 2012 at 18:48

5 Answers 5

22

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
0
3

You may do this:

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

Or if there is no joy, try fixing the internal bitstream

Conversion to stereo and asc:

ffmpeg -i input.mkv -c:v copy -c:a libfaac    \
-bsf:a aac_adtstoasc -ac 2 -ar 48000 -ab 256k \
out.mkv

If it is 5.1, surround and the voices are hard to hear it is because the dialog is on the center channel and you are only hearing the off-mike from the R & L channels but the music and sound effects are booming.

You can compensate for this with dolby-II filter to get the surround channel cut way down and the center channel split into stereo, and combine them all into right and left stereo channels.

ffmpeg -i input.mkv -c:v copy -c:a libfaac -bsf:a aac_adtstoasc   \
  -af aresample=matrix_encoding=dplii -ac 2 -ar 48000 -ab 256k    \
  out.mkv
2

MKV is just a container. You can have an MPEG-4 video inside of a .mkv container.

My suggestion is this:

Push the file to a .mkv container:

mkvmerge -o newfile.mkv inputfile.m4v

Get the mkvdts2ac3.sh script available here and run this command:

mkvdts2ac3.sh newfile.mkv

Done!

My TV supports AC3, but not DTS so this setup does wonders for me.

Please note that mkvdts2ac3.sh has some dependency requirements that are very basic. You’ll see them when you run the script.

9
  • root@Frenzen:~/Downloads/2.Days.In.New.York.2012.720p.BluRay.X264- 7SinS# mkvmerge -o 7s-2days-in-ny-720p.mkv inputfile.m4v mkvmerge v3.0.0 ('Hang up your Hang-Ups') built on Dec 29 2009 00:24:14 Error: The source file 'inputfile.m4v' could not be opened successfully, or retrieving its size by seeking to the end did not work. root@Frenzen:~/Downloads/2.Days.In.New.York.2012.720p.BluRay.X264-7SinS#
    – dale
    Oct 3, 2012 at 1:04
  • Sounds like a corrupt input file. Oct 3, 2012 at 2:31
  • @dale Could you please include the output I asked you for in the comment on your original question? That would help us troubleshoot your issue.
    – slhck
    Oct 3, 2012 at 15:27
  • Also, UtahJarhead, the OP seems to want an MP4 result file from an MKV input file. He does not have an m4v file which is why your command doesn't work. Also, dale used the wrong syntax, specifying his existing file as output and giving inputfile.m4v as input, which obviously does not exist.
    – slhck
    Oct 3, 2012 at 15:31
  • mp4 is a codec, not a container. mkv is a container, not a codec. That's like saying they want to make a garage out of a Cadillac. What codec is the input .mkv file because that may make a difference. Oct 3, 2012 at 15:35
0

As @UtahJarhead said, MKV is the container. Basically, what you want is to convert DTS audio to AC3 or AAC.

Best way to do this is to use FFmpeg for the audio and MKVToolNix to merge audio and video.

If you prefer a GUI instead of commands, I described how to do this here: Convert unsupported audio from video.

2
  • 1
    You should describe the process here, then and only then, provide the download link.to the application.
    – Ramhound
    Mar 16, 2016 at 19:27
  • @Ramhound I just edited the answer
    – IvanRF
    Mar 16, 2016 at 20:38
0

It's an old question but I guess I found an easy answer.
Its from everyone's favourite media player VLC. The best part is that you can change only what you want (audio or video separately) it doesn't re-encode everything and saves time if you only want to re-encode only one of them.

  1. Press ctrl+R OR click on top left media--->convert/save

  2. Add Video file from here. Add file from here

  3. Then click on Convert/Save

  4. Choose a container of your choice. enter image description here

  5. Choose a video format. Or if you don't want to change that then tick keep original video track enter image description here

  6. Choose a audio format. Or if you don't want to change that then tick keep original audio track enter image description here

  7. Select save.

  8. Select convert/save.

  9. Wait!!! and You are done. enjoy!!!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .