Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Compression Techniques Convert SubRip to drawtext (source code included)

  • Convert SubRip to drawtext (source code included)

    Posted by Chiq Garcia on March 20, 2014 at 5:37 am

    I haven’t had much luck with burning in subtitles using ffmpeg’s subtitles filter, so I wrote this tiny Windows CLI app that I would like to share with anyone interested.

    The app’s name is ‘srtdrawtext’ and it takes SubRip subtitles (*.srt) as input and outputs a text file containing drawtext commands which ffmpeg (or ffplay) can read via the sendcmd filter. The generated text file basically tells ffmpeg what text to draw and when to draw it. While this method may seem ‘desperate’, this may also prove to be the easiest way to burn-in subtitles.

    srtdrawtext (~300 kb) is absolutely free and includes the manual and the source code (210 lines, *.au3) which you can modify/distribute (due credit would be nice). Instructions on how to use the generated text file will be written on the file itself. An example:

    ffplay -vf “sendcmd=filename=’C\:\\srtdrawtext_output.txt’, drawtext=fontfile=’C\:\\Windows\\Fonts\\tahoma.ttf’: fontcolor=yellow: fontsize=18: box=1: boxcolor=0x000000@0xA5: x=(w-text_w)*0.5: y=(h-text_h-line_h)*1: text=”” -autoexit -framedrop “C:\Movies\Tinimbang_ka_ngunit_kulang_(1974).avi”

    download link:
    https://www.mediafire.com/download/epxnpnq39v413hv/srtdrawtext.zip

    Chiq Garcia replied 11 years, 11 months ago 2 Members · 5 Replies
  • 5 Replies
  • Lou Logan

    March 20, 2014 at 5:42 pm

    Interesting concept and thanks for sharing.

    What were the limitations of the subtitles filter?

  • Chiq Garcia

    March 21, 2014 at 12:05 am

    Oh I didn’t set out to address some sort of limitation with the subtitles filter, and I’m sure everyone else is doing fine with it (on Linux?). But, I’m afraid I can’t give you a good or adequate/qualified answer, except for: I can’t get it to work (I’m embarrassed actually).

    I remember seeing video conversion apps with ffmpeg as main back-end, but relegating subtitle-burning-in tasks to ?mencoder? which I do not like.

    Anyway, I’m on Windows XP using ffmpeg-20140226-git-96fc290-win32-static. I seem to recall seeing on the log file: ‘neither playresx nor playresy defined’, reverting to 384 x some other number, a bunch of subtitle-related stuff which seemed to indicate that it can manage and everything is okay, but no subs for me. I’ve given up on this a long time ago (sorry I couldn’t give a detailed answer). I’m not complaining, though, it just so happens that an alternative (sendcmd & drawtext) exists in ffmpeg. Just another way to skin a cat, I suppose (for those having trouble doing it the proper way).

  • Chiq Garcia

    March 21, 2014 at 12:27 am

    Oh, btw, while you’re here, I wrote an ffmpeg gui with a video filter cheat sheet which has an entry with your name on it (color curves). Do you approve? If not, I will amend on next release (internet connectivity is such a precious commodity in a third-world country).

    https://tinypic.com/r/2narvw2/8

  • Lou Logan

    March 22, 2014 at 5:55 pm

    Thanks for asking, but with or without my name is fine with me. Whatever you prefer.

  • Chiq Garcia

    June 5, 2014 at 6:31 pm

    link update:

    https://www.mediafire.com/download/3is5jc5v851h274/srtdrawtext_2014.05.26.zip

    With a few samples on hand, I proceeded to coding srtdrawtext without googling SubRip specifications (oops!). As stated on the manual, HTML tags in the *.srt file will be stripped.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy