c - 如何在 Ubuntu 的默认文件夹之外编译 ffmpeg 示例?

标签 c ubuntu ffmpeg

我已经在 Ubuntu 和 make examples 上成功构建了 FFmpeg作品。我已经测试了示例“encode_video.c”,它生成了几个文件,如“encode_video”、“encode_video.d”、“encode_video.o”、“encode_video_g”和“encode_video”。 “encode_video”文件运行良好。
但是,当我想在其他地方手动构建此示例而不是命令 make examples .编译就可以完成了。但是当我运行“encoding”文件时,它总是会显示“Codec xxx not found”。
我使用命令 gcc -o encoding encode_video.c -lavcodec -lavutil .
这是“encode_video.c”的部分行。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <libavcodec/avcodec.h>

#include <libavutil/opt.h>
#include <libavutil/imgutils.h>

int main(int argc, char **argv)
{
   const char *filename, *codec_name;
   const AVCodec *codec;
   AVCodecContext *c= NULL;
   int i, ret, x, y;
   FILE *f;
   AVFrame *frame;
   AVPacket *pkt;
   uint8_t endcode[] = { 0, 0, 1, 0xb7 };

   if (argc <= 2) {
       fprintf(stderr, "Usage: %s <output file> <codec name>\n", argv[0]);
       exit(0);
   }
   filename = argv[1];
   codec_name = argv[2];

   /* find the mpeg1video encoder */
   codec = avcodec_find_encoder_by_name(codec_name);
   if (!codec) {
       fprintf(stderr, "Codec '%s' not found\n", codec_name);
       exit(1);
   }

   c = avcodec_alloc_context3(codec);
   if (!c) {
       fprintf(stderr, "Could not allocate video codec context\n");
       exit(1);
   }

   pkt = av_packet_alloc();
   if (!pkt)
       exit(1);
}

最佳答案

我可以证明我在 Ubuntu 和 mac os 上也遇到了同样的问题——具体来说,如何将 ffmpeg 示例移出默认目录树(~/ffmpeg_sources/ffmpeg/doc/examples)以便您可以修改并针对您自己的程序进行测试。
相信这在于修改makefile——但哪些需要修改——以及需要改变什么——尚不清楚。

关于c - 如何在 Ubuntu 的默认文件夹之外编译 ffmpeg 示例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64434444/

相关文章:

python - OpenCV VideoCapture 无法在 Python 中读取视频,但可以在 VS11 中读取

ffmpeg - 是什么导致 ffmpeg 中出现 "unspecified pixel format"和 "Error opening filters!"错误?

ffmpeg - windows上使用ffmpeg将一组png图片转换为一组webp图片

c - Linux 终端输入/输出 C 程序

ubuntu - 通过 SES 从托管在 Micro-EC2 上的 AWS 上的 Drupal 发送电子邮件

linux - 我无法在 Ubuntu 上使用 Vim 将复制的内容粘贴到剪贴板

ubuntu - udev 规则适用于 `udevadm test` ,但不适用于 `udevadm trigger`

c - Linux 内核 - kthread_stop 总是返回 -EINTR?

在 C 预处理器中创建结构

c - 为什么不能像这样访问链表中的指针?