Демуксинг и позиционирование.
Демуксинг и позиционирование.
api2-demux-seek <входной файл>
#include <iostream>
#include <set>
#include <map>
#include <memory>
#include <functional>
#include "avcpp/av.h"
#include "avcpp/ffmpeg.h"
#include "avcpp/codec.h"
#include "avcpp/packet.h"
#include "avcpp/videorescaler.h"
#include "avcpp/audioresampler.h"
#include "avcpp/avutils.h"
#include "avcpp/format.h"
#include "avcpp/formatcontext.h"
#include "avcpp/codec.h"
#include "avcpp/codeccontext.h"
using namespace std;
using namespace av;
int main(int argc, char **argv)
{
if (argc < 2)
return 1;
av::init();
av::setFFmpegLoggingLevel(AV_LOG_DEBUG);
string uri {argv[1]};
error_code ec;
FormatContext ictx;
ictx.openInput(uri);
ictx.findStreamInfo();
clog << "Seekable: " << ictx.seekable() << endl;
{
ictx.seek({200, {1,1}});
auto pkt = ictx.readPacket();
clog << "Seek 0: [" << pkt.streamIndex() << "] pts=" << pkt.pts() << " / " << pkt.pts().seconds() << endl;
}
{
ictx.seek({0, {1,1}});
auto pkt = ictx.readPacket();
clog << "Seek 0: [" << pkt.streamIndex() << "] pts=" << pkt.pts() << " / " << pkt.pts().seconds() << endl;
}
{
ictx.seek({200, {1,1}});
clog << "Seek 2:\n";
while (true) {
auto pkt = ictx.readPacket(ec);
if (!pkt)
break;
clog << " [" << pkt.streamIndex() << "] pts=" << pkt.pts() << " / " << pkt.pts().seconds() << endl;
}
}
{
ictx.seek({0, {1,1}});
clog << "Seek 3:\n";
size_t count = 100;
while (count --> 0) {
auto pkt = ictx.readPacket(ec);
if (!pkt)
break;
clog << " [" << pkt.streamIndex() << "] pts=" << pkt.pts() << " / " << pkt.pts().seconds() << endl;
}
}
}