零散记录

ffmpeg

  • 裁剪视频:ffmpeg -pix_fmt yuv420p -s 416x240 -i test.yuv -pix_fmt yuv420p -vf crop=192:192:0:0 test1.yuv
  • 获取固定帧数的视频: ffmpeg -pix_fmt yuv420p -s 416x240 -i "BasketballPass_416x240_50.yuv" -pix_fmt yuv420p -s 416x240 -frames 1 test.yuv

C/C++

读写

  • fgetc(FILE *fp) :从文件读取单个字符;
  • fgets(char *buf, int n, FILE *fp):从 fp 所指向的输入流中读取 n - 1 个字符。它会把读取的字符串复制到缓冲区 buf,并在最后追加一个 null 字符来终止字符串。如果这个函数在读取最后一个字符之前就遇到一个换行符 ‘\n’ 或文件的末尾 EOF,则只会返回读取到的字符,包括换行符。
#include 
#include 
#include 

#define FRAME_WIDTH 192
#define FRAME_HEIGHT 192
#define uchar unsigned char
#define uint unsigned int

int main()
{
    int number_of_words = 19;//(FRAME_WIDTH * FRAME_HEIGHT * 3) >> 1;
    unsigned char* h_src_ori_input = (unsigned char*)malloc(number_of_words);

    FILE *fp_in = fopen("read.txt", "r+");
    FILE *fp_out = fopen("write_c.txt", "w+");
    std::ifstream fin_src("read.txt");
    std::ofstream fout_src("write_cplusplus.txt");
    uchar yuv_val=0;

    if (fp_in) {
        while ()
        fscanf(fp_in, "%c", &yuv_val);
        printf("%x\n", (int)yuv_val);
        fprintf(fp_out, "%d", yuv_val);
        fclose(fp_in);
    }
    std::cout << std::endl;
    if (fin_src.is_open() && fout_src.is_open()) {
        while (!fin_src.eof()) {
            fin_src >> yuv_val;
            printf("%x\n", (int)yuv_val);
            fout_src << yuv_val;
        }
        fin_src.close();
        fout_src.close();
    }

}

你可能感兴趣的:(其他)