Hallo together,
I'M searching for code that can filter my files to dts.
Actual I take this code to convert dts to ac3.
The problem is I have files with .mkv without dts-codec. How can I filter it?Code:for /R %%a in ("\*.mkv") do (ffmpeg -y -i "%%\~a" -map 0 -vcodec copy -scodec copy -acodec ac3 -b:a 640k "%%\~dpna\_AC3.mkv" )
Thanks for your help.
Greetings
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 13 of 13
Thread
-
-
-acodec ac3 tells ffmpeg to convert the audio to AC3. It shouldn't matter what type of audio the MKV contains. Or do I not understand what you're asking?
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
Tahnks for your answer.
I just want to convert dts-files and keep the other codecs as they are. -
This thread shows how to have ffmpeg use a text file list to process a bunch of files.
https://forum.videohelp.com/threads/328303-software-that-indexes-a-drive-to-create-an-...tch-conversion
This link below downloads 'Playtime' which can open a folder of files and list the audio codecs used.
The codec column can be sorted to group same codecs together.
The group of files can be hi-lighted and saved as a text file which ffmpeg may be able to use.
I haven't tried this and I would defer to jagabo who modified the original bat file in the thread
https://www.free-codecs.com/playtime_download.htm -
Try something like:
Code:for /R %%a in (*.mkv) do ffmpeg -y -i "%%~a" 2>&1 | find "Audio: dts" && ffmpeg -i "%%~a" -map 0 -c:v copy -c:a ac3 -b:a 640k -c:s copy "%%\~dpna\_AC3.mkv"
-
Thank you very much for your answer.
That is very good, thank you very much.
Now I wanted to go one step further and rename all video files that have a dts codec to "*_dts" beforehand.
In the next step, I would then convert them and remove the "_dts" at the end of the new file. This way I could then search for all files with _dts and remove them afterwards.
Perhaps you can help me further here? -
Code:
for /R %%a in (*.mkv) do ffmpeg -i "%%~a" 2>&1 | find "Audio: dts" && ren "%%~a" "%%~na_dts.mkv" && ffmpeg -y -i "%%~dpna_dts.mkv" -map 0 -c:v copy -c:a ac3 -b:a 640k -c:s copy "%%~dpna_AC3.mkv"
Last edited by sneaker; 23rd Dec 2020 at 03:55. Reason: fixed syntax error + minor improvements
-
Thank you very much for your answer.
Everything that does not have DTS is already skipped correctly.
However, I am unfortunately still getting a syntax error. Is it possible that this is related to the renaming of the file? -
/edit:
I think I have it fixed. Try again. (ren does not accept absolute path as 2nd parameter, only a filename)Last edited by sneaker; 23rd Dec 2020 at 03:54.
-
This is the last error message.
[Attachment 56385 - Click to enlarge]
I try it with this
Code:for /R %%a in (*.mkv) do ffmpeg -y -i "%%~a" 2>&1 | find "Audio: dts" && ren "%%~dpna" "%%~na_dts.mkv" && ffmpeg -i "%%~a_dts.mkv" -map 0 -c:v copy -c:a ac3 -b:a 640k -c:s copy "%%\~dpna\_AC3.mkv"
-
Although not exactly what you're asking for, this will output to stdout a list of files along with their audio codecs, without writing or renaming anything. This is in sh/bash for any non-Windows users.
ffprobe-acodec.sh
Code:find . -depth -maxdepth 2 -regextype posix-extended -regex '.*\.mkv$|.*\.mp4$' -type f -exec bash -c 'echo "{}" $(ffprobe -loglevel error -select_streams a:0 -show_entries stream=codec_name -of default=nw=1:nk=1 "{}")' \;
ffmpeg-inotify-transcode-acodec.sh
Code:#!/usr/bin/env bash inotifywait -m /mnt/pool0/p0ds0smb/temp/ffmpeg-inotify/. -e close_write -e moved_to | while read dir action file; do if [[ "$file" =~ ^.*\.(mp4|mkv)$ ]]; then bash -c "/mnt/pool0/p0ds0smb/visualblind/Documents/Scripts/linux/ffmpeg_tcode_compat.sh -d /mnt/pool0/p0ds0smb/temp/ffmpeg-inotify -w /mnt/pool0/p0ds0smb/temp/ffmpeg-inotify/.working | /usr/bin/logger -t 'ffmpeg-inotify-transcode-acodec.sh'"; fi; done
Code:#!/usr/bin/env bash # ## DESCRIPTION: Transcode with FFmpeg all (mkv, mp4) media files in specified directory, ## overwriting the original source files. ## ## AUTHOR: Travis Runyard ## Revised: 10/31/2020 ## URL: https://sysinfo.io/ffmpeg-batch-transcode-audio/ # Exit on first non-zero exit code set -e # Set shell options shopt -s globstar shopt -u nullglob # Declare variables (optionally) are indexed arrays # Only associative arrays require declaration, but standardizing is a good thing declare -a FILENAME declare -a LOG # Modify TEMPDIR and WORKDIR to suit your needs TEMPDIR="/mnt/pool0/p0ds0smb/temp/ffmpeg" WORKDIR="$TEMPDIR/.working" SCRIPT_NAME=$(basename "$0") usage() { cat 1>&2 <<EOF Usage: "$SCRIPT_NAME" [options] -h| --help Help shows this message. -d| --directory Specify the directory to process. -w| --workdir Writable working directory for FFmpeg. If you don't specify this option, the subdirectory named "working" will be used within the --directory path or \$TEMPDIR. EOF } while [ "$1" != "" ]; do case $1 in -d | --directory ) shift TEMPDIR="${1:-$TEMPDIR}" WORKDIR="$WORKDIR" ;; -w | --workdir ) shift WORKDIR="${1:-$WORKDIR}" ;; -h | --help ) usage exit 0 ;; * ) usage exit 1 esac shift done cd $TEMPDIR echo -e "*** DEBUG ***\n\$TEMPDIR = $TEMPDIR\n\$WORKDIR = $WORKDIR" [ -d "$WORKDIR" ] || mkdir "$WORKDIR" # Set field separator to newline OIFS="$IFS" IFS=$'\n' FILENAME=($(find . ! -path "*$(basename "$WORKDIR")/*" -regextype posix-extended -regex '.*\.(mkv|mp4)$' -type f -print)) if [ -n "$FILENAME" ]; then for f in "${FILENAME[@]}"; do LOG+=("$f") AUDIOFORMAT=($(ffprobe -loglevel error -select_streams a:0 -show_entries stream=codec_name,channels -of default=nw=1:nk=1 "$f")) if ! [ "${AUDIOFORMAT[0]}" = "aac" ]; then # Build ffmpeg array within the loop to populate variables args=( -nostdin -y -i "$f" -default_mode infer_no_subs -map 0:v:0 -map 0:a -map 0:s:m:language:eng? -map 0:s:m:language:ger? -map 0:s:m:language:spa? -map 0:s:m:language:fre? -map 0:s:m:language:ita? -map 0:s:m:language:jpn? -map 0:s:m:language:kor? -map 0:s:m:language:por? -map 0:s:m:language:vie? -map 0:s:m:language:chi? -ac "${AUDIOFORMAT[1]}" -ar 48000 -metadata:s:a:0 language=eng -metadata:s:a:0 title= -map_chapters -1 -dn -bsf:v "filter_units=remove_types=6" -movflags faststart -c:v copy -c:a aac -c:s copy "$WORKDIR/$(basename "$f")" ) echo -e "*** DEBUG: ffprobe detected '${AUDIOFORMAT[0]}' in the default audio stream with '${AUDIOFORMAT[1]}' channels\nPreparing to convert audio codec to AAC..." ; sleep 1 echo -e "*** DEBUG: ffmpeg ${args[@]}" ffmpeg "${args[@]}" || break echo -e "*** DEBUG: Moving '$WORKDIR/$(basename "$f")' back to source directory name '$(dirname "$f")'"; sleep 1 mv -f -v "$WORKDIR/$(basename "$f")" "$(dirname "$f")" || break fi done printf '*** DEBUG ***\nPROCESSED:%s\n' for i in "${LOG[@]}"; do echo "$i"; done else echo -e "*** DEBUG: No files to process" fi
Similar Threads
-
batch convert DTS to Ac3 using ffmpeg
By Mishari in forum Newbie / General discussionsReplies: 7Last Post: 7th Apr 2022, 17:23 -
Help to find ffmpeg setting
By payamhd in forum Newbie / General discussionsReplies: 4Last Post: 24th Sep 2020, 06:20 -
ffmpeg throwing “Non-monotonous DTS in output stream”
By cwinthrop in forum Video ConversionReplies: 15Last Post: 27th Jun 2019, 12:25 -
Need ffmpeg 2.2 shared version, cannot find
By Corvius in forum ffmpegX general discussionReplies: 1Last Post: 2nd Dec 2017, 16:08 -
How to fix DTS non monotonous error in ffmpeg
By Chemist116 in forum RestorationReplies: 2Last Post: 23rd Aug 2017, 13:24