Passing inline fd int to FFMPEG from open URI

I am trying to open a file descriptor from a URI CATEGORY_OPENABLEfrom the repository access frame. I first try with the file on the SD card, which I can already solve using the file path using the column _dataand open (I try to get away from this and use the file descriptor instead).

I get my own int fd as follows:

int fd = getContentResolver().openFileDescriptor(data.getData(), "r").detachFd();

Then in C ++ I try to open it like this, an idea taken from How to properly transfer a FileDescriptor file to FFmpeg using JNI in Android :

pFormatCtx = avformat_alloc_context();
pFormatCtx->iformat = av_find_input_format("mp3");

char path[50];
sprintf(path, "pipe:%d", fd);

int e;
if(e=(avformat_open_input(&pFormatCtx,path,NULL,NULL)!=0)){
    av_strerror(e, path, 50);
    return error;
}

" " avformat_open_input. , jni- jniGetFDFromFileDescriptor , FileDescriptor, int fd. URI FFMPEG , ?

+6
3

@Steve M, , : : 1. ffmpeg?

, , . https://github.com/illuusio/ffmpeg-example

! @Stev M

+2

(FFmpegMediaMetadataRetriever) . . .

: , FFmpeg .

avformat_open_input, dup() , :

 if (state->offset > 0) {
        state->pFormatCtx = avformat_alloc_context();
        state->pFormatCtx->skip_initial_bytes = state->offset;
 } 
+1

This may be a stupid observation, but you tried to replace:

avformat_open_input (& ampl; avFormatPtr, "dummyFilename", nullptr, nullptr);

(avformat_open_input(&pFormatCtx,path,NULL,NULL)

Replace for:

(avformat_open_input(&pFormatCtx,path,nullptr,nullptr)

?

0
source

Source: https://habr.com/ru/post/1017037/


All Articles