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

Android - burns subtitles (.srt) into the video is not working #399

Closed
Ebdaapp opened this issue Apr 18, 2022 · 8 comments
Closed

Android - burns subtitles (.srt) into the video is not working #399

Ebdaapp opened this issue Apr 18, 2022 · 8 comments
Assignees
Labels
android Affect Android platform library Affects the library question Further information is requested v4.5.1 Affects v4.5.1 release

Comments

@Ebdaapp
Copy link

Ebdaapp commented Apr 18, 2022

I am trying to burns a srt file into a mp4 video from an android application , the executeAsync runs with no error but the generated video does not contain the subtitle

here is my code

   String cmd = "-i " + videoPath + " -vf subtitles=\"" + subtitlePAth + ":force_style='Alignment=10,Fontsize=18\" " + 
   outputVideoPath;

   FFmpegKit.executeAsync(cmd, new FFmpegSessionCompleteCallback() {

        @Override
        public void apply(FFmpegSession session) {

        }
    }, new LogCallback() {

        @Override
        public void apply(com.arthenica.ffmpegkit.Log log) {


        }
    }, new StatisticsCallback() {

        @Override
        public void apply(Statistics statistics) {              

        }
    });`

and here is the generated logs

  ffmpeg version v4.5-dev-3393-g30322ebe3c Copyright (c) 2000-2021 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=arm-linux-androideabi- --sysroot=/files/android-sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/storage/light/projects/ffmpeg-kit/prebuilt/android-arm-neon/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=armv7-a --cpu=armv7-a --target-os=android --enable-neon --enable-asm --enable-inline-asm --build-suffix=_neon --ar=arm-linux-androideabi-ar --cc=armv7a-linux-androideabi24-clang --cxx=armv7a-linux-androideabi24-clang++ --ranlib=arm-linux-androideabi-ranlib --strip=arm-linux-androideabi-strip --nm=arm-linux-androideabi-nm --extra-libs='-L/storage/light/projects/ffmpeg-kit/prebuilt/android-arm-neon/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-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libdav1d --enable-libkvazaar --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-libzimg --disable-openssl --enable-zlib --enable-mediacodec
    libavutil      57. 13.100 / 57. 13.100
    libavcodec     59. 15.102 / 59. 15.102
    libavformat    59. 10.100 / 59. 10.100
    libavdevice    59.  1.100 / 59.  1.100
    libavfilter     8. 21.100 /  8. 21.100
    libswscale      6.  1.102 /  6.  1.102
    libswresample   4.  0.100 /  4.  0.100
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Download/7b85de4d-6af2-4eea-be9d-0d13c7f7819f/001001.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2mp41
      encoder         : Lavf59.10.100
    Duration: 00:00:29.60, start: 0.000000, bitrate: 467 kb/s
    Stream #0:0[0x1](und): Video: mpeg4 (mp4v / 0x7634706D), yuv420p(tv, bt470bg/bt709/bt709), 640x480 [SAR 1:2 DAR 2:3], 336 kb/s, 5 fps, 5 tbr, 10240 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
    Stream #0:1[0x2](und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  [mpeg4 @ 0xbacc1080] The "sub_text_format" option is deprecated: Deprecated, does nothing
  [aac @ 0xbacc1400] The "sub_text_format" option is deprecated: Deprecated, does nothing
  Stream mapping:
    Stream #0:0 -> #0:0 (mpeg4 (native) -> mpeg4 (native))
    Stream #0:1 -> #0:1 (aac (native) -> aac (native))
  Press [q] to stop, [?] for help
  [Parsed_subtitles_0 @ 0xf35141e0] libass API version: 0x1502000[Parsed_subtitles_0 @ 0xf35141e0] 
  [Parsed_subtitles_0 @ 0xf35141e0] libass source: commit: 0.15.2-0-gc967a5a3d9ec0d36af1148b3fdf2f307a21dd122[Parsed_subtitles_0 @ 0xf35141e0] 
  [Parsed_subtitles_0 @ 0xf35141e0] Shaper: FriBidi 1.0.11 (SIMPLE) HarfBuzz-ng 3.2.0 (COMPLEX)[Parsed_subtitles_0 @ 0xf35141e0] 
  [Parsed_subtitles_0 @ 0xf35141e0] No usable fontconfig configuration file found, using fallback.[Parsed_subtitles_0 @ 0xf35141e0] 
  [Parsed_subtitles_0 @ 0xf35141e0] Using font provider fontconfig[Parsed_subtitles_0 @ 0xf35141e0] 
  [Parsed_subtitles_0 @ 0xf35141e0] fontselect: failed to find any fallback with glyph 0x0 for font: (Arial, 400, 0)[Parsed_subtitles_0 @ 0xf35141e0] 
  Output #0, mp4, to '/storage/emulated/0/Download/7b85de4d-6af2-4eea-be9d-0d13c7f7819f/001001_sub5.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2mp41
      encoder         : Lavf59.10.100
    Stream #0:0(und): Video: mpeg4 (mp4v / 0x7634706D), yuv420p(tv, bt470bg/bt709/bt709, progressive), 640x480 [SAR 1:2 DAR 2:3], q=2-31, 200 kb/s, 5 fps, 10240 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc59.15.102 mpeg4
      Side data:
        cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc59.15.102 aac
  frame=    1 fps=0.0 q=5.7 size=       0kB time=00:00:01.55 bitrate=   0.2kbits/s speed= 2.4x    
  frame=   10 fps=8.7 q=2.0 size=       0kB time=00:00:03.50 bitrate=   0.1kbits/s speed=3.04x    
  frame=   20 fps= 12 q=2.0 size=       0kB time=00:00:05.36 bitrate=   0.1kbits/s speed=3.24x    
  frame=   32 fps= 15 q=2.0 size=     256kB time=00:00:07.87 bitrate= 266.5kbits/s speed=3.65x    
  frame=   45 fps= 17 q=2.0 size=     256kB time=00:00:10.49 bitrate= 199.8kbits/s speed=3.95x    
  frame=   58 fps= 18 q=2.0 size=     512kB time=00:00:12.97 bitrate= 323.2kbits/s speed=4.11x    
  frame=   69 fps= 19 q=2.0 size=     768kB time=00:00:15.23 bitrate= 413.1kbits/s speed=4.16x    
  frame=   81 fps= 19 q=2.0 size=     768kB time=00:00:17.60 bitrate= 357.5kbits/s speed=4.23x    
  frame=   92 fps= 20 q=2.0 size=    1024kB time=00:00:19.85 bitrate= 422.6kbits/s speed=4.26x    
  frame=  102 fps= 20 q=2.0 size=    1024kB time=00:00:21.89 bitrate= 383.1kbits/s speed=4.24x    
  frame=  115 fps= 20 q=2.0 size=    1280kB time=00:00:24.40 bitrate= 429.7kbits/s speed=4.31x    
  frame=  126 fps= 20 q=2.0 size=    1280kB time=00:00:26.67 bitrate= 393.0kbits/s speed=4.32x    
  frame=  139 fps= 21 q=2.0 size=    1536kB time=00:00:29.28 bitrate= 429.8kbits/s speed=4.39x    
  frame=  148 fps= 22 q=8.4 Lsize=    1701kB time=00:00:29.40 bitrate= 473.9kbits/s speed=4.34x    
  video:1225kB audio:466kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.561835%
  [aac @ 0xbacc2200] Qavg: 482.514

finally here is a sample of the srt file I am trying to burn

 1
 00:00:00,000 --> 00:00:03,326
  Text 1
 
 2
 00:00:03,326 --> 00:00:09,962
  Text 2
 
 3
 00:00:09,962 --> 00:00:16,160
  Text 3
 
 4
 00:00:16,160 --> 00:00:22,223
  Text 4

any idea why the generated video does not contain the subtitle ?

@tanersener
Copy link
Collaborator

See Tips.

@tanersener tanersener added question Further information is requested android Affect Android platform library Affects the library v4.5.1 Affects v4.5.1 release labels Apr 18, 2022
@Ebdaapp
Copy link
Author

Ebdaapp commented Apr 19, 2022

Thanks, based on your link , it seems the issue is related to undefined fronConfig in android devices, as the link suggests, I will try to overcome this issue by using FFmpegKitConfig.setFontDirectory

@Ebdaapp Ebdaapp closed this as completed Apr 28, 2022
@tanersener tanersener self-assigned this Apr 28, 2022
@deepak-newzera
Copy link

Facing the same issue and could not overcome it even by using FFmpegKitConfig.setFontDirectory.
Please help me resolve the issue.

@deepak-newzera
Copy link

Thanks, based on your link , it seems the issue is related to undefined fronConfig in android devices, as the link suggests, I will try to overcome this issue by using FFmpegKitConfig.setFontDirectory

Is this working for you?

@deepak-newzera
Copy link

FFmpegKitConfig.setFontDirectory is working only if it is set with an absolute path. But it is not working when a relative path is used. How can it be resolved in this case? Any idea?

@tanersener
Copy link
Collaborator

@deepak-newzera ffmpeg and ffmpeg-kit can use relative paths. Defining a relative path is the challenge there. Why? Because, ffmpeg and ffmpeg-kit both use native libraries. Therefore, if you want to define a relative path then you must know the exact location of their native libraries first. That's the main problem there. If you can do that relative paths will work too. Also, remember that ffmpeg and ffmpeg-kit don't understand special folders like application folder, asset folder, etc.

@deepak-newzera
Copy link

@tanersener Thanks for your response.
In my react native project, there are two issues I am facing regarding ffmpeg-kit-react-native.

i) For ios(simulator): Only the absolute path is working.
This issue has been fixed by setting the path as FFmpegKitConfig.setFontDirectory(fs.MainBundlePath, null). So now there is no problem with ios. It is working fine with both the ios simulator as well as the physical device.

ii) For android: Neither absolute nor relative path is working.
[Parsed_subtitles_0 @ 0x600001fcaf70] fontselect: failed to find any fallback with glyph 0x0 for font: (BananaGrotesk-Regular, 400, 0).
This is the error I am facing when I am trying to set whatever path is possible.
So please direct me so as to fix this issue.

@tanersener
Copy link
Collaborator

@deepak-newzera I don't have enough information to be able to make a comment about your problem. We have a pinned issue #215, that explains what we need to see in order to help you with your issues. Please give it a read and update your post or create another issue with those details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Affect Android platform library Affects the library question Further information is requested v4.5.1 Affects v4.5.1 release
Projects
None yet
Development

No branches or pull requests

3 participants