Posted: . At: 11:09 AM. This was 4 years ago. Post ID: 14575
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to add subtitles to a movie with ffmpeg on Linux.


Merging a subtitle *.srt file to a move on Linux is very easy. Just download a suitable srt file from the Internet, then put it in the same directory as the TV show or movie you have.

Then do this to merge the two.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
jason@jason-desktop:~/Videos$ ffmpeg -i "Rick and Morty - S02E10 - The Wedding Squanchers.mp4" -sub_charenc 'UTF-8' -f srt -i 5a7dc644d5d2f3d0fff6ed6d5226a298.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt Morty.mkv
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Rick and Morty - S02E10 - The Wedding Squanchers.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isom
    creation_time   : 2015-10-05T04:08:21.000000Z
  Duration: 00:22:59.90, start: 0.000000, bitrate: 865 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 131 kb/s (default)
    Metadata:
      creation_time   : 2015-10-05T04:08:21.000000Z
      handler_name    : GPAC ISO Audio Handler
    Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/unknown/unknown), 720x404, 730 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
    Metadata:
      creation_time   : 2015-10-05T03:46:32.000000Z
      handler_name    : L-SMASH Video Media Handler
      encoder         : AVC Coding
Input #1, srt, from '5a7dc644d5d2f3d0fff6ed6d5226a298.srt':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Subtitle: subrip
File 'Morty.mkv' already exists. Overwrite ? [y/N] y

This is very fast and works perfectly.

Subtitles working in MPV.
Subtitles working in MPV.

Then play the new video file in MPV and choose the new subtitles to enjoy your movie.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.