libx264 not found

Linux下FFmpeg安装配置好后,使用中的一些问题。 最近项目需要用到FFmpeg,于是按照网上的教程配置了一下,配置成功后在编译时出现了一些问题,这里记录一下。 这是安装成功后的情况 这个界面显示安装成功,并且环境也配置成功。在代码中使用时出现一些问题。我的代码中包含头文件 #include <libavutil/opt.h> #include <libavcodec/avcodec.h> #include &lt... 阅读详情

最近在学习ffmpeg于是查了一些资料写了一个简单的编码并且用h264进行编码,其代码如下:

#include <stdio.h>

#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/common.h"
//SDL
#include "SDL/SDL.h"
#include "SDL/SDL_thread.h"

static char inputfile[256];
static char outputfile[256];
static int bitRate;  //ÊÓÆµÊä³öÂëÂÊ
static int yuvWidth;
static int yuvHeight;
static int totalFrame;

static FILE *pfin;
static FILE *pfout;

static AVCodec *pcodec;
static AVFrame *pframe;
static AVCodecContext *pcodecCtx;
static AVPacket packet;

/*
./ffmpegApp source.yuv out.h264 120000 352 288 50
*/
static int parse_input_param(int argc, char **argv)
{
	if (argc != 7)
	{
		printf("usage: %s <inputfile> <outputfile> <bitrate> <width> <height> <totalframe>", argv[0]);
		return -1;
	}
	strcpy(inputfile, argv[1]);
	printf("inputfile = %s\n", inputfile);
	strcpy(outputfile, argv[2]);
	printf("outputfile = %s\n", outputfile);

	bitRate = atoi(argv[3]);
	yuvWidth = atoi(argv[4]);
	yuvHeight = atoi(argv[5]);
	totalFrame = atoi(argv[6]);
	printf("bitrate = %d width = %d height = %d totalframe = %d\n", 
		   bitRate, yuvWidth, yuvHeight, totalFrame);
	return 0;
}

static int open_file(void)
{
	pfin = fopen(inputfile, "rb");
	if (pfin == NULL)
	{
		printf("input file open failed.\n");
		return -1;
	}

	pfout = fopen(outputfile, "wb");
	if (pfout == NULL)
	{
		printf("input file open failed.\n");
		return -1;
	}

	return 0;
	
}

static void close_file(void)
{
	fclose(pfin);
	fclose(pfout);
}

static int open_encoder(void)
{
	int ret;

	//×¢²áËùÓеÄffmpeg±àœâÂëÆ÷
	avcodec_register_all();
	//²éÕÒ×ÔŒºÏëÒªµÄ±àÂëÆ÷
	pcodec = avcodec_find_encoder(AV_CODEC_ID_H264);
	if (!pcodec)
	{
		printf("could not found codec\n");
		return -1;
	}
	//·ÖÅäcontexÊÂÀý
	pcodecCtx = avcodec_alloc_context3(pcodec);
	if (!pcodecCtx)
	{
		printf("could not allocate video codec context\n");
		return -1;
	}
	//ÉèÖñàÂëÆ÷²ÎÊý
	pcodecCtx->bit_rate = bitRate;
	pcodecCtx->width = yuvWidth;
	pcodecCtx->height = yuvHeight;
	AVRational rational = {1, 25}; //ÉèÖÃÖ¡ÂÊ 1ÃëÖÓ25Ö¡
	pcodecCtx->time_base = rational;
	pcodecCtx->gop_size = 12;
	pcodecCtx->max_b_frames = 1;
	pcodecCtx->pix_fmt = AV_PIX_FMT_YUV420P;
	//ÉèÖÃËœÓÐÊýŸÝ
	av_opt_set(pcodecCtx->priv_data, "preset", "slow", 0);
	
	//Žò¿ª±àÂëÆ÷
	ret = avcodec_open2(pcodecCtx, pcodec, NULL);
	if (ret < 0)
	{
		printf("could not open codec ret = %d.\n", ret);
		return -1;
	}
	//·ÖÅäAVFRAMEÒÔŒ°ÏóËØŽæŽ¢¿ÕŒä
	pframe = av_frame_alloc();
	if (!pframe)
	{
		printf("could not allocate video frame.\n");
		return -1;
	}
	pframe->format = pcodecCtx->pix_fmt;
	pframe->width = pcodecCtx->width;
	pframe->height = pcodecCtx->height;
	ret = av_image_alloc(pframe->data, pframe->linesize, pframe->width, pframe->height, pframe->format, 32);
	if (ret < 0)
	{
		printf("could not allocte raw picture buffer.\n");
		return -1;
	}

	return 0;
	
}

static void close_encoder(void)
{
	avcodec_close(pcodecCtx);
	av_free(pcodecCtx);
	av_freep(&(pframe->data[0]));
	av_frame_free(&pframe);
}

static int read_yuv_data(int color)
{
	int frame_height = color == 0 ? pframe->height : pframe->height / 2;
	int frame_width = color == 0 ? pframe->width : pframe->width / 2;
	int frame_size = frame_height * frame_width;
	int frame_stride = pframe->linesize[color];
    //±íÊŸÁ¬ÐøŽæŽ¢
	if (frame_width == frame_stride)
	{
		if (fread(pframe->data[color], 1, frame_size, pfin) == 0)
		{
			printf("read data error.\n");
			return -1;
		}
	}
	else
	{
		int row;
		for (row = 0; row < frame_height; row++)
		{
			if (fread(pframe->data[color]+row*frame_stride, 1, frame_width, pfin) == 0)
			{
				printf("read data error.\n");
				return -1;
			}
		}
	}

	return frame_size;
}


int main(int argc, char* argv[])
{
	int ret;
	int got_output;
	int packIndex = 0;
	
	if (parse_input_param(argc, argv) < 0)
	{
		printf("fail to parse input param\n");
		return -1;
	}

	if (open_file() < 0)
	{
		printf("open file faile\n");
		return -1;
	}

	if (open_encoder() < 0)
	{
		printf("open encoder faile\n");
		return -1;
	}

	int frameIndex;
	for (frameIndex = 0; frameIndex < totalFrame; frameIndex++)
	{
		//³õÊŒ»¯°üÓÉÓÚ×°ÔØ±àÂëºóµÄÂëÁ÷
		av_init_packet(&packet);
		packet.data = NULL;
		packet.size = 0;
		fflush(stdout);
		//¶ÁÈ¡ÊýŸÝµœAVFRAMEÖÐ
		read_yuv_data(0);
		read_yuv_data(1);
		read_yuv_data(2);
		pframe->pts = frameIndex;

		//encode the image
		ret = avcodec_encode_video2(pcodecCtx, &packet, pframe, &got_output);
		if (ret < 0)
		{
			printf("error encoding frame\n");
			return -1;
		}
		printf("encode frame index: %d, frame pts: %ld\n", frameIndex, pframe->pts);
		if (got_output)  //ÊÇ·ñ±àÂë³öÒ»žöÍêÕûµÄ°ü
		{
			printf("write packet %3d (size = %5d) packet pts %ld\n",packIndex++, packet.size, packet.pts);
			fwrite(packet.data, 1, packet.size, pfout);
			av_packet_unref(&packet);
		}
	}
	//œ«±àÂëÆ÷ÖÐÊ£ÓàµÄÊýŸÝÊä³ö
	for (got_output = 1; got_output; frameIndex++)
	{
		fflush(stdout);
		ret = avcodec_encode_video2(pcodecCtx, &packet, NULL, &got_output);
		if (ret < 0)
		{
			printf("error encoding frame\n");
			return -1;
		}

		if (got_output)
		{
			printf("cached frame: write packkets %3d (size=%5d) packet pts %ld\n", packIndex++, packet.size, packet.pts);
			fwrite(packet.data, 1, packet.size, pfout);
			av_packet_unref(&packet);
		}
	}
	
	close_encoder();
	close_file();
	return 0;
}

编写完后进行编译一直提示“could  found  codec”,找不到h264编码器,在网上搜索了一下原来是h264依赖libx264,于是修改了ffmpeg编译时的配置文件

将--enable-libx264加上。加上后重新配置但是此时配置是又提示:

查看日志文件如下:

这下应该是PC下没有安装x264的库,于是安装x264的库顺便也安装了其他的几个依赖库

suto  apt-get  install  libx264-dev

sudo  apt-get  install  libfaac-dev

sudo  apt-get  install  libmp3lame-dev

sudo  apt-get  install  libtheora-dev

sudo  apt-get  install  libxfixes-dev


关于Ubuntu11.04下编译和安装x264最新版本和ffmpeg 0.6.1 这个问题肯定困扰过大家,反正我是被困扰的一塌糊涂,编译ffmpeg 0.6.1的时候总是说:libx264 not find!!!!! 捣鼓了好久,终于这个问题解决了,感谢各位网友!下面我就给出我的安装和编译的过程,一方面希望可以帮助到大家,另一方面,也是为了防止自己下次编译的时候又遇到老问题而忘了解决办法! 1.如果您之前安装了x264,libx264-dev和ffmpeg,请先把它卸载,打 阅读详情

相关推荐

Centos下 ffmpeg Unknown encoder ‘libx264‘终极解决方法

1.Unknown encoder 'libx264' 2.Unrecognized option 'crf'.   Error splitting the argument list: Option not found

FeelTouch Labs 2399

全网首发:ERROR: libx264 not found

嗯?吾明明编译了啊。怎么回事?有两种可能: 在编译264的时候,configure没有加参数。正确写法: ./configure \ --prefix=${DEST_LIB_DIR} \ --enable-shared 在编译ffmpeg的时候,需要指明libx264.so所在目录。 具体是这样指定的(注意:--extra-ldflags只能有一个) BUILD_LIBS...

柳鲲鹏 1万+

WRF和WPS模型在Ubuntu系统上的安装与常见问题解决指南

本文详细介绍了在Ubuntu系统上安装WRF和WPS模型的完整教程,涵盖系统环境配置、依赖库安装、源代码编译以及常见问题的解决方案。重点解决了WPS编译中intmath.f文件的修改、环境变量设置和编译器兼容性等关键难点,帮助用户高效部署气象研究与预报模型。

weixin_29213525的博客 382

集成ffmpeg/x264:ERROR: libx264 not found的问题

在配置的时候,要注意一下NDK的安装路径,替换成自己NDK的安装路径。

u012670302的博客 2008

VCSA 上的 vmware-vpxd 服务失败,Web端提示503 服务不可用 (503 Service Unavailable)

昨晚VCSA碰到一个很诡异的问题: 使用 vSphere Web Client 连接到 vCenter Server Appliance时失败,提示: 503 服务不可用 (503 Service Unavailable) 无法连接端点 (Failed to connect to endpoint):[N7Vmacore4Http20NamedPipeServiceSpecE:0x00007f975808ee30] _serverNamespace = / action = Allow _pipeNam

徐华的博客 2万+

半导体AMHS天车振动控制:从0.5G到超低振动的技术演进与工程实战

在先进晶圆厂中,自动化物料搬运系统(AMHS)的天车如同空中出租车,承担着晶圆盒(FOUP)在洁净室各工艺区间的转运任务。然而,当天车加减速、过弯或抓取时产生的机械振动通过轨道梁和建筑结构传递至光刻机等敏感设备,便可能直接威胁套刻精度与良率。传统被动减振方案依靠橡胶垫和弹簧,在0.5G指标时代曾行之有效,但在EUV光刻和先进制程面前已力不从心。主动振动控制技术通过传感器、控制器与作动器构成的闭环系统,在轨道吊点和机械手端实时输出反向力抵消振动,配合磁悬浮走行、轻量化结构及调度系统的路径优化,将振动从0.5G

weixin_29188043的博客 345

ffmpeg 安装时ERROR: libx264 not found 异常的解决

安装 ffmpeg 时出现错误 ERROR: libx264 not found 解决方法: 安装 x264 时 增加选项 --enable-shared #./configure --enable-shared  #make #make install   再次执行 ffmpeg 安装就不报错了

boywgw的专栏 1万+

ubuntu20.04屏幕亮度无法调节(亮度条调节无效)的简单靠谱解决方案及踩坑历程

0 前言   网上关于ubuntu系统亮度无法调节的问题的解决方法有很多,但是绝大部分并没有什么用(这也是我自己的亲身体会),或者并不靠谱。在遍尝各路方法过后,我终于解决了这一棘手的问题(毕竟最大亮度真的非常刺眼,无法长时间直视),在此记录一下踩坑历程以及最后的解决方案。 1 Naive方法   由于使用需要,最近在电脑原有的win10基础上安装了ubuntu双系统。我安装的是当前新版的ubuntu20.04.2.0,靠谱的安装教程可以参考这里。   之前师兄说双ssd安装双系统会有系统启动引导的问题出现,

zeeq的博客 4万+

CentOS Compile ffmpeg libx264 not found

CentOS Compile ffmpeg libx264 not found 首先 CentOS make install x264时,只将x264可执行文件install到/usr/local/bin,还需要make install-lib-static 此时./configure --disable-yasm --enable-libx264 --enable-gpl --enable-

q_q_zh的专栏 2342

3D扩散模型的构建与优化:多模态融合在三维物体生成中的作用【附核心代码实例】

随着技术的发展,基于扩散模型的3D内容生成已经成为一个激动人心的领域。通过不断优化扩散模型的结构和算法,结合多模态信息、视角控制和高效网络架构,未来的3D生成技术将不仅能够生成逼真的物体,还能满足虚拟现实、游戏设计、电影制作等行业对高质量、实时生成的需求。

一键难忘的博客 2863

想在 Visual Studio Code 里进行 ABAP 开发,需要安装的扩展列表

安装完毕后,我们可以将 SAP 系统配置为 Visual Studio Code 连接的远程文件系统。为了连接到 SAP 系统,需要启用 ABAP 开发工具 (ADT) ICF 节点,这与 SAP Hana Studio 等工具使用的服务相同。打开 SAP GUI 并连接到目标系统,运行事务 SICF,然后激活 ADT_SRV 服务,如下所示。这启用了允许代码编辑器和 IDE 连接到 SAP 系统的服务。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 3122

ffmpeg ERROR: libx264 not found

ffmpeg ERROR: libx264 not found 看config.log来分析错误的原因 1)x624.h要自己加上 #include  2)要安装pthread 3)命令$ ./configure --enable-gpl --enable-libx264 --extra-cflags=-I/usr/local/include  --extra-ldflags=-L/us

ljh081231的专栏 8297

三维重建(十八)——colmap的使用(粗浅)

三维重建(十八)——colmap的使用(粗浅)

河海大学研究生在读的学习笔记 1376

android libx264,android – 如何解决“ERROR:libx264 not found”?

我需要安装ffmpeg,支持libx264以启用H.264编码.我使用android-ndk-r9d中提供的工具链使用下面的脚本成功安装了libx264.#!/bin/bashNDK=~/android-ndk-r9dSYSROOT=$NDK/platforms/android-8/arch-arm/TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4...

weixin_42113456的博客 1316

【人工智能】在 cc-switch 中配置 AnyRouter 接入 Claude Code 完整指南

本文介绍了在cc-switch工具中配置AnyRouter中转服务以接入Claude Code的详细步骤。主要内容包括:1) 准备API令牌和端点地址;2) 填写基础信息和模型参数;3) 保存配置并重启终端生效;4) 常见问题排查方法。重点强调了API地址格式、模型ID准确性以及配置写入的必要性,帮助用户顺利完成中转服务配置,实现Claude 4.5版本的正常使用。

奶爸的编程之路,也就一周冷个三天 3104

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

linux下ffmpeg安装时ERROR: libx264 not found 错误解决

一、下图是产生错误的,命令: [root@CentOS7 ffmpeg]# ./configure --prefix=/usr/ffmpeg --enable-shared --enable-yasm --enable-libx264 --enable-gpl --extra-cflags=-l/usr/x264/include --extra-ldflags=-L/usr/x264/lib 报出的错误: ERROR: libx264 not found If you think configure m

qq_25105163的博客 1万+

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

FFmpeg 按转 libx264 遇到 “libx264 not found”

安装FFmpeg x264支持到时候遇到了  “libx264 not found” 于是开始搜索,原来到编译libx264时的姿势不对,于是调整了一下姿势如下: cd ~/x264 make uninstall make distclean ./configure --enable-static --disable-opencl make make install

为了孩子他娘 3055

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

ERROR: libx264 not found

When I compile ffmpeg, it give me an error like: ERROR: libx264 not found, my solution: sudo apt-get install libx264-dev

CV_2013的专栏 893

ffmpeg + x264 编译提示libx264 not found 的解决方法

编译ffmpeg和x264吃了不少苦,很重要的一点就是如果你对这个编译不是很熟的话千万不要尝试用cygdrive+windows编译。建议在Ubuntu下编译! 1.首先要确保已经编译了x264的源码 这边是我x264的sh export NDK=/home/mtb0157/workspace/android-ndk-r9 export PREBUILT=$NDK/too

蓝色污点的专栏 2万+

linux下ffmpeg增加h.264库时的ERROR: libx264 not found 错误解决

Linux 操作系统:Fedora 8;FFMpeg版本:0.5;libx264 BUILD:79。 错误描述:在安装好libx264 库后configure ffmpeg-0.5 时(要选择--enable-libx264),报出ERROR: libx264 not found 的错误。即提示找不到libx264 库,并指出了是找不到'x264_encoder_open'这个宏。 解...

shappy1978的专栏 1543
上一篇: ffmpeg常用命令
下一篇: ubuntu14.04开发ffmpeg的工具软件
Aiden@semidrive
博客等级 码龄14年 110粉丝 58原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值