google / mediapy

This Python library makes it easy to display images and videos in a notebook.
https://pypi.org/project/mediapy/
Apache License 2.0
389 stars 18 forks source link

Unrecognized option 'qp' #30

Closed JunyaoHu closed 1 year ago

JunyaoHu commented 1 year ago

I run the offifial example code but go wrong.

from mediapy import *
video = moving_circle((100, 100), num_images=10)
show_video(video, fps=10)

I am not sure it is relative to torchvision or ffmpeg

when i dont conda install torchvision, the code can run well. but after i conda install torchvision (and ffmpeg also installed automatedly), mediapy can not run well, so how to solve the problem?

torchvision and ffmpeg version are as follows: image

BrokenPipeError                           Traceback (most recent call last)
File [~/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py:1663](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224e4b552d43562d4c41422d5562756e74753132227d.vscode-resource.vscode-cdn.net//~/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py:1663), in write_video(path, images, **kwargs)
   [1662](file:///home/ubuntu/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py?line=1661) for image in images:
-> [1663](file:///home/ubuntu/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py?line=1662)   writer.add_image(image)

File [~/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py:1572](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224e4b552d43562d4c41422d5562756e74753132227d.vscode-resource.vscode-cdn.net//~/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py:1572), in VideoWriter.add_image(self, image)
   [1571](file:///home/ubuntu/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py?line=1570) assert self._proc.stdin
-> [1572](file:///home/ubuntu/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py?line=1571) if self._proc.stdin.write(data) != len(data):
   [1573](file:///home/ubuntu/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py?line=1572)   self._proc.wait()

BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
Cell In[13], line 2
      1 video = moving_circle((100, 100), num_images=10)
----> 2 show_video(video, fps=10)

File [~/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py:1772](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224e4b552d43562d4c41422d5562756e74753132227d.vscode-resource.vscode-cdn.net//~/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py:1772), in show_video(images, title, **kwargs)
   [1749](file:///home/ubuntu/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py?line=1748) def show_video(
   [1750](file:///home/ubuntu/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py?line=1749)     images: Iterable[_NDArray], *, title: str | None = None, **kwargs: Any
   [1751](file:///home/ubuntu/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py?line=1750) ) -> str | None:
   [1752](file:///home/ubuntu/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py?line=1751)   """Displays a video in the IPython notebook and optionally saves it to a file.
...
   [1587](file:///home/ubuntu/anaconda3/envs/MSPred/lib/python3.9/site-packages/mediapy/__init__.py?line=1586) self._popen = None

RuntimeError: Error writing '/tmp/tmpugt6gx5m/file.mp4': Unrecognized option 'qp'.
Error splitting the argument list: Option not found

and i tried

ffmpeg pkgs/main/linux-64::ffmpeg-4.2.2-h20bf706_0 runs well

but ffmpeg pytorch/linux-64::ffmpeg-4.3-hf484d3e_0 cannot run well

hhoppe commented 1 year ago

This looks related: https://github.com/KuntaiDu/dds/issues/1 The option -qp has been available for years in ffmpeg if the libx264 codec is available. My guess is that the pytorch/...ffmpeg is a custom build that disables the H.264 codec. You can try show_video(video, fps=10, codec='gif') which uses the GIF codec instead.

JunyaoHu commented 1 year ago

thanks!