Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ffmpeg concat 20230804013241 # 20231118122511: added: -metadata:s:v rotate="" # 20231128170123: $3 for additional parameters such as -an.
- ffco() { ffmpeg -f concat -safe 0 $3 -i "$1" -metadata:s:v rotate="" -c copy "$2"; }
- # ffco-instant from last ffmpeg file 20230914000245 # 20231118122459: added: -metadata:s:v rotate=""
- ffco-instant() {
- fflist; # 20231209120458: now that fflist autodetects if the text file was already modified, it can be run automatically.
- ffmpeg -f concat -safe 0 $2 -i "$(fflastfile)" -metadata:s:v rotate="" -c copy "$1";
- }
- # ffmute - mute audio 20231123001501
- ffmute() { ffmpeg -i "$1" -c:v copy -an "$2"; }
- # fferror - verify integrity 20231123021438 #changed to fferror-core 20240211102245
- fferror-core() { ffmpeg -v error -i "$1" -f null - ;}
- fferror() { for filename in "$@"; do echo "Checking $filename for errors."; fferror-core "$filename"; done; }
- # ffmpeg filelist generator 20231020044358
- fflist() {
- selected_file="$1"
- # auto-select last file if no argument provided
- if [ "$1" == "" ]; then selected_file="$(fflastfile)"; fi
- echo "Making file list processable for FFMPEG: $selected_file";
- # sort file names and filter out blank lines
- if [[ $(sort "$selected_file" |md5sum ) != $(cat "$selected_file" |md5sum ) ]]; then # sort if not already sorted
- sort "$selected_file" |grep -v "^$" >> "${selected_file}.sorted"
- mv "${selected_file}.sorted" "$selected_file"
- echo "File sorted: $selected_file"
- else echo "This file is already sorted: $selected_file"
- fi
- if [[ $(head -n 1 "$selected_file") == "file '"* ]]; then
- echo "This file was already made processable for FFMPEG: $selected_file";
- return 1;
- fi # return if file already modified
- sed -i -r "s/([^#]+)/file '\1'/g" "$selected_file"; # make file list digestable for ffmpeg concat, exclude comments with "#"
- }
- # return last text file for concatenation
- fflastfile() { ls -t -1 ~/Documents/massdmp/ffmpeg* |head -n 1; }
- # audioreset - instantly restart laggy audio driver - 20231123230335
- audioreset() { systemctl --user restart pulseaudio; }
- HDDspin() {
- while : ; do (sudo dd if=/dev/$@ of=/dev/null iflag=direct ibs=4096 count=1; sleep 29); done
- } # 20220828230011
- # mediainfo get videos by resolution 20240121043425
- lsvideoheight_core() {
- # $1 = height
- # $2 = current file name
- mediainfo_result=$(mediainfo "$2" |egrep "(Complete name|Height.*: $1)");
- mediainfo_height=$(echo "$mediainfo_result" | tail -n 1 );
- if ( [[ $mediainfo_height == "Height"*": $1 pixels" ]] ); # if video height matches; no quotation marks to remove excessive spaces
- then { echo "$mediainfo_result" | head -n 1 | grep "$2" |sed -r "s/^.*: //g"; }; fi # remove everything except the file path
- }
- lsvideoheight() {
- # Iterate though multiple files.
- # Two separate loops because arguments containing file names with spaces can not be passed through a variable containing either all files in the current directory or all specified files, because they would be stringified into one argument.
- argument_count=0; # for loop skips over first argument with video height
- if [ ! "$2" ]; then # no file specified = list all in current directory
- for current_item in "" *; # blank dummy string so files start at second argument; not using "${@:2}" for sh compatibility
- do { if [ $argument_count -ge 1 ] && [ -f "$current_item" ]; then lsvideoheight_core "$1" "$current_item"; fi; # files only, exclude directories
- argument_count=$(( argument_count + 1 ));
- }
- done
- else # specified file names and directories
- for current_item in "$@";
- do {
- if (test $argument_count -ge 1 ); then
- # directory handler: if current item is a directory
- if [ -d "$current_item" ]; then
- for subfile in "$current_item"/*; do lsvideoheight_core "$1" "$subfile"; done
- else lsvideoheight_core "$1" "$current_item";
- fi;
- fi;
- argument_count=$(( argument_count + 1 ));
- }
- done
- fi
- }
- ls4320p() { lsvideoheight "4 320" "$@"; } # 8K
- ls2160p() { lsvideoheight "2 160" "$@"; } # 4K
- ls1440p() { lsvideoheight "1 440" "$@"; } # QHD / WQHD
- ls1080p() { lsvideoheight "1 080" "$@"; } # Full HD
- ls720p() { lsvideoheight "720" "$@"; } # HD
- ls480p() { lsvideoheight "480" "$@"; } # HQ ("high quality") / SD ("standard definition")
- # aliases
- alias ls8K=ls4320p;
- alias ls4K=ls2160p;
- alias lsUHD=ls2160p;
- alias lsQHD=ls1440p;
- alias lsFHD=ls1080p;
- alias lsHD=ls720p;
- # no alias for 480p because the abbreviations "HQ" and "SD" have ambiguous meanings such as "SD card".
- # import 20240201192822
- window_title() { printf "\033]0;$*\007"; } # 20220809154814 to prevent opening "iotop" window in task switcher.
- # 20240226104528
- flush_N() {
- echo "[incoming]" >>~/Documents/N-Mint.2023-04-11.txt
- cat ~/Documents/N-Mint-incoming.20230911101930.txt >>~/Documents/N-Mint.2023-04-11.txt
- truncate ~/Documents/N-Mint-incoming.20230911101930.txt --size=0
- }
- remove_invalid_char() { rename "s/[^A-Za-z0-9- \.]/_/g" "$@"; } # 20240302015720
- # totalsize 20240307234812
- totalsize() { du -sh -c "$@" |tail -n 1; }
- # getfps 20240309145929 - ffprobe only accepts one file.
- getfps() { ffprobe -v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate "$1"; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement