/usr/bin/ld: warning: libswresample.so.1, needed by /usr/lib/gcc/i686-linux-gnu/4.9/../../../../lib/
解决方案:gcc -o ffmpegtest acc.c -lavformat -lavcodec -lavutil -lz -lm -lswresample
·
利用FFMPEG简单分离音视频数据流
测试源码来源于:http://my.oschina.net/u/2336532/blog/399058
#include <stdio.h>
#include "libavformat/avformat.h"
static const char *media_file = "11.mp4";
int main(void)
{
int i, vid_idx, aud_idx;
FILE *fp_vides = NULL, *fp_audes = NULL;
AVFormatContext *pFormatCtx = NULL;
AVPacket pkt;
av_register_all();
avformat_open_input(&pFormatCtx, media_file, NULL, NULL);
avformat_find_stream_info(pFormatCtx, NULL);
fp_vides = fopen("vid_es.dat", "wb");
fp_audes = fopen("aud_es.dat", "wb");
// 1, handle stream info
for (i=0; i<pFormatCtx->nb_streams; i++)
{
if (pFormatCtx->streams[i]->codec->codec_type ==AVMEDIA_TYPE_VIDEO)
vid_idx = i;
else if (pFormatCtx->streams[i]->codec->codec_type ==AVMEDIA_TYPE_AUDIO)
aud_idx = i;
else
;//such as subtitile
}
while (av_read_frame(pFormatCtx, &pkt) >= 0)
{
// 2, handle pkt data
if (pkt.stream_index == vid_idx)
fwrite(pkt.data, pkt.size, 1, fp_vides);
else if (pkt.stream_index == aud_idx)
fwrite(pkt.data, pkt.size, 1, fp_audes);
else
;// such as subtitile
av_free_packet(&pkt);
}
fclose(fp_vides);
fclose(fp_audes);
avformat_close_input(&pFormatCtx);
return 0;
}
解决方案:
gcc -o ffmpegtest acc.c -lavformat -lavcodec -lavutil -lz -lm -lswresample
更多推荐
已为社区贡献2条内容
所有评论(0)