The easiest way is with the MP4Box tool.
First install the GPAC
sudo apt-get install gpac
Then you can use the following command
MP4Box -add inputfile.srt target.mp4
More about this command in this link.
Another Option to do so:
apt-get install mkvtoolnix
mkvmerge -o output.mkv video.mp4 subtitles.srt
or
mkvmerge -o output.mp4 video.mp4 subtitles.srt
In the case you need subtitle conversion:
ffmpeg -i file.srt file.vtt
or
ffmpeg -i file.vtt file.srt
More info in the ffmpeg manual ("man ffmpeg").
How to download only subtitles of videos using youtube-dl
Options:
--write-sub Write subtitle file
--write-auto-sub Write automatic subtitle file (YouTube only)
--all-subs Download all the available subtitles of the video
--list-subs List all available subtitles for the video
--sub-format FORMAT Subtitle format, accepts formats preference, for example: "srt" or "ass/srt/best"
--sub-lang LANGS Languages of the subtitles to download (optional) separated by commas, use IETF language tags like 'en,pt'
So for example, to list all subs for a video:
youtube-dl --list-subs https://www.youtube.com/watch?v=Ye8mB6VsUHw
To download all subs, but not the video:
youtube-dl --all-subs --skip-download https://www.youtube.com/watch?v=Ye8mB6VsUHw
The other way, this really works but makes the file bigger:
mencoder movie.avi -sub movie.srt -o movie.hardsubs.avi -oac copy -ovc lavc -lavcopts vbitrate=1200
Source: Ubuntu Forums.
-----------///
First install the GPAC
sudo apt-get install gpac
Then you can use the following command
MP4Box -add inputfile.srt target.mp4
More about this command in this link.
Another Option to do so:
apt-get install mkvtoolnix
mkvmerge -o output.mkv video.mp4 subtitles.srt
or
mkvmerge -o output.mp4 video.mp4 subtitles.srt
In the case you need subtitle conversion:
ffmpeg -i file.srt file.vtt
or
ffmpeg -i file.vtt file.srt
More info in the ffmpeg manual ("man ffmpeg").
How to download only subtitles of videos using youtube-dl
Options:
--write-sub Write subtitle file
--write-auto-sub Write automatic subtitle file (YouTube only)
--all-subs Download all the available subtitles of the video
--list-subs List all available subtitles for the video
--sub-format FORMAT Subtitle format, accepts formats preference, for example: "srt" or "ass/srt/best"
--sub-lang LANGS Languages of the subtitles to download (optional) separated by commas, use IETF language tags like 'en,pt'
So for example, to list all subs for a video:
youtube-dl --list-subs https://www.youtube.com/watch?v=Ye8mB6VsUHw
To download all subs, but not the video:
youtube-dl --all-subs --skip-download https://www.youtube.com/watch?v=Ye8mB6VsUHw
The other way, this really works but makes the file bigger:
mencoder movie.avi -sub movie.srt -o movie.hardsubs.avi -oac copy -ovc lavc -lavcopts vbitrate=1200
Source: Ubuntu Forums.
-----------///