Softsubs
MP4 supports streaming text format subtitles, but playback support for this among players and devices is not universal.
Basic example using default stream selection behavior while stream copying the audio:
ffmpeg -i input.mkv -c copy -c:s mov_text output.mp4
Example to stream copy all of the video and audio streams, convert the all text based subtitle input streams (SRT, ASS, VTT, etc) to the streaming text format, and set the language for the first two subtitle streams.
ffmpeg -i input.mkv -map 0 -c copy -c:s mov_text -metadata:s:s:0 language=eng -metadata:s:s:1 language=ipk output.mp4
Same as above but re-encode the video and audio to formats compatible with the MP4 container (H.264 video:
ffmpeg -i input.mkv -map 0 -c:v libx264 -c:a aac -c:s mov_text -metadata:s:s:0 language=eng -metadata:s:s:1 language=ipk output.mp4
Same as above but use the -map
option to choose the first video stream, second audio stream, and third subtitle stream:
ffmpeg -i input.mkv -map 0:v:0 -map 0:a:1 -map 0:s:2 -c:v libx264 -c:a aac -c:s mov_text -metadata:s:s:0 language=eng output.mp4
Hardsubs
Text based subtitle format inputs
Use the subtitles filter to "burn-in" text based subtitle formats (SRT, ASS, VTT, etc). Note that this requires re-encoding, so it will by much slower than using softsubs.
Basic example using default stream selection behavior while stream copying the audio:
ffmpeg -i input.mkv -filter_complex "subtitles=input.mkv" -c:a copy output.mp4
Example to use the third video stream, fifth subtitle stream, and first audio stream:
ffmpeg -i input.mkv -filter_complex "[0:v:2]subtitles=input.mkv:si=4[v]" -map "[v]" -map 0:a:0 -c:a copy output.mp4
Example for a separate subtitle input file (your-subtitles-file.srt
):
ffmpeg -i input.mp4 -filter_complex "subtitles=your-subtitles-file.srt" -c:a copy output.mp4
Image based subtitle format inputs
Use the overlay filter. This example will overlay the fourth subtitle stream over the second video stream, and stream copy the seventh audio stream:
ffmpeg -i input.mkv -filter_complex "[0:v:2][0:s:3]overlay[v]" -map "[v]" -map 0:a:6 -c:a copy output.mp4
Also see
The solution I like is to use SimpleScreenRecorder. Here's how I did it:
How to build and install latest SimpleScreenRecorder from git?
My solution turned out to be simple to follow once I got the help I needed. I hope others can follow the dev's git instructions now.
Here's more info on SSR:
Main page - SimpleScreenRecorder - Maarten Baert's website
SimpleScreenRecorder is a Linux program that I've created to record programs and games. There were already a few programs that could do this, but I wasn't 100% happy with any of them, so I created my own.
My original goal was to create a program that was just really simple to use, but as I was writing it I started adding more and more features, and the result is actually a pretty powerful program. It's 'simple' in the sense that it's easier to use than ffmpeg/avconv or VLC, because it has a straightforward user interface.
Features
Graphical user interface (Qt-based).
Faster than VLC and ffmpeg/avconv.
Records the entire screen or part of it, or records OpenGL applications directly (similar to Fraps on Windows).
Synchronizes audio and video properly (a common issue with VLC and ffmpeg/avconv).
Reduces the video frame rate if your computer is too slow (rather than using up all your RAM like VLC does).
Fully multithreaded: small delays in any of the components will never block the other components, resulting is smoother video and better performance on computers with multiple processors.
Pause and resume recording at any time (either by clicking a button or by pressing a hotkey).
Shows statistics during recording (file size, bit rate, total recording time, actual frame rate, ...).
Can show a preview during recording, so you don't waste time recording something only to figure out afterwards that some setting was wrong.
Uses libav/ffmpeg libraries for encoding, so it supports many different codecs and file formats (adding more is trivial).
Can also do live streaming (experimental).
Sensible default settings: no need to change anything if you don't want to.
Tooltips for almost everything: no need to read the documentation to find out what something does.
Best Answer
Uncomment the line you wish to use and the file type. You can add many more "presets/FLAGS", this is just an idea.
---Script for Recursive Conversion of Video stripping Audio Streams and not converting anything!
--Alias and Automation