0

What is best way to convert mkv to mp4, with default subtitle (that mkv have), and keep same quality of video / audio ?

Currently I'm using this command

ffmpeg -y -i filename.mkv -vf subtitles='filename.mkv' -disposition:s default+forced -c:v libx264 -c:a libmp3lame -crf 27 -preset ultrafast filename.mp4

But the command still not perfect, the mkv have better quality than mp4 generated. Any advise?

Thanks

Zeta
  • 663
  • 1
  • 12
  • 27
  • Why is it tagged `PHP`? – mega6382 Oct 18 '17 at 10:54
  • here https://stackoverflow.com/questions/30898671/converting-mkv-to-h-264-ffmpeg –  Oct 18 '17 at 10:55
  • @mega6382 sorry because I'm using ffmpeg via php – Zeta Oct 18 '17 at 10:57
  • @headmax I have read the suggestions in other topic, but I don't know how still to improve quality – Zeta Oct 18 '17 at 11:01
  • @Zeta you can try the `-preset xxx` that will calcul bitrate for you, try to find to famous solution depends of your mkv and the size limit you wanted https://trac.ffmpeg.org/wiki/Encode/H.264 –  Oct 18 '17 at 11:24

1 Answers1

0

your preset is lowest possible quality, and crf could be lower, 18 is more or less lossless, this will make the transcoding slower. of course So suggest -crf 18 and -preset slow

If you aren't bothered about which codecs you use you could just copy everything into the mp4 container, which would be megaquick

jdauthre
  • 21
  • 1
  • 3
  • If I copu to mp4 it will not add default subtitle hardcoded in mp4. – Zeta Oct 19 '17 at 07:57
  • regarding crf 18, I tried it, it converted a video with filesize 1GB! which previous command converted it to 400MB only – Zeta Oct 19 '17 at 07:58
  • size is another tradeoff, increase -crf a little until an acceptable compromise is reached, but definitely keep the preset on slow.. Re subtitles, Could you post your output? – jdauthre Oct 19 '17 at 09:30