简体   繁体   中英

python-vlc - Codec `h264' (H264 - MPEG-4 AVC (part 10)) is not supported

I am trying to play a video using python-vlc in python. It is giving me the following error.

[00007f92180098b0] main decoder error: Codec `h264` (H264 - MPEG-4 AVC (part 10)) is not supported.
[00007f92180098b0] main decoder error: Codec not supported
[00007f92180098b0] main decoder error: VLC could not decode the format "h264" (H264 - MPEG-4 AVC (part 10))

The code to play the video is as follows

import sys
import vlc
import easygui

if(len(sys.argv) < 2):
    print("Please enter file name as command line argument")
    exit(0)

media = vlc.MediaPlayer(sys.argv[1])
media.play()
while True:
    pass

Any help is greatly appreciated. Thank you.

I came across with this problem while using Anaconda virtual environment. I solved it by updating ffmpeg package which was very old. This action also triggered openh264 new library installation.

conda install -c conda-forge ffmpeg

In case of the usual python run, I think installing/updating ffmpeg library will solve it.

Try installing libavcodec by running apt install libavcodec58 and make sure the system VLC player can play the MP4 file without any errors.

If you are running Anaconda Python, some old-version Anaconda Python will cause the H264-codec-not-found error. So try to install the latest version Anaconda or Miniconda, and use its pip to install python-vlc and launch Python VLC.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM