>Have you tried adding (silent) audio to video 2 and trying your join operation again? You could use `anullsrc':
This is what I am trying to do, but wasn't able to accomplish the first step which is adding a silent audio to my video using anullsrc. I came up with the following command after doing some search and also based on Michael's command sample: Ffmpeg -i video.mp4 -f lavfi -i anullsrc=r=48000:cl=2 -c:v copy -c:a aac -shortest output.mp4 At the end of the console output I get the following: >>> Press [q] to stop, [?] for help [aac @ 0000023281941140] Unsupported channel layout "1 channels (FR)" [aac @ 0000023281941140] Qavg: nan Error initializing output stream 0:1 -- Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed! <<< Here is some additional data: 1 - The file I need to concatenate to already has audio and below are the parameters. As I need to create the silent audio with similar parameters, I used the same sample rate and number of channels (48000 and 2) [STREAM] index=1 codec_name=aac codec_long_name=AAC (Advanced Audio Coding) profile=LC codec_type=audio codec_tag_string=mp4a codec_tag=0x6134706d sample_fmt=fltp sample_rate=48000 channels=2 channel_layout=stereo bits_per_sample=0 id=N/A r_frame_rate=0/0 avg_frame_rate=0/0 time_base=1/48000 start_pts=0 start_time=0.000000 duration_ts=624000 duration=13.000000 bit_rate=129137 max_bit_rate=N/A bits_per_raw_sample=N/A nb_frames=611 nb_read_frames=N/A nb_read_packets=N/A DISPOSITION:default=1 DISPOSITION:dub=0 DISPOSITION:original=0 DISPOSITION:comment=0 DISPOSITION:lyrics=0 DISPOSITION:karaoke=0 DISPOSITION:forced=0 DISPOSITION:hearing_impaired=0 DISPOSITION:visual_impaired=0 DISPOSITION:clean_effects=0 DISPOSITION:attached_pic=0 DISPOSITION:timed_thumbnails=0 TAG:language=und TAG:handler_name=SoundHandler TAG:vendor_id=[0][0][0][0] [/STREAM] The full console output of adding the audio is here: ffmpeg -i trans_final_4_radial.mp4 -f lavfi -i anullsrc=r=48000:cl=2 -c:v copy -c:a aac -shortest trans_final_4_radial_WithAudio.mp4 ffmpeg version 2021-03-14-git-1d61a31497-essentials_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers built with gcc 10.2.0 (Rev6, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband libavutil 56. 68.100 / 56. 68.100 libavcodec 58.131.100 / 58.131.100 libavformat 58. 74.100 / 58. 74.100 libavdevice 58. 12.100 / 58. 12.100 libavfilter 7.109.100 / 7.109.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'trans_final_4_radial.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.74.100 Duration: 00:00:04.10, start: 0.000000, bitrate: 301 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 293 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Input #1, lavfi, from 'anullsrc=r=48000:cl=2': Duration: N/A, start: 0.000000, bitrate: 384 kb/s Stream #1:0: Audio: pcm_u8, 48000 Hz, 1 channels (FR), u8, 384 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #1:0 -> #0:1 (pcm_u8 (native) -> aac (native)) Press [q] to stop, [?] for help [aac @ 0000023281941140] Unsupported channel layout "1 channels (FR)" [aac @ 0000023281941140] Qavg: nan Error initializing output stream 0:1 -- Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed! -----Original Message----- From: ffmpeg-user <ffmpeg-user-boun...@ffmpeg.org> On Behalf Of Rob Hallam Sent: Tuesday, June 22, 2021 1:31 PM To: FFmpeg user questions <ffmpeg-user@ffmpeg.org> Subject: Re: [FFmpeg-user] Audio out of sync after video concatenation On Tue, 22 Jun 2021 at 11:15, <ibur...@compuscience.com> wrote: > Video 1 - 13 seconds with audio > Video 2 - 4 seconds without audio (I generated this video using xfade > transition Video 3 - 4 seconds with audio > > If I concatenate video 1 and 3 everything works fine; audio > synchronization is correct from start to end. However, when I > concatenate all 3 of them, the audio from video 3 starts playing a > little bit before the end of video 2. As video 3 is a person talking, > you clearly see that the audio doesn't match the mouth movements. > > Why is this happening and how can I fix it? Have you tried adding (silent) audio to video 2 and trying your join operation again? You could use `anullsrc': https://ffmpeg.org/ffmpeg-filters.html#anullsrc or make silent audio elsewhere and add to video 2 separately. You may also want to look up the `-shortest' option if you don't know of it already. Cheers, Rob _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".