Real-ESRGAN-ncnn-vulkan icon indicating copy to clipboard operation
Real-ESRGAN-ncnn-vulkan copied to clipboard

Issue with audio sync

Open w2lf opened this issue 2 years ago • 5 comments

I am trying to enhance anime video but the audio does not match the original video. Original video is 1:40 and out video is 1:39, tried -r 24. Same problem. has anyone else noticed this? The audio doesn't sync with the original video. Frames are the same in the tmp_frames folder and out_frames folder. Same happens if I do jpg and at x2 scale. So I think its something with the ffmpeg.

Link to the out video. If you go to description and find the original video. You can then see the audio not sync right. https://www.youtube.com/watch?v=qF2pXR6daUU

Using this commands as in readme, does anyone else run into this problem? Commands for enhancing anime videos:

  1. Use ffmpeg to extract frames from a video (Remember to create the folder tmp_frames ahead) ffmpeg -i onepiece_demo.mp4 -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 tmp_frames/frame%08d.png

  2. Inference with Real-ESRGAN executable file (Remember to create the folder out_frames ahead) ./realesrgan-ncnn-vulkan.exe -i tmp_frames -o out_frames -n realesr-animevideov3 -s 4 -f png

  3. Merge the enhanced frames back into a video ffmpeg -i out_frames/frame%08d.png -i onepiece_demo.mp4 -map 0:v:0 -map 1:a:0 -c:a copy -c:v libx264 -r 23.98 -pix_fmt yuv420p output_w_audio.mp4

w2lf avatar May 12 '22 17:05 w2lf

It seems to me that this case is more about your proficiency with ffmpeg than our application.

NaokiSato102 avatar Jul 18 '22 06:07 NaokiSato102

Check through ffprobe the number of frames in the video after the build, with "-r 23.98" I got less than the original video. The problem was solved by replacing "-r 23.98" with "-framerate 23.98"

M4he8hw4r4 avatar Jan 15 '23 13:01 M4he8hw4r4

Check through ffprobe the number of frames in the video after the build, with "-r 23.98" I got less than the original video. The problem was solved by replacing "-r 23.98" with "-framerate 23.98"

Yes, but at the beginning you must place it

Dark25 avatar Apr 20 '23 21:04 Dark25

For anyone in the future trying to solve this issue. "FFmpeg is dropping frames because the input framerate doesn't match the output framerate". Try this instead it fixed it for me:

ffmpeg -f image2 -framerate 23.98/1 -i out_frames/frame%08d.jpg -i original_video.mp4 -map 0:v:0 -map 1:a:0 -c:a copy -c:v libx264 -r 23.98 output_w_audio.mkv

Also add -map 1:s:0 and change mp4 to mkv to transfer subtitles.

ashsii avatar Jan 21 '24 16:01 ashsii

Not exactly related but how do I use model for video?

mlbrothers avatar Feb 18 '24 15:02 mlbrothers