yuv420P视频剪切
最近在研究使用ffmpeg库进行视频的旋转和剪切,下面就贴上视频剪切的代码
void clipSize(const uint8_t *buffer, uint8_t *result, const int nWidth, const int nHeight,
const int startX, const int startY, const int endX, const int endY)
{
static int nySize = nWidth * nHeight;
int k = 0;
static int nuSize = nySize >> 2;
static int uvWidth = nWidth >> 1;
static int uvHeight = nHeight >> 1;
static int destW = endX - startX + 1;
static int destH = endY - startY + 1;
static int destuW = destW >> 1;
static int destuH = destH >> 1;
static int startuY = startY >> 1;
static int startuX = startX >> 1;
uint8_t *ptr = result;
for (int i = 0; i < destH; ++i)
{
//for (int j = 0; j < destW; ++j)
//{
//result[k++] = buffer[(startX + i) * nWidth + j];
memcpy(ptr, buffer + ((startX + i) * nWidth), destW);
ptr += destW;
//}
}
uint8_t *temp = (uint8_t *)buffer + nySize;
for (int i = 0; i < destuH; ++i)
{
//for (int j = 0; j <

本文介绍了如何利用ffmpeg库对视频进行旋转和剪切操作,重点展示了视频裁剪的代码实现。通过指定裁剪的起始和结束坐标(如(100,100)到(500,500)),可以得到401*401像素的裁剪后视频。作者提到,学习ffmpeg入门得益于雷神的博客帮助。"
120944652,5000057,Java单元测试实践-JUnit4详解,"['单元测试', 'java', 'big data']
最低0.47元/天 解锁文章

271





