jdhao / jdhao.github.io

My personal blog: https://jdhao.github.io/
24 stars 6 forks source link

2021/11/04/pyav-video-processing/ #30

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

PyAV for video processing - jdhao's blog

ffmpeg is an excellent tool for video processing. However, using ffmpeg directly inside Python is not convenient enough. Previously, I have been using ffmpeg-python, which is a thin wrapper around the ffmpeg command line executable.

https://jdhao.github.io/2021/11/04/pyav-video-processing/

escorciav commented 2 years ago

Thanks for sharing! Do you mind to give more details about why ffmpeg-python offers "slow speed in performance-critical applications"? Telling us about your use-case and how you used it would suffix 😊

I almost bought it due to the async call in the TF example.

jdhao commented 2 years ago

Thanks for sharing! Do you mind to give more details about why ffmpeg-python offers "slow speed in performance-critical applications"? Telling us about your use-case and how you used it would suffix 😊

I almost bought it due to the async call in the TF example.

Initially, we use ffmpeg-python to extract frames from videos at a specific rate. We have observed a higher frame extraction speed when using pyav. So we switch to use pyav instead.

cfleiner commented 6 months ago

Thank you for the short introduction. It is still helpful a few years later. Note that your snippet has three typing errors.

if not os.path.exist(out_dir): # exist -> exists

frame.to_image.save("frame-{idx}.jpg") # to_image -> to_image() / "fram..." -> f"fram..."

For the to_image method to work, I also had to install the Pillow package.