• 【Codecs】yuvcut,实现yuv文件剪切功能


    参考:https://stackoverflow.com/questions/17967278/extract-some-yuv-frames-from-large-yuv-file?rq=1

    // include libraries
    #include <fstream>
    using namespace std;
    
    #define P420 1.5
    
    const int IMAGE_SIZE = 1920*1080;  // ful HD image size in pixels
    const double IMAGE_CONVERTION = P420;
    int n_frames = 300;  // set number of frames to copy
    int skip_frames = 500;  // set number of frames to skip from the begining of the input file
    
    char in_string[] = "F:\BigBucksBunny\yuv\BigBuckBunny_1920_1080_24fps.yuv";
    char out_string[] = "out.yuv";
    
    
    //////////////////////
    //   main
    //////////////////////
    int main(int argc, char** argv)
    {
        double image_size = IMAGE_SIZE * IMAGE_CONVERTION;
        long file_size = 0;
    
        // IO files
        ofstream out_file(out_string, ios::out | ios::binary);
        ifstream in_file(in_string, ios::in | ios::binary);
    
        // error cheking, like check n_frames+skip_frames overflow
        // 
        // TODO
    
        // image buffer
        char* image = new char[(int)image_size];
    
        // skip frames
        in_file.seekg(skip_frames*image_size);
    
        // read/write image buffer one by one
        for(int i = 0; i < n_frames; i++)
        {
            in_file.read(image, image_size);
            out_file.write(image, image_size);
        }
    
        // close the files
        out_file.close();
        in_file.close();
    
        printf("Copy finished ...");
        return 0;
    }

  • 相关阅读:
    windows phone 自动隐藏的Popup from http://www.cnblogs.com/LoveJenny/archive/2011/07/14/2105869.html
    Linq update
    Windows Phone 7 MVVM模式数据绑定和传递参数 from:http://www.cnblogs.com/linzheng/archive/2011/03/27/1997086.html
    web 常见攻击与防护
    SFSA
    HDU 3530
    一笔话问题
    学习技巧
    练题宝典
    雪花
  • 原文地址:https://www.cnblogs.com/SoaringLee/p/10532494.html
Copyright © 2020-2023  润新知