Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix API that has been removed from ffmpeg #115

Merged
merged 6 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
}

linux_test:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.x
Expand All @@ -143,7 +143,6 @@ jobs:
python-version: 3.x
- name: Install
run: |
sudo add-apt-repository ppa:jonathonf/ffmpeg-4 -y
sudo apt update
sudo apt install ffmpeg libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev
sudo apt install libavutil-dev libswscale-dev libswresample-dev libpostproc-dev libsdl2-dev libsdl2-2.0-0
Expand All @@ -165,7 +164,7 @@ jobs:
pytest "$name/tests"

linux_wheels:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.x
Expand Down Expand Up @@ -213,7 +212,7 @@ jobs:
pytest "$name/tests"

osx_wheels:
runs-on: macos-10.15
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: Brew setup
Expand Down Expand Up @@ -289,7 +288,7 @@ jobs:
pytest "$name/tests"

docs:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.x
Expand Down
3 changes: 1 addition & 2 deletions ffpyplayer/clib/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ int get_plane_sizes(int size[4], int required_plane[4], enum AVPixelFormat pix_f
return AVERROR(EINVAL);
size[0] = linesizes[0] * height;

if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
if (desc->flags & AV_PIX_FMT_FLAG_PAL) {
size[1] = 256 * 4;
required_plane[0] = 1;
return size[0] + size[1];
Expand Down
4 changes: 2 additions & 2 deletions ffpyplayer/includes/ffmpeg.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ cdef:
int av_interleaved_write_frame(AVFormatContext *, AVPacket *)
void avformat_free_context(AVFormatContext *)
uint8_t *av_stream_get_side_data (AVStream *, AVPacketSideDataType, int *)
AVOutputFormat *av_oformat_next(AVOutputFormat *)
AVInputFormat *av_iformat_next(AVInputFormat *)
const AVOutputFormat *av_muxer_iterate(void **)
const AVInputFormat *av_demuxer_iterate(void **)

extern from "libavdevice/avdevice.h" nogil:
void avdevice_register_all()
Expand Down
3 changes: 1 addition & 2 deletions ffpyplayer/tests/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def get_gray_image_with_val(w, h, val):
# Construct images
size = w * h
buf = bytearray([int(val)] * size)
buf2 = bytearray([0] * size)
img = Image(plane_buffers=[buf, buf2], pix_fmt='gray', size=(w, h))
img = Image(plane_buffers=[buf], pix_fmt='gray', size=(w, h))
return img


Expand Down
10 changes: 6 additions & 4 deletions ffpyplayer/tools.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,12 @@ cpdef get_fmts(int input=False, int output=False):
cdef list fmts = [], full_names = [], exts = []
cdef AVOutputFormat *ofmt = NULL
cdef AVInputFormat *ifmt = NULL
cdef void *ifmt_opaque = NULL
cdef void *ofmt_opaque = NULL
cdef object names, full_name, ext

if output:
ofmt = av_oformat_next(ofmt)
ofmt = av_muxer_iterate(&ofmt_opaque)
while ofmt != NULL:
if ofmt.name != NULL:
names = tcode(ofmt.name).split(',')
Expand All @@ -330,10 +332,10 @@ cpdef get_fmts(int input=False, int output=False):
fmts.extend(names)
full_names.extend([full_name, ] * len(names))
exts.extend([ext, ] * len(names))
ofmt = av_oformat_next(ofmt)
ofmt = av_muxer_iterate(&ofmt_opaque)

if input:
ifmt = av_iformat_next(ifmt)
ifmt = av_demuxer_iterate(&ifmt_opaque)
while ifmt != NULL:
if ifmt.name != NULL:
names = tcode(ifmt.name).split(',')
Expand All @@ -343,7 +345,7 @@ cpdef get_fmts(int input=False, int output=False):
fmts.extend(names)
full_names.extend([full_name, ] * len(names))
exts.extend([ext, ] * len(names))
ifmt = av_iformat_next(ifmt)
ifmt = av_demuxer_iterate(&ifmt_opaque)

exts = [x for (y, x) in sorted(zip(fmts, exts), key=_get_item0)]
full_names = [x for (y, x) in sorted(zip(fmts, full_names), key=_get_item0)]
Expand Down