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 "Creating concatinated video from: $selected_file"
- # sort file names and filter out blank lines
- sort "$selected_file" |grep -v "^$" >> $selected_file.sorted
- mv "${selected_file}.sorted" "$selected_file"
- if [[ $(head -n 1 $selected_file) == "file '"* ]]; then 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; }
- # mediainfo table 20231130012905 (Filter out useless audio "frame rate" first)
- mediainfotable() { mediainfo "$@" |grep -v "Frame rate.*SPF" |grep -P "(name|Width|Height|Frame rate )" |tr '\n' ' ' |sed -r 's/FPS/FPS\n/g' |sed -r "s/( )+//g"; }
- # redact geotag from video for privacy 20231203215921
- gpsnull() { sed -i -r "s/\+[0-9][0-9]\.[0-9][0-9][0-9][0-9]\+[0-9][0-9][0-9]\.[0-9][0-9][0-9][0-9]\//+00.0000+000.0000\//g" "$@"; }
- gpsnull_exif() { exiftool -gps:all="" "$@"; } # for pictures 20231218172111
- # only list time stamp and file name
- lstimestamp() { ls -l --full-time "$@" | sed -r "s/\*//g" |sed -r "s/\.000000000//g" |sed -r "s/^.* (2[0-9][0-9][0-9]-)/\1/g"; }
- # 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 == *"$1"* ]] ); # if video height matches
- 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_filename in "" *; # blank dummy string so files start at second argument; not using "${@:2}" for sh compatibility
- do { if (test $argument_count -ge 1 ); then lsvideoheight_core "$1" "$current_filename"; fi;
- argument_count=$(( argument_count + 1 ));
- }
- done
- else # list specified file names
- for current_filename in "$@";
- do { if (test $argument_count -ge 1 ); then lsvideoheight_core "$1" "$current_filename"; fi;
- argument_count=$(( argument_count + 1 ));
- }
- done
- fi
- }
- ls4320p() { lsvideoheight "2 160" "$@"; } # 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".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement