Mr.G
Mr.G

Reputation: 1275

Convert video to audio using FFMPEG with android native c

I have integrated FFMPEG into my application and I want to convert videos to audio files,

But I want to do it using native implementation , (JNI) I don't want to use ffmpeg scripts ,

I have already tried this

Upvotes: 3

Views: 409

Answers (1)

Karim Agha
Karim Agha

Reputation: 3625

You can't convert video to audio. You can however extract and only store the audio sub-streams of an AVFormatContext. Pseudocode:

// look for the first auid substream, and save its index:
for (size_t i = 0; i < AvFormatContextInstance->nb_streams; ++i)
    if (AvFormatContextInstance->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
        streamindex = i;

Now all you need to do is discard all other streams on other indexes and save AVPackets from the recognized audio stream.

Upvotes: 1

Related Questions