mkv-bash-tools icon indicating copy to clipboard operation
mkv-bash-tools copied to clipboard

No dts-hd stream found, doing nothing

Open hbbernardo opened this issue 4 years ago • 11 comments

Hi.

I have just discovered these tools. I am trying to convert DTS-HD to DTS.

But I'm only getting this No DTS-HD stream found, doing nothing

./mkv-transcode-dts The\ Expanse\ S01E01\ Dulcinea.mkv No dts-hd stream found, doing nothing

But inside of this mkv there is a DTS-HD file, as seen below:

mkvmerge -i The\ Expanse\ S01E01\ Dulcinea.mkv File 'The Expanse S01E01 Dulcinea.mkv': container: Matroska Track ID 0: video (MPEG-H/HEVC/H.265) Track ID 1: audio (DTS-HD Master Audio) Track ID 2: subtitles (HDMV PGS) Chapters: 5 entries

What am I doing wrong?

Please let me know.

hbbernardo avatar Feb 12 '21 04:02 hbbernardo

mkvmerge changed its command line interface. The output format is now JSON. This can be updated relatively easily using jq. But I was unable to pass the ! character to mkvmerge. This is an issue with bash and after wasting a couple of hours I gave up.

dfaust avatar Feb 14 '21 19:02 dfaust

I was able to pass beyond that point. I even emailed you. I only updated some depracted commands.

I'm stuck here now:

Error: The JSON option file '/tmp/tmp.HKqFK8DZcH/options_file' contains an error: parse error - unexpected '-'.

hbbernardo avatar Feb 14 '21 19:02 hbbernardo

So what does your script look like now?

dfaust avatar Feb 14 '21 19:02 dfaust

I only changed two commands that changed.

-i

--atracks

ave updated the parts that are related to mkvmerge deprecated commands. But I'm stuck with an error involving json that I honestly have no idea where to begin with.

Here's the script:

#!/bin/bash

Version 1

(C) 2017 Daniel Faust [email protected]

A BASH script that transcodes all DTS-HD tracks of a matroska file to DTS Core

while preserving the track's name and language and it's default and forced flags as well as its delay.

Requires mktemp, mkvmerge, mkvextract and ffmpeg (version 3.1 or higher)

Usage:

chmod +x mkv-transcode-dts

./mkv-transcode-dts "My File.mkv"

This will create a new file called "My File [DTS Core].mkv".

For batch converting all .mkv files in the current directoy

copy mkv-transcode-dts to a directory in your PATH and execute:

find -iname "*.mkv" -exec mkv-transcode-dts '{}' ;

if [[ "$1" == "" ]] || [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]; then echo echo "Transcode single file:" echo "mkv-transcode-dts file.mkv" echo echo "Transcode multiple files:" echo "find -iname "*.mkv" -exec mkv-transcode-dts '{}' ;" echo exit fi

hash mktemp 2>/dev/null || { echo >&2 "Error: Command mktemp not found"; exit 1; } hash mkvmerge 2>/dev/null || { echo >&2 "Error: Command mkvmerge not found"; exit 1; } hash mkvextract 2>/dev/null || { echo >&2 "Error: Command mkvextract not found"; exit 1; } hash ffmpeg 2>/dev/null || { echo >&2 "Error: Command ffmpeg not found"; exit 1; }

file_name=$1

tmp_dir=$(mktemp -d)

trap 'rm -r "$tmp_dir"' EXIT

option_file_name="$tmp_dir/options_file"

IFS=' '

tracks=$(LANG=en_US.utf8 LANGUAGE=en_US.utf8 mkvmerge -i "$file_name" | grep "DTS-HD Master Audio")

track_ids_string="" for track in $tracks; do track_id="" [[ "$track" =~ Track\ ID\ ([0-9]+) ]] && track_id=${BASH_REMATCH[1]} [[ "$track" =~ language:([a-z]+) ]] && language=${BASH_REMATCH[1]} [[ "$track" =~ track_name:([^ ]+) ]] && track_name=${BASH_REMATCH[1]} [[ "$track" =~ default_track:([0-1]) ]] && default_track=${BASH_REMATCH[1]} [[ "$track" =~ forced_track:([0-1]) ]] && forced_track=${BASH_REMATCH[1]}

if [[ "$track_id" == "" ]]; then
    continue
fi

mkvextract timecodes_v2 "$file_name" "$track_id:$tmp_dir/$track_id.ts"
mkvextract tracks "$file_name" "$track_id:$tmp_dir/$track_id.hdma.dts"
ffmpeg -i "$tmp_dir/$track_id.hdma.dts" -bsf:a dca_core -c:a copy "$tmp_dir/$track_id.core.dts"
rm "$tmp_dir/$track_id.hdma.dts"

track_ids_string="$track_ids_string,$track_id"
delay=$(sed -n "2p" "$tmp_dir/$track_id.ts")

echo "--atracks" >> "$option_file_name"
echo "0" >> "$option_file_name"
if [[ "$track_name" != "" ]]; then
    track_name=${track_name/\\s/\ }  # replace '\s' with ' '
    track_name=${track_name/\\2/\"}  # replace '\2' with '"'
    track_name=${track_name/\\c/:}   # replace '\c' with ':'
    track_name=${track_name/\\h/#}   # replace '\h' with '#'

track_name=${track_name/\\/\} # replace '\' with '' doesn't work

    track_name=$(echo "$track_name" | sed -r 's/(dts-hd|dts hd|dts-ma|dts ma)/DTS/i')
    echo "--track-name" >> "$option_file_name"
    echo "0:$track_name" >> "$option_file_name"
fi
if [[ "$language" != "" ]]; then
    echo "--language" >> "$option_file_name"
    echo "0:$language" >> "$option_file_name"
fi
if [[ "$default_track" != "" ]]; then
    echo "--default-track" >> "$option_file_name"
    echo "0:$default_track" >> "$option_file_name"
fi
if [[ "$forced_track" != "" ]]; then
    echo "--forced-track" >> "$option_file_name"
    echo "0:$forced_track" >> "$option_file_name"
fi
if [[ $delay != 0 ]]; then
    echo "--sync" >> "$option_file_name"
    echo "0:$delay" >> "$option_file_name"
fi
echo "$tmp_dir/$track_id.core.dts" >> "$option_file_name"

done track_ids_string=${track_ids_string:1} # remove first comma

if [[ "$track_ids_string" != "" ]]; then mkvmerge -o "${file_name%.*} [DTS Core].mkv" --audio-tracks "!$track_ids_string" "$file_name" "@$option_file_name" else echo "No dts

hbbernardo avatar Feb 14 '21 19:02 hbbernardo

Sorry then end was missing. I'm on mobile to my way home

hbbernardo avatar Feb 14 '21 19:02 hbbernardo

http://paste.ubuntu.com/p/Jf7ZW9pxtP/

hbbernardo avatar Feb 14 '21 19:02 hbbernardo

You can have a look at this script for parsing the json output: https://paste.ubuntu.com/p/8T7GjTNgh8/ But you will see the line at the bottom marked with FIXME, that can't be executed automatically and must be called manually.

dfaust avatar Feb 14 '21 19:02 dfaust

Thank You for replying it.

I have no idea how I can fix that. I have asked in the mkvtoolnix subreddit to no avail (as of now)

But I am gonna mail the developer asking for help on how to properly parse (adapt) this very handy script of yours to JSON

hbbernardo avatar Feb 14 '21 20:02 hbbernardo

You don't have to mail the mkvmerge Developer. The solution for that is in the Script i linked. If you are Interested in bash Scripting, you should read Up in that. But it's the Problem with the Last command of that Script that i mentioned, that's the Problem.

dfaust avatar Feb 14 '21 20:02 dfaust

I'm trying.

I have used a shellcheck to look into bash.

But I have zero knowledge. Can you point for me a direction?

According to shellcheck there is only thing wrong with the latest script you passed which is the following:

https://paste.ubuntu.com/p/9CC3VTGYRb/

shellcheck myscript

Line 82: codec_id=$(echo "$track" | jq --raw-output ".properties.codec_id") ^-- SC2034: codec_id appears unused. Verify use (or export if used externally).

But when I try to run another error is given.

./script: line 62: $2: unbound variable

hbbernardo avatar Feb 15 '21 02:02 hbbernardo

I forget to mention that I changed some parameters which were wrong according to shellcheck.net

hbbernardo avatar Feb 15 '21 03:02 hbbernardo