[FFmpeg-user] ffmpeg output audio out of sync
Yonatan Bendahan
yonatan.bendahan at gmail.com
Tue May 24 13:01:08 EEST 2022
Hi all,
I'm trying to filter a video file in multiple locations (taking out clips
from a video), with most video files it works perfectly, but sometimes the
audio is out of sync (after a second).
This is the command I'm executing:
ffmpeg -i video.mp4 -vf
"select='between(t,3.71,4)+between(t,6.05,6.4)+between(t,6.85,7.2)+between(t,8.51,8.8)+between(t,9.18,9.88)+between(t,10.76,17.96)+between(t,19.85,20.95)+between(t,23.97,26.75)+between(t,34.67,38.16)+between(t,41.46,42.2)',
setpts=N/FRAME_RATE/TB" -af
"aselect='between(t,3.71,4)+between(t,6.05,6.4)+between(t,6.85,7.2)+between(t,8.51,8.8)+between(t,9.18,9.88)+between(t,10.76,17.96)+between(t,19.85,20.95)+between(t,23.97,26.75)+between(t,34.67,38.16)+between(t,41.46,42.2)',
asetpts=N/SR/TB" out.mp4
and this the output log:
ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.1.6 (clang-1316.0.21.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/5.0.1 --enable-shared --
enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags=
--enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray
--enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --
enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --
enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf
--enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --
enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma
--enable-libfontconfig
--enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex
--enable-libsoxr
--enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --
enable-videotoolbox
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
'/Users/yonatanbd/Downloads/video.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2022-04-25T12:33:51.000000Z
com.apple.quicktime.location.accuracy.horizontal: 33.932088
com.apple.quicktime.location.ISO6709: +31.7629+035.2037+779.616/
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone 13 Pro
com.apple.quicktime.software: 15.3.1
com.apple.quicktime.creationdate: 2022-04-25T15:33:51+0300
Duration: 00:00:42.99, start: 0.000000, bitrate: 45343 kb/s
Stream #0:0[0x1](und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv,
bt709), 3840x2160, 45057 kb/s, 44.41 fps, 60 tbr, 600 tbn (default)
Metadata:
creation_time : 2022-04-25T12:33:51.000000Z
handler_name : Core Media Video
vendor_id : [0][0][0][0]
encoder : HEVC
Side data:
displaymatrix: rotation of -180.00 degrees
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 183 kb/s (default)
Metadata:
creation_time : 2022-04-25T12:33:51.000000Z
handler_name : Core Media Audio
vendor_id : [0][0][0][0]
Stream #0:2[0x3](und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
Metadata:
creation_time : 2022-04-25T12:33:51.000000Z
handler_name : Core Media Metadata
Stream #0:3[0x4](und): Data: none (mebx / 0x7862656D), 22 kb/s (default)
Metadata:
creation_time : 2022-04-25T12:33:51.000000Z
handler_name : Core Media Metadata
Stream #0:4[0x5](und): Data: none (mebx / 0x7862656D), 58 kb/s (default)
Metadata:
creation_time : 2022-04-25T12:33:51.000000Z
handler_name : Core Media Metadata
Stream mapping:
Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7fc8c0f113c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fc8c0f113c0] profile High, level 5.2, 4:2:0, 8-bit
[libx264 @ 0x7fc8c0f113c0] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC
codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options:
cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=
1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0
deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=24
lookahead_threads=4 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0
direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40
intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0
qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/Users/yonatanbd/Downloads/video Wed May 25 2022 -
Gling.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
com.apple.quicktime.creationdate: 2022-04-25T15:33:51+0300
com.apple.quicktime.location.accuracy.horizontal: 33.932088
com.apple.quicktime.location.ISO6709: +31.7629+035.2037+779.616/
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone 13 Pro
com.apple.quicktime.software: 15.3.1
encoder : Lavf59.16.100
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709,
progressive), 3840x2160, q=2-31, 60 fps, 15360 tbn (default)
Metadata:
creation_time : 2022-04-25T12:33:51.000000Z
handler_name : Core Media Video
vendor_id : [0][0][0][0]
encoder : Lavc59.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
displaymatrix: rotation of -0.00 degrees
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo,
fltp, 128 kb/s (default)
Metadata:
creation_time : 2022-04-25T12:33:51.000000Z
handler_name : Core Media Audio
vendor_id : [0][0][0][0]
encoder : Lavc59.18.100 aac
frame= 825 fps= 12 q=-1.0 Lsize= 74578kB time=00:00:17.29 bitrate=35317.
0kbits/s speed=0.252x
video:74278kB audio:274kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.034519%
[libx264 @ 0x7fc8c0f113c0] frame I:14 Avg QP:25.14 size:333236
[libx264 @ 0x7fc8c0f113c0] frame P:225 Avg QP:27.97 size:130425
[libx264 @ 0x7fc8c0f113c0] frame B:586 Avg QP:28.70 size: 71756
[libx264 @ 0x7fc8c0f113c0] consecutive B-frames: 4.7% 1.2% 1.5% 92.6%
[libx264 @ 0x7fc8c0f113c0] mb I I16..4: 4.6% 87.5% 8.0%
[libx264 @ 0x7fc8c0f113c0] mb P I16..4: 0.7% 11.3% 0.3% P16..4: 42.8% 8.8%
6.4% 0.0% 0.0% skip:29.6%
[libx264 @ 0x7fc8c0f113c0] mb B I16..4: 0.1% 2.8% 0.0% B16..8: 50.0% 2.8%
0.5% direct: 2.1% skip:41.7% L0:49.1% L1:49.4% BI: 1.5%
[libx264 @ 0x7fc8c0f113c0] 8x8 transform intra:91.9% inter:85.1%
[libx264 @ 0x7fc8c0f113c0] coded y,uvDC,uvAC intra: 76.4% 22.2% 0.7% inter:
22.4% 6.0% 0.0%
[libx264 @ 0x7fc8c0f113c0] i16 v,h,dc,p: 28% 11% 17% 44%
[libx264 @ 0x7fc8c0f113c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 6% 35% 7% 7%
10% 5% 9% 5%
[libx264 @ 0x7fc8c0f113c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 8% 15% 9% 10%
12% 5% 9% 3%
[libx264 @ 0x7fc8c0f113c0] i8c dc,h,v,p: 77% 9% 13% 1%
[libx264 @ 0x7fc8c0f113c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fc8c0f113c0] ref P L0: 46.0% 13.9% 27.8% 12.3%
[libx264 @ 0x7fc8c0f113c0] ref B L0: 73.7% 19.4% 6.9%
[libx264 @ 0x7fc8c0f113c0] ref B L1: 89.9% 10.1%
[libx264 @ 0x7fc8c0f113c0] kb/s:44253.14
[aac @ 0x7fc8c0f12b40] Qavg: 406.889
I tried -async and -vsync without success.
This command is running on a user machine, so I can't anticipate the video
variation in advance, so I'm looking for a generic solution I can apply in
my program
Thanks
Yonatan
More information about the ffmpeg-user
mailing list