arthenica / ffmpeg-kit

FFmpeg Kit for applications. Supports Android, Flutter, iOS, Linux, macOS, React Native and tvOS. Supersedes MobileFFmpeg, flutter_ffmpeg and react-native-ffmpeg.
https://arthenica.github.io/ffmpeg-kit
GNU Lesser General Public License v3.0
4.52k stars 603 forks source link

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

Open ChristopherGabba opened 2 months ago

ChristopherGabba commented 2 months ago

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

Other Add any other context about the problem here.

tanersener commented 3 weeks ago

See 9 in Tips wiki.

ChristopherGabba commented 2 weeks ago

@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.

tanersener commented 1 week ago

@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
ChristopherGabba commented 1 week ago

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

tanersener commented 1 week ago

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.

ChristopherGabba commented 1 week ago

@tanersener thanks so much!