MiniCoder is a command-line application that can take an audio or video file, encode it to various formats, check for and convert it to chapters, fetch attachments (including subtitles) and re-encode back to the original format.