Last active
February 1, 2023 16:45
-
-
Save vdakalov/3e5975fd0fe3019fa465760c8734b91d to your computer and use it in GitHub Desktop.
Find all video of the series, trim splash screen for each of them, keep and reorder two audio streams and make first by default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| source="/home/user/source" | |
| target="/home/user/target" | |
| find "$source" -type f -name "*.mkv" -print0 | while read -d $'\0' f; do | |
| name=$(basename "$f" .mkv) | |
| echo "$name" | |
| ss=$(ffprobe -i "$f" 2>&1 | grep "Chapter #0:1" | grep -Eo "[0-9.]+" | head -3 | tail +3) | |
| ss=$(echo $ss + 7 | bc) | |
| ffmpeg \ | |
| -v error \ | |
| -nostdin \ | |
| -y \ | |
| -i "$f" \ | |
| -ss "$ss" \ | |
| -map 0:v -c:v copy \ | |
| -map 0:a:1 -c:a:0 copy \ | |
| -map 0:a:0 -c:a:1 copy \ | |
| -disposition:a:0 default \ | |
| -async 1 \ | |
| "$target/$name.mkv" | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the stream disposition doesn't apply and first stream is remains default prepend this option with
-disposition:s:0 0that remove default disposition of the first stream.