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;
    }

  • 相关阅读:
    最近邻插值
    tp类型自动转换和自动完成
    tp读取器和写入器
    tp模型和数据库操作方法
    tp数据库操作
    tp请求和响应
    tp配置+路由+基本操作
    git的常见操作方法
    php 检查该数组有重复值
    公众号的TOKEN配置PHP代码
  • 原文地址:https://www.cnblogs.com/SoaringLee/p/10532494.html
Copyright © 2011-2022 走看看