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

Is Expression Evaluation supported? #1094

Open
meleffendi opened this issue Jan 5, 2025 · 0 comments
Open

Is Expression Evaluation supported? #1094

meleffendi opened this issue Jan 5, 2025 · 0 comments

Comments

@meleffendi
Copy link

Description
Executing an ffmpeg command that contains expressions fails. I tried to run the following command on ubuntu and it worked:

ffmpeg -i in.mp4 -c:a copy -qscale 0 -vf drawtext="fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=if(eq(mod(t\,30)\,0)\,rand(0\,(w-text_w))\,x):y=if(eq(mod(t\,30)\,0)\,rand(0\,(h-text_h))\,y)" out.mp4

Expected behavior
Expected behavior is that the command should execute and apply the drawtext filter on the input video which in this case draws a "hello world" in a random location that changes every 30 seconds. The filter is an example taken from the documentation here

Current behavior
Receiving the following error:

[AVFilterGraph @ 0x780d69de00] No option name near 'if(eq(mod(t'
[AVFilterGraph @ 0x780d69de00] Error parsing a filter description around: ,30),0),rand(0,(h-text_h)),y)
[AVFilterGraph @ 0x780d69de00] Error parsing filterchain 'drawtext=fontsize=30:fontfile=FreeSerif.ttf:text='X':x=if(eq(mod(t,30),0),rand(0,(w-text_w)),x):y=if(eq(mod(t,30),0),rand(0,(h-text_h)),y)' around: ,30),0),rand(0,(h-text_h)),y)
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!
Error: RetCode 1

To Reproduce

const cmd = `-y -i ${videoPath} -c:a copy -qscale 0 -vf drawtext="fontsize=30:text='X':x=if(eq(mod(t\,30)\,0)\,rand(0\,(w-text_w))\,x):y=if(eq(mod(t\,30)\,0)\,rand(0\,(h-text_h))\,y)" ${outputPath}`;
FFmpegKit.execute(cmd).then(async (session) => {
  const returnCode = await session.getReturnCode();
  const sessionLog = await session.getAllLogs();
  sessionLog.forEach((log) => console.log(log.getMessage()));

  if (ReturnCode.isSuccess(returnCode)) {
    console.log('Success')
  } else {
    console.log("Error: RetCode", returnCode.getValue());
  }
});

Screenshots
If applicable, add screenshots to help explain your problem.

Logs

Error message:

[AVFilterGraph @ 0x780d69de00] No option name near 'if(eq(mod(t'
[AVFilterGraph @ 0x780d69de00] Error parsing a filter description around: ,30),0),rand(0,(h-text_h)),y)
[AVFilterGraph @ 0x780d69de00] Error parsing filterchain 'drawtext=fontsize=30:fontfile=FreeSerif.ttf:text='X':x=if(eq(mod(t,30),0),rand(0,(w-text_w)),x):y=if(eq(mod(t,30),0),rand(0,(h-text_h)),y)' around: ,30),0),rand(0,(h-text_h)),y)
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!
Error: RetCode 1

React Native on Android configuration:

ffmpeg version n6.0
Copyright (c) 2000-2023 the FFmpeg developers

built with Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)
configuration: --cross-prefix=aarch64-linux-android- --sysroot=/home/m/Android/Sdk/ndk/22.1.7171670//toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/m/ffmpeg-kit/prebuilt/android-arm64-lts/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --target-os=android --enable-neon --enable-asm --enable-inline-asm --ar=aarch64-linux-android-ar --cc=aarch64-linux-android21-clang --cxx=aarch64-linux-android21-clang++ --ranlib=aarch64-linux-android-ranlib --strip=aarch64-linux-android-strip --nm=aarch64-linux-android-nm --extra-libs='-L/home/m/ffmpeg-kit/prebuilt/android-arm64-lts/cpu-features/lib -lndk_compat' --disable-autodetect --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --disable-static --enable-shared --enable-pthreads --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libdav1d --enable-libkvazaar --enable-libsnappy --disable-sdl2 --enable-libzimg --disable-openssl --enable-zlib --disable-mediacodec

React Native on IOS configuration:

ffmpeg version n6.0
Copyright (c) 2000-2023 the FFmpeg developers
built with Apple clang version 14.0.3 (clang-1403.0.22.14.1)
configuration: --cross-prefix=arm64-ios-darwin- --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk --prefix=/Users/sue/Projects/arthenica/ffmpeg-kit/prebuilt/apple-ios-arm64/ffmpeg --pkg-config=/opt/homebrew/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8 --target-os=darwin --enable-neon --enable-asm --ar=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar --cc=clang --cxx=clang++ --as='/Users/sue/Projects/arthenica/ffmpeg-kit/.tmp/gas-preprocessor.pl -arch aarch64 -- clang -arch arm64 -target arm64-apple-ios12.1 -march=armv8-a+crc+crypto -mcpu=generic -DFFMPEG_KIT_ARM64 -Wno-unused-function -Wno-deprecated-declarations -fstrict-aliasing -DIOS -DFFMPEG_KIT_BUILD_DATE=20230903 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk -Oz -miphoneos-version-min=12.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/include' --ranlib=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib --strip=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip --nm=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm --extra-ldflags='-miphoneos-version-min=12.1' --disable-autodetect --enable-cross-compile --enable-pic --enable-inline-asm --enable-optimizations --enable-swscale --enable-shared --disable-static --install-name-dir='@rpath' --enable-pthreads --disable-v4l2-m2m --disable-outdev=v4l2 --disable-outdev=fbdev --disable-indev=v4l2 --disable-indev=fbdev --enable-small --disable-xmm-clobber-test --disable-debug --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libass --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libdav1d --enable-libkvazaar --enable-libsnappy --disable-sdl2 --enable-libzimg --disable-openssl --enable-zlib --enable-audiotoolbox --disable-outdev=audiotoolbox --enable-bzlib --enable-videotoolbox --enable-avfoundation --enable-iconv --disable-coreimage --disable-appkit --disable-opencl --disable-opengl

Environment

  • Platform: Android/iOS/ReactNative
  • Architecture: arm64-v8a, arm64-v8a
  • Version: v6.0.2.LTS
  • Source branch: main
  • react-native info: v0.74.5
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