Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ FFMPEG API和裁剪_C++_Video_Ffmpeg - Fatal编程技术网

C++ FFMPEG API和裁剪

C++ FFMPEG API和裁剪,c++,video,ffmpeg,C++,Video,Ffmpeg,我学习了如何使用FFMPEG API,并使用库SDL实现了一个视频阅读器来显示视频 我有一个高清视频1280*720(我只使用mp4),我想在高清视频的任何地方选择一个VGA屏幕(我的意思是在高清视频中裁剪一个VGA屏幕),恢复数据并在屏幕上显示 在FFMPEG API中,我们可以使用函数av_picture_crop()。我得到了一个“黄色”的视频剪辑覆盖和我的应用程序崩溃后fews秒。在这里发布之前,我读到函数还没有完成。但是当我阅读代码时,我没有找到完成它的方法。 这是我代码的一部分: A

我学习了如何使用FFMPEG API,并使用库SDL实现了一个视频阅读器来显示视频

我有一个高清视频1280*720(我只使用mp4),我想在高清视频的任何地方选择一个VGA屏幕(我的意思是在高清视频中裁剪一个VGA屏幕),恢复数据并在屏幕上显示

在FFMPEG API中,我们可以使用函数av_picture_crop()。我得到了一个“黄色”的视频剪辑覆盖和我的应用程序崩溃后fews秒。在这里发布之前,我读到函数还没有完成。但是当我阅读代码时,我没有找到完成它的方法。 这是我代码的一部分:

AVFrame *pFrame = NULL;
AVFrame *pFrameCropped = NULL;
bmp = SDL_CreateYUVOverlay(CODEC_WIDTH, // width
                          CODEC_HEIGHT, // height
                          SDL_YV12_OVERLAY, // format
                          screen); // SDL_Surface to display


sws_ctx = sws_getContext(CODEC_WIDTH, // src width
                        CODEC_HEIGHT, // src height
                        pCodecCtx->pix_fmt, // src img format
                        STREAM_WIDTH, // dest width, 
                        STREAM_HEIGHT, // dest height
                        AV_PIX_FMT_YUV420P, // dest img format
                        SWS_BILINEAR, // option to rescalling
                        NULL, //
                        NULL, //
                        NULL //
                        );

while(
av_read_frame(pFormatCtx, 
                &packet)>=0) 
{
if(packet.stream_index==videoStream) 
{
  avcodec_decode_video2(pCodecCtx,
                         pFrame,
                         &frameFinished,
                         &packet);

  if(frameFinished) 
  {
    SDL_LockYUVOverlay(bmp);

    av_picture_crop((AVPicture*)pFrameCropped,
                     (AVPicture*)pFrame,
                     (AVPixelFormat)pFrame->format,
                     150,
                     300);
    pict.data[0] = pFrameCropped->data[0];// "X"
    pict.data[1] = pFrameCropped->data[1];
    pict.data[2] = pFrameCropped->data[2];

    // pict.linesize == number of bytes per line 
    pict.linesize[0] = pFrameCropped->linesize[0];
    pict.linesize[1] = pFrameCropped->linesize[2];
    pict.linesize[2] = pFrameCropped->linesize[1];

    sws_scale(sws_ctx, // the scaling context previously created with sws_getContext()
                (uint8_t const * const *)pFrameCropped->data, // Pointers to the planes of the source slice 
                pFrame->linesize, // the array containing the strides for each plane of the source image 
                0, // position in src img processed slice.  
                   // It's number (counted starting from zero) 
                   // in the image of the first row of the slice  
                CODEC_HEIGHT, // source slice height. Number of rows in the slice
                pict.data, // pointers to the planes of the destination image 
                pict.linesize); // strides for each plane of the destination image 

    // Unlock SDL_Overlay
    SDL_UnlockYUVOverlay(bmp);
}
获取编译错误:

*** glibc detected *** ./HDtoVGA: corrupted double-linked list: 0x08d74e30 ***
在FFMPEG命令行工具中,我们可以使用vf_crop()裁剪视频,但我找不到如何在代码中实现相同的功能

你有什么可以帮我的提示吗?

也许你提供的API()已经过时了。 对于最新API的示例,您可以参考示例

要裁剪视频,请将诸如“
crop=ow:oh:x:y”之类的值传递给变量
filter\u descr

const char *filter_descr = "crop=1/3*in_w:1/3*in_h:1/3*in_w:0";
此外,您还可以参考示例项目:。

可能您提供的API()已被弃用。 对于最新API的示例,您可以参考示例

要裁剪视频,请将诸如“
crop=ow:oh:x:y”之类的值传递给变量
filter\u descr

const char *filter_descr = "crop=1/3*in_w:1/3*in_h:1/3*in_w:0";

此外,您还可以参考示例项目:。

如何安装
libavcodec
<代码>libavformat
?和
libavformat
?如何安装
libavcodec
<代码>libavformat
?和
libavformat