Advanced settings for Matroska format for YouTube uploads?

Hi there. Trying to find a complete set of advanced settings that are appropriate for creating the best (lossless) settings for audio quality while using the Matroska video format.
This is for uploading videos to YouTube. As far as I know, Matroska is the best video format for both audio and video quality. Rendering time and file size do not matter to me. The audio files I start with are always either FLAC or WAV. Then I add pictures to make a slideshow featuring the artist. The actual video quality is not that important either since in my videos the focus is 99% audio. The reason I manually set it to 1440p is because I’ve read that that should help to increase the audio quality, somehow, when uploading to YouTube.

So which video codec on the Shotcut list should I use? I have tried h264_amf with Matroska but the final product has issues displaying all the transitions and effects that I put into my videos. I’ve tried many combinations of settings with Matroska but none seem to be the correct ones for that particular video format. In the screenshot below, it shows part of the list of available codecs on Shotcut. I’ve heard h264 and hevc are good… but which ones, exactly? There are 4 types of h264 and hevc each… For examples: h264_mf and hevc_mf. As it is, I have to settle with libx264 because it’s the only video codec I know that works.

Next, onto the audio codec. I have tried pcm_s16le but that results in there being no audio in the exported video. When I set it to libopus there is audio but I’ve heard that it’s not lossless. When choosing an audio codec on Shotcut, does it matter which audio format the file I am using is in? As I’ve mentioned, it’s always FLAC or WAV for me. As far as I know, the only ones that should be changed from the default settings here are the ‘Codec’ and ‘Bitrate’. I’ve increased the bitrate to 512k.

Next are the video settings. All are default except I’ve increased the resolution and changed the Interpolation to Lanczos.

I know most people are not that picky about audio quality on YouTube but I can tell when an audio file has been edited and exported in a lossy format. It annoys the heck outta me lol. And for my viewers’ sake, it’s important to me that my videos have the highest quality audio achievable. But for now, shotcut is the only video editor that I use. Any advice here is much appreciated. Thank you very much.

~ Ben

I can answer the video part but I have no experience with audio.

libx264 is the standard H264 encoder and will use the CPU for encoding (best quality vs filesize but longer export time). All the others are GPU versions of the H264 standard, h264_amf is for AMD cards, h264_nvenc for Nvidia, quicksync for Intel etc. Only use the one for your video card (it will fail anyway if you chose wrongly).

If it exports without a hard error then it doesn’t matter exactly which one you choose (but for your use case libx264 should be the best choice as you’re uploading to youtube anyway and if you increase the quality enough (do some short test exports, I think 65% is enough for most, 80% would be visually lossless), there’s no difference between x264, x265, av1 etc). All of these should work fine with the .mkv container.

If there’s problem with the transition then you should check your project frame by frame to make sure the keyframes and filters are working correctly in preview. The final codec only affects quality and filesize, all of them will have the same “transition” issues - but you should clarify what does this mean exactly.

Thanks Daniel. That answers some of my questions.
When I said there were issues with transitions, I mean the final product was not showing the transitions properly and sometimes the video would crash part way through. Strange but that can happen when you use incompatible encoder which Shotcut calls “codec”, and that definitely confused me. Just learning the basics haha

This is not entirely correct. Matroska is simply a container just like MP4 and has no bearing on quality except that MP4 has more limitations in choice of codec. So, with Matroska you can choose to use PCM uncompressed or FLAC audio for lossless. There are no standard codecs for Matroska.

encoder which Shotcut calls “codec”,

The “code” in “codec” refers to “encode.” The choice of codec dictates which decoder (the “dec” part of “codec”) must be used. “Codec” also can refer to an implementation of an encoder or decoder of a standard. libx264 is the most popular H.264 software-only (CPU) encoder. h264_amf requires compatible AMD GPU hardware.

Based on what you’ve described here is what I suggest:

  • start with defaults and turn on Advanced mode
  • turn off Use hardware encoder
  • change Format to matroska
  • in the Audio tab change Codec to flac

You are done. Why make it any more difficult? You can save this as a custom preset, but you should remove details that can vary by project such as resolution and frame rate:

f=matroska
acodec=flac
vcodec=libx264
1 Like

With that said, recent versions of Shotcut and FFmpeg v6 do support writing FLAC and PCM in MP4, and likely YouTube will decode it too. But some players might not like it.

This topic was automatically closed after 90 days. New replies are no longer allowed.