X264使用简略

1.下载

    忽略

2.配置编译

    忽略

3.help


x264 core:125
Syntax: x264 [options] -o outfile infile

Infile can be raw (in which case resolution is required),         支持的输入文件的类型
  or YUV4MPEG (*.y4m),
  or Avisynth if compiled with support (no).
  or libav* formats if compiled with lavf support (no) or ffms support (no).   支持的输出的文件的类型
Outfile type is selected by filename:
 .264 -> Raw bytestream
 .mkv -> Matroska
 .flv -> Flash Video
 .mp4 -> MP4 if compiled with GPAC support (no)
Output bit depth: 8 (configured at compile time)                     输出的位深

Options:

  -h, --help                  List basic options
      --longhelp              List more options
      --fullhelp              List all options

Example usage:

      Constant quality mode:
            x264 --crf 24 -o <output> <input>                              编码质量

      Two-pass with a bitrate of 1000kbps:
            x264 --pass 1 --bitrate 1000 -o <output> <input>        码率
            x264 --pass 2 --bitrate 1000 -o <output> <input>

      Lossless:
            x264 --qp 0 -o <output> <input>

      Maximum PSNR at the cost of speed and visual quality:
            x264 --preset placebo --tune psnr -o <output> <input>

      Constant bitrate at 1000kbps with a 2 second-buffer:
            x264 --vbv-bufsize 2000 --bitrate 1000 -o <output> <input>

Presets:

      --profile <string>      Force the limits of an H.264 profile
                                  Overrides all settings.
                                  - baseline,main,high,high10,high422,high444
      --preset <string>       Use a preset to select encoding settings [medium]
                                  Overridden by user settings.
                                  - ultrafast,superfast,veryfast,faster,fast
                                  - medium,slow,slower,veryslow,placebo
      --tune <string>         Tune the settings for a particular type of source
                              or situation
                                  Overridden by user settings.
                                  Multiple tunings are separated by commas.
                                  Only one psy tuning can be used at a time.
                                  - psy tunings: film,animation,grain,
                                                 stillimage,psnr,ssim
                                  - other tunings: fastdecode,zerolatency

Frame-type options:

  -I, --keyint <integer or "infinite"> Maximum GOP size [250]
      --tff                   Enable interlaced mode (top field first)
      --bff                   Enable interlaced mode (bottom field first)
      --pulldown <string>     Use soft pulldown to change frame rate
                                  - none, 22, 32, 64, double, triple, euro (requires cfr input)

Ratecontrol:

  -B, --bitrate <integer>     Set bitrate (kbit/s)
      --crf <float>           Quality-based VBR (0-51) [23.0]
      --vbv-maxrate <integer> Max local bitrate (kbit/s) [0]
      --vbv-bufsize <integer> Set size of the VBV buffer (kbit) [0]
  -p, --pass <integer>        Enable multipass ratecontrol
                                  - 1: First pass, creates stats file
                                  - 2: Last pass, does not overwrite stats file

Input/Output:

  -o, --output <string>       Specify output file
      --sar width:height      Specify Sample Aspect Ratio
      --fps <float|rational>  Specify framerate
      --seek <integer>        First frame to encode
      --frames <integer>      Maximum number of frames to encode
      --level <string>        Specify level (as defined by Annex A)
      --quiet                 Quiet Mode

Filtering:

      --vf, --video-filter <filter0>/<filter1>/... Apply video filtering to the input file

      Filter options may be specified in <filter>:<option>=<value> format.

      Available filters:
      crop:left,top,right,bottom
      select_every:step,offset1[,...]


4.ffpeg制作YUV数据



使用LZMA SDK对7z文件进行解压缩,需要先了解7z文件的结构。7z文件实际上是一个压缩文件,其中包含多个压缩数据块和一个头文件,头文件中包含了每个压缩数据块的信息。因此,我们需要先读取头文件,然后逐个解压数据块。 以下是一个简略的C语言例程,用于对7z文件进行解压缩: ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <lzma.h> #define LZMA_PROPERTIES_SIZE 5 int main(int argc, char *argv[]) { if (argc < 3) { printf("Usage: %s input_file output_dir\n", argv[0]); return 1; } char *input_filename = argv[1]; char *output_dirname = argv[2]; // 打开输入文件 FILE *input_file = fopen(input_filename, "rb"); if (input_file == NULL) { printf("Error: Failed to open input file.\n"); return 1; } // 读取7z头文件 uint8_t header[32]; if (fread(header, 1, 32, input_file) != 32) { printf("Error: Failed to read 7z header.\n"); fclose(input_file); return 1; } // 验证7z头文件 if (memcmp(header, "\x37\x7A\xBC\xAF\x27\x1C", 6) != 0) { printf("Error: Invalid 7z header.\n"); fclose(input_file); return 1; } // 获取7z头文件信息 uint8_t properties[LZMA_PROPERTIES_SIZE]; uint64_t header_size; lzma_stream_flags flags; memcpy(properties, header + 6, LZMA_PROPERTIES_SIZE); header_size = *(uint64_t *)(header + 13); flags = *(lzma_stream_flags *)(header + 21); // 初始化LZMA解压缩器 lzma_stream lzma_strm = LZMA_STREAM_INIT; lzma_ret ret = lzma_stream_decoder(&lzma_strm, UINT64_MAX, LZMA_CONCATENATED); if (ret != LZMA_OK) { printf("Error: Failed to initialize LZMA decoder.\n"); fclose(input_file); return 1; } // 创建输出目录 char output_filename[256]; sprintf(output_filename, "%s/", output_dirname); mkdir(output_filename, 0777); // 分配输入输出缓冲区 uint8_t *input_buf = malloc(flags.dict_size); uint8_t *output_buf = malloc(LZMA_BUFLEN); if (input_buf == NULL || output_buf == NULL) { printf("Error: Failed to allocate memory.\n"); free(input_buf); free(output_buf); lzma_end(&lzma_strm); fclose(input_file); return 1; } // 解压缩数据块 uint64_t offset = header_size; uint64_t uncompressed_size = 0; while (1) { // 读取数据块头信息 uint8_t block_header[17]; if (fread(block_header, 1, 17, input_file) != 17) { printf("Error: Failed to read block header.\n"); break; } // 获取数据块信息 uint64_t block_size = *(uint64_t *)(block_header + 1); uint8_t block_type = block_header[9]; // 设置LZMA输入缓冲区 lzma_strm.next_in = input_buf; lzma_strm.avail_in = block_size; // 设置LZMA输出缓冲区 lzma_strm.next_out = output_buf; lzma_strm.avail_out = LZMA_BUFLEN; // 解压数据块 while (1) { ret = lzma_code(&lzma_strm, LZMA_RUN); if (ret != LZMA_OK && ret != LZMA_STREAM_END) { printf("Error: Failed to decode LZMA data.\n"); free(input_buf); free(output_buf); lzma_end(&lzma_strm); fclose(input_file); return 1; } fwrite(output_buf, 1, lzma_strm.next_out - output_buf, output_file); lzma_strm.next_out = output_buf; lzma_strm.avail_out = LZMA_BUFLEN; if (ret == LZMA_STREAM_END) { break; } } // 更新偏移量和解压缩大小 offset += block_size + 17; uncompressed_size += *(uint64_t *)(block_header + 10); // 如果解压缩大小等于文件大小,则说明解压缩完成 if (uncompressed_size >= flags.uncompressed_size) { break; } } // 释放资源 free(input_buf); free(output_buf); lzma_end(&lzma_strm); fclose(input_file); printf("Done.\n"); return 0; } ``` 这个例程通过LZMA SDK提供的API实现了7z文件的解压缩功能。在解压缩过程中,我们需要先读取7z头文件,然后逐个解压缩数据块。在解压缩数据块时,我们需要先读取数据块头信息,然后设置LZMA输入输出缓冲区,调用`lzma_code`函数解压缩数据,最后写入输出文件。在解压缩完成后,我们需要调用`lzma_end`函数释放资源。 注意:这个例程仅适用于对单个7z文件进行解压缩。如果需要解压缩多个7z文件,需要先读取7z头文件,然后逐个解压缩7z文件中的数据块。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值