Using FFMPEG to generate video in Plint
Short summary
- There are two types of FFMPEG presets that can be created in Plint:
- "Work copy" is intended for proxies and "Deliverable" is for, well, deliverables.
- Depending on the type, they will become available in different Plint features
- When executing a Media Upload job, the "Work copy" presets can be selected
- When generating video with burnt-in subtitles, the "Deliverable" presets become available
- Presets are created under Tools & Data / FFMPEG / Presets
- Ongoing render tasks can be followed under Tools & Data / Media processing / Renders
- Here, tasks can also be cancelled or their priority changed.
"Hardsubbing" / adding burnt-in subtitles to video
Plint can combine a source video file from a project with the translations/subtitles created in the system to create deliverables; videos with burnt-in subtitles. This is done from the "Generate video copies" page or as an automatic job. In both cases, a FFMPEG preset is needed. These are handled under Tools & Data.
Here are some pointers on the available variables.
- When FFMPEG is used to render video copies, the source media and subtitles are inserted automatically, as long as they are present in the project. Examples:
- Source video: A video file with "Standard" mode
- Subtitles: a work file linked to the node in question
- For example: if an FFMPEG rendering job is started in the German node of Part 2, Plint will look for a JSON file in the same node. A "Standard" video file linked to the same Part, if found, will be automatically used. If there are multiple Standard files for the same part, the newest one will be used.
- You can add more parameters for things such as video format and resolution.
- The Parameters field is used for all FFMPEG settings except font settings. Example:
-vf scale=w=1334:h=-1,"{SUBTITLE}" -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 320k -y
- {SUBTITLE} is the path to the subtitle file and is inserted in the preset as a dynamic variable. The system will insert the correct path when the preset is used.
- Audio is set to AAC, 320k with the parameters after -c:a.
- When making copies with burnt-in subtitles, the font settings can be specified with the "Font styles" field.E.g.
- FontSize=24
Advanced font settings
FontSize=32,OutlineColour=&H66000000,BorderStyle=3,PrimaryColour=&H000000FF
- In PrimaryColour the H00 is the alpha (transparency). H00 is fully opaque, and FF (ie. 255 in decimal) is fully transparent/invisible.
- The 0000FF in the example is a hexadecimal to set the color. In this case it is bright red. Note that it is in the opposite order of HTML colors (red would be FF0000 in HTML).
(Please note that the syntax is different when using the ASS subtitle format, which yields additional options.)
Font size
Setting the font size will specify a relative size. The subtitles will be scaled based on the resolution of the video. Values around 20 are fairly "normal".
Changing the default font
The fallback font for rendering videos with burnt-in subtitles is "Arial Unicode MS". You can upload any TTF through Plint and use that instead. This is how:
- Fonts are uploaded under Tools & Data / Fonts
- make sure to spell the name exactly as the official font name
- If you want to use this font across all projects, set it as System default.
- When you render video copies with burnt-in subtitles from the "Generate video copies" page, the selected font will automatically be used.
Interlace / progressive output
If video should not be deinterlaced (for television, for example), additional flags can prevent this. See example below
-vf "{SUBTITLE}" -c:v libx264 -flags +ildct+ilme
Complex filters / adding logo
Using "filter_complex", multiple inputs can be combined. This will overlay a logo in the top left corner (with 20 pixels margin) plus burnt-in subtitles.
-i path-to-logo/logo.png -filter_complex "{SUBTITLE},overlay=20:20"
Work copies with timecode
FFMPEG can also be used to generate work copies, for example MP4 files suitable for the online editor. These presets need to be tagged as "Work copy" under "Usage". This will make them available for automatic use for "Media upload" jobs. All you need to do is select a media for upload and select a preset in the conversion dropdown. The system will create the work copy and tag it for use in the online editor.
The following parameters will generate a lo-res file with visible timecode. Audio is set to AAC, 128k.
-vf scale=w=480:h=-2,"drawtext=fontfile={FONT}: timecode=\\'00:00:00:00\\': r={FRAMERATE}: x=(w-tw)/2: y=10: fontsize=20: fontcolor=white: box=1: boxcolor=0x00000099" -keyint_min 1 -bf 16 -c:v libx264 -preset slow -crf 25 -c:a aac -b:a 128k -y
- Note that the timecode section needs to be escaped.
- Also note that the font settings used with the drawtext option are not the same as the "font styles" options used when burning in subtitles.
Some explanations
- -keyint_min 1
- Sets every frame to be a keyframe. Better response in editor but bigger file size.
- libx264
- set format h264
- crf
- compression rate, suitable values may differ for different formats
- 23 is "normal" for h264
- r=25
- framerate for burnt-in timecode
- -vsync "cfr"
- ensure constant framerate
Documentation and examples of FFMPEG settings
- FFMPEG offical site: https://ffmpeg.org
- FFMPEG An intermediate guide (Wiki): https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide
- FFmpeg Utilities Documentation (common colour codes, resolutions, etc): https://ffmpeg.org/ffmpeg-utils.html
- Useful examples: http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-need