使用带有android native c的FFMPEG将视频转换为音频

时间:2013-12-05 06:50:43

标签: android ffmpeg

我已将FFMPEG集成到我的应用程序中,我想将视频转换为音频文件,

但我想使用本机实现,(JNI)我不想使用ffmpeg脚本,

我已经尝试了this

1 个答案:

答案 0 :(得分:1)

您无法将视频转换为音频。但是,您可以提取并仅存储AVFormatContext的音频子流。伪代码:

// 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;

现在您需要做的就是丢弃其他索引上的所有其他流,并从识别的音频流中保存AVPackets。