question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ffmpeg 4.0 NVIDIA NVDEC-accelerated Support ?

See original GitHub issue

ffmpeg 4.0 has released the NVIDIA NVDEC-accelerated H.264, HEVC, MJPEG, MPEG-1/2/4, VC1, VP8/9 hwaccel decoding added.

see more ffmpeg 4.0 NVENC

so, Is it possible to increase support for gpu acceleration?

my ffmpeg

ffmpeg version N-87822-g734ed38 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
  configuration: --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/cuda/lib64
  libavutil      55. 79.100 / 55. 79.100
  libavcodec     57.108.100 / 57.108.100
  libavformat    57. 84.100 / 57. 84.100
  libavdevice    57. 11.100 / 57. 11.100
  libavfilter     6.108.100 /  6.108.100
  libswscale      4.  9.100 /  4.  9.100
  libswresample   2. 10.100 /  2. 10.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

Here is my idea:

  1. complied ffmpeg with nvidia video sdk : https://developer.nvidia.com/ffmpeg or use docker image https://hub.docker.com/r/nightseas/ffmpeg/
  2. modified the ffmpeg_reader.py in moviepy

moviepy/video/io/ffmpeg_reader.py line89-95

    cmd = ([get_setting("FFMPEG_BINARY")] + i_arg +
           ['-loglevel', 'error',
            '-f', 'image2pipe',
            '-vf', 'scale=%d:%d' % tuple(self.size),
            '-sws_flags', self.resize_algo,
            "-pix_fmt", self.pix_fmt,
            '-vcodec', 'rawvideo', '-'])

I guess the cmd is made up of multiple parameters, so I modified as the following

    cmd = ([get_setting("FFMPEG_BINARY")] + i_arg +
           ['-loglevel', 'error',
            '-f', 'image2pipe',
            '-vf', 'scale=%d:%d' % tuple(self.size),
            '-sws_flags', self.resize_algo,
            "-pix_fmt", self.pix_fmt,
            '-vcodec', 'h264_nvenc',
            '-preset', 'default'])
            #'-vcodec', 'rawvideo', '-'])

BUT, I got :

 MoviePy error: failed to read the first frame of "
                           "video file test.mp4. That might mean that the file is "
                           "corrupted. That may also mean that you are using "
                           "a deprecated version of FFMPEG. On Ubuntu/Debian "
                           "for instance the version in the repos is deprecated. "
                           "Please update to a recent version from the website."

check the file 'moviepy/video/io/ffmpeg_reader.py line 135-140

        if not hasattr(self, 'lastread'):
            raise IOError(("MoviePy error: failed to read the first frame of "
                           "video file %s. That might mean that the file is "
                           "corrupted. That may also mean that you are using "
                           "a deprecated version of FFMPEG. On Ubuntu/Debian "
                           "for instance the version in the repos is deprecated. "
                           "Please update to a recent version from the website.")%(
                            self.filename))

maybe not hasattr(self, 'lastread') is the problem.

Is there another way to solve this problem?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

6reactions
AaronNBrockcommented, Sep 30, 2018

What ended up happening with this?

3reactions
DavidM42commented, Jun 17, 2019

I’m also interested if anyone found a way to enable ffmpeg gpu acceleration in moviepy?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using FFmpeg with NVIDIA GPU Hardware Acceleration
This document explains ways to accelerate video encoding, decoding and end-to-end transcoding on NVIDIA GPUs through FFmpeg which uses APIs ...
Read more >
FFmpeg 4 with NVIDIA Encoding and Decoding support - TalOrg
It support many video and audio formats and can use hardware acceleration, with for example NVIDIA GPUs.
Read more >
FFmpeg Lands NVIDIA NVENC AV1 Encoding Support
FFmpeg Lands NVIDIA NVENC AV1 Encoding Support ... NVENC AV1 support for enjoying GPU-accelerated AV1 video encoding with GeForce RTX 40 ...
Read more >
HWAccelIntro – FFmpeg
Feature support varies – for more complex codecs with many ... NVENC and NVDEC are NVIDIA's hardware-accelerated encoding and decoding APIs.
Read more >
Best settings for FFMpeg with NVENC
Output: Encoder h264_nvenc [NVIDIA NVENC H.264 encoder]: General capabilities: delay Threading capabilities: none Supported pixel formats: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found