[FFmpeg-user] [FFMPEG]Mux audio video - delay issue

Antonio Rolo antonio.rolo at yahoo.fr
Sat Oct 14 11:36:53 EEST 2017


I need some support with ffmpeg. I would like to add the audio of video1.mp4 to video2.avi. (video1 and video2 are the same tv show with 2 different language but not the same quality video2 > video1)
The issue is that video1 and video2 don't have the same duration. I think it's due to the framerate.

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video2.mp4':
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.63.100
  Duration: 00:45:02.12, start: 0.000000, bitrate: 1105 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 974 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 126 kb/s (default)
      handler_name    : SoundHandler

Input #0, avi, from 'video2.avi':
    encoder         : Lavf54.63.104
  Duration: 00:45:48.78, start: 0.000000, bitrate: 2215 kb/s
    Stream #0:0: Video: h264 (Main) (H264 / 0x34363248), yuv420p(progressive), 720x480 [SAR 1:1 DAR 3:2], 1945 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 59.94 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 256 kb/s

I tried the following command lines but the result is OK the first 20 minutes and then there is a delay (like 3sec) between the sound and the video :

1st test :
ffmpeg -y -i video2.avi -r 25 -s 720x480 -c:v libx264 -b:v 3M -strict -2 -movflags faststart video2_a.avi (to have the same framerate as video1.mp4)
ffmpeg -i video2_a.avi -filter:v "setpts=0.9966789667896679*PTS" -qscale:v 1 video2_b.avi (to have the same duration as video1.mp4)
ffmpeg -i video1.mp4 -q:a 0 -map a video1.wav (extract sound of video1.mp4)
ffmpeg -i video2_b.avi -i video1.wav -c:v copy -map 0:v:0 -map 1:a:0 -shortest video2_c.avi (delay issue)

2nd test :
Before adding the audio I tried to change the bite/rate, freq
ffmpeg -i video1.mp4 -b:a 256k -ar 48000 -q:a 0 -map a video1.wav (delay issue)

3rd test :
I tried to perform some tests with raw video data and teh results are even worse

By advance, thanks for your help

|  | Garanti sans virus. www.avast.com  |

More information about the ffmpeg-user mailing list