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

How to avoid RIFE from Re-encoding output to MPEG codec #71

Open
Hikari2w2 opened this issue Jun 7, 2024 · 1 comment
Open

How to avoid RIFE from Re-encoding output to MPEG codec #71

Hikari2w2 opened this issue Jun 7, 2024 · 1 comment

Comments

@Hikari2w2
Copy link

Hikari2w2 commented Jun 7, 2024

First off, I apologize for my poor English. I'm not very fluent, and I hope my question isn't too naive. I don't know much about how RIFE really works.

Let's say I want to interpolate a video that uses the H.264 codec. After the interpolation process, the video ends up using the MPEG-4 codec. This not only changes the codec from H.264 but also affects the bitrate and quality. I was wondering if it's possible to choose a different codec instead of MPEG, as well as adjust output parameters like CRF, etc. (By the way, I'm using Practical RIFE on Google Colab.)

This is the command I'm currently using

!python3 inference_video.py --multi=3 --video=video.mp4

@Hikari2w2 Hikari2w2 changed the title How to avoid RIFE AI Re-encode videos to MPEG4 codec avoid RIFE from Reencoding output to MPEG4 codec Jun 7, 2024
@Hikari2w2 Hikari2w2 changed the title avoid RIFE from Reencoding output to MPEG4 codec How to avoid RIFE from Re-encoding output to MPEG4 codec Jun 7, 2024
@Hikari2w2 Hikari2w2 changed the title How to avoid RIFE from Re-encoding output to MPEG4 codec How to avoid RIFE from Re-encoding output to MPEG codec Jun 8, 2024
@AIManifest
Copy link

Hey my friend,

Just based on reading the documentation, it would appear that inference_video.py uses cv2 to write the frames to the video. There are a few things I've seen: cv2.VideoWriter_fourcc(*'avc1'), this would need to be installed using apt instead of pip --> pip uninstall opencv-python sudo apt install build-essential cmake git python3-dev python3-numpy \ libavcodec-dev libavformat-dev libswscale-dev \ libgstreamer-plugins-base1.0-dev \ libgstreamer1.0-dev libgtk-3-dev \ libpng-dev libjpeg-dev libopenexr-dev libtiff-dev libwebp-dev \ libopencv-dev x264 libx264-dev libssl-dev ffmpeg python -m pip install --no-binary opencv-python opencv-python

From here you can change the line 116 in inference_video.py from fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v') to cv2.VideoWriter_fourcc(*'avc1'). As for crf options, I haven't found a solid solution for that yet, but this is a good start and hopefully is helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants