【问题标题】:How to compile ffmpeg examples outside the default folder on Ubuntu?如何在 Ubuntu 的默认文件夹之外编译 ffmpeg 示例?
【发布时间】:2023-03-03 04:55:22
【问题描述】:

我已经在 Ubuntu 上成功构建了 FFmpeg,make examples 可以工作。我已经测试了示例“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);
}

【问题讨论】:

    标签: c ubuntu ffmpeg


    【解决方案1】:

    我可以证明我在 Ubuntu 和 mac os 上也遇到了这个 same 问题 -- 具体来说,如何将 ffmpeg 示例移出默认目录树 (~/ffmpeg_sources/ ffmpeg/doc/examples),以便您可以根据自己的程序修改和测试它们。

    相信这在于修改makefile——但哪些需要修改——以及哪些需要改变——尚不清楚。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-22
      • 2011-12-11
      • 2013-01-07
      • 2014-02-20
      • 2015-03-01
      • 1970-01-01
      • 2014-02-22
      相关资源
      最近更新 更多