{"id":365,"date":"2016-10-13T10:53:11","date_gmt":"2016-10-13T10:53:11","guid":{"rendered":"https:\/\/www.blackestknight.com\/?p=365"},"modified":"2016-10-13T10:53:11","modified_gmt":"2016-10-13T10:53:11","slug":"use-avconv-to-add-subtitles","status":"publish","type":"post","link":"https:\/\/www.blackestknight.com\/index.php\/2016\/10\/13\/use-avconv-to-add-subtitles\/","title":{"rendered":"Use avconv to add subtitles"},"content":{"rendered":"<p>avconv is a very handy program so far i have posted a few recipes for converting audio and video with it, this post is for subtitles.<br \/>\nthere are 2 types of subtitle really hard and soft. With hard subtitles they are hard encoded into the video stream which means they are present all the time, this may be needed by mobile players which do not support soft subtitles. with soft subtitles the presentation and size is decided by the player but it does give the user the option of multiple languages. With a player such as vlc having an srt file with the same name as the movie is enough to have subtitles. For itunes it is necessary to encode the subtitles within the mp4 file. <\/p>\n<p>so here are a few recipes. <\/p>\n<p><code>avconv -i infile.mp4 -f srt -i infile.srt -c:v copy -c:a copy -c:s mov_text outfile.mp4<\/code><\/p>\n<p>also with <\/p>\n<p><code>-codec copy -c:s mov_text<\/code><\/p>\n<p>using the libass library if it is compiled into your avconv<\/p>\n<p><code>avconv -i subtitles.srt subtitles.ass<\/code><\/p>\n<p>to convert and <\/p>\n<p><code>avconv -i mymovie.mp4 -vf ass=subtitles.ass mysubtitledmovie.mp4<\/code><\/p>\n<p>Mp4 and Mkv files use slightly different recipes<\/p>\n<p>MP4:<br \/>\n<code>avconv -i input.mp4 -f srt -i input.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s mov_text output.mp4<\/code><\/p>\n<p>MKV:<br \/>\n<code>avconv -i input.mp4 -f srt -i input.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt  output.mkv<\/code><\/p>\n<p>Adding a second subtitle stream<\/p>\n<p>First add another input: -i input2.srt. Second, map that as 2nd stream: -map 2:0. Finally, select encoder for 2nd subtitle stream (the same as the first one): -c:s srt. <\/p>\n<p><code>avconv -i input.mp4 -f srt -i input.srt -i input2.srt -map 0:0 -map 0:1 -map 1:0 -map 2:0 -c:v copy -c:a copy  -c:s srt -c:s srt output.mkv <\/code><\/p>\n<p>avconv supports the mov_text subtitle encoder which is about the only one supported in an MP4 container and playable by iTunes, Quicktime, iOS etc.<\/p>\n<p>Your line would read:<\/p>\n<p><code>avconv -i input.mp4 -i input.srt -map 0:0 -map 0:1 -map 1:0 -c:s mov_text output.mp4<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>avconv is a very handy program so far i have posted a few recipes for converting audio and video with it, this post is for subtitles. there are 2 types of subtitle really hard and soft. With hard subtitles they are hard encoded into the video stream which means they are present all the time, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[15,7,6],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7UXrA-5T","_links":{"self":[{"href":"https:\/\/www.blackestknight.com\/index.php\/wp-json\/wp\/v2\/posts\/365"}],"collection":[{"href":"https:\/\/www.blackestknight.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blackestknight.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blackestknight.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blackestknight.com\/index.php\/wp-json\/wp\/v2\/comments?post=365"}],"version-history":[{"count":2,"href":"https:\/\/www.blackestknight.com\/index.php\/wp-json\/wp\/v2\/posts\/365\/revisions"}],"predecessor-version":[{"id":367,"href":"https:\/\/www.blackestknight.com\/index.php\/wp-json\/wp\/v2\/posts\/365\/revisions\/367"}],"wp:attachment":[{"href":"https:\/\/www.blackestknight.com\/index.php\/wp-json\/wp\/v2\/media?parent=365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blackestknight.com\/index.php\/wp-json\/wp\/v2\/categories?post=365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blackestknight.com\/index.php\/wp-json\/wp\/v2\/tags?post=365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}