gpt4 book ai didi

c++ - 为什么 FFMPEG 适用于 1080p 但不适用于 720p 尺寸……(包含代码)

转载 作者:行者123 更新时间:2023-11-30 05:15:19 25 4
gpt4 key购买 nike

我已经在此处上传了我的完整编译代码及其 Makefile:

https://pastebin.com/xtCTj06F

如果我设置 1280x720,我会得到段错误:

[libx264 @ 0x7fdf4d25a600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7fdf4d25a600] profile High, level 3.1
[libx264 @ 0x7fdf4d25a600] 264 - core 148 r2748 97eaef2 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=12 keyint_min=1 scenecut=40 intra_refresh=0 rc_lookahead=12 rc=abr mbtree=1 bitrate=3400 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '1.mp4':
Stream #0:0: Video: h264, yuv420p, 1280x720, q=2-31, 3400 kb/s, 20 tbn
Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 64 kb/s
sws_scale BEGIN
./MakeVideo.sh: line 2: 26422 Segmentation fault: 11 ./MakeVideo 1.mp4

这条线有问题:

std::cout << "sws_scale BEGIN\n";
sws_scale( sws_context, ( const uint8_t * const * ) &rgb, inLinesize, 0, frame->height, frame->data, frame->linesize );
std::cout << "sws_scale END\n";

但如果我将视频的大小设置为 1920x1080 或 320x240 - 一切正常。

这是某种魔法吗?还是错误?

OS X 10.12.3ffmpeg/3.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= -- host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda

最佳答案

您的代码有很多问题。比如

void ffmpeg_encoder_set_frame_yuv_from_rgb( AVFrame *frame ) {
// frame pointer may be NULL, but is later used without check

uint8_t *rgb = (uint8_t *) malloc( 3 * sizeof( uint8_t ) * frame->width * frame->height );
// malloc may return NULL, but rgb is later used without check
// also rgb is never freed so memory leaks

sws_context = sws_getCachedContext(...
// sws_getCachedContext may return NULL, but sws_context is later used without check

关于c++ - 为什么 FFMPEG 适用于 1080p 但不适用于 720p 尺寸……(包含代码),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43164063/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com