Git Product home page Git Product logo

myplay's Introduction

ffplay2myplay

Introduction

ffplay is a simple media player of FFmpeg. I separate it from FFmpeg and change it to ffplay.cpp. So that we could integrate image processing algorithms into ffplay.
cmdutils.c, cmdutils.h and ffplay.c come from ffmpeg-4.3.1/fftools. I modified them a little.

How ffplay works

What does ffplay do: decode and display.

ffplay

We could put algorithms into video_image_display() or upload_texture().

display

Where I modified

cmdutils.h

In line 249, parameter class is same as C++ key word, I changed it to myclass.

// before
void show_help_children(const AVClass *class, int flags);
// after
void show_help_children(const AVClass *myclass, int flags);

ffplay.cpp

header files of FFmpeg need to be wrapped by extern "C" {}.

extern "C"
{
#include "libavutil/avstring.h"
#include "libavutil/eval.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "libavutil/dict.h"
#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/avassert.h"
#include "libavutil/time.h"
#include "libavutil/bprint.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavutil/opt.h"
#include "libavcodec/avfft.h"
#include "libswresample/swresample.h"

#if CONFIG_AVFILTER
# include "libavfilter/avfilter.h"
# include "libavfilter/buffersink.h"
# include "libavfilter/buffersrc.h"
#endif

#include "cmdutils.h"
}

In line 313, struct ShowMode need to be prefixed with VideoState::.

#define ShowMode VideoState::ShowMode
#define SHOW_MODE_NONE ShowMode::SHOW_MODE_NONE
#define SHOW_MODE_VIDEO ShowMode::SHOW_MODE_VIDEO
#define SHOW_MODE_WAVES ShowMode::SHOW_MODE_WAVES
#define SHOW_MODE_RDFT ShowMode::SHOW_MODE_RDFT
#define SHOW_MODE_NB ShowMode::SHOW_MODE_NB

In line 3551, parse_number_or_die() return a double type which could not be converted to enum in C++. So I force it convert to Int.

// before
parse_number_or_die(opt, arg, OPT_INT, 0, SHOW_MODE_NB-1);
// after
(int)parse_number_or_die(opt, arg, OPT_INT, 0, SHOW_MODE_NB-1);

Requirements

  • CMake >= 3.0
  • GNU >= 5.4.0
  • SDL2 >= 2.0
  • FFmpeg == 4.3.1 or 4.3.2

Installation

SDL2 & yasm

sudo apt install libsdl2-dev
sudo apt install yasm

FFmpeg-4.3.1

wget http://ffmpeg.org/releases/ffmpeg-4.3.1.tar.gz
tar -zxf ffmpeg-4.3.1.tar.gz
cd ffmpeg-4.3.1
mkdir build && cd build
// if cpu
./../configure --prefix=/usr/local/ffmpeg --enable-shared
make
sudo make install

// set environment variables
vim ~/.bashrc
// add them to file
export PATH=/usr/local/ffmpeg/bin:$PATH
export LIBRARY_PATH=/usr/local/ffmpeg/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib:$LD_LIBRARY_PATH
// source to make it work
source ~/.bashrc

Clone this repo

git clone git@github.com:hanjialeOK/myplay

Configuration

Modify CMakeLists.txt according to your own condition.

  • set FFMPEG_SOURCE path/to/your/ffmpeg-4.3.1

    set(FFMPEG_SOURCE ~/ffmpeg-4.3.1)
  • set FFMPEG_BUILD path/to/where/you/build/ffmpeg-4.3.1

    set(FFMPEG_BUILD ~/ffmpeg-4.3.1/build)

Compile & Run

cd myplay
mkdir build && cd build
cmake ..
make
./myplay test.mp4

myplay's People

Contributors

hanjialeok avatar

Watchers

 avatar

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.