Skip to content

Commit

Permalink
fix assigning to 'AVCodec *' from incompatible type 'const AVCodec *' (
Browse files Browse the repository at this point in the history
…#160)

* fix assigning to 'AVCodec *' from incompatible type 'const AVCodec *'

* fix ffmpeg version

* fix

* fix ffmpeg folder

* fix workflow

* permission

* fix path
  • Loading branch information
zhreshold authored Jun 14, 2021
1 parent b8fd6a5 commit e0b7f7c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,25 @@ jobs:
build-requirements: 'numpy'
pre-build-command: 'sh ../tools/build_manylinux2010.sh'
package-path: 'python'
pip-wheel-args: '-w ./dist'
pip-wheel-args: '-w ./dist --no-deps'
- name: Sanity test
run: |
pwd
ls ./python/dist/
sudo rm ./python/dist/decord-*-linux_x86_64.whl
which python
which pip
sudo find ./python/dist/ -type f -iname "decord*manylinux2010_x86_64.whl" -exec sh -c "zip --delete '{}' 'numpy/*' | true" \;
sudo find ./python/dist/ -type f -iname "decord*manylinux2010_x86_64.whl" -exec sh -c "zip --delete '{}' 'pip/*' | true" \;
sudo -H find ./python/dist/ -type f -iname "decord*manylinux2010_x86_64.whl" -exec sh -c "zip --delete '{}' 'numpy/*' | true" \;
sudo -H find ./python/dist/ -type f -iname "decord*manylinux2010_x86_64.whl" -exec sh -c "zip --delete '{}' 'pip/*' | true" \;
sudo -H find ./python/dist/ -type f -iname "decord*manylinux2010_x86_64.whl" -exec sh -c "unzip '{}' -d ./decord-cwd" \;
ls
cd ./decord-cwd
ls -la
sudo -H find . -type d -iname "decord-*.dist-info" -exec sh -c "echo decord > '{}'/top_level.txt" \;
sudo -H find . -type d -iname "decord-*.dist-info" -exec sh -c "sed -i '/^numpy/d' '{}'/RECORD" \;
sudo -H find . -type d -iname "decord-*.dist-info" -exec sh -c "sed -i '/^pip/d' '{}'/RECORD" \;
cd ..
sudo -H find ./python/dist/ -type f -iname "decord*manylinux2010_x86_64.whl" -exec sh -c "rm '{}' && cd decord-cwd && zip -r ../'{}' ./*" \;
find ./python/dist/ -type f -iname "decord*manylinux2010_x86_64.whl" -exec sh -c "which python && python -m pip install '{}' --force-reinstall" \;
python -c "import decord; print(decord.__version__)"
python -m nose -v ./tests/python/unittests/test_video_reader.py
Expand Down
6 changes: 3 additions & 3 deletions src/audio/audio_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace decord {
static const int AVIO_BUFFER_SIZE = std::stoi(runtime::GetEnvironmentVariableOrDefault("DECORD_AVIO_BUFFER_SIZE", "40960"));

AudioReader::AudioReader(std::string fn, int sampleRate, DLContext ctx, int io_type, bool mono)
: ctx(ctx), io_ctx_(), pFormatContext(nullptr), swr(nullptr), pCodec(nullptr), pCodecParameters(nullptr),
: ctx(ctx), io_ctx_(), pFormatContext(nullptr), swr(nullptr), pCodecParameters(nullptr),
pCodecContext(nullptr), audioStreamIndex(-1), outputVector(), output(), padding(-1.0), filename(fn), originalSampleRate(0),
targetSampleRate(sampleRate), numChannels(0), mono(mono), totalSamplesPerChannel(0), totalConvertedSamplesPerChannel(0),
timeBase(0.0), duration(0.0)
Expand Down Expand Up @@ -138,7 +138,7 @@ namespace decord {
}

// prepare codec
pCodec = avcodec_find_decoder(pCodecParameters->codec_id);
auto pCodec = avcodec_find_decoder(pCodecParameters->codec_id);
CHECK(pCodec != nullptr) << "ERROR Decoder not found. THe codec is not supported.";
pCodecContext = avcodec_alloc_context3(pCodec);
CHECK(pCodecContext != nullptr) << "ERROR Could not allocate a decoding context.";
Expand Down Expand Up @@ -318,4 +318,4 @@ namespace decord {
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/audio/audio_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace decord {
std::unique_ptr<ffmpeg::AVIOBytesContext> io_ctx_; // avio context for raw memory access
AVFormatContext *pFormatContext;
struct SwrContext* swr;
AVCodec* pCodec;
// AVCodec* pCodec;
AVCodecParameters* pCodecParameters;
AVCodecContext * pCodecContext;
int audioStreamIndex;
Expand Down
6 changes: 3 additions & 3 deletions src/video/video_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ VideoReader::VideoReader(std::string fn, DLContext ctx, int width, int height, i
// initialize all video streams and store codecs info
for (uint32_t i = 0; i < fmt_ctx_->nb_streams; ++i) {
AVStream *st = fmt_ctx_->streams[i];
AVCodec *local_codec = avcodec_find_decoder(st->codecpar->codec_id);
const AVCodec *local_codec = avcodec_find_decoder(st->codecpar->codec_id);
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
// store video stream codecs only
codecs_.emplace_back(local_codec);
} else {
// audio, subtitle... skip
AVCodec *tmp = NULL;
const AVCodec *tmp = NULL;
codecs_.emplace_back(tmp);
}
}
Expand Down Expand Up @@ -223,7 +223,7 @@ unsigned int VideoReader::QueryStreams() const {
// iterate and print stream info
// feel free to add more if needed
AVStream *st = fmt_ctx_->streams[i];
AVCodec *codec = codecs_[i];
const AVCodec *codec = codecs_[i];
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
LOG(INFO) << "video stream [" << i << "]:"
<< " Average FPS: "
Expand Down
2 changes: 1 addition & 1 deletion src/video/video_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class VideoReader : public VideoReaderInterface {
/*! \brief a lookup table for per frame pts/dts */
std::vector<AVFrameTime> frame_ts_;
/*! \brief Video Streams Codecs in original videos */
std::vector<AVCodec*> codecs_;
std::vector<const AVCodec*> codecs_;
/*! \brief Currently active video stream index */
int actv_stm_idx_;
/*! \brief AV format context holder */
Expand Down
6 changes: 3 additions & 3 deletions tools/build_macos_10_9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ make install

# ffmpeg
cd ~/ffmpeg_sources
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjf ffmpeg-snapshot.tar.bz2
cd ffmpeg
curl -O -L https://ffmpeg.org/releases/ffmpeg-4.1.6.tar.bz2
tar xjf ffmpeg-4.1.6.tar.bz2
cd ffmpeg-4.1.6
./configure \
--prefix="$HOME/ffmpeg_build" \
--enable-shared \
Expand Down
6 changes: 3 additions & 3 deletions tools/build_manylinux2010.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ make install

# ffmpeg
cd ~/ffmpeg_sources
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjf ffmpeg-snapshot.tar.bz2
cd ffmpeg
curl -O -L https://ffmpeg.org/releases/ffmpeg-4.1.6.tar.bz2
tar xjf ffmpeg-4.1.6.tar.bz2
cd ffmpeg-4.1.6
export PATH="$HOME/bin:$PATH"
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
Expand Down

0 comments on commit e0b7f7c

Please sign in to comment.