1

I am trying to use the ffmpeg binary and call it via a native linux command in android. Most of the commands work fine but the problem is that when i need to pass an http url as an input to the -i option i get "No such file or directory" for the url. The url however is existing and running the SAME command on a mac does the job as expected.

Here is my compile config for the ffmpeg build:

./configure \
$DEBUG_FLAG \
--arch=arm \
--cpu=cortex-a8 \
--target-os=linux \
--enable-runtime-cpudetect \
--prefix=$prefix \
--enable-pic \
--disable-shared \
--enable-static \
--cross-prefix=$NDK_TOOLCHAIN_BASE/bin/$NDK_ABI-linux-androideabi- \
--sysroot="$NDK_SYSROOT" \
--extra-cflags="-I../x264 -mfloat-abi=softfp -mfpu=neon" \
--extra-ldflags="-L../x264" \
\
--enable-version3 \
--enable-gpl \
\
--disable-doc \
--enable-yasm \
\
--enable-decoders \
--enable-nonfree \
--enable-encoders \
--enable-muxers \
--enable-demuxers \
--enable-parsers \
--enable-protocols \
--enable-protocol=http \
--enable-filters \
--enable-avresample \
\
--disable-indevs \
--enable-indev=lavfi \
\
--enable-hwaccels \
\
--enable-ffmpeg \
--enable-ffplay \
--enable-libmp3lame \
--enable-network \
\
--enable-libx264 \
--enable-libfaac \
--enable-zlib

Its based off of this project: https://github.com/guardianproject/android-ffmpeg-java

Command is something along the lines of that:

ffmpeg -i "http://someurl" -f mp3 -ab 192000 -vn demoo.mp3

The idea being to download the audio track from a video and encode it as mp3. I explicitly added multiple enable protocols options but nothing seems to do the job. I tried an alternative config as well, removing everything below enable-gpl just to make sure there arent any conflicts, but it fires the same error. If i give it a normal filesystem path it works fine.

Following the comments here is the exact output of the command and the output:

03-25 00:22:08.806: VERBOSE/FFMPEG(16491): /data/data/org.ffmpeg.android/app_bin/ffmpeg -i "http://r6---sn-gvbxgn-tt1d.c.youtube.com/videoplayback?ipbits=8&cp=U0hVSVJLV19KUUNONV9KRUFJOnQ0STMtb0JXc0py&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&id=c0045acebe0c3341&upn=IVAGxSD1hE0&source=youtube&ratebypass=yes&mv=m&key=yt1&expire=1364209857&itag=18&ms=au&ip=99.234.119.90&mt=1364185033&fexp=923418%2C901802%2C906383%2C902000%2C919512%2C913605%2C931202%2C900821%2C900823%2C931203%2C931401%2C908529%2C919373%2C930803%2C920201%2C929602%2C930101%2C930603%2C926403%2C900824%2C910223&sver=3&newshard=yes&signature=838AEB4650D8353B70DBC49341E0C40706DC6153.297639FD70A7F9710F29AE9E278A4FC4A32E0C67" -f mp3 -ab 192000 -vn /data/data/org.ffmpeg.android/files/demoooo.mp3 -loglevel debug
03-25 00:22:08.956: DEBUG/ffmpeg(16491): Process exited with code:1
03-25 00:22:08.966: DEBUG/ffmpeg(16491): Shell output:ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
03-25 00:22:08.976: DEBUG/ffmpeg(16491): Shell output:  built on Mar 24 2013 02:24:38 with gcc 4.6 20120106 (prerelease)
03-25 00:22:08.976: DEBUG/ffmpeg(16491): Shell output:  configuration: --arch=arm --cpu=cortex-a8 --target-os=linux --enable-runtime-cpudetect --prefix=/data/data/info.guardianproject.ffmpeg/app_opt --enable-pic --disable-shared --enable-static --cross-prefix=/Users/feribg/Dev/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi- --sysroot=/Users/feribg/Dev/android-ndk-r8d/platforms/android-3/arch-arm --extra-cflags='-I../x264 -mfloat-abi=softfp -mfpu=neon' --extra-ldflags=-L../x264 --enable-version3 --enable-gpl
03-25 00:22:08.976: DEBUG/ffmpeg(16491): Shell output:  libavutil      51. 54.100 / 51. 54.100
03-25 00:22:08.976: DEBUG/ffmpeg(16491): Shell output:  libavcodec     54. 23.100 / 54. 23.100
03-25 00:22:08.976: DEBUG/ffmpeg(16491): Shell output:  libavformat    54.  6.100 / 54.  6.100
03-25 00:22:08.986: DEBUG/ffmpeg(16491): Shell output:  libavdevice    54.  0.100 / 54.  0.100
03-25 00:22:08.996: DEBUG/ffmpeg(16491): Shell output:  libavfilter     2. 77.100 /  2. 77.100
03-25 00:22:08.996: DEBUG/ffmpeg(16491): Shell output:  libswscale      2.  1.100 /  2.  1.100
03-25 00:22:08.996: DEBUG/ffmpeg(16491): Shell output:  libswresample   0. 15.100 /  0. 15.100
03-25 00:22:08.996: DEBUG/ffmpeg(16491): Shell output:  libpostproc    52.  0.100 / 52.  0.100
03-25 00:22:08.996: DEBUG/ffmpeg(16491): Shell output:"http://r6---sn-gvbxgn-tt1d.c.youtube.com/videoplayback?ipbits=8&cp=U0hVSVJLV19KUUNONV9KRUFJOnQ0STMtb0JXc0py&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&id=c0045acebe0c3341&upn=IVAGxSD1hE0&source=youtube&ratebypass=yes&mv=m&key=yt1&expire=1364209857&itag=18&ms=au&ip=99.234.119.90&mt=1364185033&fexp=923418%2C901802%2C906383%2C902000%2C919512%2C913605%2C931202%2C900821%2C900823%2C931203%2C931401%2C908529%2C919373%2C930803%2C920201%2C929602%2C930101%2C930603%2C926403%2C900824%2C910223&sver=3&newshard=yes&signature=838AEB4650D8353B70DBC49341E0C40706DC6153.297639FD70A7F9710F29AE9E278A4FC4A32E0C67": No such file or directory
Feras
  • 2,114
  • 3
  • 20
  • 42
  • Very likely that the ffmpeg binary is too old. Can you post the full error output? – slhck Mar 24 '13 at 16:34
  • break your process up into 2 steps. Http to get the input file and store it on the device. Then normal ffmpeg using the local input file. – Robert Rowntree Mar 24 '13 at 19:52
  • if u plan to distribute the app, IMO - u should use normal JNI interface as in Guardian from git. CLI is brittle. If you need to go CLI route, you could look at using Busybox/WGET to get the file then normal CLI ffmpeg. You can put it in a bash script on run the script on the CLI on the device. – Robert Rowntree Mar 24 '13 at 19:58
  • @RobertRowntree I agree that would work, but the idea here is to download only the audio stream. Thats what the command above does, so that way its converting on the fly and bandwidth used is only for the audio stream (no video downloaded), which is the whole point of the concept. – Feras Mar 24 '13 at 20:19
  • @slhck are you aware since which version in FFMPEG is http streaming supported and isnt it going to fire an error during compile time when I pass options --enable-protocols and --enable-protocol=http, saying that there isnt such option? Because currently it builds just fine. – Feras Mar 24 '13 at 20:22
  • I didn't say that it doesn't include the option. Can you show the *exact* command you're using and the full, uncut output please? – slhck Mar 24 '13 at 20:29
  • I didnt mean that in an offending manner, i was asking if you had any information as to which version started to support the http protocol, but I am pretty sure thats not an issue. I updated my question to include the entire log – Feras Mar 25 '13 at 04:25
  • Not offended at all :) Many errors in FFmpeg are just bugs, and it's often worth using a recent version. Yours is 0.11, and FFmpeg is at 1.2 now, where they've fixed hundreds of bugs in between. Thanks for providing the output. I can't access that URL and get a not authorized error. It might also be a cache issue. Can you ping or curl the URL from the device? I'm not entirely sure whether binaries on the device need special permissions to access the Internet—could be worth checking. – slhck Mar 25 '13 at 07:57

1 Answers1

1

BTW if its youtub that you want to rip see youtube audio

RTSP java client libs here

Are you reading stderr from the call to ffmpeg? I bet that if you look at it that ffmpeg stdout OR stderr will contain message about what went wrong with the network interface trying to connect over http to a remote input file....

below is example of android wrapper that gets stderr:

System.out.println("Starting process " +command.toString());
            ProcessBuilder builder = new ProcessBuilder(command);
            Map<String, String> environ = builder.environment();
//          for(Entry<String, String> entry : environ.entrySet()){
    //          System.out.println("ENV " +entry.getKey() + " " +entry.getValue());
      //      }
//          builder.redirectErrorStream(true);
            Process process = null;
            try {
                process = builder.start();

            InputStream is = process.getInputStream();

            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line;
            while ((line = br.readLine()) != null) {  
              //System.out.println(line);
                outfil=line;
            }
Community
  • 1
  • 1
Robert Rowntree
  • 6,230
  • 2
  • 24
  • 43
  • Yes I am, it goes on showing the library version, configuration options, command executed and so on and stops at: "http://blabal" No such file or directory. That is the last line in the output. – Feras Mar 24 '13 at 20:21
  • u want to rip just the audio? Whats the container type? You may want to look at using VLC instead of ffmpeg? – Robert Rowntree Mar 24 '13 at 20:47
  • 1
    'ffmpeg -loglevel debug' may provide more info on whats going wrong with input over http. – Robert Rowntree Mar 24 '13 at 21:22
  • The loglevel directive didnt change the log at all unfortunately, but I updated my question to include the entire log output. Not sure what you mean by using VLC instead, isnt it an app, what i need is a library, or they offer some sort of open source tool that can do what I am trying? – Feras Mar 25 '13 at 04:25
  • vlc is often used to rip a media track. it runs on android . i think its open source. i suggest because it may be better tool to rip a track. – Robert Rowntree Mar 25 '13 at 14:38
  • changed my answer to include link on ripping youtube audio. good luck – Robert Rowntree Mar 25 '13 at 14:44
  • That might actually be a better way to do it. I will give it a try. Thanks! – Feras Mar 25 '13 at 14:54
  • added links for youtube audio only is for background. no way that i would advise instrumenting a production android app to use rtsp protocol to implement this particular feature. – Robert Rowntree Mar 25 '13 at 14:54