Results 1 to 7 of 7

Thread: Embedding subtitles in avconv

  1. #1
    Join Date
    Nov 2013
    Beans
    12

    Embedding subtitles in avconv

    Hi, I was wondering how to embed subtitles (srt) using avconv.

  2. #2
    Join Date
    Mar 2010
    Location
    Metro-ATL; PM free zone.
    Beans
    Hidden!
    Distro
    Lubuntu 14.04 Trusty Tahr

    Re: Embedding subtitles in avconv

    I dont know, but you can take any file and add SRTs to an mkv container that will work.

    mkvmerge -o output-file.mkv avconve-output.mp4 all-the-captions.en.srt all-the-captions.es.srt all-the-captions.fr.srt all-the-captions.br.srt

    The video/audio part can be 1 file or 2 or 5 as well. MKV containers are really awesome.

    There is a way to force a specific subtitle to be displayed by default too - much better than forcing them to be burned into the video stream.
    Embed can have 2 meanings. Please clarify.

    Of course, if your playback device doesnt like MKV, then we need to know the exact container AND the exact video + audio codecs used.
    Also, there are many, many, many options for avconv, so the best way to know exactly which options are available with the version on your system is through the man page. man avconv should explain. I would look for _srt_ there.

  3. #3
    Join Date
    Nov 2013
    Beans
    12

    Re: Embedding subtitles in avconv

    The video is a matroska file. My device doesn't play mkv, so I usually change the containers to mp4. In this case, I'd like to keep the subtitles, audio, video while changing the container from mkv to mp4.

    I also have some files that are mkv and have the subtitles in srt format that havent been placed in the video.

    I'm pretty new to Linux and using avconv, so I'll try my best to supply you with the information needed

  4. #4
    Join Date
    Mar 2010
    Location
    Metro-ATL; PM free zone.
    Beans
    Hidden!
    Distro
    Lubuntu 14.04 Trusty Tahr

    Re: Embedding subtitles in avconv

    avconv has _copy_ modes. I would use mkvexport to dump all the different tracks, then find a way to shove those into the mp4 container without transcoding. If done properly, it should be as fast as a file copy.

    If you are not trying to script this, then using a GUI tool like handbrake or avidemux is probably easier. Handbrake is probably the easiest, but it may transcode every time. I am unsure of how to include SRTs with avidemux - though the tool will help to convert SUB/idx files into SRTs with powerful glyph matching.

    Sorry I cant help more. avconv is not part of my normal toolkits. I use lots of other things daily, but all my systems support MKV, so I am always converting MP4 into the, better, MKV containers. Google found this:
    http://askubuntu.com/questions/50433...ile-losslessly - but since that time, avconv options have probably changed. Sadly, RTFM is probably the best answer I can provide. Can you post a few of the commands that you have tried and how they failed?

    With MKV it is possible to change aspect ratios, resync audio playback, add multiple video and audio tracks .... simply amazing what changing some settings in a track header can do without transcoding anything. Alas, that doesnt help you.

  5. #5
    Join Date
    Nov 2013
    Beans
    12

    Re: Embedding subtitles in avconv

    i've tried -scodec copy, -c:s copy, -map 0:2 but i'm probably doing it wrong. to change containers i normalle use avconv -i input.mkv -vcodec copy -acodec copy output.mp4

    i've tried doing avconv -i input.mkv -vcodec copy -acodec copy -scodec copy output.mp4 (or c:s copy; -map 0:2 in place of -scodec copy).

    for errors ill get something like:

    [mp4 @ 0x1695960] Application provided invalid, non monotonically increasing dts to muxer in stream 0: -83 >= -83
    av_interleaved_write_frame(): Invalid argument

    or

    Encoder (codec id 0) not found for output stream #0:0

    Thanks for your help though! It just caught my attention since I found a video where the .srt file was seperate-- the mkv file wasn't in English, but the srt file shows the English subtitles. Can't watch the video since the .srt file is no longer "embedded' in the video anymore

  6. #6
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    10,090
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Embedding subtitles in avconv

    I don't believe it is possible to use the copying modes while attaching and synchronizing subtitles. You might have to write an entirely new encoded file. That's obviously true if you convert the subs to hard subs, since they will need to burned into the picture. With soft subs it should be possible to avoid encoding the streams again, but I don't know for sure.

    I suggest taking a look at the mkvtoolnix package from the repositories as well. That provides utilities like mkvextract and mkvmerge which let you disassemble and reassemble Matroska files.
    Last edited by SeijiSensei; November 4th, 2013 at 10:45 PM.
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  7. #7
    Join Date
    Sep 2006
    Beans
    3,605

    Re: Embedding subtitles in avconv

    MP4 is picky when it comes to subtitles support. You can try "-codec:s mov_text". Results may vary.

    Alternatively, as SeijiSensei mentioned, you can use hard subs as a last resort. See How to burn subtitles into the video and the FFmpeg and x264 Encoding Guide. Note that you'll have to use ffmpeg from FFmpeg; not avconv or the libav version of "ffmpeg" in the repo since libav lacks the required features. Just another little bonus from the switch to libav for the Ubuntu users.

    You can simply download a Linux build of ffmpeg or follow a step-by-step guide to compile ffmpeg.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •