Git Product home page Git Product logo

avcpp's Introduction

AvCpp Build Status CodeQL C++ PRs Welcome

Wrapper for the FFmpeg that simplify usage it from C++ projects.

Currently covered next functionality:

  • Core helper & utility classes (AVFrame -> av::AudioSample & av::VideoFrame, AVRational -> av::Rational and so on)
  • Container formats & contexts muxing and demuxing
  • Codecs & codecs contexts: encoding and decoding
  • Streams (AVStream -> av::Stream)
  • Filters (audio & video): parsing from string, manual adding filters to the graph & other
  • SW Video & Audio resamplers

You can read the full documentation here.

Requirements

  • FFmpeg >= 2.0
    • libavformat >= 54.x.x
    • libavcodec >= 54.x.x
    • libavfilter >= 3.x.x
    • libavutil >= 51.x.x
    • libswscale >= 2.x.x
    • libswresample >= 0.x.x
    • libpostproc >= 52.x.x
  • GCC >= 5.0 (C++11 is required)
  • CMake (> 3.19) or Meson(> 50.0)

Debian, Ubuntu 19.10 and Linux Mint 20.x or newer

You should install FFmpeg packages from the deb-multimedia.org site:

sudo apt-get install libavformat-dev \
                     libavcodec-dev \
                     libavutil-dev \
                     libavfilter-dev \
                     libswscale-dev \
                     libswresample-dev \
                     libpostproc-dev \
                     libavdevice-dev

Note 1: I did not test building on Debian.

Note 2: Debian Wheezy repo contains only FFmpeg 1.0.8. I tested building only with 2.x. So it is strongly recoment use Wheezy back-ports repo.

Ubuntu 18.04 and Linux Mint 19.x

If you are on Ubuntu bionic or Linux Mint 19.x you should add ffmpeg-4 PPA:

sudo add-apt-repository ppa:jonathonf/ffmpeg-4 -y
sudo apt update && sudo apt upgrade

After that just install the same packages as above.


Build

There are two ways to compile either with CMake or with meson. By default meson is faster, but if your project uses CMake, those instructions might be better for integration.

Building with CMake

git clone --recurse-submodules https://github.com/h4tr3d/avcpp.git avcpp-git
cd avcpp-git
mkdir build
cd build
cmake ..
make -j8

If your Git version so old (refer to the SO for clarification) you can just replace --recurse-submodules with pair of git submodule init && git submodule update.

If FFmpeg located in non-standard place:

cmake -DPC_FFMPEG_LIBRARY_DIRS=<some_path> -DPC_FFMPEG_INCLUDE_DIRS=<some_path> ..

To point install prefix:

cmake -DCMAKE_INSTALL_PREFIX=/usr ..

Install:

sudo make install

or (for packaging)

sudo make DESTDIR=<some_prefix> install

Refer to CMake documentation for more details that can cover some special cases.

Building with meson

Before you can begin with the building you have to clone the repository like this:

git clone https://github.com/h4tr3d/avcpp.git avcpp-git
cd avcpp-git

IDE Integration:

There are extentions for various IDEs like VS Code/Codium, Eclipse, Xcode, etc. Refer to the docs for more information.

Building the project:

If you don't have the dependencies installed, meson will download and compile them. Because ffmpeg is so large (~2000 c files), you should consider using your package manager to install them. You can then build the project with the following commands:

mkdir build
cd build
meson ..
meson compile

Configuring the project:

By default the sample projects and the test are compiled. If you don't want this you can disable it with the following commands:

meson configure -Dbuild_tests=false
meson configure -Dbuild_samples=false

You can set the install prefix using meson --prefix <your/own/prefix>. To see all of the available options just type meson configure and meson configure --help to get more information.

Installing the project:

Just type meson install and the project will be installed in the configured prefix (/usr/local by default).

Running the tests:

To run the test just use meson test. If you disabled the test this will do nothing.

avcpp's People

Contributors

abdullahfarwees avatar adenilson avatar artemiuzzz avatar ashikns avatar barcharcraz avatar darktemplar008 avatar h4tr3d avatar johzzy avatar jonas-resch avatar kayshinonome avatar mgukov avatar mmomtchev avatar noah1510 avatar piotrrak avatar rayglover-ibm avatar rkfg avatar snikulov avatar tb1 avatar teowoz avatar wooshifu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avcpp's Issues

no build instructions

not everyone uses cmake. it would be proper to at least put the build instructions in the README.md

Examples don't work

Hi! I wonder whether the examples are supposed to work in the master branch.
I'm trying the api2-decode-encode-video.cpp

There might be a problem in the Stream::mediaType() method,
since m_raw->codecpar doesn't seem to contain valid data, while m_raw->codec has it, but the former is chosen by preprocessor directive.

Additionally I don't see code where you set the width/height/pix_fmt fields of AVStream's codec/codecpar. Having these unset causes an error like this:
[mp4 @ 000001bae753ba00] dimensions not set
while calling octx.writeHeader(); line of api2-decode-encode-video.cpp

I want to use avcpp in my project and willing to contribute the hardware-accelerated encoding code, but with these basic problems it might not be possible. Am I doing something wrong?

Libavformat version 57.66.102, target platform Windows 10 64-bit (visual studio toolchain is used)

Can't add subtitles stream to mkv

I'm using Debian Stretch amd64, libavformat 57.
These lines block adding a subtitles stream. I can form a valid H264+Vorbis stream packed to MKV but can't add subtitles due to that support check. MKV indeed supports subtitles but the check says otherwise. It could be an ffmpeg bug or something with my local setup. I commented the check out, after that avformat_new_stream successfully adds the subtitles stream and I can encode my subs to it getting a valid MKV file.

The code is very straightforward, like this:

        Codec sub_codec = findEncodingCodec(AV_CODEC_ID_SUBRIP);
        auto sub_stream = ofctx.addStream(sub_codec, ec);
        LOGFATAL("Can't add subtitles stream")
        subctx.openInput(argv[4], ec);
        LOGFATAL("Can't open subtitles")
        subctx.findStreamInfo(ec);
        LOGFATAL("No subtitles streams found")

        ofctx.dump();
        ofctx.writeHeader();
        ofctx.flush();

        while (true) {
            auto pkt = subctx.readPacket(ec);
            if (pkt.isNull()) {
                break;
            }
            LOGERR("Packet reading error")
            pkt.setStreamIndex(2);
            ofctx.writePacket(pkt, ec);
            LOGERR("Packet writing error")
        }

I think we shouldn't explicitly check for stream support and instead rely on avformat_new_stream returning NULL on error.

convert ogg -> wav in cpp script

Hello!

I have a question about audio format conversion. Need to create function to convert file from ogg to wav in linux. Could you provide me any instructions how I can do It via avcpp? Thanks!

Nadya

rfc // cmake // use cmake 3 for build

Can library be switched to cmake v3.1 ?

cmake_minimum_required (VERSION 3.1)

and re-use new features like

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED yes)

etc.

clear_if() is broken on newer compilers with optimizations on

This issue is pretty weird, it happens only when optimizations are on (-O1, -O2, -O3, -Os etc.) and on G++ 6 and up and clang++ 3.5 at least. G++ 5 works fine. So, here's a minimal example:

#include <iostream>
#include <system_error>

using namespace std;

error_code& throws() {
  return *((error_code*)0);
}

void clear_if(error_code& ec) {
  error_code& ec_local = throws();
  cout << &ec << " / " << &throws() << " / " << &ec_local << endl;
  if (&ec != &throws()) {
    cout << "&ec != &throws()" << endl;
  } else {
    cout << "&ec == &throws()" << endl;
  }
  if (&ec != &ec_local) {
    cout << "&ec != &ec_local" << endl;
  } else {
    cout << "&ec == &ec_local" << endl;
  }
  if (&ec_local != &throws()) {
    cout << "&ec_local != &throws()" << endl;
  } else {
    cout << "&ec_local == &throws()" << endl;
  }
  if (&ec == 0) {
    cout << "&ec == 0" << endl;
  } else {
    cout << "&ec != 0" << endl;
  }
  if (&ec != 0) {
    cout << "&ec != 0" << endl;
  } else {
    cout << "&ec == 0" << endl;
  }
  if (&ec_local == 0) {
    cout << "&ec_local == 0" << endl;
  } else {
    cout << "&ec_local != 0" << endl;
  }
  if (&ec_local != 0) {
    cout << "&ec_local != 0" << endl;
  } else {
    cout << "&ec_local == 0" << endl;
  }
}

int main() {
  clear_if(throws());
  return 0;
}

I tried to compile it with the following commands and checked the output:

g++-5 -O0 -std=c++11 test.cpp

0 / 0 / 0
&ec == &throws()
&ec == &ec_local
&ec_local == &throws()
&ec == 0
&ec == 0
&ec_local == 0
&ec_local == 0

g++-6 -O0 -std=c++11 test.cpp

0 / 0 / 0
&ec == &throws()
&ec == &ec_local
&ec_local == &throws()
&ec == 0
&ec == 0
&ec_local == 0
&ec_local == 0

g++-5 -O1 -std=c++11 test.cpp

0 / 0 / 0
&ec == &throws()
&ec == &ec_local
&ec_local == &throws()
&ec == 0
&ec == 0
&ec_local == 0
&ec_local == 0

g++-6 -O1 -std=c++11 test.cpp

0 / 0 / 0
&ec != &throws()
&ec != &ec_local
&ec_local == &throws()
&ec == 0
&ec != 0
&ec_local == 0
&ec_local == 0

clang++ -O0 -std=c++11 test.cpp

0 / 0 / 0
&ec == &throws()
&ec == &ec_local
&ec_local == &throws()
&ec == 0
&ec == 0
&ec_local == 0
&ec_local == 0

clang++ -O1 -std=c++11 test.cpp

0 / 0 / 0
&ec != &throws()
&ec != &ec_local
&ec_local == &throws()
&ec != 0
&ec != 0
&ec_local != 0
&ec_local != 0

I suspect making a null reference is an undefined behavior and that's why it breaks. Note, that only null reference arguments get borked somehow, local variables are compared just fine. Still, UB is UB and we shouldn't rely on it. As you can see, &ec both equals and not equals zero, it's undefined. The first branch is always executed as the condition is always true.

The exact issue in avcpp is that this line is executed while ec is a null reference that causes a segfault if the library is compiled with G++ 6 and up in a release configuration (which usually assumes -O3).

bytesPerSample or sampleBitDepth return confusing results for audio

I'm using avcpp and I really like it!
I'm decoding mp4 (h264+acc) and aac decoder returns AV_SAMPLE_FMT_FLTP (planar floats). In my case I have stereo aac and when I get a decoded audio av::AudioSamples frame values that I get for samples count size etc are all confusing.

these are the values that I have:

aframe.raw.nb_samples 1024
aframe.channelsCount() => 2
aframe.size() => 16384
aframe.sampleFormat().bytesPerSample() => 1 (?!)
aframe.sampleBitDepth() => 8 (?!)
aframe->linesize[0] = 8192

aframe.raw.buf[0] and buf[1] both have size 8192, however, looking at the memory in debugger it seems that samples actually take half of that buffer. Either it's ffmpeg allocates more (padding, rounding) or it's a bug? For 1024 FLTP sample it should be 4K in each plane or total 8K for 2 channels.

IMO, aframe.size() should return size of actual samples stored, and but currently it seem to return size of allocated memory. In any case, bytes per sample seems to be completely wrong there (it should be 32 or 64 if a sample is counted for all channels).

AVPacketSideData support

/**
 * Additional packet data that can be provided by the container.
 * Packet can contain several types of side information.
 */
AVPacketSideData *side_data;
int side_data_elems;

"Transmux" metadata

Add ability to copy metadata from input sources to the output one.

Metadata aware objects:

  1. AVFormatContext (FormatContext)
  2. AVChapter (#15)
  3. AVProgram (#16)
  4. AVStream (Stream2)
  5. AVFrame (VideoFrame2, AudioSamples2, av_frame_get_metadata(), av_frame_copy_props())

Note, that metadata of the FormatContext and Stream2 can be changed during playback. Refer to the FormatContext::eventFlags() and Stream2::eventFlags() family methods.

Using multiple audio Resamplers on the same stream

What I want to do:

`
Packet pkt = ictx.readPacket(ec);
AudioSamples samples = running->adec->decode(pkt, ec);

resampler1.push(samples);
resampler2.push(samples);
resampler3.push(samples);
`

Where each of those resamplers is configured to a different sampling rate and sample format.
I tried cloning the samples before feeding them into the resampler, still not working.

Is that at all possible?

little typedef typo at videorescaler.h

Hey there! It's really great project.

diff --git a/src/videorescaler.h b/src/videorescaler.h
index 169eb84..085f86e 100644
--- a/src/videorescaler.h
+++ b/src/videorescaler.h
@@ -55,8 +55,8 @@ private:

 };

-typedef std::shared_ptr<VideoRescaler> VideoResamplerPtr;
-typedef std::weak_ptr<VideoRescaler> VideoResamplerWPtr;
+typedef std::shared_ptr<VideoRescaler> VideoRescalerPtr;
+typedef std::weak_ptr<VideoRescaler> VideoRescalerWPtr;

 } // ::av

recursive cloning

Hello!
Firstly thanks a lot for a great work.
I have a little remark -- I think git cloning should be made in recursive way to clone catch2, isn't It?
Otherwise during cmake It will crash in some cases and give something like

CMake Error at tests/CMakeLists.txt:20 (include):
include could not find load file:

Catch

Best regards,
Nadya

Add support for AVFrame::extended_buf

This field (and AVFrame::nb_extended_buf) allows to store more than AV_NUM_DATA_POINTERS planes for multiplanar audio.

Look into AVFrame::extended_data (relative AVFrame::data). Size of the AVFrame::extended_data is AV_NUM_DATA_POINTERS+AVFrame::nb_extended_buf

Problem with encoding

I've made a simple encoding app, with code very similar to api2-decode-encode-video.cpp.
The only difference is that I don't really need an output Stream, since I want to manually operate on encoded packets.
The first problem that I see is that there is no VideoEncoderContext constructor which doesn't require a Stream parameter (I mean there is, but it will lead to problems, no such example provided). So maybe there should be a constructor for such scenario, shouldn't it?

Even when I create a fake output Stream, avcodec_receive_frame (codeccontext.cpp, int decode(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt), returns AVERROR(EAGAIN) during roughly first 50 decode() calls, although I seem to provide correct input data to it.

I assume it should return valid packet every time a new frame is provided to avcodec_send_packet, shouldn't it? Any ideas on that?

Libavcodec version 57.80.100, target platform Windows 10 64-bit (visual studio toolchain is used)

windows support

At the moment windows is not tested despite the large developer/user base.
Here are some steps to get basic windows support working.

  • figure out how to install windows dependencies
  • update Ci to also build for windows
  • test meson windows build (should work out of the box)
  • test cmake windows build (maybe also works out of the box)

Chapters support

Add support for AVChapter reading and adding to the streams.

Also, add ability "transmux" chapters.

How to use api2-decode-encode-video

I am trying to build a tool to convert a bunch of png's into a video. I figured the best place to start was the example api2-decode-encode-video.cpp but I don't understand how to use the example. I compiled it using homebrew ffmpeg 4.0.2 on MacOS and then run with:

./api2-decode-encode-video input.png out.mkv

The line above always crashes when initiating the VideoEncoderContext with an error:

libc++abi.dylib: terminating with uncaught exception of type av::Exception: Codec context invalid media type

I tried other output names but get the same error. How am I supposed to use this example?

VideoFrame data-constructor only uses first row of source image data

I've tried writing a simple video encoder with the source image data being read from a buffer in memory, but I've noticed that it would only encode the very first row of my image data and the rest would be black.
After inspecting the source code, I've noticed this in the constructor for VideoFrame:

VideoFrame::VideoFrame(const uint8_t *data, size_t size, PixelFormat pixelFormat, int width, int height, int align)
{
    [...]
    for (size_t i = 0; i < 4 && buf[i]; ++i) {
        std::copy(buf[i], buf[i]+linesize[i], m_raw->data[i]);
    }
}

I'm new to ffmpeg, but this looks wrong to me. linesize only contains the size of a single row, so this would only copy the very first row from the source buffer, which would explain what I got as a result.

As a test, I've tried overwriting the data manually (memcpy) after creating the frame:

auto width = encoder.width();
auto height = encoder.height();
using Color = std::array<uint8_t,3>;
std::vector<Color> colors {};
colors.resize(width *height,Color{0,255,255});

auto pxFormatRGB = AVPixelFormat::AV_PIX_FMT_RGB24;
uint32_t alignment = 32u;
av::VideoFrame frame{reinterpret_cast<uint8_t*>(colors.data()),colors.size() *sizeof(colors.front()),pxFormatRGB,static_cast<int32_t>(width),static_cast<int32_t>(height),static_cast<int32_t>(alignment)};

memcpy(frame.raw()->data[0],colors.data(),colors.size() *sizeof(colors.front()));
frame.raw()->pts = 0;
frame.raw()->pkt_dts = 0;
frame.setComplete(true);

This is just a dirty work-around (and doesn't take any line padding into account), but it fixed the issue for my test case. I'm still mostly unfamiliar with ffmpeg, so I haven't created a pull request, since I'm not sure what a proper fix would be. Or maybe I just did something wrong altogether and this is not actually a bug?

play control

I want to play the video at twice the speed. can I use this project?

[Help wanted] Unit testing

Good things. But I have no time and ffmpeg-related project for this time to implement it, so any help will be welcomed.

My preferred C++ test framework is Catch2

  1. Use current implementation of the https://github.com/h4tr3d/avcpp/tree/master/example/api2-samples as base for tests.
  2. Create another repository that can be submoduled via master repo and will contains media data for tests. Good base for media data is Big Buck Bunny.
  3. Add tests running to the CI configuration.

FormatContext::openInput(CustomIO, OptionalErrorCode, size_t) is not implemented

I tried to call this function but the linker says symbol not found. I was not able to find the implementation of this function in the cpp file either.

avcpp/src/formatcontext.h

Lines 125 to 127 in a1fef2a

void openInput(CustomIO *io,
OptionalErrorCode ec = throws(),
size_t internalBufferSize = CUSTOM_IO_DEFAULT_BUFFER_SIZE);

PS. Is this a good workaround?

av::FormatContext inputContext;
inputContext.openInput(&customIO, av::InputFormat());

avcpp is not usable as meson subproject (uninstalled) due to headers in src directory

Hello

As in subject when uninstalled I can't use library, because headers can't be included correctly:

#include <avcpp/av.h>
// or
#include "avcpp/av.h"

I am aware of 3 potential solutions to that, two simple, one not that simple:

I can live with my 'copy headers' workaround, didn't care yet to implement it for cmake though.

ffmpeg package issues

Hello, I want to compile avcpp in Windows. Can you support the PkgConfig module lookup for Windows FFmpeg? cmake tool reported wrong:

Call Stack (most recent call first):
CMake Error at cmake/FindFFmpeg.cmake:186 (set_target_properties):
set_target_properties called with incorrect number of arguments.
Call Stack (most recent call first):
CMakeLists.txt:20 (find_package)
CMake Error at D:/develop/CMake/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find FFmpeg (missing: FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS
AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIRS AVFORMAT_LIBRARIES
AVFORMAT_INCLUDE_DIRS AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIRS
AVDEVICE_LIBRARIES AVDEVICE_INCLUDE_DIRS AVFILTER_LIBRARIES
AVFILTER_INCLUDE_DIRS SWSCALE_LIBRARIES SWSCALE_INCLUDE_DIRS
SWRESAMPLE_LIBRARIES SWRESAMPLE_INCLUDE_DIRS)
Call Stack (most recent call first):
D:/develop/CMake/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
cmake/FindFFmpeg.cmake:204 (find_package_handle_standard_args)
CMakeLists.txt:20 (find_package)

Get codec information from stream?

I'm doing simple remux and replaced raw ffmpeg with your library but couldnt find a way to do this without accessing raw() ?

        const auto srcVideoStream = formatCtx.stream(videoStream).raw();
        videoOutStream = outCtx.addStream(av::Codec(srcVideoStream->codec->codec));
        if (outCtx.outputFormat().isFlags(AVFMT_GLOBALHEADER))
            videoOutStream.raw()->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;

        videoOutStream.setTimeBase(srcVideoStream->codec->time_base);

Also doing outCtx.dump() gives me Stream #0:0: Unknown: none So not sure if i even did that correctly ?

Missing source files

The examples refer to Container.h, StreamCoder.h and similar. Where can I find these files?

pkg-config file include some problem

Hi,
i found that libavcpp.pc file have a mistake in includedir,it is includedir = ${prefix}/include now.In this situation,we cant include header file directly like the way in example #include "av.h" instead of #include "avcpp/av.h"
could you please fix this problem,or im very glad to fix it
sorry im not a native english speaker.....

Compiling problems of the examples

In Ubuntu 18.04.4 Desktop I installed avcpp following these indications: https://github.com/h4tr3d/avcpp#ubuntu-and-linux-mint

(base) marco@pc01:~$ git clone --recurse-submodules https://github.com/h4tr3d/avcpp.git avcpp-
git
Cloning into 'avcpp-git'...
remote: Enumerating objects: 45, done.
remote: Counting objects: 100% (45/45), done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 1605 (delta 16), reused 14 (delta 6), pack-reused 1560
Receiving objects: 100% (1605/1605), 523.42 KiB | 1.56 MiB/s, done.
Resolving deltas: 100% (1110/1110), done.
Submodule 'catch2' (https://github.com/catchorg/Catch2.git) registered for path 'catch2'
Cloning into '/home/marco/avcpp-git/catch2'...
remote: Enumerating objects: 110, done.
remote: Counting objects: 100% (110/110), done.
remote: Compressing objects: 100% (92/92), done.
remote: Total 26279 (delta 34), reused 43 (delta 18), pack-reused 26169
Receiving objects: 100% (26279/26279), 15.91 MiB | 9.42 MiB/s, done.
Resolving deltas: 100% (18294/18294), done.
Submodule path 'catch2': checked out 'f0b7b0ca119d8cf58c2b89dea663f921dbdbd332'

(base) marco@pc01:~/avcpp-git$ mkdir build
(base) marco@pc01:~/avcpp-git$ cd build
(base) marco@pc01:~/avcpp-git/build$ cmake ..
-- The CXX compiler identification is GNU 9.2.1
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Checking for module 'libavcodec'
--   Found libavcodec, version 58.54.100
-- Checking for module 'libavformat'
--   Found libavformat, version 58.29.100
-- Checking for module 'libavdevice'
--   Found libavdevice, version 58.8.100
-- Checking for module 'libavutil'
--   Found libavutil, version 56.31.100
-- Checking for module 'libavfilter'
--   Found libavfilter, version 7.57.100
-- Checking for module 'libswscale'
--   Found libswscale, version 5.5.100
-- Checking for module 'libpostproc'
--   Found libpostproc, version 55.5.100
-- Checking for module 'libswresample'
--   Found libswresample, version 3.5.100
-- Found FFmpeg: /usr/lib/x86_64-linux-gnu/libavcodec.so;/usr/lib/x86_64-linux-gnu/libavformat.so;
/usr/lib/x86_64-linux-gnu/libavutil.so;/usr/lib/x86_64-linux-gnu/libavdevice.so;/usr/lib/x86_64-linux-
gnu$
-- /home/marco/avcpp-git/catch2/contrib
-- Configuring done
-- Generating done
-- Build files have been written to: /home/marco/avcpp-git/build
(base) marco@pc01:~/avcpp-git/build$ sudo make -j8
Scanning dependencies of target test_main
Scanning dependencies of target avcpp
Scanning dependencies of target avcpp_static
[  1%] Building CXX object tests/CMakeFiles/test_main.dir/test-main.cpp.o
[  4%] Building CXX object src/CMakeFiles/avcpp.dir/averror.cpp.o
....
[100%] Linking CXX executable test_executor
/usr/bin/ld: warning: libavutil.so.55, needed by //usr/lib/x86_64-linux-gnu/libchromaprint.so.1, may 
conflict with libavutil.so.56
[100%] Built target test_executor
(base) marco@pc01:~/avcpp-git/build$

(base) marco@pc01:~/avcpp-git/build$ sudo make install
[ 33%] Built target avcpp_static
[ 67%] Built target avcpp
[ 70%] Built target api2-decode
[ 72%] Built target api2-decode-audio
[ 75%] Built target api2-scale-video
[ 78%] Built target api2-remux
[ 81%] Built target api2-decode-rasample-audio
[ 83%] Built target api2-decode-encode-audio
[ 86%] Built target api2-demux-seek
[ 89%] Built target api2-decode-encode-video
[ 91%] Built target api2-dict-basic
[ 94%] Built target api2-timestamp
[ 97%] Built target test_main
[100%] Built target test_executor
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libavcpp.so
-- Installing: /usr/local/lib/libavcpp.a
-- Installing: /usr/local/include/avcpp
-- Installing: /usr/local/include/avcpp/stream.h
-- Installing: /usr/local/include/avcpp/packet.h
-- Installing: /usr/local/include/avcpp/dictionary.h
-- Installing: /usr/local/include/avcpp/sampleformat.h
-- Installing: /usr/local/include/avcpp/pixelformat.h
-- Installing: /usr/local/include/avcpp/codeccontext.h
-- Installing: /usr/local/include/avcpp/rational.h
-- Installing: /usr/local/include/avcpp/timestamp.h
-- Installing: /usr/local/include/avcpp/ffmpeg.h
-- Installing: /usr/local/include/avcpp/frame.h
-- Installing: /usr/local/include/avcpp/videorescaler.h
-- Installing: /usr/local/include/avcpp/avtime.h
-- Installing: /usr/local/include/avcpp/filters
-- Installing: /usr/local/include/avcpp/filters/filterpad.h
-- Installing: /usr/local/include/avcpp/filters/filtercontext.h
-- Installing: /usr/local/include/avcpp/filters/buffersink.h
-- Installing: /usr/local/include/avcpp/filters/filter.h
-- Installing: /usr/local/include/avcpp/filters/buffersrc.h
-- Installing: /usr/local/include/avcpp/filters/filtergraph.h
-- Installing: /usr/local/include/avcpp/formatcontext.h
-- Installing: /usr/local/include/avcpp/av.h
-- Installing: /usr/local/include/avcpp/avutils.h
-- Installing: /usr/local/include/avcpp/audioresampler.h
-- Installing: /usr/local/include/avcpp/linkedlistutils.h
-- Installing: /usr/local/include/avcpp/format.h
-- Installing: /usr/local/include/avcpp/avlog.h
-- Installing: /usr/local/include/avcpp/codec.h
-- Installing: /usr/local/include/avcpp/rect.h
-- Installing: /usr/local/include/avcpp/averror.h
-- Installing: /usr/local/lib/pkgconfig/libavcpp.pc
-- Installing: /usr/local/lib/cmake/Catch2/Catch2Targets.cmake
-- Up-to-date: /usr/local/include
-- Installing: /usr/local/include/catch2
-- Installing: /usr/local/include/catch2/catch.hpp
-- Installing: /usr/local/include/catch2/catch_reporter_teamcity.hpp
-- Installing: /usr/local/include/catch2/catch_reporter_automake.hpp
-- Installing: /usr/local/include/catch2/catch_reporter_tap.hpp
-- Installing: /usr/local/lib/cmake/Catch2/Catch2Config.cmake
-- Installing: /usr/local/lib/cmake/Catch2/Catch2ConfigVersion.cmake
-- Installing: /usr/local/share/doc/Catch2
-- Installing: /usr/local/share/doc/Catch2/ci-and-misc.md
-- Installing: /usr/local/share/doc/Catch2/configuration.md
-- Installing: /usr/local/share/doc/Catch2/limitations.md
-- Installing: /usr/local/share/doc/Catch2/release-notes.md
-- Installing: /usr/local/share/doc/Catch2/test-cases-and-sections.md
-- Installing: /usr/local/share/doc/Catch2/command-line.md
-- Installing: /usr/local/share/doc/Catch2/tutorial.md
-- Installing: /usr/local/share/doc/Catch2/logging.md
-- Installing: /usr/local/share/doc/Catch2/opensource-users.md
-- Installing: /usr/local/share/doc/Catch2/test-fixtures.md
-- Installing: /usr/local/share/doc/Catch2/release-process.md
-- Installing: /usr/local/share/doc/Catch2/cmake-integration.md
-- Installing: /usr/local/share/doc/Catch2/benchmarks.md
-- Installing: /usr/local/share/doc/Catch2/slow-compiles.md
-- Installing: /usr/local/share/doc/Catch2/own-main.md
-- Installing: /usr/local/share/doc/Catch2/assertions.md
-- Installing: /usr/local/share/doc/Catch2/deprecations.md
-- Installing: /usr/local/share/doc/Catch2/reporters.md
-- Installing: /usr/local/share/doc/Catch2/event-listeners.md
-- Installing: /usr/local/share/doc/Catch2/generators.md
-- Installing: /usr/local/share/doc/Catch2/commercial-users.md
-- Installing: /usr/local/share/doc/Catch2/tostring.md
-- Installing: /usr/local/share/doc/Catch2/Readme.md
-- Installing: /usr/local/share/doc/Catch2/other-macros.md
-- Installing: /usr/local/share/doc/Catch2/matchers.md
-- Installing: /usr/local/share/doc/Catch2/list-of-examples.md
-- Installing: /usr/local/share/doc/Catch2/why-catch.md
-- Installing: /usr/local/share/doc/Catch2/contributing.md
-- Installing: /usr/local/lib/cmake/Catch2/ParseAndAddCatchTests.cmake
-- Installing: /usr/local/lib/cmake/Catch2/Catch.cmake
-- Installing: /usr/local/lib/cmake/Catch2/CatchAddTests.cmake
-- Installing: /usr/local/share/Catch2/gdbinit
-- Installing: /usr/local/share/Catch2/lldbinit
-- Installing: /usr/local/share/pkgconfig/catch2.pc

(base) marco@pc01:/usr/local/include$ sudo mv avcpp av

But when trying to compile some examples I get "No such file or directory":

(base) marco@pc01:~/avcpp-git/example/test-basic$ g++ -std=c++17 -I /usr/local/include/av/ av-
main.cpp -L /usr/local/lib/libavcpp.so -o av-main
av-main.cpp:7:10: fatal error: av/containerformat.h: No such file or directory
    7 | #include "av/containerformat.h"
av-main.cpp:8:10: fatal error: av/container.h: No such file or directory
av-main.cpp:10:10: fatal error: av/streamcoder.h: No such file or directory

The same problem for another example:

(base) marco@pc01:~/avcpp-git/example/sample-view$ g++ -std=c++17 -I /usr/local/include/av/    
av-view.cpp -L /usr/local/lib/libavcpp.so -o av-view
av-view.cpp:5:10: fatal error: SDL/SDL.h: No such file or directory
    5 | #include <SDL/SDL.h>
       |          ^~~~~~~~~~~


(base) marco@pc01:~/avcpp-git/example/sample-view$ cd build
(base) marco@pc01:~/avcpp-git/example/sample-view/build$ cmake .. 
CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The C compiler identification is GNU 9.2.1
-- The CXX compiler identification is GNU 9.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:13 (pkg_search_module):
  Unknown CMake command "pkg_search_module".

CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.16)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!
See also "/home/marco/avcpp-git/example/sample-view/build/CMakeFiles/CMakeOutput.log".

How to solve the problem?

Programs support

Add support for AVProgram reading and adding to the streams.

Also, add ability "transmux" programs.

Useful documentation

One of the most important things is missing at the moment and that is some at least half decent documentation.

Here are a few suggestions on what should be done, feel free to propose additions in the comments:

  • adding a doxyfile to build html documentation (#69)
  • build and publish the documentation to github pages or something different (github actions or maybe travis)
  • document all functions (javadoc style)
  • document every type, enum and class (javadoc style)
  • properly document the examples
  • write some kind of getting started/beginners guide

provide non-gpl build option

I noticed you require swscale in your cmake, and also include its header at one point. swscale is effectively gpl, so that conflicts with the proposed bsd licensing.

How to use avcodec_receive_frame?

I have a simple app with this decoding method:

      ```
      static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
      {
      int ret;
      *got_frame = 0;
      if (pkt) 
      {
                ret = avcodec_send_packet(avctx, pkt);
                if (ret < 0) 
                {
                          return ret == AVERROR_EOF ? 0 : ret;
                }
      }
      ret = avcodec_receive_frame(avctx, frame);
      if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) 
      {
                return ret;
      }
      if (ret >= 0)
      {
                *got_frame = 1;
      }
      return 0;
      }

I use this method to store video clip but there are a few frames in the video clip with errors or 'miss frames' from previous clip.

avcodec_receive_frame(avctx, frame); - returns code '-11' that stands for 'other negative values: legitimate decoding errors'. What the 'other negative values' are?

Use from another cmake project

What's the best way to use your library from another cmake project ?

I'm a beginner at cpp, but from what i understood of cmake, shouldn't I be able to find either a FindAVCPP.cmake or AVCPPConfig.cmake file ?

Thanks.

integrating in xupnpd2 mediaserver

Hello,
I hope someone could help me. The background is: I use the xupnpd2-mediaserver (https://github.com/clark15b/xupnpd2) on my router to display some hls-streams on the TV-device. I try to receive the hls-streams from https://www.mall.tv/zive. I solved the missing https-support in xupnpd2 by using haproxy as reverse proxy. I'm not a developer, but I think there is an "error" or missing part in the m3u8 parsing/decoding (this file: https://github.com/clark15b/xupnpd2/blob/master/plugin_hls_common.cpp), because the stream https://www.mall.tv/planespotting is 4 hours behind the actual time.

I contacted the xupnpd2's original-author several times to extend/fix the hls/m3u8-decoding, but never got a reply.

My idea is to create an hls/m3u8-playlist decoder for xupnpd2 using a c++ ffmpeg wrapper. I hope you could help me, because I'm not a developer.

Best regards,
Thomas

msvc 2018 error in RawStringDeleter

Code:
Dictionary::RawStringPtr Dictionary::toRawStringPtr(const char keyValSep, const char pairsSep, OptionalErrorCode ec) const
{
RawStringPtr str;
}

\MSVC\14.20.27508\include\memory(1934): error C2664: 'void av::Dictionary::RawStringDeleter::operator ()(char *&)': cannot convert argument 1 from 'char *' to 'char *&'
\MSVC\14.20.27508\include\memory(1932): note: while compiling class template member function 'std::unique_ptr<char,av::Dictionary::RawStringDeleter>::~unique_ptr(void) noexcept'
src\dictionary.cpp(229): note: see reference to function template instantiation 'std::unique_ptr<char,av::Dictionary::RawStringDeleter>::~unique_ptr(void) noexcept' being compiled
src\dictionary.cpp(228): note: see reference to class template instantiation 'std::unique_ptr<char,av::Dictionary::RawStringDeleter>' being compiled
1>format.cpp

Compiler warning with ffmpeg 4.0.2

/Users/jeroen/workspace/avcpp/src/codec.cpp:33:28: warning: implicit conversion of nullptr constant to 'bool' [-Wnull-conversion]
    return RAW_GET(decode, nullptr);
    ~~~~~~                 ^~~~~~~
                           false
1 warning generated.

And also

/Users/jeroen/workspace/avcpp/example/api2-samples/api2-decode-rasample-audio.cpp:168:30: warning: using the result of an assignment as a condition without parentheses
      [-Wparentheses]
            while (ouSamples = resampler.pop(samples.samplesCount()/2, ec)) {
                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jeroen/workspace/avcpp/example/api2-samples/api2-decode-rasample-audio.cpp:168:30: note: place parentheses around the assignment to silence this warning
            while (ouSamples = resampler.pop(samples.samplesCount()/2, ec)) {
                             ^
                   (                                                      )
/Users/jeroen/workspace/avcpp/example/api2-samples/api2-decode-rasample-audio.cpp:168:30: note: use '==' to turn this assignment into an equality comparison
            while (ouSamples = resampler.pop(samples.samplesCount()/2, ec)) {
                             ^
                             ==
1 warning generated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.