本文整理汇总了C++中MediaSource::open方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaSource::open方法的具体用法?C++ MediaSource::open怎么用?C++ MediaSource::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaSource
的用法示例。
在下文中一共展示了MediaSource::open方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char ** argv)
{
if (argc < 3) {
fprintf(stderr, "need at least 3 arguments.\n");
exit(1);
}
av_register_all();
MediaSource ms;
MediaMuxer muxer;
ms.open(argv[1], 0);
muxer.open(argv[2], ms.getFmtCtx(), true);
AVPacket pkt;
AVFrame * frame = NULL;
while (!ms.read(&pkt)) {
AVMediaType type = ms.getMediaType(&pkt);
int ret = ms.decode(frame, &pkt);
if (ret < 0) {
fprintf(stderr, "decode error.\n");
exit(1);
}
if (ret == 0)
continue;
switch(type) {
case AVMEDIA_TYPE_AUDIO:
break;
case AVMEDIA_TYPE_VIDEO:
break;
default:
av_log(NULL, AV_LOG_INFO, "Unsupported packet type.\n");
break;
}
muxer.write(frame->data, frame->nb_samples, type);
if (pkt.data)
av_free_packet(&pkt);
}
muxer.close();
ms.close();
return 0;
}
示例2: main
int main(int argc, char ** argv)
{
av_register_all();
MediaSource ms;
AVPacket pkt;
AVFrame * frame = avcodec_alloc_frame();
// AVFrame * dst_frame = avcodec_alloc_frame();
AVPicture picture;
int index = 1;
char str[100] = {0};
ms.open(argv[1], 1);
VideoScale sc;
sc.init(ms.getWidth(), ms.getHeight(), ms.getPixFormat(), 352, 288,
ms.getPixFormat(), 0, NULL, NULL, NULL);
avpicture_alloc(&picture, ms.getPixFormat(), 352, 288);
while (ms.read(&pkt) == 0) {
int ret = ms.decode(frame, &pkt);
if (ret > 0) {
if (ms.isVideoPacket(&pkt)) {
if (index > 30)
continue;
snprintf(str, 100, "%02d.pgm", index++);
sc.scale(frame->data, frame->linesize, 0, ms.getHeight(),
picture.data, picture.linesize);
pgm_save(picture.data[0], picture.linesize[0], 352, 288, str);
}
if (ms.isAudioPacket(&pkt)) {
/*
static AudioResample rsp;
rsp.init(ms.getChannelLayout(), ms.getSampleFormat(), ms.getSampleRate(),
ms.getChannelLayout(), ms.getSampleFormat(), ms.getSampleRate());
*/
}
}
}
ms.close();
return 0;
}