Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Movie::init(const io::path &path) {
- // TODO: error checking
- avcodec_register_all();
- av_log_set_level(AV_LOG_DEBUG);
- auto file = new FileInputStream(path.filename());
- if (file->open(path.c_str())) {
- info() << "Opened video file";
- // INBUFF_SIZE = 4096
- uint8_t inputBuffer[4096 + FF_INPUT_BUFFER_PADDING_SIZE];
- char buffer[1024];
- AVPacket avPacket;
- av_init_packet(&avPacket);
- info() << "Video decoding.";
- mCodec = avcodec_find_decoder(CODEC_ID_BINKVIDEO);
- if (mCodec == nullptr) {
- info() << "Failed to find a codec.";
- return;
- }
- info() << "Loaded codec";
- mCodecContext = avcodec_alloc_context3(mCodec);
- if (mCodecContext == nullptr) {
- info() << "Failed to create a codec context.";
- return;
- }
- info() << "Created a codec context";
- mFrame = av_frame_alloc();
- if (avcodec_open2(mCodecContext, mCodec, nullptr) < 0) {
- info() << "Fail";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement