text:
How to merge videos with FFmpeg with smooth transitions
Sorry if my question is dumb, but I'm new to FFmpeg.
I have some videos. They all have the same video codec, resolution and framerate. Audio streams also have the same format. For example, MP4 files, H264, AAC.
I want to merge some of them into one file with smooth transitions between them. I just want the simplest one - when videos overlaps for 2-3 seconds. The first one fades out and the second fades in.
I read the docs and some other questions and found out that I need some set of concat filter with something like blend or overlay or fade.
Please help.
Update:
ffmpeg \
 -i input0.mp4 \
 -i input1.mp4 \
 -filter_complex \
 "[0:v]setpts=PTS-STARTPTS[v0];[1:v]setpts=PTS-STARTPTS+4/TB,format=yuva444p,fade=st=4:d=1:t=in:alpha=1[v1];[v0][v1]overlay,format=yuv420p[v];[0:a]asetpts=PTS-STARTPTS[a0];[1:a]asetpts=PTS-STARTPTS[a1];[a0][a1]acrossfade=d=1[a]" \
 -map "[v]" -map "[a]" output.mp4

Log:
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input0.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2019-10-20T09:15:30.000000Z
    com.android.version: 8.0.0
  Duration: 00:00:23.81, start: 0.000000, bitrate: 17280 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 17023 kb/s, SAR 1:1 DAR 16:9, 30.04 fps, 30 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2019-10-20T09:15:30.000000Z
      handler_name    : VideoHandle
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
    Metadata:
      creation_time   : 2019-10-20T09:15:30.000000Z
      handler_name    : SoundHandle
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'input1.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2019-10-20T09:16:05.000000Z
    com.android.version: 8.0.0
  Duration: 00:00:28.76, start: 0.000000, bitrate: 17282 kb/s
    Stream #1:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 17019 kb/s, SAR 1:1 DAR 16:9, 30.04 fps, 30 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2019-10-20T09:16:05.000000Z
      handler_name    : VideoHandle
    Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
    Metadata:
      creation_time   : 2019-10-20T09:16:05.000000Z
      handler_name    : SoundHandle
Stream mapping:
  Stream #0:0 (h264) -> setpts
  Stream #0:1 (aac) -> asetpts
  Stream #1:0 (h264) -> setpts
  Stream #1:1 (aac) -> asetpts
  format -> Stream #0:0 (libx264)
  acrossfade -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[libx264 @ 0x55dd4a513aa0] using SAR=1/1
[libx264 @ 0x55dd4a513aa0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55dd4a513aa0] profile High, level 4.0
[libx264 @ 0x55dd4a513aa0] 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 'output.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    com.android.version: 8.0.0
    encoder         : Lavf57.83.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc57.107.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      encoder         : Lavc57.107.100 aac
Past duration 0.600319 too large   24832kB time=00:00:27.11 bitrate=7502.4kbits/s speed=0.792x
Past duration 0.601662 too large
Past duration 0.602989 too large
Past duration 0.603325 too large   25344kB time=00:00:27.11 bitrate=7657.1kbits/s speed=0.78x
Past duration 0.605995 too large
Past duration 0.605659 too large
Past duration 0.608330 too large
Past duration 0.609993 too large   25856kB time=00:00:28.11 bitrate=7533.2kbits/s speed=0.797x
Past duration 0.609657 too large
Past duration 0.612663 too large
Past duration 0.613991 too large
Past duration 0.615654 too large
Past duration 0.616997 too large
Past duration 0.617989 too large
Past duration 0.618324 too large
Past duration 0.620995 too large   26368kB time=00:00:29.12 bitrate=7417.8kbits/s speed=0.812x
Past duration 0.622322 too large
Past duration 0.623665 too large
Past duration 0.623329 too large
Past duration 0.626320 too large
Past duration 0.627327 too large
Past duration 0.628990 too large
Past duration 0.630333 too large
Past duration 0.631325 too large   26880kB time=00:00:29.12 bitrate=7561.9kbits/s speed=0.798x
Past duration 0.633324 too large
Past duration 0.634666 too large
Past duration 0.634331 too large
Past duration 0.637657 too large
Past duration 0.638664 too large
Past duration 0.639656 too large
Past duration 0.641319 too large   27392kB time=00:00:29.12 bitrate=7705.9kbits/s speed=0.785x
Past duration 0.642662 too large
Past duration 0.643654 too large
Past duration 0.645653 too large
Past duration 0.646660 too large
Past duration 0.647987 too large
Past duration 0.649330 too large
Past duration 0.650993 too large
Past duration 0.652321 too large   27904kB time=00:00:30.12 bitrate=7588.6kbits/s speed= 0.8x
Past duration 0.651985 too large
Past duration 0.654991 too large
    Last message repeated 1 times
Past duration 0.657326 too large
Past duration 0.658653 too large
Past duration 0.658989 too large
Past duration 0.661995 too large
Past duration 0.662987 too large   28416kB time=00:00:31.12 bitrate=7478.9kbits/s speed=0.813x
Past duration 0.664330 too large
    Last message repeated 1 times
Past duration 0.665657 too large
Past duration 0.668663 too large
Past duration 0.667992 too large
Past duration 0.669655 too large
Past duration 0.672661 too large   28928kB time=00:00:31.12 bitrate=7613.7kbits/s speed=0.802x
Past duration 0.671989 too large
Past duration 0.675331 too large
    Last message repeated 1 times
Past duration 0.676659 too large
Past duration 0.678322 too large   29440kB time=00:00:31.12 bitrate=7748.4kbits/s speed=0.792x
Past duration 0.678658 too large
Past duration 0.679985 too large
Past duration 0.682655 too large
Past duration 0.683998 too large
Past duration 0.685326 too large
Past duration 0.687325 too large   29952kB time=00:00:31.12 bitrate=7883.2kbits/s speed=0.781x
Past duration 0.687996 too large
Past duration 0.689323 too large
    Last message repeated 1 times
Past duration 0.692665 too large
Past duration 0.693321 too large
Past duration 0.694328 too large
Past duration 0.695000 too large   30464kB time=00:00:32.12 bitrate=7767.7kbits/s speed=0.796x
Past duration 0.695656 too large
Past duration 0.698326 too large
Past duration 0.700996 too large
    Last message repeated 1 times
Past duration 0.702324 too large
Past duration 0.705330 too large
Past duration 0.704994 too large   30976kB time=00:00:33.13 bitrate=7659.2kbits/s speed=0.81x
Past duration 0.706657 too large
Past duration 0.708321 too large
Past duration 0.708656 too large
Past duration 0.710655 too large
Past duration 0.711998 too large
Past duration 0.714653 too large
Past duration 0.715996 too large   31488kB time=00:00:33.13 bitrate=7785.8kbits/s speed=0.799x
    Last message repeated 1 times
Past duration 0.717659 too large
Past duration 0.720329 too large
    Last message repeated 1 times
Past duration 0.723000 too large
Past duration 0.724327 too large
Past duration 0.725655 too large
Past duration 0.725655 too large   32000kB time=00:00:33.13 bitrate=7912.4kbits/s speed=0.788x
Past duration 0.726997 too large
Past duration 0.727989 too large
Past duration 0.729652 too large
Past duration 0.732323 too large
    Last message repeated 1 times
Past duration 0.734993 too large
Past duration 0.736320 too large
Past duration 0.736320 too large   32512kB time=00:00:34.13 bitrate=7802.9kbits/s speed=0.802x
Past duration 0.739326 too large
Past duration 0.740654 too large
Past duration 0.740318 too large
Past duration 0.742653 too large
Past duration 0.744987 too large
Past duration 0.746330 too large
Past duration 0.747658 too large   33024kB time=00:00:35.13 bitrate=7699.6kbits/s speed=0.814x
Past duration 0.748985 too large
Past duration 0.748329 too large
Past duration 0.751656 too large
Past duration 0.753319 too large
Past duration 0.752663 too large
Past duration 0.755653 too large
Past duration 0.756996 too large
Past duration 0.756996 too large   33536kB time=00:00:35.13 bitrate=7819.0kbits/s speed=0.802x
Past duration 0.759666 too large
    Last message repeated 1 times
Past duration 0.760994 too large
Past duration 0.763664 too large
Past duration 0.763664 too large   33792kB time=00:00:35.13 bitrate=7878.7kbits/s speed=0.792x
Past duration 0.764992 too large
Past duration 0.767662 too large
    Last message repeated 1 times
Past duration 0.768654 too large   34048kB time=00:00:35.13 bitrate=7938.3kbits/s speed=0.783x
Past duration 0.771660 too large
Past duration 0.773323 too large
Past duration 0.771996 too large
Past duration 0.774330 too large
Past duration 0.776329 too large
Past duration 0.776665 too large
Past duration 0.779655 too large   34560kB time=00:00:36.13 bitrate=7834.2kbits/s speed=0.795x
Past duration 0.780663 too large
Past duration 0.782326 too large
Past duration 0.783989 too large
Past duration 0.784996 too large
Past duration 0.785988 too large
Past duration 0.787666 too large
Past duration 0.788994 too large
Past duration 0.788994 too large   35072kB time=00:00:37.14 bitrate=7735.6kbits/s speed=0.806x
Past duration 0.792320 too large
Past duration 0.793663 too large
Past duration 0.794991 too large
Past duration 0.796333 too large
Past duration 0.797661 too large
Past duration 0.798988 too large
Past duration 0.800652 too large
Past duration 0.800331 too large   35328kB time=00:00:37.14 bitrate=7792.1kbits/s speed=0.794x
Past duration 0.802666 too large
Past duration 0.804329 too large
    Last message repeated 1 times
Past duration 0.807320 too large
Past duration 0.808662 too large
Past duration 0.810326 too large
Past duration 0.811653 too large
Past duration 0.812996 too large   35840kB time=00:00:37.14 bitrate=7905.0kbits/s speed=0.783x
    Last message repeated 1 times
Past duration 0.815331 too large
Past duration 0.816994 too large
Past duration 0.818321 too large
Past duration 0.819328 too large
Past duration 0.820992 too large
Past duration 0.821999 too large
Past duration 0.822319 too large   36352kB time=00:00:38.14 bitrate=7807.2kbits/s speed=0.795x
Past duration 0.824989 too large
Past duration 0.825996 too large
Past duration 0.826332 too large
Past duration 0.828987 too large
    Last message repeated 1 times
Past duration 0.830330 too large
Past duration 0.833321 too large
Past duration 0.832985 too large   36864kB time=00:00:39.14 bitrate=7714.3kbits/s speed=0.806x
Past duration 0.835991 too large
Past duration 0.836998 too large
Past duration 0.837318 too large
Past duration 0.838661 too large
Past duration 0.841331 too large
Past duration 0.840996 too large
Past duration 0.843666 too large
Past duration 0.845329 too large   37120kB time=00:00:39.14 bitrate=7767.9kbits/s speed=0.796x
Past duration 0.846657 too large
Past duration 0.847664 too large
Past duration 0.849327 too large
Past duration 0.849998 too large
Past duration 0.850990 too large
Past duration 0.853325 too large
Past duration 0.853661 too large
Past duration 0.855995 too large   37632kB time=00:00:39.14 bitrate=7875.0kbits/s speed=0.786x
Past duration 0.857658 too large
Past duration 0.858986 too large
Past duration 0.860329 too large
Past duration 0.861656 too large
Past duration 0.863319 too large
Past duration 0.864326 too large
Past duration 0.865990 too large
Past duration 0.867332 too large   38144kB time=00:00:40.17 bitrate=7778.7kbits/s speed=0.796x
Past duration 0.865990 too large
Past duration 0.869331 too large
Past duration 0.869987 too large
Past duration 0.871666 too large
Past duration 0.873665 too large
Past duration 0.872993 too large
Past duration 0.875328 too large
Past duration 0.877998 too large   38656kB time=00:00:41.15 bitrate=7695.1kbits/s speed=0.807x
Past duration 0.878319 too large
Past duration 0.878654 too large
Past duration 0.881996 too large
Past duration 0.882652 too large
Past duration 0.884987 too large
Past duration 0.885323 too large
Past duration 0.887321 too large
Past duration 0.887657 too large
Past duration 0.889992 too large   39168kB time=00:00:41.15 bitrate=7797.1kbits/s speed=0.798x
    Last message repeated 1 times
Past duration 0.891655 too large
Past duration 0.893990 too large
Past duration 0.895332 too large
    Last message repeated 1 times
Past duration 0.897987 too large
Past duration 0.899666 too large
Past duration 0.900993 too large   39680kB time=00:00:41.15 bitrate=7899.0kbits/s speed=0.79x
Past duration 0.902657 too large
Past duration 0.903999 too large
Past duration 0.904991 too large
Past duration 0.905327 too large
Past duration 0.906654 too large
Past duration 0.907997 too large
Past duration 0.910652 too large
Past duration 0.910988 too large   40192kB time=00:00:42.85 bitrate=7682.3kbits/s speed=0.814x
Past duration 0.913322 too large
frame=  985 fps= 13 q=-1.0 Lsize=   60323kB time=00:00:51.58 bitrate=9579.9kbits/s speed=0.695x
video:59484kB audio:810kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.048264%
[libx264 @ 0x55dd4a513aa0] frame I:5     Avg QP:22.90  size:206885
[libx264 @ 0x55dd4a513aa0] frame P:303   Avg QP:25.09  size:100886
[libx264 @ 0x55dd4a513aa0] frame B:677   Avg QP:27.85  size: 43292
[libx264 @ 0x55dd4a513aa0] consecutive B-frames:  6.3%  4.3%  5.8% 83.7%
[libx264 @ 0x55dd4a513aa0] mb I  I16..4: 11.1% 49.1% 39.8%
[libx264 @ 0x55dd4a513aa0] mb P  I16..4:  6.5% 14.1%  9.5%  P16..4: 37.5% 16.2%  8.2%  0.0%  0.0%    skip: 8.0%
[libx264 @ 0x55dd4a513aa0] mb B  I16..4:  1.5%  1.6%  3.3%  B16..8: 48.1%  8.4%  2.2%  direct: 4.6%  skip:30.3%  L0:52.3% L1:34.9% BI:12.8%
[libx264 @ 0x55dd4a513aa0] 8x8 transform intra:40.2% inter:46.8%
[libx264 @ 0x55dd4a513aa0] coded y,uvDC,uvAC intra: 63.8% 25.9% 2.2% inter: 27.2% 7.1% 0.0%
[libx264 @ 0x55dd4a513aa0] i16 v,h,dc,p: 20% 25% 25% 30%
[libx264 @ 0x55dd4a513aa0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 26% 25%  4%  4%  4%  6%  3%  8%
[libx264 @ 0x55dd4a513aa0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 27% 18%  6%  6%  4% 10%  4% 13%
[libx264 @ 0x55dd4a513aa0] i8c dc,h,v,p: 73% 14% 11%  2%
[libx264 @ 0x55dd4a513aa0] Weighted P-Frames: Y:18.8% UV:5.9%
[libx264 @ 0x55dd4a513aa0] ref P L0: 67.5% 18.8% 10.3%  3.0%  0.5%
[libx264 @ 0x55dd4a513aa0] ref B L0: 96.9%  2.4%  0.7%
[libx264 @ 0x55dd4a513aa0] ref B L1: 98.4%  1.6%
[libx264 @ 0x55dd4a513aa0] kb/s:14841.31
[aac @ 0x55dd4a4b21c0] Qavg: 496.588

Update 2:
As I was told, the effect I was searching for is Crossfade.
I've found these:

FFmpeg command for crossfading between 5 videos. How to manage setpts=PTS-STARTPTS?,
Concate two video file with fade effect with ffmpeg in linux
What is video timescale, timebase, or timestamp in ffmpeg?

After some experiments I've finally got the working command for my purpose:
[0:v]setpts=PTS-STARTPTS[v0];
[1:v]setpts=PTS-STARTPTS+(23/TB),format=yuva444p,fade=st=23:d=1:t=in:alpha=1[v1];[v0][v1]overlay,format=yuv420p[v];
[0:a]asetpts=PTS-STARTPTS[a0];
[1:a]asetpts=PTS-STARTPTS[a1];
[a0][a1]acrossfade=d=1[a]

It works, but I have to set times for crossfade for every pair of videos manually
So what I want to ask again:

Is there any way to automate position for crossfade (last second of the video)? Is there any use for PREV_OUTPTS or PREV_INPTS? I didn't manage to get them work.
Can this effect be done with stream copy? There is no use for encoding the stream again.

Adapt the examples in https://superuser.com/a/834035/

I used an example for crossfade with the complex filter like this for video: [0:v]setpts=PTS-STARTPTS[v0];[1:v]setpts=PTS-STARTPTS+4/TB,format=yuva444p,fade=st=4:d=1:t=in:alpha=1[v1];. But this results in output with 4 seconds from the first video then crossfade and complete second video. I suppose something should be done with this [1:v]setpts=PTS-STARTPTS+4/TB and this fade=st=4: but didn't figure out the correct result

[Edit] your question to include your full command and the complete log.

@llogan, I've updated my question

Is there any way to automate position for crossfade (last second of the video)?

Not with ffmpeg alone (yet at least–there is a patch that never got applied that would simplify this). You can use  ffprobe to get the duration of each input and use that to determine the values for setpts and fade.
Example ffprobe command:
ffprobe -v error -show_entries format=duration -of csv=p=0 input.mp4

Is there any use for PREV_OUTPTS or PREV_INPTS? I didn't manage to get them work.

No. These do not refer to previous input/output streams or files.

Can this effect be done with stream copy? There is no use for encoding the stream again.

No. You can't filter and stream copy the same stream.

Thank you for answer and noting the use of ffprobe. Maybe in some time I'll manage to write script to automate this for me. By the way - will complex filters setpts and fade work with float numbers, for example 442.224 seconds?

@AlexanderY. Yes, but such accuracy can become moot due to the frame rate.

Thanks. Will experiment more.


text:
ffmpeg: convert an existing audio stream as an additional audio stream (keeping untouched original as well)
I have a video with 1 video stream, 2 audio streams (TrueHD 7.1 and E-AC3 5.1), a bunch of PGS subtitles and chapters.
I want to copy the video, convert the 7.1 audio into AAC, copy over the original 7.1 and 5.1 streams (so 3 audio streams), keep only French and English subtitles and all the metadata.
After a few trials, this command seems to do exactly that:
ffmpeg -i input.mkv -map 0:v:0 -map 0:a:0 -map 0:m:language:eng -map 0:m:language:fre -c copy -c:a:0 aac -b:a:0 512k output.mkv

Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (truehd (native) -> aac (native))
  Stream #0:1 -> #0:2 (copy) # truehd 7.1
  Stream #0:2 -> #0:3 (copy) # e-ac3 5.1
  Stream #0:3 -> #0:4 (copy) # (English subtitles)
  Stream #0:6 -> #0:5 (copy) # (French subtitles)

Now the question is... if I wanted to get rid of the e-ac3, how would I do that?

ffmpeg -i input.mkv -map 0:v:0 -c:v copy -map 0:a:0 -c:a:0 aac -b:a:0 512k -map 0:a:0 -c:a:1 copy -map 0:s:0 -c:s:0 copy -metadata:s:s:0 language=eng -map 0:s:1 -c:s:1 copy -metadata:s:s:1 language=fre output.mkv
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (truehd (native) -> aac (native))
Stream #0:1 -> #0:2 (copy) # truehd 7.1
Stream #0:3 -> #0:3 (copy) # (English subtitles)
Stream #0:6 -> #0:4 (copy) # (French subtitles)

If I've done this correctly it should only copy or encode what you asked for and nothing else..
-canvas_size 1920x804 (WidthxHeight of video.. Is needed to copy DVD & Blu-ray picture based subtitles over..)

And on a side note:
-map 0:m:language:eng (Missing Index on which stream metadata should be changed)
-map 0:m:language:fre (Missing Index on which stream metadata should be changed)
-c copy (This will copy all streams over regardless of mapping..)

source: Stack Exchange

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

sort: votes


text:
Line up photogrammetry mesh with tracking markers
I have some footage, which I've tracked in After Effects. I've exported that 3D tracked camera to C4D Lite. I then took photos of the filming location and used Meshroom (a photogrammetry tool) to generate a mesh from the photos.
Now I want to line up the photogrammetry mesh in C4D with nulls that I've placed relative to the tracking points in After Effects. What's the best way to do this? Or is there a better workflow to get a photogrammetry mesh lined up with tracked footage?
More info: Specifically, after watching Corridor's real-life portals video I decided to try to create my own portal effect. My plan is to take a rough photogrammetry mesh of the filming area. I would then track the camera in After Effects, somehow get that tracking data into a 3D modelling program, load the photogrammetry mesh in, line everything up so the tracked camera moves through the mesh as it does in the footage then rotate the camera and its animation 180° around the point where the portal mask is tracked onto the footage in AE. This would create a perfect replica of the camera's original motion, but looking out at the world from a different angle.
As such I can't just use the footage as the photogrammetry input, as I specifically need the photogrammetry mesh to include unseen areas of the world.

Ideally you would have used images of the footage in mushroom too then your solutions would converge and the locations of the camera positions would have been solved in one go. (photogramettery is sort of automated tracking)

@joojaa I'm not really sure what you mean. I'd still just get a mesh with no particular way to line it up with the camera tracking from AE. As in, I would have no way to get the scale, rotation and position of the mesh correct relative to the tracked camera.

No you get a mesh and postion of the cameras. See mushroom solves the camera position in the first pass.

@joojaa Well sure it solves the camera positions, but how would that be useful? I'm just not seeing the practical connection. I can't export the camera positions, and even if I could, I couldn't easily turn those positions into an animated camera in a 3D modelling program or After Effects. Plus the results of photogrammetry from video would be far inferior to those from photos, since sharp images give drastically better results.

Positions are animation

@joojaa You seem very confident of this process, but I still don't see how it could be useful. The positions are not animation on their own. Please explain how you would have 3D modelling software interpret a series of positions as animation unless they were already defined as such.

Well i dont use C4D but i have done this in Maya, Blender, and 3DS max several times. Just loop over the objects and keyframe one other camera to their potions.

@joojaa I have no particular interest in using C4D if I can use Blender, but I assumed this would be something other people do commonly with C4D Lite and AE so I only mentioned C4D. Perhaps you would like to write a more in-depth answer? Because "loop over the objects" doesn't sound like something you "just" do. Unless you are implying I should write a script to do this? But aside from that, that ultimately doesn't solve my problem. I'll update my question to be more specific.

Well everything seems overly complex if you dont know anything about it

Anyway you should be using video production stackexchange. Also meshroom can export camera as animation

@joojaa It seems overly complex because it should be overly complex. As in, there should be no reason to have to go to that much effort. It essentially boils down to needing a way to make a mesh in Blender (or C4D) line up based on 3 or 4 empties to another mesh with 3 or 4 empties, where the relative positions will never be quite precisely the same. I only now realise that's my actual problem. The difficulty comes in trying to search for such a thing...

Its not allways possible to make 3 things work together without a bit of script glue. Its not much harder than writing for items selected take item copy attribute to other item

@joojaa Any scripting is hard when you have to sift through a reference for every second line. I've never written a Blender script, except 10 years ago when I tried to make games with it. I could learn for sure but this is feeling like way more effort than it's worth.

You can allways give up on your idea isnetad. But im sure somebody has wirtten this script

@joojaa Oh I'm not giving up yet. https://blender.stackexchange.com/q/163459/41192 But it's definitely pretty tiresome when something seems like it should be so simple and easy but no one else even wanted to do the same thing so there's no help on it.

Your issue might be simpler than your question says. It does not particularity matter where the warp to object is from users point of view. just use meshroom to track scene 1 and scene 2. Export scene 1 as a camera animation. place yoru other stuff in that scene wherever you want it. make the portal in 3d render that. render scene 2.  do not track anything in AE. just comp the results so that 3d portal is alphamask. AE really does not do you any favors here.

In the end I decided to just learn how Blender's scripting works and wrote a script. I know there would be simpler ways to calculate the transformations but I'm no maths expert and I wanted to spend my time debugging my logic errors rather my maths errors.
Basically what this script does is take 3 input points (in the form of empties) relative to the photogrammetry mesh and 3 input points in the same position relative to the tracking data, then attempts to line them up with each other, bringing the photogrammetry mesh along with it. This actually works pretty well in my testing. It's obviously not the fastest workflow but it does work and that's the important part.
import bpy
import bmesh
from mathutils import Matrix

#####################################
# TO USE:
#
# 1) create empties at three easily-identified positions in tracking data, called ea1, ea2 and ea3
# 2) create empties at the same three positions but in photogrammetry data, called eb1, eb2 and eb3
#    NOTE: eb1, eb2 and eb3 must be positioned IN THE SAME ORDER as ea1, ea2 and ea3!
# 3) name the photogrammetry mesh "photogrammetry"
# 4) run the script and be amazed
#
#####################################

# from https://blender.stackexchange.com/a/118783/41192
def createLookRotation(forward, up):
    rot = Matrix.Identity(3)
    rot[0] = up                 # x
    rot[1] = forward.cross(up)  # y
    rot[2] = forward            # z
    rot = rot.transposed()
    return rot.to_quaternion()

def doMeshThing(obj, mesh, empty1, empty2, empty3):
    bm = bmesh.new()
    bm.verts.new(empty1.location)
    bm.verts.new(empty2.location)
    bm.verts.new(empty3.location)
    bm.verts.ensure_lookup_table()
    bm.faces.new([bm.verts[0], bm.verts[1], bm.verts[2]])
    bm.normal_update()
    bm.to_mesh(mesh)
    bpy.ops.object.select_all(action='DESELECT')
    obj.select = True
    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
    bm.faces.ensure_lookup_table()
    normal = bm.faces[0].normal
    guide = empty2.location - empty1.location
    quatRot = createLookRotation(normal, guide)
    obj.rotation_mode = 'QUATERNION'
    obj.rotation_quaternion = quatRot.inverted()
    bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
    obj.rotation_quaternion = quatRot
    bm.free()

ea1 = bpy.data.objects['ea1']
ea2 = bpy.data.objects['ea2']
ea3 = bpy.data.objects['ea3']
eb1 = bpy.data.objects['eb1']
eb2 = bpy.data.objects['eb2']
eb3 = bpy.data.objects['eb3']

mesha = bpy.data.meshes.new('mesha')
meshb = bpy.data.meshes.new('meshb')

obja = bpy.data.objects.new('obja', mesha)
objb = bpy.data.objects.new('objb', meshb)

scene = bpy.context.scene
scene.objects.link(obja)
scene.objects.link(objb)

doMeshThing(obja, mesha, ea1, ea2, ea3)
doMeshThing(objb, meshb, eb1, eb2, eb3)

bpy.context.scene.update()

# position and rotate objb (photogrammetry) to match position and rotation of obja (tracking)
photogrammetryMesh = bpy.data.objects['photogrammetry']
photogrammetryMesh.parent = objb
photogrammetryMesh.matrix_parent_inverse = objb.matrix_world.inverted()

objb.location = obja.location
objb.rotation_quaternion = obja.rotation_quaternion

# calculate average dimension difference here and scale
scaleDiffX = obja.dimensions.x / objb.dimensions.x
scaleDiffY = obja.dimensions.y / objb.dimensions.y
scaleDiffZ = obja.dimensions.z / objb.dimensions.z
#averageScaleDiff = (scaleDiffX + scaleDiffY + scaleDiffZ) / 3
averageScaleDiff = (scaleDiffX + scaleDiffY) / 2 # seems to be in local space, so z is useless
objb.scale.x = averageScaleDiff
objb.scale.y = averageScaleDiff
objb.scale.z = averageScaleDiff

bpy.context.scene.update()

parented_wm = photogrammetryMesh.matrix_world.copy()
photogrammetryMesh.parent = None
photogrammetryMesh.matrix_world = parented_wm

bpy.ops.object.select_all(action='DESELECT')
obja.select = True
bpy.ops.object.delete()
bpy.ops.object.select_all(action='DESELECT')
objb.select = True
bpy.ops.object.delete()

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


text:
How to embed cover art into MP4 without errors?
I want to add artwork to my MP4 file. How do I do this successfully / without errors?
I've tried these methods with numerous MP4 files, none worked.
If you would like to replicate the errors / bugs, here are the sample files I've used for this question.
I've tried the following:

ffmpeg -i sample.mp4 -i sample.png -map 0 -map 1 -c copy -disposition:v:0 attached_pic sample_w_artwork.mp4
as stated by Lukas

with this error:
[mp4 @ 0000019ee4852280] Could not find tag for codec h264 in stream #0, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

ffmpeg 4.2.2 (Windows build by Zeranoe)

atomicparsley sample.mp4 --artwork sample.png --overWrite

with no success; AtomicParsley
I get this message when executing the first time:
Started writing to temp file.
 Progress: =============================================>100%|
 Finished writing to temp file.

Executing the next (nth) time gives this:
Updating metadata...   completed.

Adding artwork through the GUI Tag Editor using both available versions: i686-w64 & x86_64-w64

with no success; it creates a sample.mp4.bak file, even though the software says that the operation was successful

can't insert any more links, because I got too little rep apparently

Mp3tag (mp3tag.de/en)

with no success; I can successfully add the image as a cover, but it's not visible in the File Explorer. After saving it says Saved tag in 1 of 1 files. The picture can been seen in Mp3tag though as if it's applied.

Tag&Rename (softpointer.com)

with no success; same story as with Mp3tag, I can apply and it's visible in the app, but not in File Explorer.

mp4v2 (https:// code.google.com/archive/p/mp4v2/downloads)

mp4tags.exe -picture sample.png sample.mp4
with no success; it executes with no (error)message
I found it on this thread
(https:// forum.videohelp.com/threads/388025-How-to-set-the-thumbnail-of-a-video-clip).
Have used the updated version which is the Windows build
(https:// forum.doom9.org/attachment.php?attachmentid=14314&d=1407985798).

iTunes

iTunes 12.10.6.2 (Microsoft Store version)
iTunes doesn't load the file into the library. I can run it fine though in QuickTime Player.
I didn't notice the 'Home Videos' tab. Now I can see it in there. I tried to apply the image, and it applied it only inside iTunes... So it's still not working for me.
I tried to convert the MP4 to M4A and then adding it to iTunes. I was finally successfully able to change the cover and it was visible in File Explorer. But that's not what I want.
I know for a fact that it's possible, because I've seen pictures on the Internet and YT and different threads where an answer is upvoted.

tag

https:// github.com/b4winckler/tag
The description is: Simple command line audio tag editor... After having to install millions of libraries and a package manager I was stuck with the compilation of the software, followed all the steps, didn't work.
I've also tried using MP4art as suggested by a comment on another issue about this. He didn't include a link to it so I went looking and found another issue about this. One comment recommended MP4art as well, with a link that's dead.

I believe I've used some other methods as well but can't think of them right now. Will update if I recall.
Any help is greatly appreciated.

On the mac I use subler, https://subler.org, which works perfect. Looks like you're using Windows, but if you've got access to a mac, give that a try. I initially went looking for a tool to do this on Windows as well, came across subler, and there was no going back to anything Windows for this task after that.

I'm pretty discouraged to install a whole MacOS VM... after all the things I've tried. I also think it'd be crippling to launch the VM every time I want to update / add a cover... you know what I mean. Thanks for the comment though.

If you don't have a mac I wouldn't necessarily go to that much trouble, I just happened to have both, and subler is the best tool I've found for this job by far. Usually you can find something on either platform, I'm not sure why there don't appear to be good Windows tools for the same task.

Well, the popular FFmpeg should do it just fine, but it doesn't, at least not for me.

In the Codec Tweak Tool under Miscellaneous > Thumbnails the checkbox for .mp4 was unchecked. After checking it and saving the settings it finally showed the thumbnail.
The Tweak Tool is installed with K-Lite Codec Pack. There are different editions available, I use the Standard edition so I can't talk for the other ones.
Credits for finding the solution: Furty from the same (copied) thread on Super User as a comment

ffmpeg -i sample.mp4 -i sample.png -map 0 -map 1 -c copy \
       -disposition:v:1 attached_pic sample_w_artwork.mp4

Just change v:0 to v:1.


text:
FFMPEG - Adding audio stream to existing MKV file (which includes an audio stream already) - Coming out squeaky
I am trying to add an additional audio steam (MP3) to an existing MKV file which currently contains a video and single audio stream, such that the output will have the video, and two alternative audio streams.
This is the command I am using:
ffmpeg -i input1.mkv -i input2.mp3 -map 0 -map 1 -c copy output.mkv

This appears to work fine, but when I play the resulting output video, and select the new audio stream, it sounds all squeaky (bit like Mickey Mouse on steroids).
For the avoidance of doubt, the original (default) audio stream (and the video) still work fine in the output file.
The original MPV and MP3 files are almost exactly the same length (the audio stream is 3/100 (0.03) of a second longer than the original video) — I am figuring that is not the cause?
Is there something obvious I am missing?
Thanks,
Alan.
Edit:  Log file (Added 20200115 - 1745):
 # ffmpeg -i input1.mkv -i input2.mp3 -map 0 -map 1 -c copy output.mkv

ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[matroska,webm @ 0x55857e84b960] Could not find codec parameters for stream 2 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 0x55857e84b960] Could not find codec parameters for stream 3 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from 'input1.mkv':
  Metadata:
    ENCODER         : Lavf57.83.100
  Duration: 02:20:37.43, start: 0.000000, bitrate: 15494 kb/s
    Chapter #0:0: start 0.000000, end 312.145000
    Metadata:
      title           : Chapter 01
    Chapter #0:1: start 312.145000, end 640.640000
    Metadata:
      title           : Chapter 02
    Chapter #0:2: start 640.640000, end 795.628000
    Metadata:
      title           : Chapter 03
    Chapter #0:3: start 795.628000, end 1038.329000
    Metadata:
      title           : Chapter 04
    Chapter #0:4: start 1038.329000, end 1418.459000
    Metadata:
      title           : Chapter 05
    Chapter #0:5: start 1418.459000, end 1646.228000
    Metadata:
      title           : Chapter 06
    Chapter #0:6: start 1646.228000, end 1919.584000
    Metadata:
      title           : Chapter 07
    Chapter #0:7: start 1919.584000, end 2279.861000
    Metadata:
      title           : Chapter 08
    Chapter #0:8: start 2279.861000, end 2465.922000
    Metadata:
      title           : Chapter 09
    Chapter #0:9: start 2465.922000, end 2827.658000
    Metadata:
      title           : Chapter 10
    Chapter #0:10: start 2827.658000, end 3075.698000
    Metadata:
      title           : Chapter 11
    Chapter #0:11: start 3075.698000, end 3253.083000
    Metadata:
      title           : Chapter 12
    Chapter #0:12: start 3253.083000, end 3420.500000
    Metadata:
      title           : Chapter 13
    Chapter #0:13: start 3420.500000, end 3620.450000
    Metadata:
      title           : Chapter 14
    Chapter #0:14: start 3620.450000, end 3862.692000
    Metadata:
      title           : Chapter 15
    Chapter #0:15: start 3862.692000, end 4150.813000
    Metadata:
      title           : Chapter 16
    Chapter #0:16: start 4150.813000, end 4264.177000
    Metadata:
      title           : Chapter 17
    Chapter #0:17: start 4264.177000, end 4433.220000
    Metadata:
      title           : Chapter 18
    Chapter #0:18: start 4433.220000, end 4622.660000
    Metadata:
      title           : Chapter 19
    Chapter #0:19: start 4622.660000, end 4955.159000
    Metadata:
      title           : Chapter 20
    Chapter #0:20: start 4955.159000, end 5097.801000
    Metadata:
      title           : Chapter 21
    Chapter #0:21: start 5097.801000, end 5339.042000
    Metadata:
      title           : Chapter 22
    Chapter #0:22: start 5339.042000, end 5658.111000
    Metadata:
      title           : Chapter 23
    Chapter #0:23: start 5658.111000, end 5821.024000
    Metadata:
      title           : Chapter 24
    Chapter #0:24: start 5821.024000, end 5939.976000
    Metadata:
      title           : Chapter 25
    Chapter #0:25: start 5939.976000, end 6349.260000
    Metadata:
      title           : Chapter 26
    Chapter #0:26: start 6349.260000, end 6614.691000
    Metadata:
      title           : Chapter 27
    Chapter #0:27: start 6614.691000, end 6928.922000
    Metadata:
      title           : Chapter 28
    Chapter #0:28: start 6928.922000, end 7124.951000
    Metadata:
      title           : Chapter 29
    Chapter #0:29: start 7124.951000, end 7397.181000
    Metadata:
      title           : Chapter 30
    Chapter #0:30: start 7397.181000, end 7625.243000
    Metadata:
      title           : Chapter 31
    Chapter #0:31: start 7625.243000, end 8004.205000
    Metadata:
      title           : Chapter 32
    Chapter #0:32: start 8004.205000, end 8437.440000
    Metadata:
      title           : Chapter 33
    Stream #0:0(jpn): Video: h264 (High), yuv420p(progressive), 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Metadata:
      BPS             : 14020404
      BPS-eng         : 14020404
      DURATION-eng    : 02:20:37.429000000
      NUMBER_OF_FRAMES: 202296
      NUMBER_OF_FRAMES-eng: 202296
      NUMBER_OF_BYTES : 14787020951
      NUMBER_OF_BYTES-eng: 14787020951
      _STATISTICS_WRITING_APP: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_DATE_UTC: 2015-01-01 03:24:43
      _STATISTICS_WRITING_DATE_UTC-eng: 2015-01-01 03:24:43
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 02:20:37.428000000
    Stream #0:1(jpn): Audio: truehd, 48000 Hz, 5.1(side), s32 (24 bit) (default)
    Metadata:
      BPS             : 1353728
      BPS-eng         : 1353728
      DURATION-eng    : 02:20:37.429000000
      NUMBER_OF_FRAMES: 10124915
      NUMBER_OF_FRAMES-eng: 10124915
      NUMBER_OF_BYTES : 1427748260
      NUMBER_OF_BYTES-eng: 1427748260
      _STATISTICS_WRITING_APP: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_DATE_UTC: 2015-01-01 03:24:43
      _STATISTICS_WRITING_DATE_UTC-eng: 2015-01-01 03:24:43
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 02:20:37.428000000
    Stream #0:2(eng): Subtitle: hdmv_pgs_subtitle
    Metadata:
      BPS             : 7584
      BPS-eng         : 7584
      DURATION-eng    : 02:18:21.752000000
      NUMBER_OF_FRAMES: 1870
      NUMBER_OF_FRAMES-eng: 1870
      NUMBER_OF_BYTES : 7870766
      NUMBER_OF_BYTES-eng: 7870766
      _STATISTICS_WRITING_APP: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_DATE_UTC: 2015-01-01 03:24:43
      _STATISTICS_WRITING_DATE_UTC-eng: 2015-01-01 03:24:43
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 02:20:32.174000000
    Stream #0:3(eng): Subtitle: hdmv_pgs_subtitle
    Metadata:
      BPS             : 12266
      BPS-eng         : 12266
      DURATION-eng    : 02:18:28.759000000
      NUMBER_OF_FRAMES: 2556
      NUMBER_OF_FRAMES-eng: 2556
      NUMBER_OF_BYTES : 12739742
      NUMBER_OF_BYTES-eng: 12739742
      _STATISTICS_WRITING_APP: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_DATE_UTC: 2015-01-01 03:24:43
      _STATISTICS_WRITING_DATE_UTC-eng: 2015-01-01 03:24:43
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 02:20:32.174000000
Input #1, mp3, from 'input2.mp3':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf57.83.100
  Duration: 02:20:37.46, start: 0.023021, bitrate: 128 kb/s
    Stream #1:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s
    Metadata:
      encoder         : Lavc57.10
Output #0, matroska, to 'output.mkv':
  Metadata:
    encoder         : Lavf57.83.100
    Chapter #0:0: start 0.000000, end 312.145000
    Metadata:
      title           : Chapter 01
    Chapter #0:1: start 312.145000, end 640.640000
    Metadata:
      title           : Chapter 02
    Chapter #0:2: start 640.640000, end 795.628000
    Metadata:
      title           : Chapter 03
    Chapter #0:3: start 795.628000, end 1038.329000
    Metadata:
      title           : Chapter 04
    Chapter #0:4: start 1038.329000, end 1418.459000
    Metadata:
      title           : Chapter 05
    Chapter #0:5: start 1418.459000, end 1646.228000
    Metadata:
      title           : Chapter 06
    Chapter #0:6: start 1646.228000, end 1919.584000
    Metadata:
      title           : Chapter 07
    Chapter #0:7: start 1919.584000, end 2279.861000
    Metadata:
      title           : Chapter 08
    Chapter #0:8: start 2279.861000, end 2465.922000
    Metadata:
      title           : Chapter 09
    Chapter #0:9: start 2465.922000, end 2827.658000
    Metadata:
      title           : Chapter 10
    Chapter #0:10: start 2827.658000, end 3075.698000
    Metadata:
      title           : Chapter 11
    Chapter #0:11: start 3075.698000, end 3253.083000
    Metadata:
      title           : Chapter 12
    Chapter #0:12: start 3253.083000, end 3420.500000
    Metadata:
      title           : Chapter 13
    Chapter #0:13: start 3420.500000, end 3620.450000
    Metadata:
      title           : Chapter 14
    Chapter #0:14: start 3620.450000, end 3862.692000
    Metadata:
      title           : Chapter 15
    Chapter #0:15: start 3862.692000, end 4150.813000
    Metadata:
      title           : Chapter 16
    Chapter #0:16: start 4150.813000, end 4264.177000
    Metadata:
      title           : Chapter 17
    Chapter #0:17: start 4264.177000, end 4433.220000
    Metadata:
      title           : Chapter 18
    Chapter #0:18: start 4433.220000, end 4622.660000
    Metadata:
      title           : Chapter 19
    Chapter #0:19: start 4622.660000, end 4955.159000
    Metadata:
      title           : Chapter 20
    Chapter #0:20: start 4955.159000, end 5097.801000
    Metadata:
      title           : Chapter 21
    Chapter #0:21: start 5097.801000, end 5339.042000
    Metadata:
      title           : Chapter 22
    Chapter #0:22: start 5339.042000, end 5658.111000
    Metadata:
      title           : Chapter 23
    Chapter #0:23: start 5658.111000, end 5821.024000
    Metadata:
      title           : Chapter 24
    Chapter #0:24: start 5821.024000, end 5939.976000
    Metadata:
      title           : Chapter 25
    Chapter #0:25: start 5939.976000, end 6349.260000
    Metadata:
      title           : Chapter 26
    Chapter #0:26: start 6349.260000, end 6614.691000
    Metadata:
      title           : Chapter 27
    Chapter #0:27: start 6614.691000, end 6928.922000
    Metadata:
      title           : Chapter 28
    Chapter #0:28: start 6928.922000, end 7124.951000
    Metadata:
      title           : Chapter 29
    Chapter #0:29: start 7124.951000, end 7397.181000
    Metadata:
      title           : Chapter 30
    Chapter #0:30: start 7397.181000, end 7625.243000
    Metadata:
      title           : Chapter 31
    Chapter #0:31: start 7625.243000, end 8004.205000
    Metadata:
      title           : Chapter 32
    Chapter #0:32: start 8004.205000, end 8437.440000
    Metadata:
      title           : Chapter 33
    Stream #0:0(jpn): Video: h264 (High) (H264 / 0x34363248), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      BPS             : 14020404
      BPS-eng         : 14020404
      DURATION-eng    : 02:20:37.429000000
      NUMBER_OF_FRAMES: 202296
      NUMBER_OF_FRAMES-eng: 202296
      NUMBER_OF_BYTES : 14787020951
      NUMBER_OF_BYTES-eng: 14787020951
      _STATISTICS_WRITING_APP: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_DATE_UTC: 2015-01-01 03:24:43
      _STATISTICS_WRITING_DATE_UTC-eng: 2015-01-01 03:24:43
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 02:20:37.428000000
    Stream #0:1(jpn): Audio: truehd ([255][255][255][255] / 0xFFFFFFFF), 48000 Hz, 5.1(side), s32 (24 bit) (default)
    Metadata:
      BPS             : 1353728
      BPS-eng         : 1353728
      DURATION-eng    : 02:20:37.429000000
      NUMBER_OF_FRAMES: 10124915
      NUMBER_OF_FRAMES-eng: 10124915
      NUMBER_OF_BYTES : 1427748260
      NUMBER_OF_BYTES-eng: 1427748260
      _STATISTICS_WRITING_APP: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_DATE_UTC: 2015-01-01 03:24:43
      _STATISTICS_WRITING_DATE_UTC-eng: 2015-01-01 03:24:43
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 02:20:37.428000000
    Stream #0:2(eng): Subtitle: hdmv_pgs_subtitle ([255][255][255][255] / 0xFFFFFFFF)
    Metadata:
      BPS             : 7584
      BPS-eng         : 7584
      DURATION-eng    : 02:18:21.752000000
      NUMBER_OF_FRAMES: 1870
      NUMBER_OF_FRAMES-eng: 1870
      NUMBER_OF_BYTES : 7870766
      NUMBER_OF_BYTES-eng: 7870766
      _STATISTICS_WRITING_APP: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_DATE_UTC: 2015-01-01 03:24:43
      _STATISTICS_WRITING_DATE_UTC-eng: 2015-01-01 03:24:43
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 02:20:32.174000000
    Stream #0:3(eng): Subtitle: hdmv_pgs_subtitle ([255][255][255][255] / 0xFFFFFFFF)
    Metadata:
      BPS             : 12266
      BPS-eng         : 12266
      DURATION-eng    : 02:18:28.759000000
      NUMBER_OF_FRAMES: 2556
      NUMBER_OF_FRAMES-eng: 2556
      NUMBER_OF_BYTES : 12739742
      NUMBER_OF_BYTES-eng: 12739742
      _STATISTICS_WRITING_APP: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.4.0 ('Circles') 64bit built on Dec 12 2014 12:19:56
      _STATISTICS_WRITING_DATE_UTC: 2015-01-01 03:24:43
      _STATISTICS_WRITING_DATE_UTC-eng: 2015-01-01 03:24:43
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 02:20:32.174000000
    Stream #0:4: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 128 kb/s
    Metadata:
      encoder         : Lavc57.10
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
  Stream #0:3 -> #0:3 (copy)
  Stream #1:0 -> #0:4 (copy)
Press [q] to stop, [?] for help
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=12153.6kbits/s speed=15.7x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=14942.8kbits/s speed=9.25x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=15239.4kbits/s speed=7.54x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=14992.4kbits/s speed=7.55x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=15474.4kbits/s speed=7.13x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=15580.3kbits/s speed=7.01x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=15632.8kbits/s speed=6.98x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=15709.1kbits/s speed= 6.9x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=15599.5kbits/s speed=6.91x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=15762.9kbits/s speed=6.82x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=15724.3kbits/s speed=6.82x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampte=15615.7kbits/s speed=6.84x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15626.0kbits/s speed=6.83x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15550.4kbits/s speed=6.83x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15530.4kbits/s speed=6.82x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15632.8kbits/s speed=6.76x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15639.4kbits/s speed=6.73x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15771.6kbits/s speed=6.65x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15801.6kbits/s speed=6.63x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15799.3kbits/s speed=6.63x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15745.5kbits/s speed=6.64x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15784.7kbits/s speed=6.61x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15793.7kbits/s speed=6.61x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15865.5kbits/s speed=6.57x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15985.6kbits/s speed= 6.5x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15995.0kbits/s speed=6.49x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=16084.9kbits/s speed=6.44x
[matroska @ 0x55857e89aba0] Starting new cluster due to timestampate=15632.1kbits/s speed=6.62x
frame=202296 fps=159 q=-1.0 Lsize=16093151kB time=02:20:37.42 bitrate=15625.0kbits/s speed=6.62x
video:14440450kB audio:1526121kB subtitle:56055kB other streams:0kB global headers:0kB muxing overhead: 0.440162%

Share full log. Which player?

Hi Gyan - Do you mean the full output I get when I run the command in my OP?  If not, please advise which log.  Thanks,  Alan.

Full log from the ffmpeg command. What player(s) did you try?

Log added to question.  I only tried playing it with the default player in Ubuntu (Totem Movie Player) which is what I would (hope to) use to watch the video too:  [totem:
Installed: 3.26.0-0ubuntu6.2
Candidate: 3.26.0-0ubuntu6.2
Version table:
*** 3.26.0-0ubuntu6.2 500
500 http://nz.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
100 /var/lib/dpkg/status
3.26.0-0ubuntu6 500
500 http://nz.archive.ubuntu.com/ubuntu bionic/main amd64 Packages]

Does another player show the same behavior? Try a more recent ffmpeg: either download the git master version or follow a guide to compile. Or use snap to install ffmpeg if you prefer but I am not sure what version it provides.

Hi - Windows 10 Pro default player has no problem, so it must be something to do with Totem on Ubuntu I guess.  Unless anyone has another view, I'll close this as not being anything to do with FFMPEG.

Did you try given different commands to copy the codecs?
You're trying to mix sources, with different codecs in each source.
Also, I will specify more precisely the video stream, if you stream is 0:0 I rather use that.
Something like:
ffmpeg -i input1.mkv -i input2.mp3 -map 0:0 -map 1 -c:v copy -c:a copy output.mkv

It is not relevant if the length of the audio stream is different.

Hi Claudio,  To be honest, it has been over a year, and I cannot now recall what the file was that gave me the issues.  However, given that one player had no problem, and another did, is strongly suggestive that the issue is within the player, and not related to FFMPEG.  Thanks, Alan.


text:
Contrast equalizer OFX plugin
I'm looking for Contrast equalizer OFX plugin, or similar functionality.
If you don't similar about it, Contrast Equalizer can manage contrasts on different level of details, like you have several Hi-pass/low-pass filters with different radius in one simple setup. It has similar functionality in DR - mid tone details, but it does not affect all tones and various details sizes.
Examples how it works:

Resolve already has a few built in.
The "Beauty" plugin is what looking for, if you're trying to do what Photoshoppers sometimes call the "frequency separation" method of skin refinement.  It controls blur/sharpness based on different detail thresholds.  In Resolve, you'll want to select "Advanced" from the dropdown menu to get access to the Hi/Low rolloff sliders, although they have unusual names ("Smoothing threshold", "Diffuse Lighting", etc, which doesn't actually have anything to do with Lighting).
The image you posted looks like what "Beauty" does, but when you talk about Davinci's Midtone Detail slider, you're looking for something more like "Contrast Pop."
Contrast Pop works similarly, but instead of letting you blur/sharpen based on a detail threshold, it lets you adjust midtone detail based on adjustable thresholds.  Again, the plugin name is bad, and I didn't discover it for a while because the name was so distasteful, but It's probably close to what you're looking for, and works well in conjunction with "Beauty".
"De-flicker" also lets you qualify the plugin's application based on a threshold, and then blends the image temporally, over a number of frames, in the chosen regions.  It uses optical flow motion estimation to set the threshold, however, and might not work exactly like you need, but it might be worth a shot, depending on what you're doing.
Those are the three built-in ones that come to mind, and you could always roll your own, so to speak.  If you google "frequency separation" and watch some photoshop videos, the technique can be achieved with Resolve nodes fairly simply, and adapted however you see fit.  Once you've got a setup that works, save it as a "power grade," and it'll be accessible from all of your new projects.  No need for a plugin.


text:
Issues with transcoding to a MXF container
I'm new here, so hi to all :).
I'm new to FFmpeg too, and I'm trying to transcode a HEVC file to a mxf file and I'm having some issues. The original file is a rip I made from a Bluray HDR movie a while ago, its container is mkv, and I honestly didn't remember the codec I used and all that stuff, but Mediainfo is telling me that it's HEVC, UHD, main 10, level 5, RC. 2020, cbr, 4:2:0, 10 bit. The thing is that I want to make a trailer in Adobe Premiere Pro, which I've been using for a while and now I'm dealing with its 2020 version (which, to be honest, it's not so good because of random crashes). I intend to export an HDR video, even knowing that Premiere's internal monitors don't support REC. 2020 yet.
Since Premiere doesn't accept mkv files, and I want to lose the less amount of quality possible (hence, I don't want to make too many transcoding steps), I tried to take the proxy approach, but after trying many times I couldn't make them sync with the original footage (the proxy was always a couple of seconds late or early compared to the original file, which defeats its purpose for editing). The only ones that didn't have this issues where the ones made with DNxHD/DNxHR (I guess it could be related to them being cbr as the source files, while Prores is vbr. Idk, it's just a theory), but even though they are synced with the footage, I get stability issues with them as proxies (the program hangs when trying to manipulate them, even moving a clip or making a cut many times caused a crash).
Well, after all this, I decided to try to edit with a high rip of the original file, with a non long-OP format but with high quality, so I could export directly from it (hence, no proxies). The choice was between a Prores flavor, or a DNxHR flavor, and I decided to go for DNxHR because, idk, I've always preferred cbr for streaming and quality purposes. File size is not an issue for me, and I have a beast of a PC to handle them. Since I want to retain the most quality from the original, I used FFmpeg to transcode to a DNxHR RGB 444 10 bit file into a mxf container (which I've read it's better than MOV for editing purposes) from the original mkv file, but after trying many times I read that on the audio side the mxf container only accepts pcm audio, and my mkv file has two streams, both DTS 5.1. Apparently that's why my FFmpeg command worked for the video part, but always gave an error on the audio part. This was my initial command:
ffmpeg -i 1.mkv -map 0:0 -c:v dnxhd -profile:v dnxhr_444 -pix_fmt yuv444p10le -c:a \
   -map 0:2 aac -b:a 640k 1.mxf

(audio stream 2 is the one I need, hence the 0:2. I need a single file for editing, with only one language, which is the second stream).
Well, that command didn't work, and I realized that it worked only if I changed the extension of the output file to MOV, so it's a container limitation I guess.
Here's my problem: I could easily create a mxf file with the video as DNxHR 444 10 bits and the audio as uncompressed pcm in 6 channels (the source file is 5.1), with this command:
ffmpeg -i 1.mkv -map 0:0 -c:v dnxhd -profile:v dnxhr_444 -pix_fmt yuv444p10le -c:a copy 1.mxf

It sounded like the ideal command to me, because I want to retain the 5.1 audio, and just copying the stream sounds like a good idea to me. Ffmpeg did its job, but when I imported the file to Adobe Premiere Pro, I could see that the audio couldn't be placed in a 5.1 track, but in 6 individual mono tracks. I could use this, but it's really annoying having to edit with 6 separated tracks for every single cut or clip. In other words, I wanted to edit with a DNxHR 444 10 bits and 5.1 audio with their tracks being recognized by Premiere as a true 5.1 audio, and showed as only one 5.1 track. If I rip the original mkv movie to, let's say, h.264, it creates a 5.1 audio track without issues, but editing in h.264 is not ideal at all.
The question is simple. What would you do? I'm still trying to do this with DNxHR 444 10 bits, but I'm starting to assume that I won't be able to incorporate the audio inside a mxf file without it being separated into individual pcm tracks.
Ideas that I had, and wanted to know your opinion, or if you have a better idea:

Create a DNxHR 444 10 bits only with the video stream, no audio. Create a m4u file for the audio stream using aac or ac3 as codec, with -channel_layout 63 command. That way, I guess I'm going to be able to import the video file, the audio file, and link them inside Premiere. The editing, color grading and exporting would be done directly from those files, not the originals. Not ideal at all, but could be an idea at least.
Use ffmpeg to create the master file with DNxHR 444 10 bits and copy the audio stream or transcode it with aac or ac3, but to a MOV container, which seems to support those audio formats. Could be an option, I've not tried it yet to see if the audio is recognized as a single 5.1 track inside Premiere.
Give up on DNxHR, and use a Prores flavor. I've read that it's not the best format to encode when working on a PC (I'm not a Mac guy), and that because of it being vbr, sometimes the dark areas could suffer some quality loss (remember that I want to export in HDR). The original footage is cbr too.
Edit with the separated six tracks. I really want to avoid this.
Somehow go with the proxy route, but like I said, the sync problem is always present unless I use DNxHD/DNxHR, and when using them I see the 6 separated tracks, which is one of the things I want to avoid. I don't know how to go with this route.

Any ideas? This is my first hdr project and I'm having this elemental issues. What would you do? Thanks in advance.
PD: I used the last version of FFmpeg , and have an AMD 2990WX cpu, with 64 GB ram, a Nvidia GTX 1070 card, Windows 10 with the latest drivers and latest version of K-Lite codec pack. Using Adobe Premiere Pro 2020, and sometimes Adobe Media Encoder 2020. Adobe Premiere is optimized for memory use, not performance. Sadly, I still have a sdr monitor for the meanwhile.
UPDATE: A friend of mine, after telling him about the issues I'm having, said to me that I should stop worrying about the container, so his suggestion was to use FFmpeg to transcode the original mkv file (h.264 main 10, level 5, REC. 2020, cbr, 4:2:0, 10 bits) to a mov container, with DNxHR 444 10 bits and AC3 as codecs (or just copy the original audio stream), because for this purpose having the master file in mxf or mov container is not going to make a difference in quality or performance. Is that so? I'm still learning all I can but I've read more than once that mov should not be used as often, as it's an old type of container with certain limitations (I don't know what they are. I still have a lot of reading to do, but I've read that mxf is a better container in other forums too). If that's a good idea, the command would be the following (please correct me if I'm wrong):
ffmpeg -i 1.mkv -map 0:0 -c:v dnxhd -profile:v dnxhr_444 -pix_fmt yuv444p10le -c:a aac -b:a 640k -map 0:2 1.mov
Would you do that? Would it work if I just copy the audio stream (in that case, after -c:a I would just add "copy -map 0:2 1.mov")?
IN SUMMARY:
My main goal with all of this is having a non long-GOP file with the highest quality for editing, color correcting and exporting directly from it, preserving all the hdr data, and keeping the audio as 5.1 that can be recognized by Premiere Pro as a single 5.1 track and not six individual tracks. I was going for DNxHR 444 10 bit (cbr as my original file), but can't figure out the audio issue with a mxf container, and I could transcode to a mov container without problems. I'd like to know if there's some catch with using a mov container instead of mxf, and also I would like to know what would you do in my situation (and if there's an extra idea about how to use proxies with my original file without having sync issues, please let me know).
Thanks again.

I could see that the audio couldn't be placed in a 5.1 track, but in 6 individual mono tracks

I just ran a quick test on my machine, and while a 6 channel mxf does import by default into Premiere with 6 mono tracks, if you right-click and run modify > audio channels on the imported clip, you can can change the clip channel format to 5.1 and the number of audio clips to 1, which should then let you add the clip to the timeline in the way you want.

You should be able to use FFMPEG to reassign the channels such that Premiere be able to recognize it as 5.1 channel layout.
ffmpeg \
  -filter_complex \
    "[0:a]pan=FL|c0=c0[a0];[0:a]pan=FR|c0=c1[a1];....;\
    [a0][a1]..[a5]amerge=inputs=6[aout]" \
  -c:a pcm_s24le \
  -map "[aout]"

Documentation: https://trac.ffmpeg.org/wiki/AudioChannelManipulation


text:
FFmpeg: DNxHR 444 10 bits transcoding issue (HDR project). SMPTE2084 unsupported?
I have a couple of questions regarding intra-frame codecs for editing purposes (in Premiere Pro).
UPDATE (01/24/20). More details of the original issue after this:
I seem to have encountered a dead end. While transcoding I noticed that the source file was tv, bt2020nc/bt2020/smpte2084 (I mean range, space, etc.), and when trying to transcode with the command specified down below (after this UPDATE) FFmpeg didn't say anything about those settings. I started to do some test giving FFmpeg input and output commands (-color_space 1, -color_trc 16, -colorspace 9, etc), and now it started to show the correct values while transcoding (bt2020nc...).
The command line for that test was:
ffmpeg -color_range 1 -color_primaries 9 -colorspace 9 -color_trc 16 -channel_layout 63 -i input.mkv -map 0:0 -c:v dnxhd -profile:v dnxhr_444 -pix_fmt yuv444p10le -color_range 1 -color_primaries 9 -colorspace 9 -color_trc 16 -acodec pcm_s24le -ar 48000 -ac 6 -channel_layout 63 -map 0:2 -hide_banner output.mxf
I read that those commands only add the flags to the container, but doesn't transcode or do anything to the stream itself. Like I said, while transcoding with that command line it said yuv444p10le (tv /bt2020nc,bt2020,smpte2084), the same as the source file, but when running FFprobe it still says yuv444p10le(bt709/unknown/unknown, progressive). The rest is fine (correct DNxHR profile, fps, resolution).
My guess was that those commands were only adding flags that maybe FFprobe and players don't actually read or use (the videos still look very different from the original footage), so I added a command using colorspace filter for actual conversion:
ffmpeg -color_range 1 -color_primaries 9 -colorspace 9 -color_trc 16 -channel_layout 63 -i input.mkv -map 0:0 -c:v dnxhd -vf format=yuv420p10le,colorspace=all=bt2020:trc=smpte2084:range=tv:primaries=bt2020:space=bt2020ncl -profile:v dnxhr_444 -pix_fmt yuv444p10le -color_range 1 -color_primaries 9 -colorspace 9 -color_trc 16 -acodec pcm_s24le -ar 48000 -ac 6 -channel_layout 63 -map 0:2 -hide_banner output.mxf
With that, I couldn't make past the initial checks because it says "unsupported input transfer characteristics 16 (smpte2084). No matter what I do with the colorspace filter, the output is always the same. The same happens if I delete the "trc=smpte2084" line. Anyway, that's the only error message I'm getting now, but seems like a dead end if it's not supported. And if I don't use the colorspace filter and only the flags (-color_trc...), it transcodes without issues, but FFprobe says it's BT709 (and behaves like a BT709 video while comparing it to the original footage using VLC).
QUESTIONS: Is SMPTE2084 really unsupported? Any workaround for this? Is it really possible to have BT2020 and true HDR with DNxHR 444 10 bits in a MXF container using FFmpeg? If not, any suggestions? Already tried with Adobe Media Encoder 2020, same results, but you don't have much settings to tweak there.
Thanks in advance.
INITIAL ISSUE:
A LITTLE CONTEXT:
I ripped a HDR movie to a MP4 container some months ago, using H.264 as codec (high 10, level 5, UHD, YUV, subsampling 4:2:0). The video looks great, as it should. Now I want to edit a trailer for that movie (I edit in Adobe Premiere Pro, current version), and for fast playback I need to work with proxies or transcode the source file to an intra-frame non long GOP file and use it as the source file (hopefully as lossless as that transcoding step can be). I tried for several days to transcode the source file to DNxHR 444 10 bits (using FFmpeg and then Adobe Media Encoder), but the result was always a video with the colors messed up (sometimes very washed out, sometimes over saturated).
FFprobe of the resulting DNxHR file said that the color space was BT709 (source file is obviously BT2020), and I don't know why. The transcoding involved upsampling since the source file is 4:2:0 and DNxHR doesn't support it, but I tried upsampling to 4:4:4 and also to 4:2:2, and both of those files looked exactly the same to me, and very different from the original footage (so, I don't think upsampling is the cause of the color issue, but maybe the apparent color space change or something wrong with the metadata). The results were the same when transcoding with Adobe Media Encoder. Anyway, I seem to have given up transcoding to DNxHR and use it as the source file, unless someone has an idea of what's causing this problem. I could have worked with the source file for exporting and DNxHR LB for proxies, but there were sync issues (between source file and proxy) that defeated all purposes while editing. Prores is out of the picture, sync issues were worse (several seconds of delay).
For the record, the command used that didn't work as expected (color wise) is:
ffmpeg -channel_layout 63 -i input.mkv -map 0:0 -c:v dnxhd -vf "scale=in_range=limited:out_range=full" -color_range 2 -profile:v dnxhr_444 -pix_fmt yuv444p10le -acodec pcm_s24le -ar 48000 -ac 6 -channel_layout 63 -map 0:2 -hide_banner output.mxf
I also tried without the commands "scale=in_range=limited:out_range=full" and "-color_range 2", with same results. Always used FFmpeg latest version, and I'm working in Windows 10 Pro, latest drivers and latest Klite codec pack. Video files were compared with Mediainfo, FFprobe, and visually with VLC.
Well, like I said, I'm giving up using DNxHR as the source file for my project (it would have been ideal since it doesn't have sync issues with the DNxHR proxies, and file size is not a problem for me). A user here at the forums suggested transcoding and use H.264 intra-frame as source file, which I didn't know was an option (I didn't know H.264 was capable of intra-frame, my bad). I'm aware that one should avoid unnecesary transcoding steps, but I can't work with a H.264 UHD HDR source file (ultra slow playback), and the sync issues with proxies, no matter the codec, make it impossible to make accurate cuts. So, bottom line, I need to find a way to fix the color issue when transcoding to DNxHR, or try with an inter-frame codec that's not DNxHR and that's capable of preserving all the HDR info (and then see if it doesn't have sync issues. I'm assuming that those may dissapear when using intra-frame for both source file and proxies).
NOTE: When importing the DNxHR 444 file to Premiere Pro and looking at the Lumetri scopes tab, you can tell that the colors are clipped at 100 nits, like a regular SDR video. So apparently the color space was really reduced to BT709, and I don't know why. The H.264 source file behaves as expected, with colors going past 100 nits.
MY QUESTIONS:
1) Is H.264 intra-frame a good format for editing with a good playback performance?
2) If H.264 intra-frame is a good option, what would be the advantages of the DNxHR codec (or Prores) over it for editing purposes? Everybody suggests DNxHD/DNxHR or Prores as intermediate codecs, but if intra-frame H.264 has the same advantages for editing and supports HDR, what would be the reason to choose another codec like DNxHR?
3) Any ideas on what could be the cause of the colors not transcoding correctly from the H.264 source file to the DNxHR 444 10 bits one? The command looks ok to me, but FFprobe output says the DNxHR video is BT709, while with the source file it says BT2020. Like I said, apparently there's something wrong with the transcoding process regarding metadata or color space.
4) I haven't tried to transcode the source file to a DNxHR 444 10 bits video file, but in a MOV container. I don't know how this works internally, but maybe the color issue has something to do with the container metadata or something. I may try this if there's not another suggestion (transcoding this kind of files, as you know, takes time, so I'll wait for some ideas first).
NOTE: I tried to transcode the source file in the same way (DNxHR 444, 10 bits, etc) with Adobe Media Encoder 2020 and the result was the same, with colors messed up and FFprobe saying the video is BT709. Also tried transcoding to DNxHR HQX profile (10 bits), same result.
Any help would be greatly appreciated.
Thanks in advance.

Just a few notes: 1) HDR as per spec needs to be 10-bit.  2) Metadata flagging, gamma/color encode/decode is a messy situation, and has been for nearly 30 years.  3) You might find this ongoing discussion on the subject helpful: https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=101253  and finally, 4) On SE, you should try to limit your questions to one question per "Question," if ya know what I mean.

Oh, also, don't do your color correction using proxies.  Edit with proxies if you need to, color correct the original footage, and cache the original footage to ram and loop playback if it's important that you see the image move.  Otherwise, park the playhead.

Yep, I’m aware of that. None of the transcoding steps I’ve made involve going lower (or higher) than 10 bits, I’ve always stayed on that bit depth to avoid extra conversion. 2) I know, and I’m suffering from it now  3) Thanks! I’m already reading it. Not sure if it’s going to help me to troubleshoot this, but I have a lot to learn about this. 4) Sorry, my reasoning was to put all my question related to the same topic on one post, to avoid multiple posts. My bad, won’t happen again, and thanks for your reply. PS: I never color correct with proxies, I use the high quality footage for that.

According to what I’ve read, now I’m not even sure if it’s possible to preserve HDR data when transcoding to DNxHR. The farther I could get with FFmpeg was that it showed the correct data WHILE transcoding (bt2020nc,bt2020, etc), but either FFprobe still showed bt709 on the resulting file, or stopped and showed an error message saying smpte2084 is unsupported. Apparently all the HDR important metadata info is only preserved when transcoding to codecs like h.264, but not DNxHR. And the video doesn’t look like HDR at all. I guess I’ll just have to give up, I can’t seem to find a way to fix this

Have you tried H.265 HEVC?  I've seen people say they'll go prores out of Resolve, then use AME to transcode to HEVC, and it handles the flagging correctly.  It's been a while since I messed with it.

You mean editing with a non long-GOP format and exporting to HEVC? Yep, same results. The problem has never been the final export, but preserving colors while transcoding from source file to an intermediate codec like DNxHR. Summary of the situation: Proxies with DNxHR or Prores have sync issues if the source file is the original H.264 (that way I can’t edit properly). Only way I’ve found to avoid sync issues so far: DNxHR for both source file and proxies. And neither preserve the HDR data. So exporting to HEVC still doesn’t look as HDR because the source file isn’t HDR either.

And if you meant transcoding the H.264 original file to HEVC and then use the latter as source file (and DNxHR for proxies), I get the same sync issues than with the H.264 one.

Sorry, missed the bit about sync issues earlier.  I tried to untangle the HDR mess two or three years ago, gave it about a year, then gave up, so my information is probably out of date.  The metadata flagging wasn't supported properly by any of the major NLE's (not sure anybody actually has it right now)  You had to use FFMPeg or Handbrake.  In the end, there were so few combinations on the downstream end which would interpret the HDR flags correctly, that it wasn't worth the headache for me.  I.E., (TV/PC/Phone/MediaPlayer) + software/browser combination + streaming service.

But I've never heard anybody have issues with proxy sync like that.  To deliver HDR right, you need big hardware, big money, a RAID, good playback on 10-bit source material (minimum for HDR delivery; companies like Netflix require higher original media bit depth), and at least a 1000 nit reference monitor.  If you're getting several seconds of delay with prores, you need faster hardware to do whatever you're trying to do.  If you can't get the expensive hardware, then you have to lower your expectations.  U don't need to edit or color in 4K to deliver it; chances are your viewer is <100% anywy

Speaking of netflix... have you seen their delivery guidelines?  You might find them helpful.  https://partnerhelp.netflixstudios.com/hc/en-us/articles/215148917-Full-Technical-Specification-v9-0

They also have a link to JES extensifier, which, as I understand might also help diagnose (fix?) your gamma issues if you're trying to deliver using quicktime containers (or if your DI containers are quicktime), but I think it only worked on pre-catalina Macs.  IDK about other platforms.

After looking into JES extensifier, I can't endorse it.   It's a mystery to me why Netflix does.  The developer doesn't support it well, distributes it through dangerous download sites, and the top page of google results are about how to uninstall it.


text:
Intra-frame H.264 / H.265 compared to DNxHR or Prores as intermediate codecs for editing
IMPORTANT: ISSUE SOLVED (STILL A COUPLE OF QUESTIONS, THOUGH), I POSTED SOME INFO BELOW THE ORIGINAL POST AS AN UPDATE IF SOMEONE FINDS THIS USEFUL:
Quick question: what are the advantages of using the most common non long-GOP codecs for editing (DNxHD/DNxHR and Prores) vs intra-frame H.264 with a high bitrate? In theory the compression capability, even if is intra-frame only, is better with H.264, and just by being intra-frame the playback performance while editing should be equivalent to the other two codecs. Besides, H.264 suppports up to 12 bits and 4:4:4 (so it's flexible). I've read what I could regarding these codecs, but I've yet to find a reason for why intra-frame H.264 is not used more extensively for editing.
For the record, I'm asking this because I'm starting an HDR project from a H.264 high 10 UHD 4:2:0 video, and I have two issues: if I try to edit with proxies (with DNxHR or Prores), I get serious sync issues between the source file and proxies, so I can't edit properly. And if I transcode the source file to a file that doesn't have those sync issues (like DNxHR, with DNxHR for proxies too), I lose the HDR data and the video looks like a SDR one (and this happens with any codec, not just DNxHR. I haven't been able to preserve the HDR info of the source file with any codec, and tried with FFmpeg and Adobe Media Encoder), but that is an issue for another post. The thing is that I'm stuck with using the original footage as the source file, but can't edit that way without proxies (obviously the playback is extremely slow), so I was wondering if transcoding the source file to an intra-frame H.264 video and work with that (and without proxies) would have an impact on the final quality. I haven't found info comparing intra-frame H.264 to other intermediate codecs, quality and performance wise.
Thanks in advance.
UPDATE (02/03/20):
I made some tests to see how intra-frame H.264 behaves with Adobe Premiere Pro 2020:
1) I transcoded the original footage (H.264, MKV container, HDR, 10 bits, UHD, 4:2:0, VBR) with FFmpeg to an intra-frame "version" of the file, without changing any other setting (just added -intra to my original FFmpeg command line). I used CRF 18 and veryslow as preset (I have a very good CPU, so the whole file was transcoded overnight). I then imported the file to Adobe Premiere Pro 2020. First, I have to say that I haven't started to edit yet, but at least I could tell that it was compatible, and behaved like an intra-frame video while testing playback (I could go forward and backward very fast). I couldn't see any difference in quality when compared to the original footage either. In other words intra-frame H.264, so far, looks like a good alternative to other intermediate codecs like Prores or DNxHD/DNxHR. In fact, because of H.264 intra-frame compression, file size is smaller than with the others mentioned, and I don't know if it's because of my system (Threadripper 2990WX, 64GB ram, very good motherboard), but performance wise I couldn't tell a difference when comparing to DNxHR at least.
2) I know that extra transcoding steps are never a good thing quality wise, but since I had to transcode to an intra-frame video anyway, I made another test and transcoded the original footage to an HEVC video using FFmpeg (with libx265), keeping all the original settings. CRF used was 18, with veryslow as preset too. I used the main10-intra profile of x265. Then I did the same with another video, which was SDR. It took a little longer as you can expect, but I wanted to do this for a couple of reasons: first, because I wanted to know how Adobe Premiere Pro 2020 handles an H.265 HDR UHD intra-frame video. Second, because I've read (and don't quote me on this) that after transcoding any 8 bit video to a 10 bit one, many perceive an increase in quality, because of the broader colorspace that lets the encoder pick from many more colors while transcoding, which reduces banding. Well, I didn't perceive any difference quality wise (compared to the intra-frame H.264 file, and to the original footage, on both the HDR and SDR files), but the file sizes were obviously smaller and at least on my PC they performed very well on Premiere Pro (playback was as fast as with the intra-frame H.264 videos). Obviously the HDR video playback doesn't show the correct colors, but that's a restriction of Premiere because of the way it handles color spaces (no REC2020 yet).
3) Because I had color issues while transcoding to DNxHR before and couldn't solve that, I started to think that it may had to do with the chroma subsampling (none of the DNxHR flavors support 4:2:0, which is the subsampling of the original video). That was another reason for trying with intra-frame H.264 (or H.265), to see if transcoding to 4:2:0, 4:2:2 or 4:4:4 made a similar difference in colors compared to DNxHR. Turns out that when transcoding to 4:2:0 (with H.264 or H.265 as codecs) the colors look exactly the same as the original footage, and both 4:2:2 and 4:4:4 look a lot like the DNxHR video (colors washed out). Can't see a difference between 4:2:2 and 4:4:4, but when compared to 4:2:0, the difference is huge. I never wanted to upsample the video in the first place, it was just because DNxHR doesn't support 4:2:0, but I never expected such a difference. And if it was because of upsampling, I don't quite get why 4:2:2 and 4:4:4 look exactly the same. Maybe it's some kind of a FFmpeg bug that messes with colorspace when upsampling, idk.
Anyway, now I have working H.264 and H.265 intra-frame videos, without the color issues (checked the files visually, with Mediainfo, and with the Lumetri scopes tab of Premiere. They indeed preserved all the metadata needed for HDR), without sync issues (I also made a couple of proxies with the exact same settings, but only with less resolution. They sync perfecly with the source file), with smaller file size than with DNxHR and Prores, and that perform very well on Premiere Pro 2020 while previewing (maybe they don't with an inferior CPU, I don't know). So one could say, for the meantime (I have to start editing, maybe I'll encounter some issues along the way. And I haven't tested to export from Premiere using these files yet), that my issue is solved.
But my question remains after these tests: why aren't intra-frame H.264 or intra-frame H265 more extended as alternatives to DNxHR or Prores (the most commonly used intermediate codecs)? I can't see nothing but advantages: smaller file size, good playback performance, very good quality (and if you have enough space, you could even make an intra-frame H.264 lossless file if you want), they preserve the HDR data, and both codecs are very well known and extended. They even have their own intra-frame profiles (for example, H.265 has main10-intra, main444-10-intra, etc.). Transcoding times, in my experience, at least using FFmpeg on a PC, is not that different when compared to DNxHR or Prores. Is there any reason for this not being the ideal way to go while editing, besides the fact that these intra-frame "versions" of H.264 and H.265 are not as frequently used as the other codecs in bigger productions?
Thanks, any insight on this would be appreciated. And I don't mind sharing the FFmpeg commands I used if someone finds this useful.

I think the main reason is that it's a novel approach; while all I-frame h.264 may have similar performance to ProRes or DNxHR, it's not generally used for editing, so there may be patchy support in the NLEs. Or not. I'd give it a go and see how it performs

Thanks for your reply. I haven’t tried it yet (transcode to intra-frame h.264 and import it in Premiere Pro), but lets say it performs fine for editing. Do you know if there’s a difference quality wise compared to most established intermediate codecs (Prores, DNxHD/DNxHR)? If the NLE supports it, on paper I don’t see why it should be inferior, but I’m no expert.

Hi. Made a couple of tests, I posted them on the OP. Thanks!

ProRes/CineForm/DNxHR caught on because of the platforms which decided to use them. Initially, H.264 didn't have 10-bit implementations and H.265 didn't exist.
Those formats are made to hold up to being re-encoded while being very fast to encode/decode. They're not painstakingly tweaked for the best possible quality at a given bitrate.
Several cameras can save files in all-intra H.264. I know Panasonic and Sony support it. Sony calls it XAVC S-I. That's just their brand name for H.264 all-intra with 10-bit, 12-bit, 422, and 444 support. And it supports PCM audio which is not actually compliant with the MP4 container spec. These formats are catching on in cameras because the cameras have very specific bitrate requirements to write to an SD card. But then if you look at an external recorder like the Ninja V which can record to an SSD, that's going to record in ProRes/DNxHR because it can handle the higher bitrate — and because nobody's going to run out to buy something that says it supports XAVC S-I. People want ProRes/DNxHR because it makes their life simpler. I can pop the SSD out of my Ninja and plug it into my Mac and drop it onto a timeline in Resolve and I know that works and it's not going to try to make a proxy of it.
So if you want the best quality all-intra file you can certainly get that. You can make it lossless. You can do a "veryslow" FFMPEG render. But Premiere/Resolve aren't going to add the option to do an all-night proxy render.
Here's a very good discussion of the quality of all-intra H.265 vs. H.264 vs. ProRes:
https://www.eoshd.com/comments/topic/46562-prores-vs-h264-vs-h265-and-ipb-vs-all-i-how-good-are-they-actually/
The reason H.265 isn't much better than H.264 is because most of the gains in compression in newer codecs are from advanced temporal compression, and all-intra by definition has no temporal compression.
Maybe in the future we'll have more standard all-intra formats, but that's probably going to be something post-HEVC. There is arguably a benefit to keeping archival footage in an all-intra format that's easy to work with. An all-intra format has less quirks and might be better for uploading to YouTube in some cases depending on how it gets along with however they're transcoding it. But these are edge cases. The all-intra version is by definition lower quality for a given bitrate.
The real nightmare — which is what made you ask the question in the first place — is dealing with that HDR metadata. It's all a bunch of voodoo which you might be able to sort out with ffprobe, mkvmerge, and mkvpropedit.
You need to figure out what your problem actually is: What metadata is on the file? Is it tags on the video stream or tags in a separate side data stream? You should be able to get FFMPEG to preserve that. But what works in one container format might not work at all for another container format.
It looks like Premiere doesn't like your source file and screws up the sync, and FFMPEG doesn't like your source file and screws up the metadata. Where exactly is this source coming from?


text:
How to fix scale Key-framing issue
I have been facing an issue with my Premiere Pro for a while now and no matter how hard I tried to find a solution, I never managed to find something that will fix my specific problem so that is why I came here and am asking for your help...
Here goes the problem,
I want to use the scaling option to create that basic effect of an image slowly zooming in/out over time but whenever I create two keyframes with a different scale value, the image just stays stuck on the bigger value even though it hasn't reached the keyframe yet and the scale value is slowly increasing/decreasing in the Effect Controls panel. To be more clear, here is a quick video of me doing it.
Now, another thing that I noticed happening is that when I create motion on any other layer (doesn't necessarily have to be scaling motion) and try to do the scaling effect on the background image, the scaling effect reacts in some way, but it seems like it is interconnected with the keyframes of the other layer and follows them.
I really can't find the words to explain this phenomenon so here is a video of it happening...

It looks like you machine might just be too slow to live render the effects. The red bar on your timeline is an indicator of that. Try selecting the clip in the timeline after you add the scale keys, then from the menu bar choose Sequence > Render Selection. After that renders out, the red bar in the timeline should change to green, and you should be able to play the preview video.
If rendering each effect before preview isn't an option, or is just too slow for you, you could also try changing the playback resolution in the Program monitor. That's the small fly-out menu under the main preview area that currently says Full. You can change that to 1/2 or 1/4 and it can significantly improve the live render capability of your machine. Everything will look more pixelated during preview playback, but it won't affect the final exports.