text:
Audio and video out of sync after hstack/amerge
I am using ffmpeg to combine two videos in one side-by-side. This is a recorded 1:1 video-call (WebRTC); each stream recorded separately by the media server.
I've come up with this command, which fits the needs of our project:
ffmpeg \
  -ss 1054403ms -c:a libopus -i str_CAM_Fs1t_con_CjOpssSpAe.webm \
  -i -c:a libopus str_CAM_GQcn_con_RzVjNmZY6i.webm \
  -filter_complex "[0][1]scale2ref='oh*mdar':'if(lt(main_h,ih),ih,main_h)'[0s][1s]; \
                   [0s][1s]scale2ref='oh*mdar':'if(lt(main_h,ih),ih,main_h)'[1s][0s]; \
                   [0s][1s]hstack=inputs=2:shortest=1,setsar=1[v]; \
                   [0:a][1:a]amix[a]" \
  -map "[v]" -map "[a]" -ac 2 -r 30 -crf 23 out.mp4

The problem
Audio/video gets out of sync significantly in the resulting file, most noticeably on the right-side video. As far as I can tell, the desync is progressive - it's getting obvious in the middle, and by the end of the video it's off by 1-2 seconds. The videos are 50-60 minutes in average.
ffprobe output from source files:
Input #0, matroska,webm, from 'str_CAM_Immw_con_YmU3u1Tcmv.webm':
  Metadata:
    encoder         : GStreamer matroskamux version 1.8.1.1
    creation_time   : 2020-06-01T10:05:48.000000Z
  Duration: 00:44:24.20, start: 0.000000, bitrate: 335 kb/s
    Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 1k tbr, 1k tbn, 1k tbc (default)
    Metadata:
      title           : Video
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Audio

Input #0, matroska,webm, from 'str_CAM_JK8k_con_FMwTtVVBqL.webm':
  Metadata:
    encoder         : GStreamer matroskamux version 1.8.1.1
    creation_time   : 2020-06-01T09:56:15.000000Z
  Duration: 00:53:49.77, start: 0.000000, bitrate: 676 kb/s
    Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 30 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      title           : Video
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Audio

What I've tried

pre-converting source files separately to .mp4. Audio stays in sync in both files after this step, but out of sync after hstack
[0:a][1:a]amerge,aresample=async=1000[a] instead of amix (in fact, amerge was my first approach, but I found amix doing the same with the shorter syntax)
-vsync 0 instead of constant frame rate
ffmpeg -i source.mp4 -time_base 1/30 -c copy source1.mp4 (source.mp4 is the converted separately file from Step 1)
ffmpeg -i source.webm -c copy -map 0 -fflags +shortest -max_interleave_delta 0 source1.webm

Now, after the last command I get 'DURATION' in the metadata, and it looks like audio and video tracks lengths don't match:
Input #0, matroska,webm, from 'ed.webm':
  Metadata:
    ENCODER         : Lavf58.44.100
  Duration: 00:53:49.77, start: 0.000000, bitrate: 671 kb/s
    Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      title           : Video
      DURATION        : 00:53:49.732000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Audio
      DURATION        : 00:53:49.766000000

Honestly, I don't know where to go from this point, my (very little) understanding about video encoding has come to a brick wall, and I'm unable to get any new results in Google.
Please help me understand what's happening and what to do.
Update
debug output from the command:
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'.
Reading option '-ss' ... matched as option 'ss' (set the start time offset) with argument '85526ms'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'libopus'.
Reading option '-i' ... matched as input url with argument './str_CAM_N0PW_con_Gz4hFc86ts.webm'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'libopus'.
Reading option '-i' ... matched as input url with argument './str_CAM_GPjV_con_NxaIMlsISO.webm'.
Reading option '-filter_complex' ... matched as option 'filter_complex' (create a complex filtergraph) with argument '[1][0]scale2ref='oh*mdar':'if(lt(main_h,ih),ih,main_h)'[0s][1s];[0s][1s]scale2ref='oh*mdar':'if(lt(main_h,ih),ih,main_h)'[1s][0s];[1s][0s]hstack=inputs=2:shortest=1,setsar=1[v];[0][1]amerge,aresample=async=1[a]'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '[v]'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '[a]'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '30'.
Reading option '-crf' ... matched as AVOption 'crf' with argument '23'.
Reading option '-ac' ... matched as option 'ac' (set number of audio channels) with argument '2'.
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '300s'.
Reading option './out.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option v (set logging level) with argument debug.
Applying option hide_banner (do not show program banner) with argument 1.
Applying option filter_complex (create a complex filtergraph) with argument [1][0]scale2ref='oh*mdar':'if(lt(main_h,ih),ih,main_h)'[0s][1s];[0s][1s]scale2ref='oh*mdar':'if(lt(main_h,ih),ih,main_h)'[1s][0s];[1s][0s]hstack=inputs=2:shortest=1,setsar=1[v];[0][1]amerge,aresample=async=1[a].
Successfully parsed a group of options.
Parsing a group of options: input url ./str_CAM_N0PW_con_Gz4hFc86ts.webm.
Applying option ss (set the start time offset) with argument 85526ms.
Applying option c:a (codec name) with argument libopus.
Successfully parsed a group of options.
Opening an input file: ./str_CAM_N0PW_con_Gz4hFc86ts.webm.
[NULL @ 0x7fffc338fbc0] Opening './str_CAM_N0PW_con_Gz4hFc86ts.webm' for reading
[file @ 0x7fffc3390680] Setting default whitelist 'file,crypto,data'
[matroska,webm @ 0x7fffc338fbc0] Format matroska,webm probed with size=2048 and score=100
st:0 removing common factor 1000000 from timebase
st:1 removing common factor 1000000 from timebase
[matroska,webm @ 0x7fffc338fbc0] Before avformat_find_stream_info() pos: 473 bytes read:32768 seeks:0 nb_streams:2
[matroska,webm @ 0x7fffc338fbc0] All info found
[matroska,webm @ 0x7fffc338fbc0] rfps: 34.000000 0.019089
[matroska,webm @ 0x7fffc338fbc0] After avformat_find_stream_info() pos: 44966 bytes read:65536 seeks:0 frames:100
Input #0, matroska,webm, from './str_CAM_N0PW_con_Gz4hFc86ts.webm':
  Metadata:
    encoder         : GStreamer matroskamux version 1.8.1.1
    creation_time   : 2020-06-13T14:02:03.000000Z
  Duration: 00:55:22.57, start: 0.000000, bitrate: 1034 kb/s
    Stream #0:0(eng), 41, 1/1000: Video: vp8, 1 reference frame, yuv420p(progressive), 640x480, 0/1, SAR 1:1 DAR 4:3, 1k tbr, 1k tbn, 1k tbc (default)
    Metadata:
      title           : Video
    Stream #0:1(eng), 59, 1/1000: Audio: opus, 48000 Hz, stereo, s16 (default)
    Metadata:
      title           : Audio
Successfully opened the file.
Parsing a group of options: input url ./str_CAM_GPjV_con_NxaIMlsISO.webm.
Applying option c:a (codec name) with argument libopus.
Successfully parsed a group of options.
Opening an input file: ./str_CAM_GPjV_con_NxaIMlsISO.webm.
[NULL @ 0x7fffc33c5f80] Opening './str_CAM_GPjV_con_NxaIMlsISO.webm' for reading
[file @ 0x7fffc33bb2c0] Setting default whitelist 'file,crypto,data'
[matroska,webm @ 0x7fffc33c5f80] Format matroska,webm probed with size=2048 and score=100
st:0 removing common factor 1000000 from timebase
st:1 removing common factor 1000000 from timebase
[matroska,webm @ 0x7fffc33c5f80] Before avformat_find_stream_info() pos: 473 bytes read:32768 seeks:0 nb_streams:2
[matroska,webm @ 0x7fffc33c5f80] All info found
[matroska,webm @ 0x7fffc33c5f80] After avformat_find_stream_info() pos: 52734 bytes read:65536 seeks:0 frames:114
Input #1, matroska,webm, from './str_CAM_GPjV_con_NxaIMlsISO.webm':
  Metadata:
    encoder         : GStreamer matroskamux version 1.8.1.1
    creation_time   : 2020-06-13T14:03:29.000000Z
  Duration: 00:53:59.94, start: 0.000000, bitrate: 1018 kb/s
    Stream #1:0(eng), 41, 1/1000: Video: vp8, 1 reference frame, yuv420p(progressive), 640x480, 0/1, SAR 1:1 DAR 4:3, 1k tbr, 1k tbn, 1k tbc (default)
    Metadata:
      title           : Video
    Stream #1:1(eng), 73, 1/1000: Audio: opus, 48000 Hz, stereo, s16 (default)
    Metadata:
      title           : Audio
Successfully opened the file.
[Parsed_scale2ref_0 @ 0x7fffc33b2d40] Setting 'w' to value 'oh*mdar'
[Parsed_scale2ref_0 @ 0x7fffc33b2d40] Setting 'h' to value 'if(lt(main_h,ih),ih,main_h)'
[Parsed_scale2ref_0 @ 0x7fffc33b2d40] w:oh*mdar h:if(lt(main_h,ih),ih,main_h) flags:'bilinear' interl:0
[Parsed_scale2ref_1 @ 0x7fffc33c19c0] Setting 'w' to value 'oh*mdar'
[Parsed_scale2ref_1 @ 0x7fffc33c19c0] Setting 'h' to value 'if(lt(main_h,ih),ih,main_h)'
[Parsed_scale2ref_1 @ 0x7fffc33c19c0] w:oh*mdar h:if(lt(main_h,ih),ih,main_h) flags:'bilinear' interl:0
[Parsed_hstack_2 @ 0x7fffc33e5840] Setting 'inputs' to value '2'
[Parsed_hstack_2 @ 0x7fffc33e5840] Setting 'shortest' to value '1'
[Parsed_setsar_3 @ 0x7fffc33caac0] Setting 'sar' to value '1'
[Parsed_aresample_5 @ 0x7fffc33cc000] Setting 'async' to value '1'
Parsing a group of options: output url ./out.mp4.
Applying option map (set input stream mapping) with argument [v].
Applying option map (set input stream mapping) with argument [a].
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 30.
Applying option ac (set number of audio channels) with argument 2.
Applying option t (record or transcode "duration" seconds of audio/video) with argument 300s.
Successfully parsed a group of options.
Opening an output file: ./out.mp4.
[file @ 0x7fffc33cb300] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
detected 4 logical cores
Stream mapping:
  Stream #0:0 (vp8) -> scale2ref:ref
  Stream #0:1 (libopus) -> amerge:in0
  Stream #1:0 (vp8) -> scale2ref:default
  Stream #1:1 (libopus) -> amerge:in1
  setsar -> Stream #0:0 (libx264)
  aresample -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 1 times
[vp8 @ 0x7fffc33fb440] Format yuv420p chosen by get_format().
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 2 times
[vp8 @ 0x7fffc33fe580] Format yuv420p chosen by get_format().
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 3 times
[vp8 @ 0x7fffc34016c0] Format yuv420p chosen by get_format().
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 2 times
[vp8 @ 0x7fffc3404800] Format yuv420p chosen by get_format().
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 2 times
[vp8 @ 0x7fffc3407940] Format yuv420p chosen by get_format().
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[vp8 @ 0x7fffc33a5740] Format yuv420p chosen by get_format().
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 2 times
[vp8 @ 0x7fffc33a7d80] Format yuv420p chosen by get_format().
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 2 times
[vp8 @ 0x7fffc33e9a00] Format yuv420p chosen by get_format().
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 1 times
[vp8 @ 0x7fffc33ec800] Format yuv420p chosen by get_format().
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 1 times
[vp8 @ 0x7fffc33ef800] Format yuv420p chosen by get_format().
[Parsed_scale2ref_0 @ 0x7fffc3473a00] Setting 'w' to value 'oh*mdar'
[Parsed_scale2ref_0 @ 0x7fffc3473a00] Setting 'h' to value 'if(lt(main_h,ih),ih,main_h)'
[Parsed_scale2ref_0 @ 0x7fffc3473a00] w:oh*mdar h:if(lt(main_h,ih),ih,main_h) flags:'bilinear' interl:0
[Parsed_scale2ref_1 @ 0x7fffc3474080] Setting 'w' to value 'oh*mdar'
[Parsed_scale2ref_1 @ 0x7fffc3474080] Setting 'h' to value 'if(lt(main_h,ih),ih,main_h)'
[Parsed_scale2ref_1 @ 0x7fffc3474080] w:oh*mdar h:if(lt(main_h,ih),ih,main_h) flags:'bilinear' interl:0
[Parsed_hstack_2 @ 0x7fffc34762c0] Setting 'inputs' to value '2'
[Parsed_hstack_2 @ 0x7fffc34762c0] Setting 'shortest' to value '1'
[Parsed_setsar_3 @ 0x7fffc3477480] Setting 'sar' to value '1'
[Parsed_aresample_5 @ 0x7fffc3478a40] Setting 'async' to value '1'
[graph 0 input from stream 1:0 @ 0x7fffc3477a40] Setting 'video_size' to value '640x480'
[graph 0 input from stream 1:0 @ 0x7fffc3477a40] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 1:0 @ 0x7fffc3477a40] Setting 'time_base' to value '1/1000'
[graph 0 input from stream 1:0 @ 0x7fffc3477a40] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 1:0 @ 0x7fffc3477a40] Setting 'frame_rate' to value '1000/1'
[graph 0 input from stream 1:0 @ 0x7fffc3477a40] w:640 h:480 pixfmt:yuv420p tb:1/1000 fr:1000/1 sar:1/1
[graph 0 input from stream 0:0 @ 0x7fffc3474280] Setting 'video_size' to value '640x480'
[graph 0 input from stream 0:0 @ 0x7fffc3474280] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0x7fffc3474280] Setting 'time_base' to value '1/1000'
[graph 0 input from stream 0:0 @ 0x7fffc3474280] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:0 @ 0x7fffc3474280] Setting 'frame_rate' to value '1000/1'
[graph 0 input from stream 0:0 @ 0x7fffc3474280] w:640 h:480 pixfmt:yuv420p tb:1/1000 fr:1000/1 sar:1/1
[graph_0_in_0_1 @ 0x7fffc348eb00] Setting 'time_base' to value '1/48000'
[graph_0_in_0_1 @ 0x7fffc348eb00] Setting 'sample_rate' to value '48000'
[graph_0_in_0_1 @ 0x7fffc348eb00] Setting 'sample_fmt' to value 's16'
[graph_0_in_0_1 @ 0x7fffc348eb00] Setting 'channel_layout' to value '0x3'
[graph_0_in_0_1 @ 0x7fffc348eb00] tb:1/48000 samplefmt:s16 samplerate:48000 chlayout:0x3
[graph_0_in_1_1 @ 0x7fffc3490240] Setting 'time_base' to value '1/48000'
[graph_0_in_1_1 @ 0x7fffc3490240] Setting 'sample_rate' to value '48000'
[graph_0_in_1_1 @ 0x7fffc3490240] Setting 'sample_fmt' to value 's16'
[graph_0_in_1_1 @ 0x7fffc3490240] Setting 'channel_layout' to value '0x3'
[graph_0_in_1_1 @ 0x7fffc3490240] tb:1/48000 samplefmt:s16 samplerate:48000 chlayout:0x3
[format_out_0_1 @ 0x7fffc3474680] Setting 'sample_fmts' to value 'fltp'
[format_out_0_1 @ 0x7fffc3474680] Setting 'sample_rates' to value '96000|88200|64000|48000|44100|32000|24000|22050|16000|12000|11025|8000|7350'
[format_out_0_1 @ 0x7fffc3474680] Setting 'channel_layouts' to value '0x3'
[format @ 0x7fffc34769c0] Setting 'pix_fmts' to value 'yuv420p|yuvj420p|yuv422p|yuvj422p|yuv444p|yuvj444p|nv12|nv16|nv21'
[Parsed_amerge_4 @ 0x7fffc3478180] No channel layout for input 1
[AVFilterGraph @ 0x7fffc3472880] query_formats: 17 queried, 23 merged, 0 already done, 9 delayed
[AVFilterGraph @ 0x7fffc3472880] query_formats not finished
[Parsed_amerge_4 @ 0x7fffc3478180] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
[AVFilterGraph @ 0x7fffc3472880] query_formats: 1 queried, 9 merged, 23 already done, 0 delayed
[Parsed_amerge_4 @ 0x7fffc3478180] in0:stereo + in1:stereo -> out:4.0
[Parsed_aresample_5 @ 0x7fffc3478a40] [SWR @ 0x7fffc34791c0] Using fltp internally between filters
[Parsed_aresample_5 @ 0x7fffc3478a40] [SWR @ 0x7fffc34791c0] Matrix coefficients:
[Parsed_aresample_5 @ 0x7fffc3478a40] [SWR @ 0x7fffc34791c0] FL: FL:1.000000 FR:0.000000 FC:0.707107 BC:0.500000
[Parsed_aresample_5 @ 0x7fffc3478a40] [SWR @ 0x7fffc34791c0] FR: FL:0.000000 FR:1.000000 FC:0.707107 BC:0.500000
[Parsed_aresample_5 @ 0x7fffc3478a40] ch:4 chl:4.0 fmt:s16 r:48000Hz -> ch:2 chl:stereo fmt:fltp r:48000Hz
[Parsed_scale2ref_0 @ 0x7fffc3473a00] w:640 h:480 fmt:yuv420p sar:1/1 -> w:640 h:480 fmt:yuv420p sar:1/1 flags:0x2
[Parsed_scale2ref_1 @ 0x7fffc3474080] w:640 h:480 fmt:yuv420p sar:1/1 -> w:640 h:480 fmt:yuv420p sar:1/1 flags:0x2
[Parsed_hstack_2 @ 0x7fffc34762c0] [framesync @ 0x7fffc3476498] Selected 1/1000 time base
[Parsed_hstack_2 @ 0x7fffc34762c0] [framesync @ 0x7fffc3476498] Sync level 1
[Parsed_setsar_3 @ 0x7fffc3477480] w:1280 h:480 sar:1/1 dar:8/3 -> sar:1/1 dar:8/3
[libx264 @ 0x7fffc33a27c0] using mv_range_thread = 40
[libx264 @ 0x7fffc33a27c0] using SAR=1/1
[libx264 @ 0x7fffc33a27c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX XOP FMA3 BMI1
[libx264 @ 0x7fffc33a27c0] profile High, level 3.1
[libx264 @ 0x7fffc33a27c0] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - 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=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 './out.mp4':
  Metadata:
    encoder         : Lavf58.44.100
    Stream #0:0, 0, 1/15360: Video: h264 (libx264), 1 reference frame (avc1 / 0x31637661), yuv420p, 1280x480 [SAR 1:1 DAR 8:3], 0/1, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc58.90.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
    Stream #0:1, 0, 1/48000: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, delay 1024, 128 kb/s (default)
    Metadata:
      encoder         : Lavc58.90.100 aac
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 32 times
*** dropping frame 6 from stream 0 at ts 4
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 3 times
*** dropping frame 7 from stream 0 at ts 5
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 5 times
*** dropping frame 8 from stream 0 at ts 6
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 4 times
*** dropping frame 9 from stream 0 at ts 7
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 5 times
*** dropping frame 10 from stream 0 at ts 9
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 2 times
*** dropping frame 10 from stream 0 at ts 9
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 3 times
*** dropping frame 11 from stream 0 at ts 10
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 6 times

...

*** dropping frame 919 from stream 0 at ts 917
[libx264 @ 0x7fffc33a27c0] frame= 869 QP=24.99 NAL=0 Slice:B Poc:234 I:0    P:951  SKIP:1448 size=989 bytes
*** dropping frame 920 from stream 0 at ts 918
*** dropping frame 920 from stream 0 at ts 919
[libx264 @ 0x7fffc33a27c0] frame= 870 QP=25.62 NAL=0 Slice:B Poc:238 I:9    P:1022 SKIP:1366 size=1462 bytes
*** dropping frame 921 from stream 0 at ts 920
[libx264 @ 0x7fffc33a27c0] frame= 871 QP=20.97 NAL=2 Slice:P Poc:248 I:170  P:1812 SKIP:418  size=11296 bytes
[libx264 @ 0x7fffc33a27c0] frame= 872 QP=24.64 NAL=2 Slice:B Poc:244 I:31   P:1274 SKIP:1080 size=3317 bytes
*** dropping frame 923 from stream 0 at ts 921
...
[libx264 @ 0x7fffc33a27c0] frame= 888 QP=21.04 NAL=2 Slice:P Poc:282 I:135  P:1533 SKIP:732  size=7943 bytes
[libx264 @ 0x7fffc33a27c0] frame= 889 QP=24.72 NAL=2 Slice:B Poc:278 I:10   P:1027 SKIP:1355 size=1865 bytes
[libx264 @ 0x7fffc33a27c0] frame= 890 QP=24.85 NAL=0 Slice:B Poc:276 I:0    P:804  SKIP:1596 size=716 bytes

...

Not writing 'clli' atom. No content light level info.
Not writing 'mdcv' atom. Missing mastering metadata.
frame=  923 fps= 49 q=-1.0 Lsize=    4233kB time=00:00:30.86 bitrate=1123.2kbits/s dup=0 drop=847 speed=1.64x
video:3714kB audio:484kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.818652%
Input file #0 (./str_CAM_N0PW_con_Gz4hFc86ts.webm):
  Input stream #0:0 (video): 939 packets read (3924348 bytes); 936 frames decoded;
  Input stream #0:1 (audio): 1560 packets read (117307 bytes); 1560 frames decoded (1497600 samples);
  Total: 2499 packets (4041655 bytes) demuxed
Input file #1 (./str_CAM_GPjV_con_NxaIMlsISO.webm):
  Input stream #1:0 (video): 871 packets read (1365403 bytes); 868 frames decoded;
  Input stream #1:1 (audio): 1545 packets read (97667 bytes); 1545 frames decoded (1483200 samples);
  Total: 2416 packets (1463070 bytes) demuxed
Output file #0 (./out.mp4):
  Output stream #0:0 (video): 923 frames encoded; 923 packets muxed (3803227 bytes);
  Output stream #0:1 (audio): 1447 frames encoded (1481728 samples); 1448 packets muxed (495667 bytes);
  Total: 2371 packets (4298894 bytes) muxed
4909 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x7fffc33bc040] Statistics: 2 seeks, 20 writeouts
[libx264 @ 0x7fffc33a27c0] frame I:4     Avg QP:19.28  size: 34312
[libx264 @ 0x7fffc33a27c0] frame P:251   Avg QP:21.50  size:  9620
[libx264 @ 0x7fffc33a27c0] frame B:668   Avg QP:25.66  size:  1872
[libx264 @ 0x7fffc33a27c0] consecutive B-frames:  2.7%  1.7%  2.0% 93.6%
[libx264 @ 0x7fffc33a27c0] mb I  I16..4: 16.3% 70.5% 13.2%
[libx264 @ 0x7fffc33a27c0] mb P  I16..4:  2.9%  5.9%  0.5%  P16..4: 44.1% 14.0%  6.0%  0.0%  0.0%    skip:26.6%
[libx264 @ 0x7fffc33a27c0] mb B  I16..4:  0.2%  0.3%  0.0%  B16..8: 37.7%  1.5%  0.2%  direct: 0.7%  skip:59.4%  L0:46.2% L1:52.0% BI: 1.8%
[libx264 @ 0x7fffc33a27c0] 8x8 transform intra:63.3% inter:79.9%
[libx264 @ 0x7fffc33a27c0] coded y,uvDC,uvAC intra: 47.6% 57.8% 14.3% inter: 11.6% 9.1% 0.1%
[libx264 @ 0x7fffc33a27c0] i16 v,h,dc,p: 21% 18% 32% 29%
[libx264 @ 0x7fffc33a27c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 17% 28%  5%  4%  6%  5%  5%  5%
[libx264 @ 0x7fffc33a27c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 18% 16%  5%  6%  7%  6%  5%  3%
[libx264 @ 0x7fffc33a27c0] i8c dc,h,v,p: 54% 21% 21%  5%
[libx264 @ 0x7fffc33a27c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fffc33a27c0] ref P L0: 58.7% 18.4% 16.6%  6.3%
[libx264 @ 0x7fffc33a27c0] ref B L0: 89.8%  8.3%  1.9%
[libx264 @ 0x7fffc33a27c0] ref B L1: 95.4%  4.6%
[libx264 @ 0x7fffc33a27c0] kb/s:988.74
[aac @ 0x7fffc33a4a80] Qavg: 242.930
[AVIOContext @ 0x7fffc3398a80] Statistics: 4162659 bytes read, 3 seeks
[AVIOContext @ 0x7fffc33a1940] Statistics: 1507328 bytes read, 0 seeks
Exiting normally, received signal 2.

@PaulB.Mahol I updated my original post with the debug output

didn't work. I decided to abandon ffmpeg, since whenever I encode anything to mp4/h264/aac, the result is always out of sync, regardless of the machine, system, or ffmpeg version. Very frustrating...


text:
(ffmpeg - Audio) Two streams, One Channel, Two Languages
I need your help with a command line for ffmpeg that I just started to use.
Here's the deal :
I have a .MOV file witch contains 18 audio streams (for 7.1). Stream 1 to 10 is for original language and stream 11 to 18 is for French version.
What I want to do :

merge stream 1 (Lt) and 2 (Rt) in a single orginal language stereo track
merge stream 10 (Lt) and 11 (Rt) in a single French language stereo track
Tag them properly to identify them when playing the video.

Here's my command :
ffmpeg -ss 00:00:00.00 -t 00:15:00.00 -i input.MOV
-map 0:v:0 -map 0:a:0 -map 0:a:1 -map 0:a:2 -map 0:a:3 -map 0:a:4 -map 0:a:5 -map 0:a:6 -map 0:a:7 -map 0:a:8 -map 0:a:9 -map 0:a:10 -map 0:a:11 -map 0:a:12 -map 0:a:13 -map 0:a:14 -map 0:a:15 -map 0:a:16 -map 0:a:17
-filter_complex "[0:a:0][0:a:1]amerge=inputs=2[a];[0:a:10][0:a:11]amerge=inputs=2[a]"
-map "[a]" -map "[a]"
-metadata:s:a:0 language="eng" -metadata:s:a:0 title="Stéréo - Version Originale"
-metadata:s:a:1 language="fra" -metadata:s:a:1 title="Stéréo - Français"
-c:a output.MOV

My problems :

video is not include and audio streams are "inverted"
When I execute it, I have these warnings :

[Parsed_amerge_0 @ 000001f8f0340240] No channel layout for input 1
[Parsed_amerge_1 @ 000001f8f0283940] No channel layout for input 1
[Parsed_amerge_0 @ 000001f8f0340240] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
[Parsed_amerge_1 @ 000001f8f0283940] Input channel layouts overlap: output layout will be determined by the number of distinct input channels

How can I fix this ?
I precise that I don't wan't any loss of quality.
Thank you all for your help ;)

Try it in smaller steps. Have you tried to only copy and merge two audio channels and copy the video? Does that work? First try it simple, then more complex. Then search for when the problem occurs. And write your answer here, so that others can learn.

Hello erik and thanks for your answer.
Well, I finally (partly) succeeded to get a proper command. I had to precise the codec of the audio streams (MediaInfo).
So now, I have :
ffmpeg -ss 00:00:00.00 -t 00:10:00.00
-i G:\input.MOV
-filter_complex "[0:a:6][0:a:7]amerge=inputs=2;[0:a:14][0:a:15]amerge=inputs=2"
-metadata:s:a:0 language="kor" -metadata:s:a:0 title="Stéréo - Version Originale"
-metadata:s:a:1 language="fra" -metadata:s:a:1 title="Stéréo - Français"
-c:v copy
-c:a pcm_s24le
G:\output.MOV

And it works as expected !!!
The only two small problems I still have :
1. [Parsed_amerge_0 @ 000001f8f0340240] No channel layout for input 1
I just don't know how to set a chanel layout...
2. In the output result, video became stream 3 and not first as it should properly be.
They are not big deals but if I want to be perfect in what I'm doing ;)
Thanks again !!

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
ffmpeg amix filter command execution never stops
Hello I want to achieve something like in this pic below using ffmpeg:

Initially I used below command:
ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -filter_complex
nullsrc=size=960x304 [base];
[0:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v0];
[1:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v1];
[2:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v2];
[base][v0] overlay=x=0:y=0[tmp0];
[tmp0][v1] overlay=x=320:y=0[tmp1];
[tmp1][v2] overlay=x=640:y=0[tmp2]
 -map [tmp2] -c:v libx264 output.mp4

It was working well but audio was missing in the output so I used below command to mix audios of input videos:
ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -filter_complex
nullsrc=size=960x304 [base];
[0:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v0];
[1:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v1];
[2:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v2];
[base][v0] overlay=x=0:y=0[tmp0];
[tmp0][v1] overlay=x=320:y=0[tmp1];
[tmp1][v2] overlay=x=640:y=0[tmp2];
[0:a][1:a][2:a]amix=inputs=3:duration=shortest[audio]
-map [tmp2] -map [audio] -c:v libx264 output.mp4

I don't know what happened but the execution never stops. It keeps on going. I thought the input audio's sample rate and channel types are mismatched, so I tried below:
ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -filter_complex
nullsrc=size=960x304 [base];
[0:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v0];
[1:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v1];
[2:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v2];
[base][v0] overlay=x=0:y=0[tmp0];
[tmp0][v1] overlay=x=320:y=0[tmp1];
[tmp1][v2] overlay=x=640:y=0[tmp2];
[0:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=1[audio0];
[1:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=1[audio1];
[2:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=1[audio2];
[audio0][audio1][audio2]amix=inputs=3:duration=shortest[audio]
-map [tmp2] -map [audio] -c:v libx264 output.mp4

but same result. The execution never stops. I think there is something with audio handling. Also currently if I remove audio portion and only output video, the output video stops when shortest of the video finishes. I want that the output video should have lenght of the longest video. The short clips should display their last frame until the longest video finishes. Any help regarding this?
PS: Logs from logcat:
ffmpeg version 3.3.4
     Copyright (c) 2000-2017 the FFmpeg developers
      built with gcc 4.9 (GCC) 20140827 (prerelease)

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input1.mp4':
      Metadata:
        major_brand     :
    isom
        minor_version   :
    512
        compatible_brands:
    isomiso2avc1mp41
        title           :
    1946246598843281
        encoder         :
    Lavf56.40.101
      Duration:
    00:00:53.91
    , start:
    -0.022109
    , bitrate:
    256 kb/s
        Stream #0:0
    (und)
    : Video: h264 (avc1 / 0x31637661), yuv420p, 400x304, 206 kb/s
    ,
    25 fps,
    25 tbr,
    90k tbn,
    50 tbc
     (default)
        Metadata:
          handler_name    :
    VideoHandler
        Stream #0:1
    (und)
    : Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 47 kb/s
     (default)
        Metadata:
          handler_name    :
    SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'input2.mp4':
      Metadata:
        major_brand     :
    isom
        minor_version   :
    512
        compatible_brands:
    isomiso2avc1mp41
title           :
    617689615538740
        encoder         :
    Lavf56.40.101
      Duration:
    00:00:15.37
    , start:
    -0.022109
    , bitrate:
    392 kb/s
        Stream #1:0
    (und)
    : Video: h264 (avc1 / 0x31637661), yuv420p, 400x400, 349 kb/s
    ,
    30 fps,
    30 tbr,
    90k tbn,
    60 tbc
     (default)
        Metadata:
          handler_name    :
    VideoHandler
        Stream #1:1
    (und)
    : Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 47 kb/s
     (default)
        Metadata:
          handler_name    :
    SoundHandler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'input3.mp4':
      Metadata:
        major_brand     :
    isom
        minor_version   :
    512
        compatible_brands:
    isomiso2avc1mp41
        encoder         :
    Lavf57.25.100
      Duration:
    00:00:05.97
    , start:
    0.000000
    , bitrate:
    770 kb/s
        Stream #2:0
    (und)
    : Audio: aac (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 128 kb/s
     (default)
        Metadata:
          handler_name    :
    SoundHandler
        Stream #2:1
    (und)
    : Video: h264 (avc1 / 0x31637661), yuv420p, 368x480, 608 kb/s
    ,
27.29 fps,
    120 tbr,
    12k tbn,
    60 tbc
     (default)
        Metadata:
          handler_name    :
    VideoHandler
Stream mapping:
      Stream #0:0 (h264) -> crop
      Stream #0:1 (aac) -> aformat
      Stream #1:0 (h264) -> crop
      Stream #1:1 (aac) -> aformat
      Stream #2:0 (aac) -> aformat
      Stream #2:1 (h264) -> crop
      overlay
     -> Stream #0:0 (libx264)
      amix
     -> Stream #0:1 (aac)
    Press [q] to stop, [?] for help

Upgrade to v 4.3 and limit the duration of the base layer, which is infinite, by default. Audio is fine.
ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -filter_complex
nullsrc=size=960x304,trim=0:1 [base];
[0:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v0];
[1:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v1];
[2:v] crop=min(iw\,320):304:(iw-min(iw\,320))/2:0 [v2];
[base][v0] overlay=x=0:y=0[tmp0];
[tmp0][v1] overlay=x=320:y=0[tmp1];
[tmp1][v2] overlay=x=640:y=0[tmp2];
[0:a][1:a][2:a]amix=inputs=3:duration=longest[audio]
-map [tmp2] -map [audio] -c:v libx264 output.mp4

I don't know how to limit the duration of the [base] layer. Though, I added trim=0:1 in base layer as you added but the result is same.

Works here with v4.3

Already answered in other page
I just copy paste it
The overlay filter has a shortest option:
If set to 1, force the output to terminate when the shortest input terminates. Default value is 0.
Example:
ffmpeg -i input -filter_complex "color[c];[0:v][c]overlay=shortest=1" output

Usage of shortest is needed because the color duration is indefinite (unless you use the d option).

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Avisynth+ How to install
My system is windows 7 64 bit, Avisynth+ 3.6.0 is installed.
Displayed when loading 64-bit dll:
Cannot load a 64 bit DLL in 32 bit Avisynth: 'D:/Program Files/AviSynthPlus/plugins64+/avss.dll'

Your path D:/Program Files/AviSynthPlus/plugins64+/ is by AviSynth recognized as an autoload path for 32-bit plugins, because this path is set (as a value) in an inappropriate registry key.
Launch Registry Editor and check / change path values in these keys:

HKEY_CURRENT_USER\SOFTWARE\Avisynth\PluginDir+ for 64-bit version,
HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Avisynth\PluginDir+ for 32-bit version.

or (lower priority)

HKEY_LOCAL_MACHINE\SOFTWARE\Avisynth\PluginDir+ for 64-bit version,
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Avisynth\PluginDir+ for 32-bit version.

But the version according to OP is 3.6.0 which is the release from May 2020. Your link points to sth. way older. Have you mixed up things?

You're right, thanks. Version which I meant was then bumped to 3.4.0 and continues with this form of version numbering.

The problem now is that 64-bit avisynth does not work.

Please specify in details what does it mean “does not work”.

You want to run 64bit plugins in a 32bit application - that's what the error, you got, tells us. You should install or build the 64bit version of avisynth as this should be able to work with the plugins.
Also Windows 7 is unsupported by Microsoft. The longer you wait with upgrading to Windows 10 (or using another modern OS) the more problems you will face.

I installed 32-bit and 64-bit avisynth
(AviSynthPlus_3.6.0_20200520_vcredist), this is not wrong. Why is it displayed 32 bit

You have a path D:\Program Files\ where the 64bit version should be but do you also have D:\Program Files (x86)\ where the 32 bit version is?  Maybe sth. during installation went wrong and they both installed in the same location?


text:
Will a Youtube video with clips from a copyright protected anime website (AnimeID) be taken down even if I give credit in the video and description?
This is my first post here, but I think I used the search function and couldn't find what I was looking for. This is probably a stupid question, but here goes: I'm creating an analysis of an anime just for fun on Youtube. I have fairly short clips from a free but copyright protected anime website in this video I'm making. I have already given credit in advance on my blog, and I will include credit both in the video and in the description. Is this enough, or is it not guaranteed that the video will remain up and not be removed by Youtube (because of a copyright issue)?
It would be great if someone could answer this sometime today because if this will work out alright, I want to upload it today if possible. I am also asking this question on another online forum in case no one sees this here.
Thank you so much in advance!

Also, I was thinking about asking someone on youtube for their clips, but I decided to just go to the same website. Again, I'm not planning to use my own video for making money, just for fun.

It's a strange case. In court, you would win because you're using the footage under the "fair use" regulations. However, many videos still get claimed wrongfully. You can request a manual review, and possibly get approved, but by then the main viewership per day has gone down (since approval may take a few days).
So from a monetary standpoint, for video-projects such as these should be supported via patreon, since you will most likely miss out on a big chunk of ad-revenue.
But if you don't care much about the earnings, you will very likely get away if you live in a country/state in which the "fair use" right is applicable.

An algorithm decides that. It can go both directions. The system is not smart enough to correctly decide if your video meets the cirteria for fair use/citation. In case of a wrong decision you can appeal and sometimes you succeed.
If you give credit or not does not play a role for Youtube, however it's a legal requirement for correct citation.
If a copyright violation is detected, the video either gets blocked or the income will be redirected to the holders of these rights. And you get a strike.
Funny: As I write this I'm listening to an experienced Youtuber in a live stream and by chance she speaks about this topic and says: "It's a game of luck if you get a copyright strike or not." I think this confirms my point.


text:
Adobe Premiere Pro Green Lines Problem
Can you please help me to fix this?

How can I remove these green lines from my video preview in Premiere Pro 2020?

Is this only happening with that one video, with multiple videos that have something in common, or with every video?

I had the same problem when i updated my graphics driver, I use Windows 10, Intel i3 8th Gen. Version which did the problem was 27.20.100.8336.
you need Intel Graphics - BETA Windows 10 DCH Driver
Windows 10, 64-bit version 27.20.100.8425
link to update your driver https://downloadcenter.intel.com/product/80939/Graphics


text:
How can I prevent YouTube from distorting the audio in my QuickTime video?
I recorded about 20 MP4 clips: most on my Android phone with the stock camera, a couple from Facebook (downloaded from the mobile web view), and one from a Zoom session. I cropped or scaled and padded the FB and Zoom clips with ffmpeg to match the clips from my phone (vertical 1080p). I trimmed all the clips in the Mac QuickTime player, which exported .m4v. I then combined the clips into a single video with the QuickTime player, which saved .mov.
The .mov video looks and sounds as it should throughout. However, when I upload the .mov video to YouTube

the result has two audio problems:

The audio in the clips immediately before the Zoom clip and one of the FB clips is lowered in pitch. The preceding, distorted clips start at 1:08:18 and 41:01 respectively.
The audio in the Zoom clip is really distorted, almost gone, partway through, at 1:11:21.

(The clip at 6:18 doesn't seem to have been distorted by the clip from FB which follows it. The FB clip that doesn't cause the problem is from the FB Live Android app; I think the one that does is from the Acapella app, but I didn't make it so I'm not sure.)
The problems are much worse in the Zoom clip and the clip that precedes it, which are the second- and third-to-last clips in the video, so I worked around the problem by posting a video including only the last 3 clips. The audio in that video is fine throughout!?!

How can I adjust my clips so that YouTube preserves the audio in the full-length video?
Side note: I found that converting the .mov video to .mp4 with a recent ffmpeg snapshot causes the exact same problems in the result, so, if we knew what to do to get a good result with ffmpeg, that might fix the problem on YouTube.

The problem was that different clips had different frame rates. My phone records a variable frame rate around 30 fps, the Zoom video had a fixed frame rate of 25 fps, the FB live video was variable around 30 fps and the Acapella-via-FB video was fixed 30 fps. I fixed the problem by reencoding all clips to a fixed frame rate of 30 fps with ffmpeg -r 30. (I also set a minimum audio bitrate of 96 kb/s, the bitrate of most of the original footage, with -b:v 96k. ffmpeg defaulted to an audio bitrate of 69 kb/s.)
The QuickTime player refused to concatenate the frame-rate-adjusted clips, so I concatenated the clips in batches of 32 with ffmpeg's concat filter and then concatenated the result of that with ffmpeg's more efficient concat demuxer. (Concatenating in one pass with ffmpeg's concat demuxer dropped the audio entirely from some scenes; I didn't take the time to figure out why.) I was able to combine frame rate adjustment and batch concatenation into one ffmpeg command, i.e. one reencoding step.


text:
A specific MP4 file is not playable with avfoundation in iOS
I have an mp4 video file that I want to play it in iOS using avfoundation. Unfortunately, the file is not being played and save into the default gallery (photos) even it has h264 video codec and aac audio codec. And it is only playable when I reencode it using ffmpeg. I want to know why the file only becomes playable after reencoding the video?
Not Playable(originalFile.mp4) vs Playable File(outputFile.mp4) Information Comparison

File is playable with avfoundation when these commands are being applied:

ffmpeg -y -hide_banner -i originalFile.mp4 -f mp4 -vcodec h264 -vf scale=out_color_matrix=bt709 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -b:v 5703k -acodec aac -b:a 249k outputFile.mp4

ffmpeg -y -hide_banner -i originalFile.mp4 -f mp4 -vcodec h264 -acodec aac outputFile.mp4

File is not playable with avfoundation when this command is being applied:

ffmpeg -y -hide_banner -i originalFile.mp4 -f mp4 -vcodec copy -acodec aac outputFile.mp4

originalFile.mp4 file link: https://drive.google.com/file/d/1-yZFL0EsLztMIfwU79Al6dv8gdwJyGAD/view?usp=sharing
ffprobe streams of both files are here
https://www.diffchecker.com/VgZL66QB

NOTE: I can't comment to Jason Conrad so I am posting it as an answer and will delete it. How do we understand if a video is interlaced from the information FFMPEG provides us? In the above answer Jason Conrad mentions that "smpte170m/bt470bg/bt709." means its interlaced video. But this is just color space information. How does it mean interlace or progressive? Is it possible to share anymore details or URL to read further? Thanks very much for your answer.

Share the full output of ffprobe -show_streams for both original file and outputfile.

@Gyan I've modified the question and now you can get the outputs of ffprobe streams  from there. Thanks.

Only the colorimetry appears to be different. But that shouldn't stop playback. Nevertheless, try ffmpeg -i originalFile.mp4 -c copy -color_primaries bt709 -color_trc bt709 -colorspace bt709 -movflags +faststart outputFile.mp4

@Gyan I've applied your suggested command but nothing has changed in the outputFile's information and the video isn't playable on iOS either. Can you suggest any special reads on colorimetry, please?
Thanks.

Since you're using 4.2.1, also add -write_colr 1 and check.

@Gyan I've applied this command
ffmpeg -i originalFile.mp4 -c copy -color_primaries bt709 -color_trc bt709 -colorspace bt709 -movflags write_colr outputFile.mp4 and still there is no difference between originalFile.mp4 and outputFile.mp4 information. Is it the appropriate command that you suggested to apply?

@Gyan I've included originalFile.mp4 link in the question which file is not playable via iOS default video player or Avfoundation. Thanks.

Link not accessible

@Gyan The link should be accessible now.

The H.264 video stream is stored using MBAFF coding, which is likely not supported in AVFoundation. You'll have to re-encode.

@Gyan How can we ensure that the video stream is stored using MBAFF coding? Thank you.

How is original file generated?

Basically, we've got this file from one of our users!

The original video is an old, interlaced format.  At least, according to the line that says, "smpte170m/bt470bg/bt709."  The SMPTE standard is available for purchase here, but you can tell from the summary that it's interlaced.
The second ffmpeg command is copying the format without re-encoding, or handling the interlacing, which isn’t supported on iOS.  The first set of commands work because the video is being re-encoded. Whether or not the video is automatically being de-interlaced, I can’t say without seeing, but I doubt it.  See my answer to this question to judge for yourself.

smpte170m/bt470bg/bt709 only indicates colorimetry and nothing about scan.

The incompatibility  -- regardless of its nature -- is present in the original file.  The blue highlighting in the "Information Comparison" graphic illustrates the only differences between the files of which we know.  Of those differences, only the SMPTE spec is salient.  Sure, it's an educated guess, but there's really not much else to go on.

The first string smpte170m refers to the colorspace, the 2nd bt470bg refers to the color primaries and the 3rd bt709 to the transfer function (gamma). Interlacing, when detected, will be indicated by printing of the field order e.g. top first, after colorimetry.

So you're saying the original file follows the smpte170m color standard, but isn't interlaced.  I accept that.  But still, whatever incompatibility exists, is in the original file, which is why the -copy argument produces an incompatible file, and why re-encoding doesn't.


text:
What is the best settings in handbrake for 640x480?
I tried the default setting of the handbrake but generated video's size get greater than the original video itself. My video files are generally in between 100mb and 1.5Gb
I was wondering is it possible to detect the size before starting comprassion in handbrake and what is the best settings in handbrake for 640x480?

My current setup is as follows:

One thing you can certainly do is lower the bitrate. 23 is quite a high bitrate, even more so for a h.264 .mp4. You should get away with a bitrate of 5-7. Also, you're encoding using the preset of 720p, which would be 1280×720 pixels. However, you stated that your resolution is only 640x480, so matching those settings will do a great deal in filesize aswell.

A lower RF produces a larger file. Roughly, an increase of RF by 6 reduces size by half.

of course, thank you for pointing this out. I edited my answer accordingly.


text:
severe artifacts pixelation when using cuda rendering premiere pro
In premiere pro when I set the renderer to GPU Acceleration (CUDA), for the timeline and on media encoder export, half the video is completely messed up with lots of pixelation artifacts when I switch on any effect or make a change in the lumetri colour panel. Any solutions?
I'm running premiere pro 2020 v14.3.0 and have the GTX 1060 3GB GPU with Nvidia drivers 451.48.
I have also tried reinstalling both and deleting all the cache to no effect.

Could you post your export settings please?

Hi this issue happens in the timeline window as well as the render export only when GPU rendering is on making me think it's independent of the export settings. I use h.264 full hd 1080p export preset.

Oh yikes - could it be that the footage is corrupted? What happens when you use a different clip in the timeline?

Rolled back the Nvidia driver to the version before and it seems to have fixed it. Might be a bug. Typical!


text:
Getting hdmi signal of a camera to TCP/IP network and read on computer
I would like to know if such application can be made with this type of devices and what would I require to actually read the signal on my computer?
here is a small figure I made

i plan on putting DSLRs and cine cam like this
I know that 6D MII have network capabilities but they use wireless communication which is not really stable. The 6D mII Has a mini hdmi port.
I would like to mount on network multiple cameras to make concert recording, studio session recording, game live streaming etc.
I could not find any answers on that topic since every searches return to amazon and eBay.
I'll be highly thankful for any help,
best regards;
the Link of the device I plan on using:
https://www.amazon.fr/Mirabox-Extendeur-Ethernet-Switch-extension/dp/B06WD82BPG/ref=sr_1_8?dchild=1&keywords=Adaptateur+Rj45+Hdmi&qid=1598867556&s=computers&sr=1-8

I think that the best way to go is to use a mixer like the BlackMagic ATEM-series. I am working in a film-studio and have worked mainly with the ATEM Television Studio HD Mixer, which has all the capabilities you would want.
Mixers like these have SDI/BNC and HDMI inputs and are capable of mixing and converting each signal, using lower-thirds, live-keying (if you want to use a webcam with greenscreen) and much more. Yes, they are expensive, but if you're serious about this I would highly recommend it. You will have a better signal than through Wifi streaming or wireless transmissions...

Thanks i’ll take a look at it !

I think I'll go with the Atem mini since I only need hdmi for now, the one I'll choose will depend on its characteristics so I'll do a bit more research and if it works well with capture softwares. Thanks for your help though.

and the cdmi to ethernet will be used to extend cdmi cables so I don't have to buy 50m hdmi

That sounds like a good choice! I hope you're successful in what you're doing :)

Thanks! I hope so


text:
ffmpeg concatenation of MP3 files to single M4A file fails
Instructions from this site, Can ffmpeg input mp4 and convert it to m4b or m4a?  fail to concatenate and convert multiple MP3 files into one M4A file.
I downloaded the ffmpeg static build for Windows 10 git-2020-06-26-7447045 from http://ffmpeg.zeranoe.com/builds/
I generated a file list.txt containing the files to concatenate, numbered from 01.mp3 to 51.mp3 .
When I try to combine those MP3 files into 1 M4A file, the error happened as below. How do I resolve this?
I ran:
ffmpeg -f concat -safe 0 -i list.txt -vn -y -b:a 64k -acodec aac -ac 2 result.m4a

and got
[concat @ 000002652204c840] Line 1: unknown keyword '01.mp3'
list.txt: Invalid data found when processing input

Here's the content of list.txt:
01.mp3
02.mp3
03.mp3
04.mp3
05.mp3
06.mp3
07.mp3
08.mp3
09.mp3
10.mp3
11.mp3
12.mp3
13.mp3
14.mp3
15.mp3
16.mp3
17.mp3
18.mp3
19.mp3
20.mp3
21.mp3
22.mp3
23.mp3
24.mp3
25.mp3
26.mp3
27.mp3
28.mp3
29.mp3
30.mp3
31.mp3
32.mp3
33.mp3
34.mp3
35.mp3
36.mp3
37.mp3
38.mp3
39.mp3
40.mp3
41.mp3
42.mp3
43.mp3
44.mp3
45.mp3
46.mp3
47.mp3
48.mp3
49.mp3
50.mp3
51.mp3

Each line in the concat list must be either a comment (start line with #) or a keyword. To specify an input, start with file,
so 01.mp3 becomes file 01.mp3.


text:
Removing streams in HEVC H.265 MKV file?
I have multiple MKV files with video encoded a la HEVC/H.265.  I want to, using the Windows command line, make a new MKV file, stripping out all but specific subtitle tracks and audio tracks, on a file-by-file basis, as I have no need to retain multiple foreign language sound tracks and subtitle tracks.
Let's say I used ffprobe to find what streams are in a given MKV file. Further, I want to keep the first and third audio tracks, and the 24th and 25th subtitle tracks, from said file. I used https://stackoverflow.com/questions/63302454/map-metadata-stream-by-filter-in-ffmpeg as a reference.
I have tried to do that with
ffmpeg -i INPUTFILE.MKV -map 0:0 -map 1:1 -map 1:3 -map 1:a:24 -map 1:a:25 OUTPUTFILE.MKV

which fails. How should I write the command?

In the syntax -map 1:a:24, 1 stands for the input file index. Counting starts from 0, so 1 refers to the 2nd input file but the command only has one input. a stands for stream type, and in this case, it's audio - v is for video, s for subtitles, d for data. 24 represents the 25th (0-indexed, remember) audio track. If your command has one input file with three video, three audio and three subtitle streams in the following order: V A S A V S V A S, then the 2nd video will be -map 0:v:1 You can reference it using absolute index by using -map 0:4. With absolute indexing, there's no stream type specifier.
Assuming the stream numbering in your description is correct, use
ffmpeg -i IN.MKV -map 0:0 -map 0:a:0 -map 0:a:2 -map 0:s:23 -map 0:s:24 -c copy OUT.MKV

Note that if -c copy is omitted, all streams will be re-encoded - not what you want normally.


text:
Find duration only with ffprobe in Windows
I want to find video file duration only with ffprobe but
ffprobe FILENAME.EXT 2| find "Duration:"

does not filter output to show just the line with "Duration:"  Instead, I got:

Argument '2' provided as input filename, but 'FILENAME.MP4' was
already specified.

How do I see just the duration of a file from the Windows command prompt?

First, if you just want information about a file, you should probably use "ffprobe", not "ffmpeg". Otherwise you'll get an answer, but you'll also have an error return status.
As to your real question: By convention, ffmpeg reserves STDOUT for binary video and audio data only. Everything else, including all the possible kinds of informative text, is sent to STDERR.
So, try changing your code to:
ffprobe FILENAME.EXT 2| find "Duration:"  (for a *nix shell)
or
ffprobe.exe FILENAME.EXT 2>&1 | findstr Duration (for a Windows shell)

Does not work. See revised question.

Improved it. Thank you


text:
Shooting RAW vs 4:2:2 10-bit HDR PQ for HDR output
With the Canon EOS R5 I can choose to record in 12 bit RAW (DCI) or 10-bit HDR PQ H.265 (All-I or IPB compressed).
Is there a big advantage of shooting in RAW vs HDR PQ for non professional HDR output?

It’s not RAW vs 10bit HDR PQ. That’s apples and oranges. It’s RAW vs Canon compressed(?) log, and either one of them is capable of covering PQ, but 10 bits is just enough to deliver as HDR — you want to record at 12-16 and cut it down, if you can. Netflix requires it.  Actually, you should check out the technical docs they publish, especially their camera requirements, for an idea about what’s important in a camera. It’s a good resource.

Would you say 12 bit RAW would make a big difference compared to 10 bit Canon log for HRD output?

The RAW is better, but if you stacked them side-by-side, normalized, you'd be hard pressed to tell the difference, visually.  Where you'd notice a difference is when you're trying to do color qualifications --  say like selecting all of a particular red and increasing the luminance, or keying a greenscreen -- that's where you'd see more noise in the 10-bit log, but it's still very usable.  IDK the specs on those cameras, but usually, if one does RAW, it'll also have the option to do compressed log.  The codec they're shooting will also be a factor in how smoothly you can edit.  H.265 no bueno.

I was wrong. Netflix only requires 10 bit log, but still...  https://partnerhelp.netflixstudios.com/hc/en-us/articles/360000579527-Cameras-and-Image-Capture

Oh, wow.  Those are some nice specs.  Those both look like good cameras.  HEIF is H.265, so you'll need a GPU that can decode that well, or else transcode it.


text:
How to filter out footage into one clip
The problem I am facing is I have too much of footage of which only 10% is going to be used for editing.
I don't want to store tons of footage which is not going to be used.
The most reasonable idea which comes to my mind is to run through all the footage, trim the bits ( which I would like to use in ONE or MORE future videos ) and save this trimmed compilation as a file for use in the future, 'open and pick up what I need' clip compilation file.
So the question is:
What would be the best approach to save space and time in filtering out the usable footage and getting rid of the footage that is never going to be used?

There are 2 solutions:

Create a sequence with all assets that have not been used so far, but which you would like to keep. Next, use the Project Manager to export all relevant files to a new location (your archive) and have "Exclude unused Clips" checked. You may choose to do 2 exports: one with all the sequences for the main video except the extra sequence and another with only the extra assets sequence. When done, delete the original project folder.

Use a metadata attribute to mark which assets you do not want to keep. In the project panel, select list view and sort by that metadata column. Or you may move all the extra assets in other bins. For each bin select all the assets marked as unwanted and right click on Make Offline and select the delete option.

I think the first approach will be faster in most cases.

Thank you @Matt, rethinking this now, actually what I ideally want to do is to pickup few seconds of each footage and re render it as one file, so I can delete all the original footage. I will ask a separate question how to do it to not loose frames or quality when rerending.


text:
Best and easiest way to delete a layer by a specific time in the After Effects timeline
I use Adobe After Effects (Last version) for video editing
I created a composition with a video, shape and null Object. So far everything work well.
Now I want to hide the layer from a certain point in my timeline.
Let say my timeline is 10s, I want my layer to be visible at the first 3s and then to be invisible the remaining seconds

What is the best and easiest way to perform that?
Thank You

Make a key frame (or more than one at different points) on the Opacity control. You can get to it by selecting the layer and pressing T. Or open up all the triangles to find it. Set the opacity to zero to make the layer invisible.

Apologies if I misunderstood - I'm not sure how well you know after effects. Maybe you mean you just want to trim the end of a layer? You can do this by selecting the layer at a certain time, and pressing the ] key.

By the way, this is an old but very good beginner's guide to After Effects. You might find it useful: http://www.videocopilot.net/basic/

You could try to create an expression that sets the opacity of your layer to 0 once you've hit a certain time in your timeline. You should be able to code this properly in Java or the basic expression-language. A syntax should look somewhat like this:

if (comptime)>"yourtime"
opacity.yourlayer=0

Thank You for your answer. I know Java, and please, how to create that expression in AE? I very newbie with AE


text:
H.264 Max Resolution
I was trying to find the technical reasons for why H.264 is limited for 4K.
Obviously that in terms of bit-rate it becomes less efficient but the encoding itself is limited and for some reason, I couldn't find any publicly available references.
Someone?

One of the bits of information associated with a H264 stream is its level. The level informs the decoder the computational resources needed for a successful decode. Turns out that the highest level 5.2 supports upto 9437184 luma samples per frame, which is the number of luma samples needed for a frame of size 4096x2304. So, there may be encoders that can (be forced to) encode higher resolutions but there's no valid level which can be set for the stream, and probably no decoder that can be guaranteed to produce reliable playback.

This is not the issue. New levels can be added (5.2 was added in the ITU-T recommendation in 2011-2012).  The issue is the coding efficiency.

Of course, new levels can be added. But encoders already out there don't go past the spec at the time of their production. So, what level do you expect an encoder compiled today to set if fed, say, 8K input?

The level is just a flag. Some decoders ignore it completely.

Here's one real life example why your answer is incomplete: Nvidia NVEC supports H.264 at up to 4096x4096, which falls outside 5.2 https://developer.nvidia.com/sites/default/files/akamai/cuda/files/CUDADownloads/NVENC_AppNote.pdf

H.264/AVC is not limited for 4K in terms of max resolution as it supports  DCI 4K (4092x2160) @ 60 fps at Level 5.2.  For example Sony already uses XAVC which is exactly 4K AVC.
For a while the max level was 5.1 and 5.2 was introduced later. If needed new levels can be introduced as long there's the hardware to support it.
For eg. the Nvidia NVEC supports H.264 up to 4096x4096: https://developer.nvidia.com/sites/default/files/akamai/cuda/files/CUDADownloads/NVENC_AppNote.pdf
The actual problem with 4K are the bandwidth requirements for streaming, not the hardware support. To do 4K streaming at 12-15 Mbps the encoder needs a 40% efficiency increase.
The problem with H.264 is that it's not efficient enough for this purpose. This is what the new H.265/HEVC (High Efficiency Video Coding) tries to achieve.

The resolution you state is lower than the resolution I stated as max. possible under level 5.2. The issue of coding efficiency is germane to viability of H264 as a choice for 4K stream given a bandwidth constraint, not to why an encoder doesn't output higher-res.

The max resolution is not supported at 60 fps on 5.2 and 60 fps is also becoming a requirement. There's no reason why AVC won't work with higher resolutions and it could be used for say, storage. In fact AVC is way faster than HEVC.

I'll post all further comments here. The OP's query is why is encoding "limited". Presumably, this was provoked by an empirical observation. So, the question isn't whether there are theoretical considerations in the spec which prevent 8K H.264 streams, but why don't encoders output greater sizes. Now, the level is just a metadatum and players may ignore it but non-turnkey commercial and FOSS encoders probably try to generate compliant streams, and at present, the spec doesn't allow for it.

The OP asked for technical reasons. The level is conformance, not strictly a technical issue with the underlying codec. Coding efficiency is a technical reason.

But the reason doesn't seem to be functional but legal. This is the reason proffered by the Adobe liaison at https://forums.creativecow.net/thread/2/1046747 - "Adobe Media Encoder is enforcing the limits on H.264 video that are imposed by the MPEG-4 specification."

That's exactly what I was trying to point out: there's no technical limit, just a conformance limit subject to change.

That use of 'technical' is obviously a generic use on the part of the OP. If they meant to differentiate between algorithmic vs bureaucratic reasons, that would show up in the Q. In fact, since my answer doesn't convey a technical (in your sense) reason and yet was accepted by the OP shows that they didn't have your distinction of 'technical' in mind.

Let us continue this discussion in chat.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Batch processing in ImageMagick to create image masks from .mp4
I am creating animated sequences from video files. I am hoping to create image masks from the video files to save time on masking them by hand. This tutorial seems to clearly outline the process, however I have not been able to successfully input this command:
for i in *.tiff;
do
    name=`echo $i | cut -d'.' -f1';
    convert t01.tiff $i -compose difference -composite -threshold 5% -blur 0x3 \
          -threshold 20% -blur -0x3 "$name-mask.tiff" convert $i "name-mask.tiff" \
          -compose multiply -flatten "$name-clean.jpg"
done

When I enter this code, I receive:
>

I am using bash on Catalina and am a bit new to this workflow and command line in general.

Do you have two convert commands? Also, in your sample code you have "name-mask.tiff", is the $ missing? I would advice you use ${<varname>} when using variables. It works everywhere and even if followed by a character which could be construed as a variable name character.

The problem is probably caused by line breaks when pasted in the terminal. Try creating a script instead. Read here: https://www.taniarascia.com/how-to-create-and-use-bash-scripts/

@Matt This was the case! Followed the link, put the command in a script, worked as expected! Thank you!


text:
Copy chapter metadata of input to output for Apple compatibility
I have a set of media where I'm trying to strip an audio track and copy everything else over. My command is like so:
ffmpeg -i input.m4v -dn -map 0 -map -0:a:2 -c copy output.m4v

The source file has the following metadata:
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.m4v':
  Metadata:
    major_brand     : M4V
    minor_version   : 512
    compatible_brands: M4V isomiso2avc1
    encoder         : Lavf58.45.100
  Duration: 01:56:22.98, start: 0.000000, bitrate: 3320 kb/s
    Chapter #0:0: start 0.000000, end 589.923000
    Metadata:
      title           : Chapter 1
    Chapter #0:1: start 589.923000, end 1052.802000
    Metadata:
      title           : Chapter 2
    Chapter #0:2: start 1052.802000, end 1408.282000
    Metadata:
      title           : Chapter 3
    Chapter #0:3: start 1408.282000, end 2034.157000
    Metadata:
      title           : Chapter 4
    Chapter #0:4: start 2034.157000, end 2461.709000
    Metadata:
      title           : Chapter 5
    Chapter #0:5: start 2461.709000, end 3146.101000
    Metadata:
      title           : Chapter 6
    Chapter #0:6: start 3146.101000, end 3454.534000
    Metadata:
      title           : Chapter 7
    Chapter #0:7: start 3454.534000, end 3786.449000
    Metadata:
      title           : Chapter 8
    Chapter #0:8: start 3786.449000, end 4169.207000
    Metadata:
      title           : Chapter 9
    Chapter #0:9: start 4169.207000, end 4569.398000
    Metadata:
      title           : Chapter 10
    Chapter #0:10: start 4569.398000, end 5121.825000
    Metadata:
      title           : Chapter 11
    Chapter #0:11: start 5121.825000, end 5737.065000
    Metadata:
      title           : Chapter 12
    Chapter #0:12: start 5737.065000, end 6326.320000
    Metadata:
      title           : Chapter 13
    Chapter #0:13: start 6326.320000, end 6982.517000
    Metadata:
      title           : Chapter 14
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1910x804 [SAR 1:1 DAR 955:402], 2417 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 254 kb/s (default)
    Metadata:
      handler_name    : Stereo
    Stream #0:2(eng): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 640 kb/s
    Metadata:
      handler_name    : Surround
    Side data:
      audio service type: main
    Stream #0:3(eng): Data: bin_data (text / 0x74786574)
    Metadata:
      handler_name    : SubtitleHandler

Without the -dn flag I get an error when running the command:
[ipod @ 0x7f9d4100be00] Tag text incompatible with output codec id '100359' ([0][0][0][0])
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input

When I use the -dn flag I can't select a chapter on my Apple TV which leads me to believe the metadata is incorrect.
When I try and run ffprobe on the produced file I get:
[m4v @ 0x7f966880b800] Format m4v detected only with low score of 1, misdetection possible!
[m4v @ 0x7f966880b800] Could not find codec parameters for stream 0 (Video: mpeg4, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options

I also tried adding -map_chapters and -map_metadata but I get an error:
[ipod @ 0x7f93a0026400] Tag text incompatible with output codec id '100359' ([0][0][0][0])
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input

The command that resulted in the above is:
ffmpeg -i input.m4v -map 0 -map -0:a:2 -map_metadata 0 -map_chapters 0 -c copy output.m4v

What's the proper command to copy everything over EXCEPT the track I want to exclude?

A command like the following seemed to do the trick.
ffmpeg -i input.m4v -dn -map 0 -map -0:a:2 -map_metadata 0 -map_chapters 0 -c copy output.m4v


text:
ffmpeg invalid argument. Which argument was invalid?
UPDATED with info from -report

I'm new to ffmpeg.
I am trying to loop a video to a linux v4l2 device.
ffmpeg -stream_loop -1 -re -f lavfi  -i "movie=snail.mp4" -f v4l2 /dev/video4 -report

It plays the video once and then exits with the message "Invalid
[Parsed_movie_0 @ 0x56289dec9a00] EOF timestamp not reliable=N/A speed=   1x
Error while filtering: Invalid argument
frame=  391 fps= 25 q=-0.0 Lsize=N/A time=00:00:15.64 bitrate=N/A speed=0.999x
video:43988kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Which argument is invalid and why?
The output of the report file generated by ffmpeg is available here: https://gist.github.com/ahoffer/7217aa0572061e7c255cf08914be53e2

Add -report and rerun. Share report.

I added -report, but it provided no additional information.
ffmpeg  -stream_loop -1  -re -f lavfi  -i "movie=snail.mp4" -f v4l2 /dev/video4 -report

It will have generated a report file in pwd. Share that.

-stream_loop is buggy in versions older than 4.1, so upgrade.
Also, stream_loop won't work with movies opened via movie filter. Use it as a direct input.
ffmpeg -stream_loop -1 -re -i "snail.mp4" -f v4l2 /dev/video4 -report

ffmpeg is already the newest version (7:3.4.8-0ubuntu0.2)

That command sort of works. However, the framerate slowly drops from 24 FPS to about 8 FPS. Then it picks back up. It repeats the pattern indefinitely. I looking in the report file. Some kind of recursive problem? A warning of over 1000 duplicated frames? I don't know.

Distro packages are very out of date. Latest ver is 4.3; you're using 3.4.8. Get a static binary - see ffmpeg.org/download.html


text:
How to create a educational video by only using your voice and some photos
I would like to create some educational videos in which I will use only my voice and some photos/text headlines, notes etc. on my Mac computer. I am aiming at creating videos that are as much as possible in better definition while as much as possible smaller size in order to make them upload easily. All I think is two options.
First one is I can create a video using slides and then record my voice over it by using a video editing program.
Secondly, I can create a slide and record a voice over it while screen recording.
Second one sounds easier for me because I can be more flexible on timing and duration.
I can use Quicktime for screen recording. Do you think it is a good idea for a video? Its recordings can be very large size. I do not think I need super-quality definition on my videos. 480p is good enough for me.
What are your suggestions in terms of video recording techniques and applications/programs for my situation?

Use PowerPoint.
The truth is that the latest version of it can do nice transitions so the presentation is not dull at all.
At the end, you can export as a video to Mp4. If used properly you do not need video edition at all.
Do not use less than HD for your videos. The resolution may not be important to you, but the viewers are used to Full HD.

Thank you buddy

If you're on a Mac, Keynote is free, and works well. You could prepare your slides, then open Quicktime Player to do a screen record whilst you record your audio and run your slides.
It's a good idea to have lots of hard drive space when working on a video - the files can be large, but then you can make a smaller compressed version for sharing afterwards.
If the file size is large at the end, you can choose how you save it afterwards in Quicktime using the "Export As" option in the File Menu. 4K will result in large files and high resolution. 480p will give smaller files but a lot lower resolution.
If you want more precision, and the ability to go back and fix mistakes etc, you may need to use a video editing package such as iMovie (free and inlcuded with MacOS), or Premiere (paid).  Screenflow (paid) is also excellent and designed for recording and editing screen recordings.

Thank you for  concise answer. I made a video using Keynote and Quicktime yesterday. The video 45 minutes long, in 720p  and its size is around 1 GB! It took 30 minutes to upload it but when I  tried to export to it as 480p, it lasted around 2 hours! Why does it take so long? It is a pity that Quicktime does not allow us to choose the definition of the video before recording. It could be problem when the internet connection has slow for large videos. So I try to find out the ways of decreasing the size of videos I make.

Hi. Videos are big files. There are a lot of pixels in a 720p video, and they can all change at any time! A 45 min video at around 1GB sounds about right to me.  You could compress the file to make it smaller, but the quality will get worse. Video compression is a trade-off between file size and quality. You could try an app like Handbrake (free) to recompress your video and see whether the quality is still acceptable. https://handbrake.fr/downloads.php


text:
python for loop result in ffmpeg command
hi im trying to insert for loop results in a ffmpeg command i tried some code but all i get is first text with no sound and it glitches and freezes i tried many modification but no success i appreciate if you have any ideas that would be great, the imported text from api should display only the duration of audio file here is my code:

import requests
import json
import os
import requests
import http.client
import io
import subprocess

response = requests.get('http://api.quran.com:3000/api/v3/chapters/2/verses?text_type=image&language=ar&recitation=10')

json = json.loads(response.content)

data= json['verses']
#print(data)

for i in data:
    input_text = i['text_madani']
    input_duration = i['audio']['duration']
    input_mp3 = i['audio']['url']
    input_img = i['image']['url']
 #   print(input_duration)
    command = f'''ffmpeg -re -stream_loop -1 \
                    -i img2.jpeg \
                    -i {input_mp3} \
                    -vf 'pad=ceil(iw/2)*2:ceil(ih/2)*2,drawtext=enable='between(t, n, {input_duration})':text={input_text}:fontsize=90:x=50:y=50:fontcolor=black@0.8' \
                    -c:v libx264 -preset veryfast -b:v 3000k \
                    -maxrate 3000k -bufsize 6000k -pix_fmt yuv420p -g 50 \
                    -c:a aac -b:a 160k \
                    -ac 2 -ar 44100 \
                    -y -f flv rtmp://localhost/hls/test'''
    print(command)
    os.system(command)

minor nitpick. If you're executing ffmpeg on the command line like you are, you don't need to import ffmpeg from your code.

thanks i did not see the import but i'm using the command for now not python module

It should be a ffmpeg command to stream loop contents instead of commands of breaking rtmp connection

would plz explain more i think i'm using an ffmpeg command with loop option

Idea attributes to https://trac.ffmpeg.org/wiki/Concatenate


text:
AE linear() function is not working with variable
I have set up a pretty simple expression that animates the number of copies of a shape layers' repeater:
copies = 14;
anim_start= 12;
anim_end = 32;

ftime = timeToFrames(time,25);
if(ftime<anim_end)
x =linear(ftime,anim_start,anim_end,0,copies);
else
x = linear(ftime,225,243,copies,0);
x;

It works fine if I replace "anim_end" with a number, but what it does now is have 0 copies at frame 11, and 14 copies one frame later. I am confused why AE won't exept my variable "anim_end". Can someone point me in the right direction?
thanks,
Barbara
edit: since I can't comment on the answer that was already given: putting { brackets in the if-else clause did not change anything, unfortunately. Thanks anyway :)

Try putting the clauses of the if … else … expression in {braces}.

@Barbara - We can merge the two accounts you currently have, if you like, then you will be able to comment. At the moment it looks like you just created 2 accounts by accident.


text:
Optimized Parameters of `FFMPEG` for Screen Recording
Windows has a great codec for screen recording called Windows Media Video Screen.
It generates artifacts free videos which are highly compressed (small size).
I was wondering, what would be the equivalent using FFMPEG?
Are there parameters to be set for any codec in FFMPEG which can yield similar results?
Is there a mode for lossless intra and inter compression?
If not, what would be a good set of parameters for FFMPEG for this task?


text:
Video Color is changing After Importing It Into Adobe Premiere Pro 2022
I captured my desktop screen using OBS Studio and when i import the captured videos into Adobe Premiere Pro 2022, their color become a little bit lighter, you can see the image i attached below, the original video is darker and the same video is imported into Premiere Pro, the color of video changes.
Difference

OBS Studio Settings

Check the colour profile of the footage you imported from OBS.
Make sure the colour profile of your footage matches the colour management settings in Premiere.
OBS is likely to be exporting sRGB colour footage.  Premiere defaults to working in rec.709 colour profile.
When you export from Premiere, again check which colour profile is being used.
https://blog.frame.io/2019/08/26/color-management-abobe-cc/#Premiere_Pro

I uploaded Obs studio Settings, i Think its 709.

I check marked Display Color Management option according to this blog >> https://blog.frame.io/2019/08/26/color-management-abobe-cc/#Premiere_Pro and it solved the problem for me... thank you


text:
Using ffmpeg gdigrab to capture desktop output to h264 yuv420p. Color shift problem
The ffmpeg command below is being used to capture the desktop and create a resulting mp4.  ffmpeg log says the input stream is bmp and I specified the target as h264 yuv420p.   I found several older articles talking about a ffmpeg color shift problem issue and experimented several hours with the suggestions and filters.  But as the pics show the resulting mp4 is washed out and not as vibrant as the original screen.
Using

Win 10
ffmpeg 5.0
VLC 3.16
Chrome

ffmpeg -f gdigrab -offset_x 1600 -offset_y 0 -video_size 1600x1200 -i desktop -pix_fmt yuv420p -vcodec libx264 -profile:v main -crf 16 outfile.mp4

Original -  Resulting file -
--- end of original post ---
Updates and information
I really needed this project done so after making the original post I made some further experiments which I think will mostly address the issue and create a workable solution.
The first issue to resolve is which color space to use for the resulting file? The basic choice revolves around where you want to play the resulting file. Some players do not like certain formats.  According to this post yuv420p is for old players and it was yuv420p that was causing the issues that resulted in my posting here.
The rest of this post will concern itself with the rgb & yuv options.
RGB
The ffmpeg string which captures desktop to an rgb colorspace mp4.  Played fine in chrome and vlc 3.16
Just like the yuv file below the rgb colors in the output file were true to the original desktop.
ffmpeg -f gdigrab -offset_x 1600 -offset_y 0 -video_size 1600x1200 -i desktop -c:v libx264rgb -qp 0 -pix_fmt rgb24 outfile.mp4

YUV
The ffmpeg string which captures desktop to a yuv colorspace mp4.
Using the yuv444p color space results in a file which to the eye looks just like the desktop looked when it was recorded.  There may be some rounding errors and slight color variations if you look at it from a mathematical perspective but for my eyes and purposes it offers great fidelity to the original image.  I found no combination of parameters which could make yuv420p true to the original desktop - all my results with 420 resulted in washed out images.  Played fine in chrome and vlc 3.16
I was hoping the file size would be significantly smaller than rgb but that was not the result of my test - yuv and rgb produced files approximately the same size.
ffmpeg -f gdigrab -offset_x 1600 -offset_y 0 -video_size 1600x1200 -i desktop -vf scale=out_color_matrix=bt709:out_range=full,format=yuv444p -color_primaries bt709 -colorspace bt709 -color_trc bt709 -pix_fmt yuv444p outfile.mp4

You cannot go from BGR to YUV420p without having a shift in colors, a bug with a known workaround (accurate_rnd). https://trac.ffmpeg.org/ticket/979
You also did not tag the output.
ffmpeg -f gdigrab -offset_x 1600 -offset_y 0 -video_size 1600x1200 -i desktop \
    -vf scale=flags=accurate_rnd:out_color_matrix=bt709, format=yuv420p \
    -color_primaries bt709 -colorspace bt709 -color_primaries bt709 \
    -color_trc iec61966_2_1 -c:v libx264 -profile:v main -crf 16 outfile.mp4

I hope you understand that sRGB uses sRGB transfer (iec61966_2_1), not BT.709, but uses BT.709 primaries.
Your RGB is incorrectly tagged as limited, gdigrab had this bug, update FFmpeg to latest build here: https://github.com/BtbN/FFmpeg-Builds/

Other option for updating FFmpeg: Gyan's FFmpeg Builds
binaries for Windows.


text:
How do I get better sound quality when screencasting with ffmpeg without having to increase -r?
I wrote the following script to capture both the screen and the audio from the microphone, both lossless from my laptop:
#!/bin/bash

d=$(date +"%Y%m%d_%-H%M")
dimensions=$(xdpyinfo |grep dimensions| awk '{print $2}';)

ffmpeg -f x11grab -r 25 -s "${dimensions}" -i "${DISPLAY}" -f alsa -ac 2 -i default -c:v libx264rgb -crf 0 -color_range 2 -preset ultrafast -c:a pcm_s16le -strict -2 "${d}.mkv"

The sound becomes very intermittent when setting to a very low number of frames per second (the sound practically disappears when r is set to 7) and it improves substantially to an acceptable quality with -r set to 50 or higher.
This behaviour is also present with lossy capturing of the screen and audio as with ffmpeg -f alsa -ac 2 -i default -f x11grab -s "${dimensions}" -r 7 -i "${DISPLAY}" "${d}.mkv"
Why does the -r parameter influence the quality of the sound? Is the syntax of my script incorrect?
When I record the audio without screencasting, either ffmpeg -f alsa -ac 2 -i default "${d}.mp4"  or ffmpeg -f alsa -ac 2 -i default "${d}.wav" works fine giving me satisfying quality of the audio.
The output from recording with ffmpeg -f x11grab -r 25 -s "${dimensions}" -i "${DISPLAY}" -f alsa -ac 2 -i default -c:v libx264rgb -crf 0 -color_range 2 -preset ultrafast -c:a pcm_s16le -strict -2 "${d}.mkv" is:
ffmpeg version 5.1.4-0+deb12u1 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr --extra-version=0+deb12u1 --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-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
[x11grab @ 0x55d20fe24040] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0':
  Duration: N/A, start: 1707046868.487852, bitrate: 1658880 kb/s
  Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1080, 1658880 kb/s, 25 fps, 1000k tbr, 1000k tbn
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, alsa, from 'default':
  Duration: N/A, start: 1707046868.768038, bitrate: 1536 kb/s
  Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264rgb))
  Stream #1:0 -> #0:1 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[libx264rgb @ 0x55d20fe7e9c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264rgb @ 0x55d20fe7e9c0] profile High 4:4:4 Predictive, level 4.0, 4:4:4, 8-bit
[libx264rgb @ 0x55d20fe7e9c0] 264 - core 164 r3095 baee400 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=0 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=24 lookahead_threads=4 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, matroska, to '20240204_1241-loseless.mkv':
  Metadata:
    encoder         : Lavf59.27.100
  Stream #0:0: Video: h264 (H264 / 0x34363248), bgr0(pc, progressive), 1920x1080, q=2-31, 25 fps, 1k tbn
    Metadata:
      encoder         : Lavc59.37.100 libx264rgb
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
  Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
    Metadata:
      encoder         : Lavc59.37.100 pcm_s16le
frame=    1 fps=0.0 q=0.0 size=       1kB time=00:00:00.02 bitrate= 286.5kbits/sframe=   21 fps=0.0 q=0.0 size=       1kB time=00:00:00.02 bitrate= 286.5kbits/s[alsa @ 0x55d20fe30440] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=   33 fps= 32 q=0.0 size=       1kB time=00:00:00.81 bitrate=   7.3kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=   46 fps= 30 q=0.0 size=       1kB time=00:00:00.82 bitrate=   7.3kbits/sframe=   58 fps= 28 q=0.0 size=       1kB time=00:00:01.58 bitrate=   3.8kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=   71 fps= 28 q=0.0 size=       1kB time=00:00:02.34 bitrate=   2.6kbits/sframe=   84 fps= 28 q=0.0 size=    5376kB time=00:00:02.34 bitrate=18780.5kbits/[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=   96 fps= 27 q=0.0 size=    5376kB time=00:00:03.14 bitrate=14003.2kbits/[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  109 fps= 27 q=0.0 size=    5376kB time=00:00:03.93 bitrate=11186.2kbits/frame=  122 fps= 27 q=0.0 size=    5376kB time=00:00:03.93 bitrate=11186.2kbits/[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  134 fps= 26 q=0.0 size=    5376kB time=00:00:04.70 bitrate=9358.3kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  147 fps= 26 q=0.0 size=    5376kB time=00:00:04.88 bitrate=9020.9kbits/sframe=  160 fps= 26 q=0.0 size=    5376kB time=00:00:05.49 bitrate=8010.2kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  173 fps= 26 q=0.0 size=    5376kB time=00:00:06.25 bitrate=7039.7kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  185 fps= 26 q=0.0 size=    5376kB time=00:00:06.39 bitrate=6889.9kbits/sframe=  198 fps= 26 q=0.0 size=    5376kB time=00:00:07.02 bitrate=6268.2kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
[matroska @ 0x55d20fe7d800] Non-monotonous DTS in output stream 0:1; previous: 7108, current: 7104; changing to 7108. This may result in incorrect timestamps in the output file.
[matroska @ 0x55d20fe7d800] Non-monotonous DTS in output stream 0:1; previous: 7173, current: 7170; changing to 7173. This may result in incorrect timestamps in the output file.
frame=  211 fps= 26 q=0.0 size=    7424kB time=00:00:07.82 bitrate=7776.2kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  223 fps= 26 q=0.0 size=    7424kB time=00:00:07.97 bitrate=7626.0kbits/sframe=  236 fps= 26 q=0.0 size=    7424kB time=00:00:08.58 bitrate=7088.3kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  248 fps= 26 q=0.0 size=    7424kB time=00:00:09.34 bitrate=6510.1kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  261 fps= 26 q=0.0 size=    7424kB time=00:00:09.40 bitrate=6469.2kbits/sframe=  273 fps= 26 q=0.0 size=    7424kB time=00:00:10.14 bitrate=5996.0kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  286 fps= 26 q=0.0 size=    8960kB time=00:00:10.93 bitrate=6711.2kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  299 fps= 26 q=0.0 size=    8960kB time=00:00:10.94 bitrate=6703.8kbits/sframe=  312 fps= 26 q=0.0 size=    8960kB time=00:00:11.69 bitrate=6276.2kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  324 fps= 26 q=0.0 size=    8960kB time=00:00:12.46 bitrate=5888.5kbits/sframe=  337 fps= 26 q=0.0 size=    8960kB time=00:00:12.46 bitrate=5888.5kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  349 fps= 26 q=0.0 size=    8960kB time=00:00:13.26 bitrate=5533.0kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  362 fps= 26 q=0.0 size=    8960kB time=00:00:13.47 bitrate=5445.9kbits/s[matroska @ 0x55d20fe7d800] Non-monotonous DTS in output stream 0:1; previous: 13457, current: 13451; changing to 13457. This may result in incorrect timestamps in the output file.
[matroska @ 0x55d20fe7d800] Non-monotonous DTS in output stream 0:1; previous: 13457, current: 13453; changing to 13457. This may result in incorrect timestamps in the output file.
frame=  374 fps= 25 q=0.0 size=    8960kB time=00:00:14.05 bitrate=5220.9kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  387 fps= 25 q=0.0 size=    8960kB time=00:00:14.82 bitrate=4952.8kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  400 fps= 25 q=0.0 size=    8960kB time=00:00:15.04 bitrate=4878.7kbits/sframe=  413 fps= 25 q=0.0 size=   11776kB time=00:00:15.57 bitrate=6193.0kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  425 fps= 25 q=0.0 size=   11776kB time=00:00:16.33 bitrate=5905.7kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.
frame=  438 fps= 25 q=0.0 size=   11776kB time=00:00:16.48 bitrate=5853.3kbits/sframe=  451 fps= 25 q=0.0 size=   17408kB time=00:00:17.09 bitrate=8340.0kbits/s[alsa @ 0x55d20fe30440] ALSA buffer xrun.

[q] command received. Exiting.

frame=  455 fps= 25 q=-1.0 Lsize=   21617kB time=00:00:18.16 bitrate=9750.7kbits/s speed=1.01x
video:20715kB audio:896kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.025721%
[libx264rgb @ 0x55d20fe7e9c0] frame I:2     Avg QP: 0.00  size:950424
[libx264rgb @ 0x55d20fe7e9c0] frame P:453   Avg QP: 0.00  size: 42629
[libx264rgb @ 0x55d20fe7e9c0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264rgb @ 0x55d20fe7e9c0] mb P  I16..4: 56.4%  0.0%  0.0%  P16..4:  0.1%  0.0%  0.0%  0.0%  0.0%    skip:43.5%
[libx264rgb @ 0x55d20fe7e9c0] coded y,u,v intra: 1.8% 1.8% 2.0% inter: 0.1% 0.1% 0.1%
[libx264rgb @ 0x55d20fe7e9c0] i16 v,h,dc,p: 98%  2%  0%  0%
[libx264rgb @ 0x55d20fe7e9c0] kb/s:9323.81

The laptop (Debian based system, utilizing X11 for the window manager, 16GB of RAM, Intel i7-10870H CPU 2.20GHz - 16 cores, NVIDIA Corporation GA106M [GeForce RTX 3060 Mobile / Max-Q]) does not lack compute, the loading averages when not recording are:
0.16, 0.14, 0.38.

For x11grab you should be using -framerate and not -r.
Here is what you should use:
ffmpeg -f x11grab -framerate 25 -s ${dimensions} -i ${DISPLAY} -f alsa -ac 2 -i default -c:v libx264rgb -crf 0 -color_range 2 -vf mpdecimate=0:1:1:1 -preset superfast -c:a flac ${d}.mkv

I also changed the preset to superfast to enable CABAC coding which improves compression ratio significantly and in my experience will never be a bottleneck for screen recording.
I also added a video filter which will deduplicate frames that are 100% identical and create a VFR video (very very useful when screen recording and lets you increase the framerate a lot without increasing system load or video bitrate much). It's still lossless and has identical output to a CFR video with duplicated frames.
Finally I changed the audio codec to flac. It is lossless and it's much better to use flac than raw pcm.


text:
FFMPEG: How to remove audio from entire directory
I am a novice coder using Terminal on MAC that has installed FFMPEG and attempting to edit an entire directory.
My goal is to remove all of the audio from all of the videos and output or overwrite the existing files. I was successful in writing a line of code that inputted and outputted ONE file accurately, however, when I attempted to adapt the code others have posted across the web, the terminal would time-out or error. Attached are a couple of screenshots of what happens for two of the scenarios I thought was sure to work:
Screenshot one:

Screenshot two:

Next time posting code, please copy-paste the code into the editor. Screenshots are hard to read and copy from. Thanks!

The problem is that the code you adapted was intended for .avi files, not .mp4, so you are trying to replace a string that does not exist.
The following would work:
for f in *.mp4; do
  ffmpeg -i "$f" -an -c:v copy "${f/%.mp4/-noaudio.mp4}"
done