Convert2MKV - New Options; New Hardware Logic! - WIP [UPDATED 27/01/19]

Updated with new functionality:

  • Refocus on HEVC
  • Added Recursive functionality by default - (not a toggle yet)
  • Added ‘fastdecode’ to tune options by default
  • Added temp file transcode by default
  • Added delete source, rename temp file and move to source functionality by default

New update:

  • Breaks a lot of functionality
  • Trying to remove MP4 (may add back in later)
  • Trying to remove reliance on libx264
  • Attempting to add new file naming logic
  • Attempting to use raw video for transcoding

Script is in the first post: Convert2MKV - MKV & HEVC - WIP [UPDATED 22/07/18]

New update:

  • Fixed original functionality
  • Re-enabled *.mp4 container
  • libx264 re-added (legacy support)
  • Added new file naming logic, to remove original file, no more clashes if the extension is the same
  • Added libx264rgb video extraction with -crf 0 option
  • Added aac audio copy
  • Added fastdecode and grain tuning options for x265/HEVC
  • Added better output information
  • Added a text file output for successful transcode per video in origin folder
  • Lowered general output in console
  • Added removal of all transcode files after completion

Script is in the first post: Convert2MKV - MKV & HEVC - WIP [UPDATED 22/07/18]

New Update:

  • If video already HEVC encoded, it is skipped and the loop continues onto the next file
  • Added libx265 as default encoder
  • Changed base CRF to 24 as output file size was out of control
  • Added AC3 audio passthrough, no longer forced to transcode the audio if AC3 is detected

Script is in the first post: Convert2MKV - MKV & HEVC - WIP [UPDATED 02/08/18]

I have a script I wrote a long time ago that does something similar, except that I copy the audio and subtitle streams always. I found a couple things:

  1. If the source is from Blu-Ray and audio is LPCM, then you have to convert it since MKV does not support LPCM
  2. I had to handle the stream mapping differently if the source is from DVD and has a stream called dvd_nav_packet in it

Here is the code I used if you are interested (${vidinp} is the input video file of course):

ffprobe "${vidinp}" -show_streams -v quiet | while read line; do
    if [[ $line = *"pcm_bluray" ]]; then
        islpcm="true"
    fi

    if [[ $islpcm = "true" && $line = *"sample_fmt"* ]]; then
        audio="-c:a:$(( audcnt - 1 )) pcm_${line#*=}be"
        break
    fi
done

if [[ $vobfmt = *"dvd_nav_packet" ]]; then
    outmap="-c:a copy"
else
    outmap="-map 0 -c copy"
fi
1 Like

I see, so you’re using physical media/raw rips from disc as the source media?

Yes, I pull out the main video, main audio, and english subtitle tracks from the disk and then then move the resulting M2TS or VOB to the server and then let the script encode it into MKV with HEVC video and copy the audio and subs where possible.

1 Like

Understood! Thank you! I never intended the script for that purpose, but as soon as I can, I’ll try and integrate it!

I dont have any real media to test with (no BluRay reader), but as soon as I get around to grabbing one, I’m happy to test and integrate. :smiley:

Great contribution! Thanks!

No problem! I PM’ed you the entire script…some of it may be useful.

1 Like

Legend! Just got it and will read through it today. Thanks again :smiley:

New Update:

  • Added prelim QuickSync support!
  • Added “-qp” in lieu of “-crf” for HEVC
  • Fixed file detection bug
  • Fixed CRF duplication

Script is in the first post: Convert2MKV - Now with Prelim Hardware Support! - WIP [UPDATED 08/11/18]

New Update:

  • Added H264’s “4:4:4 Predictive” profile, as it is not supported in most hardware

Script is in the first post: Convert2MKV - Now with Prelim Hardware Support! - WIP [UPDATED 08/11/18]

  • New Option “vbitrate” - You can now use “auto” which will set a default of 1 Byte per pixel, or you can override the logic with a specific number like you would in ffmpeg (using the standard options of K, M or G eg. “10M”)
  • New Option “hw” - Now you can choose either “cpu” or “vaapi”, meaning you can now use the script even if you don’t have hardware acceleration available
  • New Option “overwrite” - Instead of deleting your original files, you can now choose to create a backup instead. The original file will be renamed *.bak. If you are satisfied that this script is capable of carrying out the tasks you want it to, you can choose “yes” to replace the original file
  • New Logic “bitrate” - Using the height and width of input video, the bitrate is calculated per pixel using a simple height x width formula. This can be overridden as listed above
  • New parameters - x265 parameters have been added and can be manually tweaked if needed
  • New Logic “transcode” - using the “hw” option, the logic determines how to use the output, either with vaapi or cpu transcoding
  • New Logic for file moves - when encoding the file, the output is to the $tempdir using the original file name (making it easier to find if needed). It is then moved after transcoding is complete, taking into account the “overwrite” parameter
  • Removed Logic h264 - The script no longer outputs in h264 as this codec is already easily accessible via other tools, so is wasted effort in this script
  • Removed Option - No longer extracts to RGB, difference was negligible, and added extra transcoding time

Script is in the first post: Convert2MKV - New Options; New Hardware Logic!

Currently Testing File: Garfield.and.Friends.02E06.CUSTOM.DVDRip.XviD.HUN.avi Bitrate (based on input resolution): 291200 Input File: Garfield.and.Friends.02E06.CUSTOM.DVDRip.XviD.HUN.avi Input Video Codec: h264 Working… ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright © 2000-2018 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 [avi @ 0x56394e97eae0] non-interleaved AVI Input #0, avi, from ‘Garfield.and.Friends.02E06.CUSTOM.DVDRip.XviD.HUN.avi’: Metadata: encoder : AVI-Mux GUI 1.17.8.3, Feb 16 201019:42:50 JUNK : Duration: 00:23:27.80, start: 0.000000, bitrate: 745 kb/s Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(progressive), 700x416 [SAR 1:1 DAR 175:104], 613 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 kb/s Metadata: title : HUN Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265)) Stream #0:1 -> #0:1 (mp3 (native) -> aac (native)) Press [q] to stop, [?] for help Too many packets buffered for output stream 0:1. [aac @ 0x56394e983a00] Qavg: 3482.516 [aac @ 0x56394e983a00] 2 frames left in the queue on closing Conversion failed! Completed

Any idea, why the conversation failed?

Apologies for the late reply @syluccy - I’ve been working my butt off.

I’ve just read your other thread:

You’re absolutely right. That’s probably what caused the issue. I kinda new about it, but completely forgot to test it.

On that note: Well done for fixing it up! That’s awesome!

Do you mind if I grab your logic, so I can test/integrate it into my script? That may solve a lot of issues I’ve had with naming. Efficiency in code would be awesome :smile:

Let me know, I wont without your permission.

no worries, use it buddy, 99% of this script is your work. :slight_smile:
thanks a lot for it!

1 Like

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