Giter Site home page Giter Site logo

Comments (12)

sytelus avatar sytelus commented on August 26, 2024 7

I got this error with Ubuntu 18.04 while using Monitor class in OpenAI Gym. You need correct versions of ffmpeg and x264 encoder. To get them, I used following and it worked:

conda install x264=='1!152.20180717' ffmpeg=4.0.2 -c conda-forge

from gym.

mimoralea avatar mimoralea commented on August 26, 2024 4

In 2019, the solution by @sytelus down 2 comments is what worked for me. He has exact versions which work well! Leaving this comment for context only

For those using conda (and my future self,) I solved a similar issue by:

  1. Installing x264:
    conda install x264

  2. Upgrading ffmpeg:
    conda install ffmpeg==4.0

from gym.

DanielTakeshi avatar DanielTakeshi commented on August 26, 2024 1

This error also happens on OS X 10.11.6 (El Capitan). In that case, the solution is to reinstall ffmpeg with the -x265 (not -x264...) library:

brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265

(From the ffmpeg docs, though I had to get rid of --with-libass to get this to work.)

from gym.

gdb avatar gdb commented on August 26, 2024

I'm slightly surprised that there isn't a nicer error message for you, but does using the xvfb command recommended here help: https://gist.github.com/joschu/e42a050b1eb5cfbb1fdc667c3450467a?

I'll re-open the other issue so we can chat there about readability. Sorry, think we missed that the first time around!

from gym.

tlbtlbtlb avatar tlbtlbtlb commented on August 26, 2024

Most likely ffmpeg is failing. Can you try this:

dd if=/dev/zero bs=750000 count=50 | ffmpeg -nostats -loglevel error -y -r 60 -f rawvideo -s:v 500x500 -pix_fmt 'rgb24' -i /dev/stdin -vcodec libx264 -pix_fmt yuv420p /tmp/foo.mp4

and see if it's able to generate a /tmp/foo.mp4 video file (of all black pixels). If not, the error message should give a clue.

from gym.

justheuristic avatar justheuristic commented on August 26, 2024

Thanks a lot. It said id doesn't know about libx264.

dd if=/dev/zero bs=750000 count=50 | ffmpeg -nostats -loglevel error -y -r 60 -f rawvideo -s:v 500x500 -pix_fmt 'rgb24' -i /dev/stdin -vcodec libx264 -pix_fmt yuv420p /tmp/foo.mp4
Unknown encoder 'libx264'

This did not help (still getting the same error)

sudo apt-get update
sudo apt-get install libav-tools
sudo apt-get install libavcodec-extra-53

However, doing the same thing with avconv worked

dd if=/dev/zero bs=750000 count=50 | avconv -nostats -loglevel error -y -r 60 -f rawvideo -s:v 500x500 -pix_fmt 'rgb24' -i /dev/stdin -vcodec libx264 -pix_fmt yuv420p /tmp/foo.mp4
50+0 records in
50+0 records out
37500000 bytes (38 MB) copied, 0,141512 s, 265 MB/s

Yet the error in the game monitoring stays the same.
It may actually be due to weirdness of that server, so if you have no idea why such behaviour may happen and no one can reproduce it, i believe it's worth simply closing the thing.

from gym.

tlbtlbtlb avatar tlbtlbtlb commented on August 26, 2024

The video_recorder logic is

        if distutils.spawn.find_executable('ffmpeg') is not None:
            self.backend = 'ffmpeg'
        elif distutils.spawn.find_executable('avconv') is not None:
            self.backend = 'avconv'

Try deleting the ffmpeg executable so it will use avconv instead. Use:
sudo apt-get remove ffmpeg

I suspect we should prefer avconv over ffmpeg, since it is more predictable.

from gym.

justheuristic avatar justheuristic commented on August 26, 2024

Thank you, that finally worked 👍

from gym.

avivrosenberg avatar avivrosenberg commented on August 26, 2024

In case this helps someone, this issue got resolved for me by specifying ffmpeg>4.1 in my environment.yml file (using conda). It installed 4.1.3. My gym version is 0.12.1.

Before this I had ffmpeg 4.0 which didn't work.

from gym.

hagh avatar hagh commented on August 26, 2024

I get the same error with Ray RLlib when setting the video recording on.
I tried both methods, i.e. conda install x264=='1!152.20180717' ffmpeg=4.0.2 -c conda-forge (and also the newer versions), as well as installing x265 instead of x264.
Both method worked for me in the sense that I don't get the error any more. However, many of the recorded videos are corrupted and cannot be played. I am wondering if people may have experienced the same problem? any suggestion to fix this later issue?

EDIT: Source of my problem should be something else. I tested these in a container and all worked fine.

from gym.

avivrosenberg avatar avivrosenberg commented on August 26, 2024

I encountered this issue again after updating packages.
It works with: ffmpeg=4.2.2, x264=1!157.20191217, gym=0.17.3.
The problem occurred with ffmpeg=4.3 and disappeared when downgrading to 4.2.2.

from gym.

nhanph avatar nhanph commented on August 26, 2024

I got this error with Ubuntu 18.04 while using Monitor class in OpenAI Gym. You need correct versions of ffmpeg and x264 encoder. To get them, I used following and it worked:

conda install x264=='1!152.20180717' ffmpeg=4.0.2 -c conda-forge

This works for gym==0.18.3 python==3.7.10 torch=1.7.1 with Ubuntu 20.04.

from gym.

Related Issues (20)

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.