ffmpeg-kit icon indicating copy to clipboard operation
ffmpeg-kit copied to clipboard

text_align throwing `Option not found` error - React Native Ffmpeg

Open ChristopherGabba opened this issue 1 year ago • 6 comments

Description I am trying to use the text_align property noted in the docs:

drawtext=text='Test caption that is long enough to wrap on the screen':x=60:y=120:fontcolor=white:text_align=C:text_align=C+M:line_spacing=10:fontsize=46,

I've ruled down the text_align property as the source and I have tried numerous combinations of entering it. I found this thread on reddit and it talks about needing ffmpeg 6.1? https://www.reddit.com/r/ffmpeg/comments/18pcr34/why_dont_we_allow_drawtext_option_align_text_yet/

And I get this error:

'drawtext': Option not found\nError reinitializing filters!
Failed to inject frame into filter network: Option not found
Error while processing the decoded data for stream #0:0
Conversion failed!

Expected behavior The text should align center.

Current behavior The ffmpeg fails to compile.

To Reproduce Use the code above to generate an image with text. Here is my full ffmpeg command:

    command = `-f lavfi -i color=color=white:size=${captionWidth}x${captionHeight} -vf " \
    drawbox=x=0:y=0:w=iw:h=ih:color=black:t=fill, \
    drawtext=text='Chris':x=60:y=50:fontfile=${semiBoldFont}:fontcolor=0xFF3981:fontsize=46, \
    drawtext=text='This is a long caption test in order to try\nfor wrapping font':x=60:y=${BASE_HEIGHT_OF_FIRST_NAME}:fontfile=${semiBoldFont}:fontcolor=white:line_spacing=${LINE_SPACING}:fontsize=46, \
    drawtext=text='Other User:x=60:y=${positionOfSecondName}:fontfile=${semiBoldFont}:fontcolor=0xFF3981:fontsize=46, \
    drawtext=text='This is a super long caption that should \n wrap as well and be centered.':x=60:y=${positionOfSecondCaption}:fontfile=${semiBoldFont}:line_spacing=${LINE_SPACING}:fontcolor=white:fontsize=46 \
  " -frames:v 1 -update 1 ${captionOutput}`

Logs Logs shown above

Environment

  • Platform: ReactNative
  • "ffmpeg-kit-react-native": "^6.0.2",
  • "react-native": "0.74.5",
  • "@config-plugins/ffmpeg-kit-react-native": "^8.0.0",

Other Add any other context about the problem here.

ChristopherGabba avatar Sep 13 '24 19:09 ChristopherGabba

See 9 in Tips wiki.

tanersener avatar Oct 27 '24 00:10 tanersener

@tanersener Thanks for sharing. However, I'm not getting this issue with draw-text not being found, it is working fine. It's just the draw-text option of text_align that is not working.

Basically, as soon as I add text_align I get this error.

ChristopherGabba avatar Nov 07 '24 18:11 ChristopherGabba

@ChristopherGabba I've checked it again. text_align is a new option added in FFmpeg 7.0. That's why you see that error. The latest we have in FFmpegKit is FFmpeg 6.0.

In old versions, text can be aligned by manually setting the x and y coordinates to position the text as desired.

x=(W-tw)/2 centers the text horizontally
y=(H-th)/2 centers the text vertically

tanersener avatar Nov 08 '24 15:11 tanersener

@tanersener okay perfect, thanks! Any forecast on v7?

ChristopherGabba avatar Nov 08 '24 16:11 ChristopherGabba

A new release is expected in the coming weeks, but it hasn't been decided yet whether it will be a 6.x or 7.x release.

tanersener avatar Nov 08 '24 16:11 tanersener

@tanersener thanks so much!

ChristopherGabba avatar Nov 08 '24 17:11 ChristopherGabba