ffmpeg-learning-1

在Windows下,下載相應的包。測試

先測試一下:code

libavutil下adler32和fifo功能。get

 

cmake文件寫法:it

add_executable(test_ffmpeg ${PROJECT_SOURCE_DIR}/src/test_ffmpeg.cpp)
target_link_libraries(test_ffmpeg ${PROJECT_SOURCE_DIR}/../ffmpeg_dev/lib/avutil.lib)io

代碼:table

#include <stdlib.h>
#include <stdio.h>
#include <memory>
extern "C" {
#include "libavutil/adler32.h"
#include "libavutil/fifo.h"
}test

unsigned char * load_data(const char *filename, int& len)
{
    FILE * fp = fopen(filename, "rb");
    if (fp == NULL)
        return NULL;
    fseek(fp, 0, SEEK_END);
    len = ftell(fp);
    fseek(fp, 0, SEEK_SET);ffmpeg

    if (len == 0) {
        fclose(fp);
        return NULL;
    }
    unsigned char * buf = new unsigned char[len];
    fread(buf, len, 1, fp);
    fclose(fp);date

    return buf;
}file

bool write_data(const char *filename, unsigned char *buf, int size)
{
    FILE * fp = fopen(filename, "wb");
    if (fp == NULL)
        return false;

    fwrite(buf, size, 1, fp);
    fclose(fp);
    return true;
}

 

int main(int argc, char * argv[])
{
    if (argc != 2) {
        printf("usage:test_ffmpeg filename\n");
        return 0;
    }
    const char * filename = argv[1];

    int len;
    std::unique_ptr<unsigned char> buf(load_data(filename, len));

    unsigned long adler32_code = av_adler32_update(0, buf.get(), len);

    printf("adler32_code is:%x\n", adler32_code);


    AVFifoBuffer* fifo = av_fifo_alloc(1024);


    av_fifo_free(fifo);

    

    return 0; }

本站公眾號
   歡迎關注本站公眾號,獲取更多信息