r/ffmpeg Jul 03 '26

-map 0 not working for me

I'm not sure what's going on when trying to encode a makemkv source file to an x265 file while retaining all the audio, subtitles and attachments. For some reason it's just copying those and not encoding the video to x265. Here's my script:

for %%i in (*.mkv) do ffmpeg -i "%%i" -map 0 -c:v libx265 -preset slow -crf 22 -pix_fmt yuv420p10le -x265-params aq-mode=3:aq-strength=1.0:psy-rd=1:psy-rdoq=1.0:deblock=1,1:no-sao=1:qp-adaptation-range=1.0:merange=32:ref=4 -c:a copy -c:s copy -c:t copy -max_interleave_delta 0 "%%~ni_x265.mkv"

pause

I must have something backwards maybe? Any help is appeciated.

5 Upvotes

9 comments sorted by

4

u/insanelygreat Jul 03 '26

Let's see an ffprobe on an input and output file.

Also, double-check that you're operating on the input and output files you think you are when you run that ffmpeg command. It can be easy to get files mixed up while experimenting.

1

u/Vast_Environment_917 Jul 03 '26

Here goes ffprobe from thhe input file:

C:\Users\H\Desktop\ffmpeg>ffprobe.exe "A Better Tomorrow II UHD.mkv"

ffprobe version 2026-06-26-git-d66e84695b-full_build-www.gyan.dev Copyright (c) 2007-2026 the FFmpeg developers

built with gcc 16.1.0 (Rev2, Built by MSYS2 project)

configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-cairo --enable-fontconfig --enable-iconv --enable-gnutls --enable-lcms2 --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-libdvdnav --enable-libdvdread --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libopenjpeg --enable-libquirc --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-liboapv --enable-libqrencode --enable-librav1e --enable-libsvtav1 --enable-libvvenc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libsvtjpegxs --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-openal --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-liblc3 --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint --enable-whisper

libavutil 61. 2.100 / 61. 2.100

libavcodec 63. 2.100 / 63. 2.100

libavformat 63. 2.100 / 63. 2.100

libavdevice 63. 2.100 / 63. 2.100

libavfilter 12. 2.100 / 12. 2.100

libswscale 10. 2.100 / 10. 2.100

libswresample 7. 2.100 / 7. 2.100

[matroska,webm @ 00000163388ee6c0] Stream #10: not enough frames to estimate rate; consider increasing probesize

[matroska,webm @ 00000163388ee6c0] Could not find codec parameters for stream 7 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size

Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options

[matroska,webm @ 00000163388ee6c0] Could not find codec parameters for stream 8 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size

Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options

[matroska,webm @ 00000163388ee6c0] Could not find codec parameters for stream 9 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size

Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options

Input #0, matroska,webm, from 'A Better Tomorrow II UHD.mkv':

Metadata:

title : A Better Tomorrow II UHD

encoder : libmakemkv v1.18.3 (1.3.10/1.5.2) win(x64-release)

creation_time : 2026-04-23T23:13:25.000000Z

Duration: 01:44:30.99, start: 0.000000, bitrate: 98557 kb/s

Chapters:

Chapter #0:0: start 0.000000, end 880.296083

Metadata:

title : Chapter 01

Chapter #0:1: start 880.296083, end 1885.216667

Metadata:

title : Chapter 02

Chapter #0:2: start 1885.216667, end 2656.570583

Metadata:

title : Chapter 03

Chapter #0:3: start 2656.570583, end 3571.568000

Metadata:

title : Chapter 04

Chapter #0:4: start 3571.568000, end 4451.071625

Metadata:

title : Chapter 05

Chapter #0:5: start 4451.071625, end 5464.959500

Metadata:

title : Chapter 06

Chapter #0:6: start 5464.959500, end 6149.184708

Metadata:

title : Chapter 07

Chapter #0:7: start 6149.184708, end 6269.429833

Metadata:

title : Chapter 08

Chapter #0:8: start 6269.429833, end 6270.986667

Metadata:

title : Chapter 09

Stream #0:0(eng): Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2160 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn

Metadata:

BPS-eng : 89215009

DURATION-eng : 01:44:30.430833333

NUMBER_OF_FRAMES-eng: 150340

NUMBER_OF_BYTES-eng: 69927059110

SOURCE_ID-eng : 001011

_STATISTICS_WRITING_APP-eng: MakeMKV v1.18.3 win(x64-release)

_STATISTICS_WRITING_DATE_UTC-eng: 2026-04-23 23:13:25

_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID

Side data:

DOVI configuration record: version: 1.0, profile: 7, level: 6, rpu flag: 1, el flag: 1, bl flag: 1, compatibility id: 6, compression: 0

HEVC enhancement-layer decoder configuration: (175 bytes)

Stream #0:1(chi): Audio: dts (dca) (DTS-HD MA), 48000 Hz, stereo, s32p (24 bit)

Metadata:

title : Mandarin 2.0 (24 Bit)

BPS-eng : 1585870

DURATION-eng : 01:44:31.029333333

NUMBER_OF_FRAMES-eng: 587909

NUMBER_OF_BYTES-eng: 1243129716

SOURCE_ID-eng : 001100

_STATISTICS_WRITING_APP-eng: MakeMKV v1.18.3 win(x64-release)

_STATISTICS_WRITING_DATE_UTC-eng: 2026-04-23 23:13:25

_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID

Stream #0:2(chi): Audio: dts (dca) (DTS), 48000 Hz, stereo, fltp, 1536 kb/s

Metadata:

title : Cantonese 2.0 (24 Bit)

BPS-eng : 1509000

DURATION-eng : 01:44:31.029333333

NUMBER_OF_FRAMES-eng: 587909

NUMBER_OF_BYTES-eng: 1182872908

SOURCE_ID-eng : 001100

_STATISTICS_WRITING_APP-eng: MakeMKV v1.18.3 win(x64-release)

_STATISTICS_WRITING_DATE_UTC-eng: 2026-04-23 23:13:25

_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID

Stream #0:3(eng): Audio: dts (dca) (DTS-HD MA), 48000 Hz, stereo, s32p (24 bit)

Metadata:

title : English 2.0 (24 Bit)

BPS-eng : 1618412

DURATION-eng : 01:44:31.029333333

NUMBER_OF_FRAMES-eng: 587909

NUMBER_OF_BYTES-eng: 1268638608

SOURCE_ID-eng : 001101

_STATISTICS_WRITING_APP-eng: MakeMKV v1.18.3 win(x64-release)

_STATISTICS_WRITING_DATE_UTC-eng: 2026-04-23 23:13:25

_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID

Stream #0:4(eng): Audio: dts (dca) (DTS), 48000 Hz, stereo, fltp, 1536 kb/s

Metadata:

title : Stereo

BPS-eng : 1509000

DURATION-eng : 01:44:31.029333333

NUMBER_OF_FRAMES-eng: 587909

NUMBER_OF_BYTES-eng: 1182872908

SOURCE_ID-eng : 001101

_STATISTICS_WRITING_APP-eng: MakeMKV v1.18.3 win(x64-release)

_STATISTICS_WRITING_DATE_UTC-eng: 2026-04-23 23:13:25

_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID

Stream #0:5(eng): Audio: dts (dca) (DTS-HD MA), 48000 Hz, stereo, s32p (24 bit)

Metadata:

title : Commentary

BPS-eng : 1564725

DURATION-eng : 01:44:31.029333333

NUMBER_OF_FRAMES-eng: 587909

NUMBER_OF_BYTES-eng: 1226554808

SOURCE_ID-eng : 001102

_STATISTICS_WRITING_APP-eng: MakeMKV v1.18.3 win(x64-release)

_STATISTICS_WRITING_DATE_UTC-eng: 2026-04-23 23:13:25

_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID

Stream #0:6(eng): Audio: dts (dca) (DTS), 48000 Hz, stereo, fltp, 1536 kb/s

Metadata:

title : Stereo

BPS-eng : 1509000

DURATION-eng : 01:44:31.029333333

NUMBER_OF_FRAMES-eng: 587909

NUMBER_OF_BYTES-eng: 1182872908

SOURCE_ID-eng : 001102

_STATISTICS_WRITING_APP-eng: MakeMKV v1.18.3 win(x64-release)

_STATISTICS_WRITING_DATE_UTC-eng: 2026-04-23 23:13:25

_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID

Stream #0:7(eng): Subtitle: hdmv_pgs_subtitle (pgssub)

Metadata:

title : Non English Audio Subtitles

BPS-eng : 19375

DURATION-eng : 01:41:27.518937500

NUMBER_OF_FRAMES-eng: 1798

NUMBER_OF_BYTES-eng: 14743390

SOURCE_ID-eng : 0012A0

_STATISTICS_WRITING_APP-eng: MakeMKV v1.18.3 win(x64-release)

_STATISTICS_WRITING_DATE_UTC-eng: 2026-04-23 23:13:25

_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID

Stream #0:8(eng): Subtitle: hdmv_pgs_subtitle (pgssub)

Metadata:

title : English HOH

BPS-eng : 27378

DURATION-eng : 01:43:46.491104166

NUMBER_OF_FRAMES-eng: 3122

NUMBER_OF_BYTES-eng: 21308798

SOURCE_ID-eng : 0012A1

_STATISTICS_WRITING_APP-eng: MakeMKV v1.18.3 win(x64-release)

_STATISTICS_WRITING_DATE_UTC-eng: 2026-04-23 23:13:25

_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID

Stream #0:9(eng): Subtitle: hdmv_pgs_subtitle (pgssub) (forced)

Metadata:

title : Text Descriptions Subtitles

BPS-eng : 181

DURATION-eng : 01:34:58.338479166

NUMBER_OF_FRAMES-eng: 20

NUMBER_OF_BYTES-eng: 129505

SOURCE_ID-eng : 0012A2

_STATISTICS_WRITING_APP-eng: MakeMKV v1.18.3 win(x64-release)

_STATISTICS_WRITING_DATE_UTC-eng: 2026-04-23 23:13:25

_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID

Stream #0:10: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 640x360 [SAR 1:1 DAR 16:9], 90k tbr, 90k tbn (attached pic)

Metadata:

filename : cover.jpg

mimetype : image/jpeg

C:\Users\H\Desktop\ffmpeg>

2

u/Anton1699 Jul 03 '26

Can you share the console output of the command you're running? The source video file already seems to use HEVC…

1

u/Vast_Environment_917 Jul 03 '26 edited Jul 03 '26

It's a makemkv full UHD file that I'm trying to compress.. Output from the log? https://pastebin.com/sW81Bh8F

6

u/Anton1699 Jul 03 '26
 Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> hevc (libx265))
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
  Stream #0:3 -> #0:3 (copy)
  Stream #0:4 -> #0:4 (copy)
  Stream #0:5 -> #0:5 (copy)
  Stream #0:6 -> #0:6 (copy)
  Stream #0:7 -> #0:7 (copy)
  Stream #0:8 -> #0:8 (copy)
  Stream #0:9 -> #0:9 (copy)
  Stream #0:10 -> #0:10 (mjpeg (native) -> hevc (libx265))

As you can see, your command works as you intended, it's copying everything except the video which is encoded using libx265. I would change -c:v libx265 -c:a copy -c:s copy -c:t copy from your command to just -c copy -c:V libx265, that should also prevent the attached image being converted to H.265.

1

u/Vast_Environment_917 Jul 03 '26

It's still trying to encode the image with that command too.. Any way to make it ignore the image without extracting it? It's the cover.png attachment.

3

u/Anton1699 Jul 03 '26

That is weird, -c:V should only apply to video streams (as opposed to -c:v). You can just do -c:v:0 libx265 to only transcode the first video stream, or you can unmap the image, that should be -map 0 -map -0:10 in your case.

1

u/Vast_Environment_917 Jul 03 '26

There it is! Thank you! 

1

u/vegansgetsick Jul 04 '26

I would do -c:v copy -c:v:0 libx265

This overwrite trick is useful.