0

I'm trying to create a metadata retriever based on FFmpeg. Since raw Android application resources are often only accessible using a file descriptor I need a way to pipe this data to FFmpeg via JNI. I know FFmpeg supports a "pipe" protocol:

UNIX pipe access protocol.

Allow to read and write from UNIX pipes.

The accepted syntax is: 

    pipe:[number]

number is the number corresponding to the file descriptor of the pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr). If number is not specified, by default the stdout file descriptor will be used for writing, stdin for reading.

For example: cat test.wav | ffmpeg -i pipe:0

My question is, how do I programmatically emulate cat test.wav | ffmpeg -i pipe:0 using JNI and avformat_open_input using a FileDescriptor? Is this possible?

William Seemann
  • 3,440
  • 10
  • 44
  • 78

1 Answers1

1

People from AndroidFFmpeg project implemented "jni://" protocol to stream data via JNI, see https://github.com/appunite/AndroidFFmpeg/blob/master/FFmpegLibrary/jni/jni-protocol.c

I do not know how it's used, just I came across that file and saw your question. I think you could use the same solution.

You may want to look at this post: https://stackoverflow.com/a/24747137/1028256 about passing FileDescriptor to JNI

Community
  • 1
  • 1
Mixaz
  • 4,068
  • 1
  • 29
  • 55