Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moviepy -- At least one output file must be specified #1860

Open
bengabp opened this issue Nov 2, 2022 · 11 comments
Open

moviepy -- At least one output file must be specified #1860

bengabp opened this issue Nov 2, 2022 · 11 comments
Labels
question Questions regarding functionality, usage text Issues dealing with TextClip, SubtitlesClip, or handling of text in general.

Comments

@bengabp
Copy link

bengabp commented Nov 2, 2022

I am trying to apply text overlay on video using moviepy. There are 2 possible sources of the video, either a video upload or a capture . The idea is to handle video input in the frontend then call a python api to process the video and add text using moviepy. I am not using opencv because i also care about the audio since opencv will only load video. When i try this on image uploaded from the users gallery, everything works well . but if i try this with video recorded with Javascript MediaStream browser api, this error shows in moviepy

Traceback (most recent call last):
  File "/home/bengab/.local/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_reader.py", line 286, in ffmpeg_parse_infos
    match = re.findall("([0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9])", line)[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/bengab/Remote Jobs Files/Weperch/moviepy_test/main.py", line 16, in <module>
    g = generate_watermark_video("house","$500","/home/bengab/Remote Jobs Files/Weperch/Watermark Video/upload_videos_dir/aea7d48358ed4ef99ceea98a46b1f1a7.webm","pvid.mp4")
  File "/home/bengab/Remote Jobs Files/Weperch/moviepy_test/main.py", line 5, in generate_watermark_video
    with VideoFileClip(original_video_path) as video_clip:
  File "/home/bengab/.local/lib/python3.10/site-packages/moviepy/video/io/VideoFileClip.py", line 88, in __init__
    self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
  File "/home/bengab/.local/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
  File "/home/bengab/.local/lib/python3.10/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 /home/bengab/Remote Jobs Files/Weperch/Watermark Video/upload_videos_dir/aea7d48358ed4ef99ceea98a46b1f1a7.webm.
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
Input #0, matroska,webm, from '/home/bengab/Remote Jobs Files/Weperch/Watermark Video/upload_videos_dir/aea7d48358ed4ef99ceea98a46b1f1a7.webm':
  Metadata:
    encoder         : Chrome
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
    Stream #0:1(eng): Video: vp8, yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 250 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      alpha_mode      : 1
At least one output file must be specified

I have tried using ffmpeg from command line to convert video using os.system but when I do this, the audio does not synchronize with the video.

@bengabp bengabp added the question Questions regarding functionality, usage label Nov 2, 2022
@keikoro keikoro added the text Issues dealing with TextClip, SubtitlesClip, or handling of text in general. label Nov 29, 2022
@JIACHENG135
Copy link

Have the same issue.

@camoverride
Copy link

same issue...

@Abdur-rahmaanJ
Copy link

Same

@TheNewCivilian
Copy link

In my case, this originated from an incomplete .webm file. Copying the file manually with ffmpeg -i video_original.webm -vcodec copy -acodec copy video_copy.webm and loading this copy into moviepy

@Mankvis
Copy link

Mankvis commented Aug 13, 2023

I also encountered the same problem today. The previous code has not been changed. At least one output file must be specified appeared today. Do you have a solution?

@Dennis-Delgado
Copy link

Dennis-Delgado commented Jan 19, 2024

I have had the same issue, and I fixed it by updating something; however, I installed moviepy on another computer, and now I am getting this same error and can not fix it this time. Will post an answer once I get it.

@Juniorduc44
Copy link

Well guess no one came up with a solution yet. Poop. Ill have to troubleshoot another day then.

@OsaAjani
Copy link
Collaborator

Thank you for your contributions and for reporting issues in this repository. With the release of v2, which introduces significant changes to the codebase and API, we’ve reviewed the backlog of open PRs and issues. Due to the length of the backlog and the likelihood that many of these are either fixed or no longer applicable, we’ve made the decision to close all previous PRs and issues.

If you believe that any of these are still relevant to the current version or if you'd like to reopen a related discussion, please feel free to create a new issue or pull request, referencing the old one.

Thank you for your understanding and continued support!

@zubu007
Copy link

zubu007 commented Jan 15, 2025

I am still facing this even in v2. I am using moviepy directly in the python script and not on the command line. What is the solution?

@OsaAjani OsaAjani reopened this Jan 15, 2025
@OsaAjani
Copy link
Collaborator

Could you please provide one of the video triggering the error and some basic code to reproduce the error with the video ?

@zubu007
Copy link

zubu007 commented Jan 15, 2025

Yes I think a screenshot would be enough. I am getting this error by trying to do the most basic thing which is load the video as variable using VideoFileClip thing. Using moviepy==2.0.0

Screenshot 2025-01-15 at 20 57 03

The entire error is below

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/project/auto-subtitle-generator/.conda/lib/python3.11/site-packages/moviepy/video/io/ffmpeg_reader.py:825, in ffmpeg_parse_infos(filename, check_duration, fps_source, decode_file, print_infos)
    818 try:
    819     return FFmpegInfosParser(
    820         infos,
    821         filename,
    822         fps_source=fps_source,
    823         check_duration=check_duration,
    824         decode_file=decode_file,
--> 825     ).parse()
    826 except Exception as exc:

File ~/project/auto-subtitle-generator/.conda/lib/python3.11/site-packages/moviepy/video/io/ffmpeg_reader.py:503, in FFmpegInfosParser.parse(self)
    501     self._current_stream["metadata"] = {}
--> 503 field, value = self.parse_metadata_field_value(line)
    505 if self._current_stream["stream_type"] == "video":

File ~/project/auto-subtitle-generator/.conda/lib/python3.11/site-packages/moviepy/video/io/ffmpeg_reader.py:734, in FFmpegInfosParser.parse_metadata_field_value(self, line)
    731 """Returns a tuple with a metadata field-value pair given a ffmpeg `-i`
    732 command output line.
    733 """
--> 734 raw_field, raw_value = line.split(":", 1)
    735 return (raw_field.strip(" "), raw_value.strip(" "))

ValueError: not enough values to unpack (expected 2, got 1)

The above exception was the direct cause of the following exception:

OSError                                   Traceback (most recent call last)
Cell In[3], line 1
----> 1 video = VideoFileClip("IMG_8040.mov")

File ~/project/auto-subtitle-generator/.conda/lib/python3.11/site-packages/decorator.py:232, in decorate.<locals>.fun(*args, **kw)
    230 if not kwsyntax:
    231     args, kw = fix(args, kw, sig)
--> 232 return caller(func, *(extras + args), **kw)

File ~/project/auto-subtitle-generator/.conda/lib/python3.11/site-packages/moviepy/decorators.py:94, in preprocess_args.<locals>.wrapper(func, *args, **kwargs)
     86 new_args = [
     87     fun(arg) if (name in varnames) and (arg is not None) else arg
     88     for (arg, name) in zip(args, names)
     89 ]
     90 new_kwargs = {
     91     kwarg: fun(value) if kwarg in varnames else value
     92     for (kwarg, value) in kwargs.items()
     93 }
---> 94 return func(*new_args, **new_kwargs)

File ~/project/auto-subtitle-generator/.conda/lib/python3.11/site-packages/moviepy/video/io/VideoFileClip.py:108, in VideoFileClip.__init__(self, filename, decode_file, has_mask, audio, audio_buffersize, target_resolution, resize_algorithm, audio_fps, audio_nbytes, fps_source, pixel_format, is_mask)
    106 if not pixel_format:
    107     pixel_format = "rgba" if has_mask else "rgb24"
--> 108 self.reader = FFMPEG_VideoReader(
    109     filename,
    110     decode_file=decode_file,
    111     pixel_format=pixel_format,
    112     target_resolution=target_resolution,
    113     resize_algo=resize_algorithm,
    114     fps_source=fps_source,
    115 )
    117 # Make some of the reader's attributes accessible from the clip
    118 self.duration = self.reader.duration

File ~/project/auto-subtitle-generator/.conda/lib/python3.11/site-packages/moviepy/video/io/ffmpeg_reader.py:31, in FFMPEG_VideoReader.__init__(self, filename, decode_file, print_infos, bufsize, pixel_format, check_duration, target_resolution, resize_algo, fps_source)
     29 self.filename = filename
     30 self.proc = None
---> 31 infos = ffmpeg_parse_infos(
     32     filename,
     33     check_duration=check_duration,
     34     fps_source=fps_source,
     35     decode_file=decode_file,
     36     print_infos=print_infos,
     37 )
     38 self.fps = infos["video_fps"]
     39 self.size = infos["video_size"]

File ~/project/auto-subtitle-generator/.conda/lib/python3.11/site-packages/moviepy/video/io/ffmpeg_reader.py:831, in ffmpeg_parse_infos(filename, check_duration, fps_source, decode_file, print_infos)
    829 elif not os.path.exists(filename):
    830     raise FileNotFoundError(f"'{filename}' not found")
--> 831 raise IOError(f"Error passing `ffmpeg -i` command output:\n\n{infos}") from exc

OSError: Error passing `ffmpeg -i` command output:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'IMG_8040.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2025-01-15T15:38:42.000000Z
    com.apple.quicktime.location.accuracy.horizontal: 13.431160
    com.apple.quicktime.full-frame-rate-playback-intent: 0
    com.apple.quicktime.cinematic-video: 
    com.apple.quicktime.location.ISO6709: +49.6007+011.0390+287.683/
    com.apple.quicktime.make: Apple
    com.apple.quicktime.model: iPhone 14 Pro
    com.apple.quicktime.software: 18.1.1
    com.apple.quicktime.creationdate: 2025-01-15T16:09:57+0100
  Duration: 00:00:21.20, start: 0.000000, bitrate: 16318 kb/s
  Stream #0:0[0x1](und): Video: hevc (Main 10) (hvc1 / 0x31637668), yuv420p10le(pc, bt2020nc/bt2020/arib-std-b67), 1920x1080, 16131 kb/s, 30 fps, 30 tbr, 600 tbn (default)
      Metadata:
        creation_time   : 2025-01-15T15:38:42.000000Z
        handler_name    : Core Media Video
        vendor_id       : [0][0][0][0]
        encoder         : HEVC
      Side data:
        DOVI configuration record: version: 1.0, profile: 8, level: 4, rpu flag: 1, el flag: 0, bl flag: 1, compatibility id: 4, compression: 0
        displaymatrix: rotation of -90.00 degrees
        Ambient Viewing Environment, ambient_illuminance=314.000000, ambient_light_x=0.312700, ambient_light_y=0.329000
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 174 kb/s (default)
      Metadata:
        creation_time   : 2025-01-15T15:38:42.000000Z
        handler_name    : Core Media Audio
        vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](und): Data: none (mebx / 0x7862656D), 2 kb/s (default)
      Metadata:
        creation_time   : 2025-01-15T15:38:42.000000Z
        handler_name    : Core Media Metadata
  Stream #0:3[0x4](und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
      Metadata:
        creation_time   : 2025-01-15T15:38:42.000000Z
        handler_name    : Core Media Metadata
At least one output file must be specified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions regarding functionality, usage text Issues dealing with TextClip, SubtitlesClip, or handling of text in general.
Projects
None yet
Development

No branches or pull requests