imageio / imageio-ffmpeg

FFMPEG wrapper for Python
BSD 2-Clause "Simplified" License
237 stars 52 forks source link

Reading video in local and docker-compose file works fine but in minikube below issue occured #90

Open nikhiltree opened 1 year ago

nikhiltree commented 1 year ago

Problem : based on my understanding ffmpeg-linux64-v4.2.2 needs some of depedancies which is i don't know ffmpeg_reader.py used this ffmpeg-linux64-v4.2.2 for subprocess start more info : link line 257 minikube path : /usr/local/lib/python3.8/site-packages/imageio_ffmpeg/binaries/ffmpeg-linux64-v4.2.2

Expected Behavior

>>> from moviepy.editor import *
>>> clip=VideoFileClip("https://videorenderingbucket.s3.ap-south-1.amazonaws.com/video_file/Pranali_Shukan_Wedding_Invite.mp4_video_2023-06-19_10%3A25%3A13.685572.mp4")
>>> clip
<moviepy.video.io.VideoFileClip.VideoFileClip object at 0x7f175c97ac40>

Actual Behavior

From moviepy. Editor import *
clip=videofileclip("https: //videorenderingbucket. S3. Ap-south-1. Amazonaws. Com/video_file/the+breathtaking+beauty+of+nature+-+hd. Mp4")`
### Logs
traceback (most recent call last):
file "/usr/local/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader. Py", line 285, in ffmpeg_parse_infos
line = [l for l in lines if keyword in l][index]
indexerror: list index out of range

during handling of the above exception, another exception occurred:

traceback (most recent call last):
file "<stdin>", line 1, in <module>
file "/usr/local/lib/python3.8/site-packages/moviepy/video/io/videofileclip. Py", line 88, in __init__
self. Reader = ffmpeg_videoreader(filename, pix_fmt=pix_fmt,
file "/usr/local/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader. Py", line 35, in __init__
infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
file "/usr/local/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader. Py", line 289, in ffmpeg_parse_infos
raise ioerror(("moviepy error: failed to read the duration of file %s. \n"
oserror: moviepy error: failed to read the duration of file https: //videorenderingbucket. S3. Ap-south-1. Amazonaws. Com/video_file/the+breathtaking+beauty+of+nature+-+hd. Mp4.
Here are the file infos returned by ffmpeg:

ffmpeg version 4.2.2-static https: //johnvansickle. Com/ffmpeg/ copyright (c) 2000-2019 the ffmpeg developers
built with gcc 8 (debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100`

Specifications

Requirement.txt

almarklein commented 1 year ago

My first guess is that the OS of the container is not compatible with the binary ffmpeg executable that is shipped with imageio-ffmpeg. The system's ffmpeg is then used, which seems to behave differently. If ffmpeg is not available I would expect a different error, but it could be that the detection in ffmpeg_reader.py let it slip through.

To be honest, this looks to me like a bug in moviepy, since the code wrongfully assumes that the lines object is not empty.

nikhiltree commented 1 year ago

I am using minikube it's running inside docker-container i don't how to make this ffmpeg executable inside docker-container i didn't find any solution since 3 week and my project is hold on now

almarklein commented 1 year ago

What OS are you using in the container? You could try using a recent Ubuntu to see if that works, which would at the least narrow down the problem.

nikhiltree commented 1 year ago

My first guess is that the OS of the container is not compatible with the binary ffmpeg executable that is shipped with imageio-ffmpeg. The system's ffmpeg is then used, which seems to behave differently. If ffmpeg is not available I would expect a different error, but it could be that the detection in ffmpeg_reader.py let it slip through.

To be honest, this looks to me like a bug in moviepy, since the code wrongfully assumes that the lines object is not empty.

I don't think there is bug in moviepy if there is bug in moviepy then it will not work in docker-compose i thinks issue is between minikube and ffmpeg executable Os : Ubuntu 20.04 LTS

nikhiltree commented 1 year ago
from __future__ import division

import logging
import os
import re
import subprocess as sp
import warnings

import numpy as np

from moviepy.compat import DEVNULL, PY3
from moviepy.config import get_setting  # ffmpeg, ffmpeg.exe, etc...
from moviepy.tools import cvsecs

is_GIF = False
cmd = [get_setting("FFMPEG_BINARY"), "-i", "https://videorenderingbucket.s3.ap-south-1.amazonaws.com/video_file/The+Breathtaking+Beauty+of+Nature+-+HD.mp4"]
if is_GIF:
  cmd += ["-f", "null", "/dev/null"]

popen_params = {"bufsize": 10**5,"stdout": sp.PIPE,"stderr": sp.PIPE,"stdin": DEVNULL}
if os.name == "nt":
    popen_params["creationflags"] = 0x08000000

proc = sp.Popen(cmd, **popen_params)
(output, error) = proc.communicate()
infos = error.decode('utf8')
print(infos)

this code is working fine in host machine as well as docker-compose but issue with minikube

almarklein commented 1 year ago

I don't think there is bug in moviepy if there is bug in moviepy then it will not work in docker-compose i thinks issue is between minikube and ffmpeg executable

You're right, it's more subtle ... I agree there's likely a problem in ffmpeg not working or producing different output than expected with minicube. But moviepy has not taken this case into account - which results in an error that hides the real cause.

this code is working fine in host machine as well as docker-compose but issue with minikube

Can you also make it print cmd and show what it prints in minicube?

nikhiltree commented 1 year ago

cmd : ["/usr/local/lib/python3.8/site-packages/imageio_ffmpeg/binaries/ffmpeg-linux64-v4.2.2"," -i", "https://videorenderingbucket.s3.ap-south-1.amazonaws.com/video_file/The+Breathtaking+Beauty+of+Nature+-+HD.mp4"]

almarklein commented 1 year ago

And what does print(infos) show?

liuyhwangyh commented 1 year ago

ubuntu22.04 ffmpeg version 4.2.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 段错误 (核心已转储)