Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no possibility to provide additional settings for ffmpeg subtitles #86

Open
MikeKoval opened this issue Apr 30, 2020 · 1 comment

Comments

@MikeKoval
Copy link

I spent much time trying to understand why MarginR and custom font are not working for my fullhd video, then I bumped into documentation of ffmpeg http://ffmpeg.org/ffmpeg-all.html#subtitles-1 and found that there are additional properties original_size and fontsdir but videshow has only basic option of providing subtitles to ffmpeg so it's impossible to reach what I need(

    if (subtitles) {
      options.push('-vf subtitles=\'' + subtitles + '\'')
    }
@MikeKoval
Copy link
Author

MikeKoval commented Apr 30, 2020

Figured out that original_size does not have any impact on .ass margins while PlayResX and PlayResY in Script Info of .ass do, PlayResY=800 is hardcoded so it's impossible to change it.
My PR changes signature, so probably lib requires major version update or maybe you suggest other way of setting these options without signature changing and major update?

Here is how it works for me:

const subtitleStyle = {
  Fontname: 'Domus-Light',
  Fontsize: '42',
  PrimaryColour: '&H000000&',
  Bold: '0',
  Italic: '0',
  BorderStyle: '0',
  Outline: '0',
  Shadow: '0',
  Alignment: '5',
  MarginL: '40',
  MarginR: '40',
  MarginV: '100',
};

const subtitleOptions = {
  fontsdir: path.join(__dirname, '../src/api/static'),
};

const MarginR = `${+subtitleStyle.MarginR + width / 2}`;

        const srt = substation.stringify(subtitles, {
          'V4 Styles': {
            Style: {
              ...subtitleStyle,
              MarginR,
            },
          },
          'Script Info': {
            PlayResX: width,
            PlayResY: height,
          },
        });

 return fs.writeFile(filename, srt, err => {
          if (err) {
            return cb(err);
          }

          return cb(null, filename);
        });

----

 const video = videoshow(
            [
              {
                path: slideImageWithTitle,
                loop: duration,
                transition: false,
              },
            ],
            {
              size: `${width}x${height}`,
              format: 'mp4',
              audioCodec: 'aac',
              mime: 'video/mp4',
              videoCodec: 'libx264',
              outputOptions,
              subtitleOptions,
            },
          )
.subtitles(subtitles)
.audio(slideAudio);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant