Skip to content

Commit

Permalink
transcoder: implement a video filter chain for deint+scale
Browse files Browse the repository at this point in the history
This patch reimplements deinterlacing and scaling with a simple libav
filter chain, to make the transcoder compatible with newer ffmpeg/libav
codebase.

Upstream ffmpeg has removed the long deprecated deinterlacer module
used by this code, which made the reimplementation using a filter
chain necessary.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
  • Loading branch information
mlauss2 authored and perexg committed Nov 3, 2015
1 parent a3e787f commit c63371c
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 93 deletions.
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -64,7 +64,7 @@ CFLAGS += -I${ROOTDIR}/libav_static/build/ffmpeg/include
LDFLAGS_FFDIR = ${ROOTDIR}/libav_static/build/ffmpeg/lib
LDFLAGS += ${LDFLAGS_FFDIR}/libavresample.a
LDFLAGS += ${LDFLAGS_FFDIR}/libswresample.a
LDFLAGS += ${LDFLAGS_FFDIR}/libswscale.a
LDFLAGS += ${LDFLAGS_FFDIR}/libavfilter.a
LDFLAGS += ${LDFLAGS_FFDIR}/libavutil.a
LDFLAGS += ${LDFLAGS_FFDIR}/libavformat.a
LDFLAGS += ${LDFLAGS_FFDIR}/libavcodec.a
Expand Down Expand Up @@ -101,6 +101,7 @@ LDFLAGS += -lmfx
endif
LDFLAGS += ${CONFIG_LIBMFX_VA_LIBS}
endif
LDFLAGS += -lavfilter
endif

ifeq ($(CONFIG_HDHOMERUN_STATIC),yes)
Expand Down
2 changes: 1 addition & 1 deletion Makefile.ffmpeg
Expand Up @@ -62,7 +62,7 @@ FFMPEG_URL = http://ffmpeg.org/releases/$(FFMPEG_TB)
FFMPEG_SHA1 = 95046cd9251b69c61b11ebcd1e163ac14d0fc2c6

EXTLIBS = libx264 libvorbis libvpx
COMPONENTS = avutil avformat avcodec swresample swscale avresample
COMPONENTS = avutil avformat avcodec swresample avfilter avresample
PROTOCOLS = file
DECODERS = mpeg2video mp2 ac3 eac3 h264 h264_vdpau hevc aac aac_latm vorbis libvorbis
ENCODERS = mpeg2video mp2 libx264 libvpx_vp8 libvpx_vp9 aac libaacplus vorbis libvorbis
Expand Down
4 changes: 2 additions & 2 deletions configure
Expand Up @@ -467,7 +467,7 @@ else
has_libav=false
fi

if $has_libav && ! check_pkg libswscale ">=2.3.100"; then
if $has_libav && ! check_pkg libavfilter ">=4.0.0"; then
has_libav=false
fi

Expand All @@ -493,7 +493,7 @@ else
has_libav=false
fi

if $has_libav && ! check_pkg libswscale ">=2.1.2"; then
if $has_libav && ! check_pkg libavfilter ">=4.0.0"; then
has_libav=false
fi

Expand Down
1 change: 1 addition & 0 deletions src/libav.c
Expand Up @@ -214,5 +214,6 @@ libav_init(void)
av_log_set_callback(libav_log_callback);
libav_set_loglevel();
av_register_all();
avfilter_register_all();
transcoding_init();
}
1 change: 1 addition & 0 deletions src/libav.h
Expand Up @@ -24,6 +24,7 @@
#if ENABLE_LIBAV

#include <libavformat/avformat.h>
#include <libavfilter/avfilter.h>
#include "tvheadend.h"

/*
Expand Down

1 comment on commit c63371c

@pfsysadmin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to build the latest git version of tvheadend (version 3882~ga26944c) on debian jessie (latest updates) on the armel platform and noticed there was an additional package check I had not seen which failed related to libavfilter. I decided to install libavfilter5 and libavfilter-dev (the stable packages available in jessie). Note, I am not using the ffmpeg libraries.

The package check now shows:
checking for ffmpeg libraries ... fail
checking for pkg libavcodec >=55.34.1 ... ok (detected 56.1.0)
checking for pkg libavutil >=53.3.0 ... ok (detected 54.3.0)
checking for pkg libavformat >=55.12.0 ... ok (detected 56.1.0)
checking for pkg libavfilter >=4.0.0 ... ok (detected 5.0.0)
checking for pkg libavresample >=1.1.0 ... ok (detected 2.1.0)

However the build failed on transcoding.c. The errors were:
src/plumbing/transcoding.c: In function ‘create_video_filter’:
src/plumbing/transcoding.c:1093:3: error: implicit declaration of function ‘av_opt_set_int_list’ [-Werror=implicit-function-declaration]
err = av_opt_set_int_list(vs->flt_bufsinkctx, "pix_fmts", pix_fmts,
^
src/plumbing/transcoding.c:1115:3: error: implicit declaration of function ‘avfilter_graph_parse_ptr’ [-Werror=implicit-function-declaration]
err = avfilter_graph_parse_ptr(vs->flt_graph,
^
It seems the libavfilter and libavutil versions in debian jessie is missing these declarations.

Is there any advantage in using ffmpeg over libav versions of these libraries?

I did some searching and found a reference to using avfilter_graph_parse2 instead of avfilter_graph_parse_ptr (https://www.mail-archive.com/libav-user@ffmpeg.org/msg05353.html). This function is present in the libavfilter5 included with debian jessie.

av_opt_set_int_list is more problematic. It is a define in opt.c of libavutil which can be added but this in turn uses another define (av_int_list_length) which would also have to be added. This define uses av_int_list_length_for_size() which is specified in utils.c. I am not sure how to rewrite the code to achieve the same outcome and support both libav and ffmpeg.

It's certainly a challenge trying to make the code compatible with both libav and ffmpeg libraries and the different versions included by different distributions!

If you require further information, please do not hesitate to contact me.

Regards

Paul

Please sign in to comment.