0

I'm trying to trim a video and draw text on it. Although the command below "works" (source), there's a 2-3 second delay at the beginning of the clip. Specifically, for example, if I want to trim "00:05:27"-"00:05:37", the resulting clip seems to lag from "00:05:27"-"00:05:29", then trim from "00:05:29"-00:05:37".

When using -c copy, the lag/delay is gone, so I'm quite sure it's caused by my -vf command below.

Full Command (minus paths):

ffmpeg -ss 00:05:27 -to 00:05:37 -i "..." -vf "drawtext=fontfile='OpenSans-VariableFont_wdth,wght.ttf':text='Clip 1 (00\:05\:27-00\:05\:37)':fontcolor=0xF
F0000:fontsize=40:box=1:boxcolor=black@0.5:boxborderw=15:x=w-tw-15:y=h-th-15" -c:v libx264 -c:a copy "..."

Full Output:

ffmpeg version 4.4.1-0ubuntu1~20.04.sav0 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --prefix=/usr --extra-version='0ubuntu1~20.04.sav0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libdav1d --enable-libzimg --enable-crystalhd --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr --extra-version='0ubuntu1~20.04.sav0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libdav1d --enable-libzimg --enable-crystalhd --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-libglslang --enable-liblensfun --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libsmbclient --enable-libtesseract --enable-libvo_amrwbenc --enable-vulkan --enable-libsvtav1 --enable-libsmbclient
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5649184d6fc0] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/wilsonchan/Giratina/Projects/BadmintonAI/AceOne-BadmintonAI/Production/crop_videos/Temp/[Temp] 20211201 - HSBC BWF World Tour Finals 2021 _ Lakshya Sen (IND) vs Kento Momota (JPN) _ Group A/[Temp] 20211201 - HSBC BWF World Tour Finals 2021 _ Lakshya Sen (IND) vs Kento Momota (JPN) _ Group A.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : HSBC BWF World Tour Finals 2021 | Lakshya Sen (IND) vs Kento Momota (JPN) | Group A
    artist          : BWF TV
    date            : 20211201
    encoder         : Lavf58.45.100
    comment         : https://www.youtube.com/watch?v=MUf-wrbUNEg
    description     : HSBC BWF World Tour Finals 2021
                    : Men's Singles | Group A
                    : Lakshya Sen (IND) vs Kento Momota (JPN)
                    : 
                    : #BWFWorldTour #BaliFinals2021
                    : 
                    : Disclaimer: If you are not able to watch the live stream of matches on BWF TV due to it being geo-blocked in your country that is because the rights for this tournament has been sold to a broadcaster in your country.
                    : 
                    : Subscribe: http://smarturl.it/BWFsubscribe
                    : 
                    : Download the Badminton4U app: https://badminton4u.sport
                    : 
                    : This live stream is enhanced with SXFI LIVE holographic audio. Put on your headphones for the best experience! For more information, including a special treat for BWF fans, visit https://www.creative.com/bwfsxfi 
                    :  
                    : BWF TV is the official channel of the Badminton World Federation (BWF), where we bring to you live, catch-up and delayed streaming of the big events on the HSBC BWF World Tour, as well as the majors like the TotalEnergies BWF Sudirman Cup Finals, TotalEne
                    : 
                    : Website: http://www.bwfbadminton.org
                    : Twitter: https://twitter.com/bwfmedia 
                    : Facebook: https://www.facebook.com/bwfbadminton 
                    : Instagram: https://www.instagram.com/bwf.official 
                    : Weibo: https://weibo.com/BWFofficial
    synopsis        : HSBC BWF World Tour Finals 2021
                    : Men's Singles | Group A
                    : Lakshya Sen (IND) vs Kento Momota (JPN)
                    : 
                    : #BWFWorldTour #BaliFinals2021
                    : 
                    : Disclaimer: If you are not able to watch the live stream of matches on BWF TV due to it being geo-blocked in your country that is because the rights for this tournament has been sold to a broadcaster in your country.
                    : 
                    : Subscribe: http://smarturl.it/BWFsubscribe
                    : 
                    : Download the Badminton4U app: https://badminton4u.sport
                    : 
                    : This live stream is enhanced with SXFI LIVE holographic audio. Put on your headphones for the best experience! For more information, including a special treat for BWF fans, visit https://www.creative.com/bwfsxfi 
                    :  
                    : BWF TV is the official channel of the Badminton World Federation (BWF), where we bring to you live, catch-up and delayed streaming of the big events on the HSBC BWF World Tour, as well as the majors like the TotalEnergies BWF Sudirman Cup Finals, TotalEne
                    : 
                    : Website: http://www.bwfbadminton.org
                    : Twitter: https://twitter.com/bwfmedia 
                    : Facebook: https://www.facebook.com/bwfbadminton 
                    : Instagram: https://www.instagram.com/bwf.official 
                    : Weibo: https://weibo.com/BWFofficial
  Duration: 00:12:35.04, start: 0.000000, bitrate: 1157 kb/s
  Stream #0:0(eng): Video: vp9 (Profile 0) (vp09 / 0x39307076), yuv420p(tv, bt709), 1920x1080, 1017 kb/s, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 16k tbn, 16k tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1(eng): Audio: opus (Opus / 0x7375704F), 48000 Hz, stereo, fltp, 121 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
  Stream #0:2: Video: png, rgb24(pc), 1280x720, 90k tbr, 90k tbn, 90k tbc (attached pic)
Stream mapping:
  Stream #0:0 -> #0:0 (vp9 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 @ 0x56491855a600] using SAR=1/1
[libx264 @ 0x56491855a600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x56491855a600] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x56491855a600] 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=34 lookahead_threads=5 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, matroska, to '/home/wilsonchan/Giratina/Projects/BadmintonAI/AceOne-BadmintonAI/Production/crop_videos/Temp/[Temp] 20211201 - HSBC BWF World Tour Finals 2021 _ Lakshya Sen (IND) vs Kento Momota (JPN) _ Group A/1. Clips (OG)/1_clip_00-05-27_00-05-37.mkv':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    title           : HSBC BWF World Tour Finals 2021 | Lakshya Sen (IND) vs Kento Momota (JPN) | Group A
    artist          : BWF TV
    date            : 20211201
    synopsis        : HSBC BWF World Tour Finals 2021
                    : Men's Singles | Group A
                    : Lakshya Sen (IND) vs Kento Momota (JPN)
                    : 
                    : #BWFWorldTour #BaliFinals2021
                    : 
                    : Disclaimer: If you are not able to watch the live stream of matches on BWF TV due to it being geo-blocked in your country that is because the rights for this tournament has been sold to a broadcaster in your country.
                    : 
                    : Subscribe: http://smarturl.it/BWFsubscribe
                    : 
                    : Download the Badminton4U app: https://badminton4u.sport
                    : 
                    : This live stream is enhanced with SXFI LIVE holographic audio. Put on your headphones for the best experience! For more information, including a special treat for BWF fans, visit https://www.creative.com/bwfsxfi 
                    :  
                    : BWF TV is the official channel of the Badminton World Federation (BWF), where we bring to you live, catch-up and delayed streaming of the big events on the HSBC BWF World Tour, as well as the majors like the TotalEnergies BWF Sudirman Cup Finals, TotalEne
                    : 
                    : Website: http://www.bwfbadminton.org
                    : Twitter: https://twitter.com/bwfmedia 
                    : Facebook: https://www.facebook.com/bwfbadminton 
                    : Instagram: https://www.instagram.com/bwf.official 
                    : Weibo: https://weibo.com/BWFofficial
    comment         : https://www.youtube.com/watch?v=MUf-wrbUNEg
    description     : HSBC BWF World Tour Finals 2021
                    : Men's Singles | Group A
                    : Lakshya Sen (IND) vs Kento Momota (JPN)
                    : 
                    : #BWFWorldTour #BaliFinals2021
                    : 
                    : Disclaimer: If you are not able to watch the live stream of matches on BWF TV due to it being geo-blocked in your country that is because the rights for this tournament has been sold to a broadcaster in your country.
                    : 
                    : Subscribe: http://smarturl.it/BWFsubscribe
                    : 
                    : Download the Badminton4U app: https://badminton4u.sport
                    : 
                    : This live stream is enhanced with SXFI LIVE holographic audio. Put on your headphones for the best experience! For more information, including a special treat for BWF fans, visit https://www.creative.com/bwfsxfi 
                    :  
                    : BWF TV is the official channel of the Badminton World Federation (BWF), where we bring to you live, catch-up and delayed streaming of the big events on the HSBC BWF World Tour, as well as the majors like the TotalEnergies BWF Sudirman Cup Finals, TotalEne
                    : 
                    : Website: http://www.bwfbadminton.org
                    : Twitter: https://twitter.com/bwfmedia 
                    : Facebook: https://www.facebook.com/bwfbadminton 
                    : Instagram: https://www.instagram.com/bwf.official 
                    : Weibo: https://weibo.com/BWFofficial
    encoder         : Lavf58.76.100
  Stream #0:0(eng): Video: h264 (H264 / 0x34363248), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 1k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc58.134.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
  Stream #0:1(eng): Audio: opus ([255][255][255][255] / 0xFFFFFFFF), 48000 Hz, stereo, fltp, 121 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
frame=  300 fps=278 q=-1.0 Lsize=    2033kB time=00:00:09.98 bitrate=1668.3kbits/s speed=9.26x    
video:1850kB audio:172kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.505417%
[libx264 @ 0x56491855a600] frame I:2     Avg QP:15.83  size:151344
[libx264 @ 0x56491855a600] frame P:81    Avg QP:18.24  size: 12503
[libx264 @ 0x56491855a600] frame B:217   Avg QP:23.46  size:  2666
[libx264 @ 0x56491855a600] consecutive B-frames:  2.7%  2.0%  2.0% 93.3%
[libx264 @ 0x56491855a600] mb I  I16..4: 20.5% 51.8% 27.7%
[libx264 @ 0x56491855a600] mb P  I16..4:  1.5%  4.5%  0.8%  P16..4: 10.8%  2.5%  1.5%  0.0%  0.0%    skip:78.6%
[libx264 @ 0x56491855a600] mb B  I16..4:  0.2%  0.7%  0.1%  B16..8:  7.6%  0.6%  0.2%  direct: 0.3%  skip:90.2%  L0:49.5% L1:46.5% BI: 4.0%
[libx264 @ 0x56491855a600] 8x8 transform intra:64.6% inter:71.8%
[libx264 @ 0x56491855a600] coded y,uvDC,uvAC intra: 33.4% 40.8% 20.5% inter: 2.0% 2.6% 0.2%
[libx264 @ 0x56491855a600] i16 v,h,dc,p: 36% 39%  7% 18%
[libx264 @ 0x56491855a600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 16% 49%  2%  2%  3%  3%  2%  3%
[libx264 @ 0x56491855a600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 30% 13%  5%  7%  7%  6%  6%  5%
[libx264 @ 0x56491855a600] i8c dc,h,v,p: 62% 20% 14%  4%
[libx264 @ 0x56491855a600] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x56491855a600] ref P L0: 71.2%  9.9% 14.1%  4.8%
[libx264 @ 0x56491855a600] ref B L0: 83.7% 14.2%  2.2%
[libx264 @ 0x56491855a600] ref B L1: 93.2%  6.8%
[libx264 @ 0x56491855a600] kb/s:1515.15

I'd really appreciate it if anyone could give me some hints or thoughts on why this is happening. Thank you for reading!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.