ffmpeg
- 裁剪yuv视频:
ffmpeg -pix_fmt yuv420p -s 416x240 -i test.yuv -pix_fmt yuv420p -vf crop=w:h:x:y test1.yuv
x:y:裁剪区域的左上角坐标 - 获取固定帧数的yuv视频:
ffmpeg -pix_fmt yuv420p -s 416x240 -i "BasketballPass_416x240_50.yuv" -pix_fmt yuv420p -s 416x240 -frames 1 test.yuv
- 获取某几帧视频:
./ffmpeg -s 1280x720 -i 720p.yuv -c:v rawvideo -filter:v "select='between(n\, 10\, 15)'" out720p.yuv
- 剪切mp4视频:
ffmpeg -ss 00:00:00 -t 00:00:30 -i test.mp4 -vcodec copy -acodec copy output.mp4
ss:开始时间,t:截取时长
- 加入-avoid_negative_ts避免结尾不是关键帧出现的空白
- 加入-c:v libx264 -c:a aac -strict experimental -b:a 98k重新编码,避免交集或空白 - 合并视频:
ffmpeg -f concat -i list.txt -c copy concat.mp4
list.txt:
file ./split.mp4
file ./split1.mp4
- 解码:
ffmpeg -i test.mp4 test.yuv
- 把265码流打包成mp4:
ffmpeg -f hevc -i test.265 -vcodec copy test.mp4
- 音视频打包成mp4:
ffmpeg -i test.265 -i test.aac -vcodec copy -acodec copy test.mp4
- 从mp4中提取出265码流:
ffmpeg -i test.mp4 -vcodec copy -f hevc test.265
- 从mp4中提取出音频:
ffmpeg -i test.mp4 -vn -acodec copy test.aac
- 缩放10bit yuv: (详细缩放可查看https://ffmpeg.org/ffmpeg-scaler.html文档)
-ffmpeg.exe -s:v 3840x2160 -pix_fmt yuv420p10le -i test_4k.yuv -vf scale=1920:1080 -c:v rawvideo -pix_fmt yuv420p10le test_1080p.yuv
-保持纵横比(指定其中一个,另一个设为-1):ffmpeg.exe -s:v 3840x2160 -i test_4k.yuv -vf scale=1920:-1 -c:v rawvideo test_1080p.yuv
-指定图像宽高(宽拉伸为原来的2倍):ffmpeg.exe -s:v 3840x2160 -i test_4k.yuv -vf scale=iw*2:ih -c:v rawvideo test_1080p.yuv
/ffmpeg.exe -s:v 3840x2160 -i test_4k.yuv -vf "scale=iw/2:ih/2" -c:v rawvideo test_1080p.yuv
/ffmpeg.exe -s:v 3840x2160 -i test_4k.yuv -vf "scale=iw*.5:ih*.5" -c:v rawvideo test_1080p.yuv
- 改变帧率:
ffmpeg.exe -s:v 1920x1080 -pix_fmt yuv420p10le -r 120 -i test_1080p_120fps.yuv -c:v rawvideo -pix_fmt yu v420p10le -r 25 test_1080p_25fps.yuv
- 8bit/10bit转换:
ffmpeg -s:v 1920x1080 -pix_fmt yuv420p -i test_8bit.yuv -pix_fmt yuv420p10le test_10bit.yuv
-pixel_format is an input option for raw demuxers.
-pix_fmt is an output option for the target format.
- 生成与视频匹配的无声音频:
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i test.265 -i test.aac -c:v copy -c:a aac -shortest test.mp4
C/C++
读写
fgetc(FILE *fp)
:从文件读取单个字符;fgets(char *buf, int n, FILE *fp)
:从 fp 所指向的输入流中读取 n - 1 个字符。它会把读取的字符串复制到缓冲区 buf,并在最后追加一个 null 字符来终止字符串。如果这个函数在读取最后一个字符之前就遇到一个换行符 ‘\n’ 或文件的末尾 EOF,则只会返回读取到的字符,包括换行符。
#include <stdio.h>
#include <iostream>
#include <fstream>
#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();
}
}
x265 10bit工程编译
Linux和Windows通用方法:简单粗暴的做法,直接修改source/CmakeLists.txt,如下
- 找到HIGH_BIT_DEPTH的option,把前后的if-endif注释掉
- 将OFF改为ON
- 按照readme.txt进行编译
#if(X64)
# NOTE: We only officially support high-bit-depth compiles of x265
# on 64bit architectures. Main10 plus large resolution plus slow
# preset plus 32bit address space usually means malloc failure. You
# can disable this if(X64) check if you desparately need a 32bit
# build with 10bit/12bit support, but this violates the "shrink wrap
# license" so to speak. If it breaks you get to keep both halves.
# You will need to disable assembly manually.
option(HIGH_BIT_DEPTH "Store pixel samples as 16bit values (Main10/Main12)" ON)
#endif(X64)
dolby vision
杜比影片对编码器要求,截图自Dolby Vision Professional Encoder SIDM(Software Integration Development Manual).pdf
取消windows软链接
取消mklink的链接:unlink
windows重命名:rename a.txt b.txt
Git
多次commit合并成一次merge的commit:git merge --squash xx
($ git checkout master
$ git merge --squash dev)
撤回本地commit:git reset --soft|–mixed|–hard {commit_id}
–mixed
会保留源码,只是将git commit和index 信息回退到了某个版本.
–soft
保留源码,只回退到commit信息到某个版本.不涉及index的回退,如果还需要提交,直接commit即可.
–hard
源码也会回退到某个版本,commit和index 都会回退到某个版本.(注意,这种方式是改变本地代码仓库源码)
强制覆盖分支
1.我想将test分支上的代码完全覆盖dev分支,首先切换到dev分支
git checkout dev
2.然后直接设置代码给远程的test分支上的代码
git reset --hard origin/test
3.执行上面的命令后dev分支上的代码就完全被test分支上的代码覆盖了,注意只是本地分支,这时候还需要将本地分支强行推到远程分支。
git push -f
Windows
certutil -hashfile filename MD5
certutil -hashfile filename SHA1
certutil -hashfile filename SHA256