saifhassan / Wav2Lip-HD

High-Fidelity Lip-Syncing with Wav2Lip and Real-ESRGAN
Other
320 stars 75 forks source link

Option to continue encoding even when some frames do not have a face (enhancement) #18

Open Barnacules opened 10 months ago

Barnacules commented 10 months ago

I would like to request a switch that allows the program to continue even with videos that have some frames where a face isn't detected. It should just continue with the .WAV playback as usual when nobody is shown on screen and then sync the lips back as they jump cut back from another scene. This would save form having to cut up videos into multiple little chunks to run them and then re-edit them back together.

Current Behavior If the passed in video file to interfence_realersgan_video.py contains any frames without a face in them, it will fail to continue.

Wanted Behavior Continue with a warning to the user that some frames a face wasn't' detected and the audio will just continue to play during those segments without any lip syncing until a face is detected again.

Implementation You could add a switch --ignore-missing-faces to allow this behavior while preserving the existing behavior of just failing outright if no faces are detected in a single frame in the target video

I think this change should be somewhat easy to make since you would just have to add another parameter to the queue, you're putting the extracted frames into indicating if it should be fed to the lip sync algorithm or if it should just be placed in the final encoded video untouched. If things like ESRGAN are being utilized to upscale the video or smooth thing then just apply those to the frames without doing the face detection or altering the image with the new lip positions.