I would like to know how to convert an mkv file with several subtitle and audio tracks into an mp4 with one of the subtitle tracks hardcoded and a single audio track selected using ffmpeg? It should be a single command without resorting to extract the tracks from the original mkv (if possible).
What I tried so far:
ffmpeg -i File.mkv -map 0:s:1 -map 0:v -map 0:a:1 -c:a aac -c:v copy output.mp4
but the subtitle is not being hardcoded into the file, just muxed into the mp4 container, if that is possible (maybe the file is just ending up with the mp4 extension but it's still an mkv).
ffmpeg -i File.mkv
Input #0, matroska,webm, from 'File.mkv':
Metadata:
encoder : libebml v1.2.1 + libmatroska v1.1.1
creation_time : 2018-08-11T22:02:55.000000Z
Duration: 00:24:57.22, start: 0.000000, bitrate: 2271 kb/s
Stream #0:0: Video: h264 (High), yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
title : A Day in Ichinoseki
Stream #0:1(eng): Audio: aac (LC), 48000 Hz, 5.1, fltp (default)
Metadata:
title : English
Stream #0:2(jpn): Audio: aac (LC), 48000 Hz, stereo, fltp
Metadata:
title : Japanese
Stream #0:3(eng): Subtitle: ass (default)
Metadata:
title : English (Translation Only)
Stream #0:4(eng): Subtitle: ass
Metadata:
title : English
Stream #0:5: Attachment: ttf
Metadata:
filename : OpenSans-Semibold_0.ttf
mimetype : application/x-truetype-font
At least one output file must be specified
PS: I used to know of a command that used to get me a simple summary of an mkv streams that could be used verbatim with ffmpeg commands but forgot it.
ffmpeg -i video.mkv -vf subtitles=video.mkv:si=1 out.mp4
wheresi
is subtilte stream id?-vf
option had problems with the spaces in the filename even though I had escaped them. The final command wasffmpeg -i video.mkv -map 0:v -map 0:a:1 -c:a copy -vf subtitles=video.mkv:si=1 -preset veryslow -crf 18 out.mp4
because I wanted a specific audio track, can this be improved somehow? Is it redundant? @konradmb post your comment as an answer so I can mark it as the answer.