[FFmpeg-user] Problems with ffmpeg

Torsten Kaiser info at linux-rebellen.de
Wed Oct 11 03:12:30 EEST 2023


On 10.10.23 22:26, Alper Kücük via ffmpeg-user wrote:[...]

> recover_mp4.exe good.mp4 result.h264 result.wav

I'm not familiar with recover_mp4.exe

Please verify that your result.h264 really contains a flawless video 
track of equal duration as the audio track result.wav

You can do this by trying to play the results audio and video with 
ffplay, probing with ffprobe gives you the estimated duration of video 
and audio

> ffmpeg.exe -r 60000/1001 -i result.h264 -i result.wav -c:v copy -c:a 
> copy result.mov
As you describe your end result, your video track might contain too few 
or even no video data. In this case your audio would get transcoded 
completely, while the video output keeps playing the last frame of the 
video track. This seems to be the default of ffmpeg. Encountered this 
myself with shorter audio than video while post-editing a master.mp4. In 
my usecase audio went out of sync, leaving tiny audio gaps at the ends 
of all 10-second-clips.

At least for the Linux-version ffmpeg/ffplay/ffprobe doesn't require a 
file extension for input files, since it probes the input-file anyway in 
order to activate a compatible demuxer.

Your -r 60000/1001 results in about 60fps.  Since you copy both video 
and audio this might as well be ignored by ffmpeg.

To repair buggy videos I use two passes, one for video and for audio.

ffmpeg -an -i buggy.mp4 buggy-video.avi

ffmpeg -vn -i buggy.mp4 buggy-video.wav

Rumor has it, that both AVI and WAV are lossless formats. And this way 
ffmpeg salvages all that is left from buggy.mp4

Now you can examine both video and audio separately with ffplay and ffprobe

As described above, different durations result in a desynchronized video 
when using -c:copy for both video and audio

In this case you might want to stretch the shorter track to the duration 
of the longer one. Or squeeze the longer one to hurry up.

For audio i recommend the rubberband filter, e.g. something like this: 
-af rubberband=tempo=$TEMPO

For video I found the minterpolate filter the best choice for my needs. 
Korn-Shellscript Snippet following:

MI_MODE="dup"
#MI_MODE="blend"
#MI_MODE="mci"
VSPEED="minterpolate=mi_mode=$MI_MODE:me_mode=bidir:mc_mode=aobmc:me=esa:scd=none:scd_threshold=5.0:vsbmc=1:search_param=32:fps=$FPS/$SPDSTART,setpts=1/$SPDSTART*PTS"

When $SPDSTART and $TEMPO are set to 1, video and audio get rendered 
with their original speed. Slower playback, longer duration. Quicker 
playback, shorter duration.

Note that $FPS is set to the unchanged original FPS of the input video, 
as parsed from the output of ffprobe.




More information about the ffmpeg-user mailing list