NgSekLong / musicxml2video

Convert an MusicXML score to play by your selected video sample
Apache License 2.0
4 stars 1 forks source link

Bug when trying out #1

Open soundnotation opened 4 years ago

soundnotation commented 4 years ago

Hello there,

We are searching for a tool to build a video with notes from XML and stumbled upon your repo.

I just tried out your code but I get some bugs when running python main.py:

('Processing Audio: Start: ', 102000, 'Duration:', 1760)
...
('Processing Audio: Start: ', 0, 'Duration:', 286)
Process patching segmented audio finished
('Processing Audio: Segment: ', 0, 'Segment Duration:', 4000)
...
('Processing Audio: Segment: ', 14, 'Segment Duration:', 4000)
('Processing Audio: Segment: ', 15, 'Segment Duration:', 4000)
('Processing Audio: Segment: ', 16, 'Segment Duration:', 4000)
('Processing Audio: Segment: ', 25, 'Segment Duration:', 4000)
Audio process total duration: 0:00:08.873864
Traceback (most recent call last):
  File "main.py", line 19, in <module>
    video_process(notes, start_timestamp)
  File "/home/ubuntu/musicxml2video/video_process.py", line 141, in video_process
    all_video_path = p.map(segment_video_mutliprocess, all_segment_video_infos)
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 253, in map
    return self.map_async(func, iterable, chunksize).get()
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 572, in get
    raise self._value
AttributeError: 'module' object has no attribute 'input'

Note that I have installed ffmpeg and pydub using:

pip install ffmpeg # -> Successfully installed ffmpeg-1.4
pip install pydub # -> Successfully installed pydub-0.23.1

ffmpeg is already installed separately:

ffmpeg -version
# => ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
# => built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
# => configuration: ...

I'm trying from an EC2 instance with Ubuntu 18.04 LTS.

No output is being written anywhere, checked with git status:

On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   audio_process.pyc
        modified:   config.pyc
        modified:   musicxml_processor.pyc
        modified:   video_process.pyc

no changes added to commit (use "git add" and/or "git commit -a")

If this is useful, I tried also using pip3 and python3, i.e.

pip3 install ffmpeg
pip3 install pydub

so running python3 main.py gives the following:

Processing Audio: Start:  102000 Duration: 1760
...
Processing Audio: Start:  0 Duration: 286
Process patching segmented audio finished
Processing Audio: Segment:  25 Segment Duration: 4000
Processing Audio: Segment:  16 Segment Duration: 4000
Processing Audio: Segment:  15 Segment Duration: 4000
Processing Audio: Segment:  14 Segment Duration: 4000
...
Processing Audio: Segment:  2 Segment Duration: 4000
Processing Audio: Segment:  1 Segment Duration: 4000
Processing Audio: Segment:  0 Segment Duration: 4000
Audio process total duration: 0:00:09.302450
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/usr/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/home/ubuntu/musicxml2video/video_process.py", line 19, in segment_video_mutliprocess
    segment_video = ffmpeg.input(segment_video_input_file)
AttributeError: module 'ffmpeg' has no attribute 'input' """

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

Traceback (most recent call last):
  File "main.py", line 19, in <module>
    video_process(notes, start_timestamp)
  File "/home/ubuntu/musicxml2video/video_process.py", line 141, in video_process
    all_video_path = p.map(segment_video_mutliprocess, all_segment_video_infos)
  File "/usr/lib/python3.7/multiprocessing/pool.py", line 268, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/usr/lib/python3.7/multiprocessing/pool.py", line 657, in get
    raise self._value
AttributeError: module 'ffmpeg' has no attribute 'input' Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/usr/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/home/ubuntu/musicxml2video/video_process.py", line 19, in segment_video_mutliprocess
    segment_video = ffmpeg.input(segment_video_input_file)
AttributeError: module 'ffmpeg' has no attribute 'input' """

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

Traceback (most recent call last):
  File "main.py", line 19, in <module>
    video_process(notes, start_timestamp)
  File "/home/ubuntu/musicxml2video/video_process.py", line 141, in video_process
    all_video_path = p.map(segment_video_mutliprocess, all_segment_video_infos)
  File "/usr/lib/python3.7/multiprocessing/pool.py", line 268, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/usr/lib/python3.7/multiprocessing/pool.py", line 657, in get
    raise self._value
AttributeError: module 'ffmpeg' has no attribute 'input'
NgSekLong commented 4 years ago

Hello,

Hopefully I am not too late to response!

Thank you very much for your interest in the project and the issue, I have looked into it and seems like the issue is that: I forget to reorganize the input folder before uploading to github. Hence making your above crash.

I have just update the repository with the bug fixed, please try pulling again and executing python main.py again.

FYI, my PC setup is basically the same as you, so after the fix you probably would be able to use it, FYI my setup is:

Thank you!!

soundnotation commented 4 years ago

Hello,

after git pulling and running python main.py I still get the same error.

NgSekLong commented 4 years ago

I look into it again, the problem happens in my README.md giving wrong instruction, sorry about that:

Prevoius README.md command (Wrong): pip install ffmpeg pydub

You should use this instead (Note the ffmpeg-python): pip install ffmpeg-python pydub

For your case, you would probably need to do the following:

  1. pip uninstall ffmpeg
  2. pip install ffmpeg-python Just so you can make sure the right library is being used

See if the above fix it, thanks!

P.s. I also added the ability to run the program using docker, if you still have problem with the current script, you can try using the docker procedure.

soundnotation commented 4 years ago

Hello again,

I tried your project again with python main.py and the processes (python and multiple ffmpeg) were still running after 1 hour! I had to stop them using pkill. No output file was generated. I can't check the stack trace right now because meanwhile the connection dropped, but how can such things be possible?

NgSekLong commented 4 years ago

I did stumble across similar bug last time, what I did to fix was git clone again and run it.

I have tried git clone and python main.py in a completely different directory and it still works for me,

see If the above fixed it, thanks!

soundnotation commented 4 years ago

I cloned the repo into another directory, and still the problem persists. At least the python process is hanging for more than an hour. Here are the last log lines:

Video process segment: 0 done, total duration: 0:00:34.277536
Video process segment: 3 done, total duration: 0:01:14.943729
Video process segment: 1 done, total duration: 0:01:57.281143
Video process segment: 4 done, total duration: 0:02:30.586024
Video process segment: 2 done, total duration: 0:02:30.648181
Video process segment: 5 done, total duration: 0:02:45.252746
Video process segment: 6 done, total duration: 0:01:37.197188
Video process segment: 7 done, total duration: 0:01:23.527680
Video process segment: 9 done, total duration: 0:01:52.107917
Video process segment: 8 done, total duration: 0:01:07.128646
Video process segment: 10 done, total duration: 0:01:50.687454
Video process segment: 12 done, total duration: 0:01:25.662201
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 392, in _handle_results
    task = get()
TypeError: __init__() takes exactly 4 arguments (2 given)

Video process segment: 11 done, total duration: 0:04:53.520438
Video process segment: 15 done, total duration: 0:01:08.026143
Video process segment: 16 done, total duration: 0:00:22.891225
Video process segment: 25 done, total duration: 0:00:16.201146
NgSekLong commented 4 years ago

I have no idea why this happen... This happen normally for me.

You sure you got the right library? Thanks.

soundnotation commented 4 years ago

Yes, I have the right libraries