zoukankan      html  css  js  c++  java
  • 【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;
    }

  • 相关阅读:
    AWS Dynamodb aggregation的处理问题
    Java线程池的实现与应用
    机器学习笔记之基本框架:
    Azure machine learning series 1 Introduction
    AWS的安全机制
    模板
    矩阵快速幂总结
    中位数总结
    KMP算法
    动态规划----背包总结
  • 原文地址:https://www.cnblogs.com/SoaringLee/p/10532494.html
Copyright © 2011-2022 走看看