androidandroid-studiovideoffmpegmultimedia

FFmpeg error: Unable to find a suitable output format for ''


I'm new to ffmpeg as well as Android programming. I'm trying to load a video from a URL and crop it with ffmpeg. I want to save that video to a file. This is the command I found online:

"-i " + videoUrl + "-filter:v crop=240:120:100:100 -c:a copy test.mp4"

I have tried it and got the error Unable to find a suitable output format for ''

So I tried to narrow the possible cause down and tried these commands as well:

"-i " + videoUrl + " -c:v copy -c:a copy test.mp4"
"-i " + videoUrl + " -c:v copy test.mp4"
"-i " + videoUrl + " -c:a copy test.mp4"
"-i " + videoUrl + " test.mp4"

So with that last one I basically boiled it down to the bare minimum of what a comment needs, as far as I know. But still, same result.

All of them give me the same error. Here is the full output I got via FFmpeg.getLatestOutput()

ffmpeg version v4.2-dev-480 Copyright (c) 2000-2018 the FFmpeg developers
      built with Android (4751641 based on r328903) clang version 7.0.2 (https://android.googlesource.com/toolchain/clang 003100370607242ddd5815e4a043907ea9004281) (https://android.googlesource.com/toolchain/llvm 1d739ffb0366421d383e04ff80ec2ee591315116) (based on LLVM 7.0.2svn)
      configuration: --cross-prefix=i686-linux-android- 
                     --sysroot=/files/android-sdk/ndk-bundle/toolchains/mobile-ffmpeg-api-24-i686/sysroot
                     --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-x86/ffmpeg 
                     --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=i686 --cpu=i686 
                     --target-os=android --disable-neon --disable-asm --disable-inline-asm 
                     --enable-cross-compile --enable-pic --enable-jni --enable-lto 
                     --enable-optimizations --enable-swscale --enable-shared 
                     --disable-v4l2-m2m --disable-outdev=v4l2 
                     --disable-outdev=fbdev --disable-indev=v4l2 --disable-indev=fbdev 
                     --enable-small --disable-openssl --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-static --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-libopencore-amrwb 
                     --enable-libshine --enable-libspeex --enable-libwavpack 
                     --enable-libkvazaar --enable-libilbc --enable-libopus 
                     --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame 
                     --disable-sdl2 --enable-zlib --enable-mediacodec
      libavutil      56. 25.100 / 56. 25.100
      libavcodec     58. 42.104 / 58. 42.104
      libavformat    58. 25.100 / 58. 25.100
      libavdevice    58.  6.101 / 58.  6.101
      libavfilter     7. 46.101 /  7. 46.101
      libswscale      5.  4.100 /  5.  4.100
      libswresample   3.  4.100 /  3.  4.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://MyVideoUrl.com/example':
      Metadata:
        major_brand     : mp42
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        creation_time   : 2019-01-28T13:44:03.000000Z
        encoder         : HandBrake 1.2.0 2018122200
      Duration: 00:00:14.33, start: 0.000000, bitrate: 4478 kb/s
        Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1520x2700 [SAR 6075:4864 DAR 45:64], 4475 kb/s, 30.07 fps, 30 tbr, 90k tbn, 180k tbc (default)
        Metadata:
          creation_time   : 2019-01-28T13:44:03.000000Z
          handler_name    : VideoHandler
    [NULL @ 0x91833c00] Unable to find a suitable output format for ''
    : Invalid argument
    .

Why does ffmpeg assume that I have given it no output format and what I need to do to make this work?

I'm using implementation 'com.arthenica:mobile-ffmpeg-full:4.2'.


Solution

  • Turns out the error message was more than misleading. To all the other android programming beginners.

    Just because you get a directory path from your activity, does not mean you have permission to write in it.

    Seems obvious (and might be), but still. If an external source gives you wrong error messages, this can be confusing. My mistake was to try and write the output file in a folder I had no permission for.

    Tested it via this code:

    File test = new File("existingPath/myTestPath");
    
    if(test.mkdirs())
        Log.e("FILE", "MADE IT!!");
    else
        Log.e("FILE", "DIDNT MAKE IT!!");