S Andreason wrote:
1. frame# as n, or at playback and pressing the keys for back to beginning, does not start until 0.566 for frame # 0 because (I think) the source video has an audio offset. This makes problem#1 affect all future edits.

2. How can I override the timing, and just copy frame by frame ignoring the timestamps of [1]?


Perhaps if I supply sample files... here is a sample source video from the camera in question.
https://www.seahorsecorral.org/videos/tests/20190628_163959_driving-WCurlewLkRd-S_30sec_FHDw.MOV
https://www.seahorsecorral.org/videos/tests/redwave-500x400.gif

I have also recompiled latest git with no change.

Step 1. clip desired video. I want to start at 22.0 seconds, (where the blue sign is visible on left) but the nearest I-frame appears to be at 21.933 sec according to mpv.
$ ffprobe -show_frames says 21.566 for nearest pict_type=I

Giving a -ss 22 or -ss 21.97 results in a 0.566 gap in video, where the audio is not cut at the same place as the video, so it was not cut at the I-frame.

-ss 21.933 results in a 0.114 sec gap.
-ss 21.566 results in a 0.497 sec gap.
-ss 21.96 results in 0.092 sec gap, which seems to be the best I can get. Too many of these concat together later will result in audio sync problems, so there is a good reason to ask how to improve the cut here.

$ ffmpeg -i 20190628_163959_driving-WCurlewLkRd-S_30sec_FHDw.MOV -ss 21.96 -t 6 -c copy 20190628_163959_driving-WCurlewLkRd-S_30sec_FHDw_c21.96t6.MOV ffmpeg version N-96573-g73aab08d9d Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --prefix=/usr/local --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libx264 --enable-libopenjpeg --enable-libfreetype --disable-doc --disable-htmlpages --disable-podpages --enable-shared --enable-libvpx --extra-cflags=-I/usr/include --extra-ldflags=-L/usr/lib/i386-linux-gnu --enable-libass --enable-libtesseract --extra-cflags=-msse2 --enable-openssl --enable-nonfree
  libavutil      56. 38.100 / 56. 36.101
  libavcodec     58. 67.100 / 58. 64.101
  libavformat    58. 37.100 / 58. 35.101
  libavdevice    58.  9.103 / 58.  9.101
  libavfilter     7. 72.100 /  7. 68.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1569540] st: 0 edit list: 1 Missing key frame while searching for timestamp: 2000 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x1569540] st: 0 edit list 1 Cannot find an index entry before timestamp: 2000. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20190628_163959_driving-WCurlewLkRd-S_30sec_FHDw.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2019-06-28T16:39:59.000000Z
    playback_requirements: QuickTime 6.0 or greater
    playback_requirements-eng: QuickTime 6.0 or greater
  Duration: 00:00:29.50, start: 0.000000, bitrate: 15212 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 15078 kb/s, 30 fps, 30 tbr, 60k tbn, 120k tbc (default)
    Metadata:
      creation_time   : 2019-06-28T16:39:59.000000Z
      handler_name    : Video Handler
      encoder         : iCatch AVCC
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      creation_time   : 2019-06-28T16:39:59.000000Z
      handler_name    : Audio Handler
Output #0, mov, to '20190628_163959_driving-WCurlewLkRd-S_30sec_FHDw_c21.96t6.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    playback_requirements-eng: QuickTime 6.0 or greater
    playback_requirements: QuickTime 6.0 or greater
    encoder         : Lavf58.35.101
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, q=2-31, 15078 kb/s, 30 fps, 30 tbr, 60k tbn, 60k tbc (default)
    Metadata:
      creation_time   : 2019-06-28T16:39:59.000000Z
      handler_name    : Video Handler
      encoder         : iCatch AVCC
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      creation_time   : 2019-06-28T16:39:59.000000Z
      handler_name    : Audio Handler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  180 fps=0.0 q=-1.0 Lsize=   10873kB time=00:00:05.98 bitrate=14878.9kbits/s speed=74.4x video:10772kB audio:94kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.068655%

Step 2 add gif and show n
$ ffmpeg -i 20190628_163959_driving-WCurlewLkRd-S_30sec_FHDw_c21.96t6.MOV -ignore_loop 0 -i redwave-500x400.gif -filter_complex "[0]scale=1280x720,drawtext='fontfile=/usr/share/fonts/TrueType/lsansd.ttf:text=%{n}:x=(w-tw)/2:y=h-(2*lh):fontcolor=white:box=1:boxcolor=0x00000099'[0st],[0st][1]overlay=x=(570+(n*6)):y=10:enable=between(n\,30\,120)" -s 1280x720 -c:v h264 -b:v 4700k -r 30 -t 6 CurlewLk_c216t6-red_30-120-720e.mov ffmpeg version N-96573-g73aab08d9d Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --prefix=/usr/local --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libx264 --enable-libopenjpeg --enable-libfreetype --disable-doc --disable-htmlpages --disable-podpages --enable-shared --enable-libvpx --extra-cflags=-I/usr/include --extra-ldflags=-L/usr/lib/i386-linux-gnu --enable-libass --enable-libtesseract --extra-cflags=-msse2 --enable-openssl --enable-nonfree
  libavutil      56. 38.100 / 56. 36.101
  libavcodec     58. 67.100 / 58. 64.101
  libavformat    58. 37.100 / 58. 35.101
  libavdevice    58.  9.103 / 58.  9.101
  libavfilter     7. 72.100 /  7. 68.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20190628_163959_driving-WCurlewLkRd-S_30sec_FHDw_c21.96t6.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    encoder         : Lavf58.35.101
  Duration: 00:00:06.00, start: 0.013000, bitrate: 14845 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 14707 kb/s, 30 fps, 30 tbr, 60k tbn, 120k tbc (default)
    Metadata:
      handler_name    : Video Handler
      encoder         : iCatch AVCC
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : Audio Handler
Input #1, gif, from 'redwave-500x400.gif':
  Duration: 00:00:01.35, start: 0.000000, bitrate: 2635 kb/s
    Stream #1:0: Video: gif, bgra, 500x400, 34 fps, 100 tbr, 100 tbn, 100 tbc
Stream mapping:
  Stream #0:0 (h264) -> scale (graph 0)
  Stream #1:0 (gif) -> overlay:overlay (graph 0)
  overlay (graph 0) -> Stream #0:0 (libx264)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x1ac8d40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX LZCNT BMI1 SlowPshufb
[libx264 @ 0x1ac8d40] profile High, level 3.1
[libx264 @ 0x1ac8d40] 264 - core 148 r2748 97eaef2 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - 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=6 lookahead_threads=1 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=abr mbtree=1 bitrate=4700 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mov, to 'CurlewLk_c216t6-red_30-120-720e.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    encoder         : Lavf58.35.101
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720, q=-1--1, 4700 kb/s, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc58.67.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/4700000 buffer size: 0 vbv_delay: N/A
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : Audio Handler
      encoder         : Lavc58.67.100 aac
frame=  180 fps=9.2 q=-1.0 Lsize=    2921kB time=00:00:05.99 bitrate=3991.5kbits/s dup=3 drop=0 speed=0.308x video:2819kB audio:94kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.270207%
[libx264 @ 0x1ac8d40] frame I:1     Avg QP:16.49  size:136468
[libx264 @ 0x1ac8d40] frame P:45    Avg QP:23.47  size: 27882
[libx264 @ 0x1ac8d40] frame B:134   Avg QP:26.75  size: 11154
[libx264 @ 0x1ac8d40] consecutive B-frames:  0.6%  0.0%  1.7% 97.8%
[libx264 @ 0x1ac8d40] mb I  I16..4:  6.2% 58.4% 35.4%
[libx264 @ 0x1ac8d40] mb P  I16..4:  1.3%  6.8%  2.1%  P16..4: 44.2% 16.8% 10.0%  0.0%  0.0%    skip:18.8% [libx264 @ 0x1ac8d40] mb B  I16..4:  0.1%  0.9%  0.4%  B16..8: 41.1%  6.5%  2.4%  direct: 2.1%  skip:46.5%  L0:43.7% L1:48.2% BI: 8.1%
[libx264 @ 0x1ac8d40] final ratefactor: 20.29
[libx264 @ 0x1ac8d40] 8x8 transform intra:64.4% inter:68.0%
[libx264 @ 0x1ac8d40] coded y,uvDC,uvAC intra: 82.4% 80.6% 41.9% inter: 17.5% 21.8% 3.4%
[libx264 @ 0x1ac8d40] i16 v,h,dc,p:  3% 48%  4% 45%
[libx264 @ 0x1ac8d40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 22% 17% 6%  8%  7%  9%  6% 14% [libx264 @ 0x1ac8d40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 26% 15% 7%  9%  7% 10%  6%  9%
[libx264 @ 0x1ac8d40] i8c dc,h,v,p: 50% 31% 10%  9%
[libx264 @ 0x1ac8d40] Weighted P-Frames: Y:6.7% UV:4.4%
[libx264 @ 0x1ac8d40] ref P L0: 53.1% 16.7% 21.6%  8.2%  0.3%
[libx264 @ 0x1ac8d40] ref B L0: 83.3% 13.4%  3.3%
[libx264 @ 0x1ac8d40] ref B L1: 91.1%  8.9%
[libx264 @ 0x1ac8d40] kb/s:3847.67
[aac @ 0x1ab7600] Qavg: 222.272

Notice frame 1 overlay doesn't start at 0.0  I really need frame 0 to be 0 for all later calculations to work without adding offsets.

Notice the gif frame starts at 24 or 0.900 sec.
Notice the last gif frame is 105 at 3.600 sec.
I can work around this limitation (unless you have a solution) by recalculating the start and stop points for n. x/30/0.03=n

I can't duplicate problem 3 on such a short file, so let's focus on the above questions.
Thank you, Stewart

_______________________________________________
ffmpeg-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to