-
Notifications
You must be signed in to change notification settings - Fork 5
Home
Code or bash sniplets and useful scripts
Rename filenames (without spaces) "from-*.*" to "to-*.*" using Regular Expressions
for i in *; do mv "$i" "`echo $i | sed "s/from-/to-/"`"; done
Rename filenames (without spaces) to filenames with creation date (YYYYMMDD-HHMMSS)
for i in *; do mv "$i" "`stat -c %Y $i | awk '{print strftime("%Y%m%d-%H%M%S", $1)}'`".${i#*.}; done
exiftool -d %Y%m%d-%H%M%S%%-c.%%e "-FileName<DateTimeOriginal" <filename>
exiftool '-datetimeoriginal<filemodifydate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "JPEG")' .If you are interested in moving all files (but not folders) from Downloads folder to Videos folder, use this command
find ~/Downloads/ -type f -print0 | xargs -0 mv -t ~/Videos
find . -type f -iname "*.umap" -print0 | xargs -0 -i md5sum {} | sort | uniq -w 32 --all-repeated=separate | uniq -w 32 | awk 'NF {print $2}' | xargs -I{} echo mv {} {}.keep
for folder in *; do if [ -d "$folder" ]; then cd "$folder" for file in *; do mv -- "$file" "${folder}_$file" done cd .. fi done
j=0;for i in *;do ((j++));mv $i $(printf "%04d\n" $j).jpg; done
for i in *; do mv "$i" "`echo $i | sed -e "s/^\(.*\)\([0-9]\{2\}\)\.\([0-9]\{2\}\)\.\([0-9]\{4\}\)\(.*\)$/\4\3\2_\0/;s/PDF/pdf/"`"; done
IFS=$'\n';for i in $(find . -type f -iname "*.pdf"); do cp "$i" .; donerequires /usr/bin/rename (a Perl script):
sudo find . -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;
- https://twitter.com/Wikinaut/status/1339542686387359747ffmpeg -i output0.mp3 -map_metadata -1 -write_xing 0 -id3v2_version 0 -c copy output00.mp3
nl -w4 -n rz -s ' ' text.txt -w4: 4 digits -n rz: leading zeroes -s ' ': separated by a single space
Delete files older than 30 days
find . -mtime +30 -print0 | xargs -0 rm find . -mtime +30 -print0 | xargs -0 rm -Rf (recursive, force = dangerous)
See http://stackoverflow.com/questions/16758525/use-xargs-with-filenames-containing-whitespaces for the use of -print0 and -0 options to allow filenames with white spaces.
find . -type f -name "*" -newermt 2016-01-17 ! -newermt 2016-01-18 -print0 | xargs -0 --no-run-if-empty ls -lsa
Edit the /etc/updatedb.conf file. Add the paths to the PRUNEPATHS line and then re-run updatedb. For example:
PRUNEPATHS="/tmp /timeshift /var/spool /media /mnt"
find . -name "*.gz" -print0 | xargs -0 zgrep -i -E "(ne.dle1|needle2)"
Show "heavy" directories deeper than /this-dir.... ordered by size, show size in Megabytes (M) or Gigabytes (G)
sudo du -BM / | sort -nr | head -n 40 sudo du -BG / | sort -nr | head -n 40
du -h --max-depth=1 | lpr
find /this-dir -type f | wc -l find . -type f | wc -l
ls -p | grep -v /
find . -maxdepth 1 -type d
cat `ls -- files*.ext | sort -V` > files-all.ext
ls | sed -e 's/^\(.*\)\([0-9]\{2\}\)\.\([0-9]\{2\}\)\.\([0-9]\{4\}\)\(.*\)$/\4\3\2_\0/;s/PDF/pdf/' | sort -r
sort infile | uniq > outfile
comm -23 <(sort file1) <(sort file2)
Zip (or zip and move) all files older than x days
Usage:
./zip-all-files-older-than.sh number-of-days [move]
#!/bin/bash # 20121217 if [ $1 ] ; then UNTIL="$(date "+%Y%m%d" -d "$1 days ago")" if [ $2 ] && [ $2 == move ] ; then echo "zip and move all files older than $1 days (until $UNTIL)" find . -daystart -mtime +$(($1-1)) | xargs zip -m files-$UNTIL.zip ls -lh files-$UNTIL.zip df -h else echo "zip all files older than $1 days (until $UNTIL)" find . -daystart -mtime +$(($1-1)) | xargs zip files-$UNTIL.zip ls -lh files-$UNTIL.zip df -h fi else echo zip all files older than n days echo Usage: $0 n [move] fi exit
echo; echo "PHYSICAL CPUs:"; grep "physical id" /proc/cpuinfo | sort | uniq | wc -l; echo; echo "CPU Cores:"; grep "cpu cores" /proc/cpuinfo | uniq; echo; echo "VIRTUAL PROCESSORS:"; grep "^processor" /proc/cpuinfo
- see also http://www.sysadminslife.com/linux/quicktipp-installierte-linux-distribution-anzeigen-und-version-herausfinden/
- https://linuxconfig.org/check-what-debian-version-you-are-running-on-your-linux-system
cat /proc/version cat /etc/os-release uname -a uname -mrs lsb_release -a hostnamectl
sudo dmidecode -t bios
mount -o remount,rw /media/user/device /media/user/device
sudo systemd-resolve --flush-caches
time echo "scale=4000; a(1)*4" | bc -l
or use sysbench, see http://developer-blog.net/hardware/benchmark/
sysbench --test=cpu --cpu-max-prime=20000 run
or vanitygen.
Rsync has two major modes of operation: the modes are dependent on the absence or presence of the trailing slash on the source directory. You need to add the trailing slash, otherwise, a folder called "x" is created inside the "x" folder that we specify as destination.
- https://serverfault.com/questions/529287/rsync-creates-a-directory-with-the-same-name-inside-of-destination-directory
- http://www.jveweb.net/en/archives/2010/11/synchronizing-folders-with-rsync.html
-
https://wiki.archlinux.org/index.php/Full_system_backup_with_rsync
; show overall progress info and transfer speed instead of huge list of files. rsync -aAX --info=progress2 --log-file="/home/benutzer/rsync.log" --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /path-to-backup/ /path/to/backup/folder ; show huge list of files rsync -aAXv --log-file="/home/benutzer/rsync.log" --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /path-to-backup/ /path/to/backup/folder sudo rsync --dry-run -aAXv --log-file="/root/rsync.log" --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/home/**/.thumbnails/*","/home/**/Trash/*","/home/**/.cache"} / . ; Using rsync to move (not copy) files between directories ; https://unix.stackexchange.com/questions/43957/using-rsync-to-move-not-copy-files-between-directories ; https://wiki.ubuntuusers.de/rsync/ ; https://wiki.archlinux.org/index.php/rsync rsync -avh -e ssh --progress --log-file="/home/benutzer/rsync.log" --remove-source-files /home/user/mystuff/* user@external.server:/path/to/backup find . -depth -type d -empty -delete
- https://github.com/laurent22/rsync-time-backup
- https://github.com/thomas-mc-work/rtb-wrapper rtb-wrapper: Allows creating backup profiles in config files. Handles both backup and restore operations.
- for x64 CPUs and with execution of embedded scripts
sudo alien -c --target=amd64 package.rpm
https://linuxprograms.wordpress.com/2010/05/12/remove-packages-marked-rc/
just use sudo timeshift --list-devices to list availables devices (including raid partitions) and then sudo timeshift --snapshot-device /dev/mdXXX with correct device name to set your backup destination The interface still doesn't list the partition but the backup seems ok
sed ':a;N;$!ba;s/string\n//g' <file>
- https://www.howtoforge.com/tutorial/linux-raid-replace-failed-harddisk/
- https://blog.stefan-betz.net/2015/09/06/defekte-festplatten-im-linux-software-raid-ersetzen/
- https://wiki.ubuntuusers.de/gdisk/
shell> mysql -u root -p mysql> CREATE USER 'ownclouduser'@'localhost' IDENTIFIED BY 'password'; CREATE DATABASE IF NOT EXISTS owncloud; GRANT ALL PRIVILEGES ON owncloud.* TO 'ownclouduser'@'localhost' IDENTIFIED BY 'password'; or GRANT CREATE,ALTER,SELECT,INSERT,UPDATE,DELETE ON owncloud.* TO 'ownclouduser'@'localhost' IDENTIFIED BY 'password'; FLUSH PRIVILEGES; EXIT;
mysqldump -u root -p --no-data dbname > schema.sql
#!/bin/bash echo dump and zip all databases # http://serverfault.com/questions/331057/mysqldump-unknown-table-engine-performance-schema # http://www.sysadminslife.com/linux/mysql-warning-skipping-the-data-of-table-mysql-event-debian-ubuntu/ NOW="$(date "+%Y%m%d")" mysqldump -u root -p \ --all-databases \ --events \ --default-character-set=utf8 --skip-set-charset \ --ignore-table=performance_schema.cond_instances \ --ignore-table=performance_schema.events_waits_current \ --ignore-table=performance_schema.cond_instances \ --ignore-table=performance_schema.events_waits_history \ --ignore-table=performance_schema.events_waits_history_long \ --ignore-table=performance_schema.events_waits_summary_by_instance \ --ignore-table=performance_schema.events_waits_summary_by_thread_by_event_name \ --ignore-table=performance_schema.events_waits_summary_global_by_event_name \ --ignore-table=performance_schema.file_instances \ --ignore-table=performance_schema.file_summary_by_event_name \ --ignore-table=performance_schema.file_summary_by_instance \ --ignore-table=performance_schema.mutex_instances \ --ignore-table=performance_schema.performance_timers \ --ignore-table=performance_schema.rwlock_instances \ --ignore-table=performance_schema.setup_consumers \ --ignore-table=performance_schema.setup_instruments \ --ignore-table=performance_schema.setup_timers \ --ignore-table=performance_schema.threads | gzip - > mysqldump-alldatabases_$NOW.gz
- https://www.spiller.me/error-error-running-shared-postrotate-script-for-varlogmysqllog/
- http://www.electrictoolbox.com/restore-debian-sys-maint-mysql-user/
Sequence to generate a compressed and encrypted database dump:
mysqldump <dbname> -u root -p | gzip - | openssl aes-256-cbc -salt -k <password> -out <dbdump>
Example:
mysqldump test -u root -p | gzip - | openssl aes-256-cbc -salt -k SeCrEt -out test.gz.aes
This creates test.gz.aes.
To decode this on our server use
gunzip <dbdump> --stdout | openssl aes-256-cbc -d -k <password> > <dbname>.sql
Example:
gunzip test.gz.aes --stdout | openssl aes-256-cbc -d -k SeCrEt > test.sql
Import the database dump in MySQL:
mysql <dbname> -u root -p < <dbname>.sql
or, run the command directly in MySQL:
mysql> use <dbname>; mysql> SOURCE <dbname>.sql
git checkout --orphan newBranch git add -A # Add all files and commit them git commit git branch -D master # Deletes the master branch git branch -m master # Rename the current branch to master git push -f origin master # Force push master branch to github git gc --aggressive --prune=all # remove the old files
for i in $(borg list --short $repo);do borg list --short $repo::$i "re:.*$pattern";done for i in $(borg list --short $repo);do borg list --format="{archivename} {mode} {user:6} {group:6} {size:8d} {isomtime} {path}{extra}{NEWLINE}" $repo::$i "re:.*$pattern";done
borg mount -o versions $repo /tmp/mountpoint
Read https://github.com/owncloud/core/issues/5139#issuecomment-28285731 about resulting issues "Failed to update | Multiple primary key for oc_locks table" from the Sqlite to MySQL conversion:
# show all built-in options (~320 options) gpg --dump-options gpg --dump-options | wc -l # show the fingerprint of a keyfile without importing it first # --with-fingerprint is an option, and not a regular command. But the default command (list key data) is used for the keyfile gpg --with-fingerprint KEYFILE # show internal key structures gpg --list-packets KEYFILE # generate public key from imported old PGP private keys gpg --import --allow-non-selfsigned-uid KEYFILE # use an old key for encryption gpg --e --allow-non-selfsigned-uid recipient # generate message digests (checksum, file hashes) in all available formats # the "*" must be quoted to avoid command line expansion (globbing) on operating systems like Linux gpg --print-md "*" FILENAME # set better hash defaults in ~/.gnupg/gpg.conf personal-digest-preferences SHA512 cert-digest-algo SHA512 default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed # create and verify a detached ascii armored signature file for FILENAME gpg --detach-sign -a FILENAME gpg --verify -v FILENAME.asc # clear the passphrase cache. Call that before leaving the computer. gpgconf --reload gpg-agentThis requires automake version 1.11 (see http://lists.gnupg.org/pipermail/gnupg-devel/2014-June/028537.html and see inside the script how to compile automake 1.11). The exemplary script shows what you need to compile GnuPG; a few commands require
root
privileges.
#!/bin/bash echo clone GnuPG with all dependencies from git and compile # Before actually starting the compilation, # the following two lines can create an ad-hoc backup of the libraries # with the date-time as part of the backup filename. # These files can be deleted afterwards if everything went fine. # # NOW="$(date "+%Y%m%d")" # tar -czf git-$NOW.tgz npth libgpg-error libgcrypt libassuan libksba pinentry gnupg # GnuPG compilation requires automake version 1.11 # # please make sure that automake 1.11 is installed (automake-1.11 on Debian). # Newer automakes are not compatible, because # - these have parallel regression tests enabled by default # - old automakes do not have an option for disabling # # if you have a recent automake: # for compiling GnuPG install automake 1.11 using the following steps: # # wget http://ftp.gnu.org/gnu/automake/automake-1.11.6.tar.gz # wget http://ftp.gnu.org/gnu/automake/automake-1.11.6.tar.gz.sig # wget ftp://ftp.gnu.org/gnu/gnu-keyring.gpg # gpg --verify --keyring ./gnu-keyring.gpg automake-1.11.6.tar.gz.sig # tar -xzf automake-1.11.6.tar.gz # cd automake-1.11.6/ # ./configure # make # AUTOMAKE_SUFFIX=1.11 # check if automake version == 1.11 # automake --version rm -rf npth libgpg-error libgcrypt libassuan libksba pinentry gnupg for i in npth libgpg-error libgcrypt libassuan libksba pinentry gnupg ; do git clone --depth 1 git://git.gnupg.org/$i.git # Alternative location in case the other cannot be accessed: # git clone http://git.spodhuis.org/gnupg.org/$i.git cd $i ./autogen.sh if [ $i -eq gnupg ] ; then ./configure --enable-maintainer-mode else ./configure --enable-maintainer-mode fi make sudo make install cd .. done sudo pkill gpg-agent
cd /usr/local/src ./make-gnupg.sh # check the compiled gpg2 version cd /usr/local/src/gnupg/g10 ./gpg2 --version
(not tested)
- backup the .gnupg directory
- export your key and store it in a safe place
- start key-editor: gpg --edit-key YourID
- selected expired subkeys (e.g. key 1), the selected subkey is marked with "*"
- delete this subkey with "delkey"
- remove with "uid number" and "deluid" not needed further User-IDs
- exit the gpg key-editor
- re-import your own key which is now of minimal size
- re-import your own private key from step 2
- check whether your key is complete. If not: restore the backup from step 1
- see https://admin.hostpoint.ch/pipermail/enigmail-users_enigmail.net/2014-January/001262.html
- see https://www.enigmail.net/download/source.php
git clone git://git.code.sf.net/p/enigmail/source enigmail ; or git clone --branch enigmail-1-4-3 git://git.code.sf.net/p/enigmail/source enigmail make distclean ./configure make make xpi
# this is no longer needed for cross-compilation (since 28.01.2014) # ./configure --host=i686-pc-mingw32 ; for cross-compilation with http://mxe.cc/ # # make distclean # ./configure --host=i686-pc-mingw32 ; for cross-compilation with http://mxe.cc/ # make # make xpi # # When cross-compiling for windows: # the problem is that install.rdf file is not adapted properly. # You'll have to unzip enigmail.xpi # remove a line in file install.rdf: # # # cd build # unzip enigmail-1.6-win32-x86-msvc.xpi # ( edit install.rdf ) # ( remove the line "<em:targetPlatform>...</em:platform>" ) # zip -r enigmail-1.6-win32-x86-msvc.xpi * # ^these steps are no longer needed.
- OpenPGP Encryption for Webmail (client-side encryption, encryption in the browser)
- https://github.com/toberndo/mailvelope
#!/bin/bash # based on https://github.com/toberndo/mailvelope NOW="$(date "+%Y%m%d-%H%M%S")" echo Make a fresh and shallow clone of Mailvelope with all dependencies from git and compile echo Create a backup of local repositories in mailvelope-$NOW.tgz tar -czf mailvelope-$NOW.tgz mailvelope addon-sdk rm -r mailvelope addon-sdk git clone --depth 1 git://github.com/toberndo/mailvelope.git cd mailvelope git submodule init git submodule update make build cd .. git clone --depth 1 git://github.com/mozilla/addon-sdk.git cd addon-sdk source bin/activate cd ../mailvelope make dist-ff
cd /usr/local/src ./make-mailvelope.sh # check the resulting file dir /usr/local/src/mailvelope/dist/mailvelope.firefox.xpi
# script: # ogg2mp3.sh ogg123 -d wav x.ogg -f out.wav ogg123 -d wav x.ogg -f - | lame -q0 -V2 -ms - out.mp3 ogg123 -d wav x.ogg -f - | lame -q0 -b 256 -ms - out.mp3
# use mplayer! # script wma2wav.bat mplayer -vc null -vo null -af resample=44100 -ao pcm:fast -ao pcm:waveheader -ao pcm:file="out.wav" "in.wma" mplayer -vc null -vo null -af resample=44100 -ao pcm:fast -ao pcm:waveheader -ao pcm:file="out.wav" "in.mp3"
# use wma2ogg.pl which is an mplayer tool script in /usr/lib/mplayer # see https://help.ubuntu.com/community/MPlayerTips # script wma2ogg.pl /usr/lib/mplayer/wma2ogg.pl -lame -t mp3 -f <filename.WMA>
ffmpeg -i input.mp4 -c copy -map 0:a:0 output.aac (or output.m4a)
ffmpeg -f concat -safe 0 -i <(for f in ./*.mp4; do echo "file '$PWD/$f'"; done) -c copy temp.mp4; ffmpeg -r 25 -i temp.mp4 -strict -2 -c copy out.mp4
ffmpeg -i in.mp4 -movflags faststart -acodec copy -vcodec copy out.mp4The -movflags faststart parameter is what tells ffmpeg to reorder the MP4 video atoms so that moov is at the start. We are also instructing ffmpeg to copy the video and audio data instead of re-encoding them, so nothing gets altered.
- https://trac.ffmpeg.org/ticket/6507 ffmpeg always leaves "encoder: Lavf57.75.100"
ffmpeg -i in.mp4 -c:v copy -c:a copy -metadata encoder="" -fflags +bitexact out.mp4
ffmpeg -i in.mp4 -vf vflip -c:a copy out.mp4
ffmpeg -i infile.mkv -c copy outfile.mp4
ffmpeg -i in.mov -vcodec libx264 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -pix_fmt yuv420p -strict experimental -r 30 -t 2:20 -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100 -ac 2 out.mp4
- https://twitter.com/Wikinaut/status/1355314141519618051
- use I-frames only to minimize play length; apply filte option to enable loop-playing
- bash script: https://gist.github.com/Wikinaut/fa5145684e6943a4fd7eecc5ac271957
ffmpeg -loop 1 -i stillimage.png -i audio.mp3 -filter_complex "loop=-1:1:0" -c:v libx264 -x264-params keyint=1 -shortest -pix_fmt yuv420p -c:a aac video-for-twitter.mp4
fmpeg -loop 1 -framerate 25 -i stillimage.png -i audio.wav -filter_complex "loop=-1:1:0" -c:v libx264 -x264-params keyint=100 -shortest -pix_fmt yuv420p -c:a aac video-for-twitter.mp4
ffmpeg -r 25 -i in.webm -strict -2 -c copy out.mp4
https://til.simonwillison.net/macos/downloading-partial-youtube-videos
Here's another fun variation if you like ocean wave sounds (it's not perfect).play -n synth brownnoise synth pinknoise mix synth 0 0 0 15 40 80 trapezium amod 0.2 20
play -n synth sin 900 bend 0.3,800,1 bend 1.2,-150,1 trim 0 3.5 reverb -w
play -n synth 0.5 saw 300-2000 repeat - vol 0.5
espeak -f <filename.txt> -s 150 -vde --stdout | lame -h -V2 - "filename.mp3"
Google Android TTS https://elinux.org/RPi_Text_to_Speech_(Speech_Synthesis)
sudo apt-get install libttspico-utils pico2wave -w out.wav -l de-DE "Deutschlandradio Kultur" && aplay out.wav
Filme transkodieren
- http://www.zoharbabin.com/build-and-install-ffmpeg-and-x264-on-debian-squeeze-the-dumb-guide
- http://ubuntuforums.org/showthread.php?t=1564791
- http://www.ffmpeg.org/documentation.html
cat /media/DVD_VIDEO_RECORDER/VIDEO_TS/VTS_01_*.VOB | ffmpeg -i - -strict -2 -vcodec libx264 /work/video_all.mp4
mp4 to ogg vorbis audio and video https://trac.ffmpeg.org/wiki/TheoraVorbisEncodingGuide
ffmpeg -i input.mp4 -codec:v libtheora -qscale:v 7 -codec:a libvorbis -qscale:a 5 output.ogv
# transcoding to "-V2 -q0 -ms" example lame -ms -V2 -q0 -mp3input in.mp3 out.mp3 # -mp3input is default for mp3 input files. so we can use lame -ms -V2 in.mp3 out.mp3
Use ffmpeg with vidstab: https://github.com/georgmartius/vid.stab
# pass1 ffmpeg -i input.mp4 -vf vidstabdetect -f null - # pass2 ffmpeg -i input.mp4 -vf vidstabtransform=crop=black:smoothing=20,unsharp=5:5:0.8:3:3:0.4 output.mp4
https://www.martin-riedl.de/2019/08/10/remove-station-logo-from-video-using-ffmpeg/
How to remove two station logos, starting at 10' and processing 15 seconds only:
ffmpeg -i in.mp4 -ss 00:10:00 -vf "delogo=x=1100:y=47:w=121:h=46,delogo=x=87:y=47:w=46:h=56" -t 15 out.mp4
https://stackoverflow.com/questions/8672809/use-ffmpeg-to-add-text-subtitles http://stackoverflow.com/a/13125122/731798
Requirements:
Install Aegisub program http://www.aegisub.org/ for editing subtitles. Install ffmpeg as the "Swiss Army Knife" for video processing including "hard-subbing" (to burn subtitles into the video).
# if you have an srt file, then convert to ass ffmpeg -i 1.srt 1.ass # use yuv420 for compatibility with old decoders ffmpeg -i "video-without-subtitles.mp4" -vf ass="subtitle-textfile.ass" -c:v libx264 -r 25 -pix_fmt yuv420p "video-with-subtitles.mp4"
- https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo
- https://www.bannerbear.com/blog/how-to-add-subtitles-to-a-video-with-ffmpeg-5-different-styles/
ffmpeg -i in.mp4 -vf subtitles=in.srt out.mp4
ffmpeg -i in.mp4 -vf "subtitles=in.srt:force_style='PrimaryColour=&H00ffff&,FontSize=18,OutlineColour=H40000000&,BorderStyle=3,Spacing=1.0,BackColour=Black,Outline=1'" out.mp4
!#/bin/bash for i in *.ass do # encode ("burn") subtitle files into video files # use yuv420 for compatibility with old decoders ffmpeg -i 1.mp4 -vf ass=$i -c:v libx264 -r 25 -pix_fmt yuv420p ${i%.*}.mp4 done
sed -e "0,/^Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text/d;s/^Dialogue:.*\([0-9]\+:[0-9]\+:[0-9]\+.[0-9]\+\).*Default.*0,,\(.*\)/\1 \2/g;s/{\\\i1}/<i>/g;s/{\\\i0}/<\/i>/g;s/\\\N/<br>/g" $1 $2
mplayer -vc null -vo null -ao pcm:fast:waveheader:file="out.wav" rtsp://stream4.rbb-online/.... mplayer -dumpstream -dumpfile out.mp3 http://kulturradio.de/livemp3
Videos mit Untertiteln umkodieren Ich kodiere meine Videos regelmäßig gemäß Ihrer Anleitung aus c’t 13/2019, Seite 174 („Stummfilm auf dem Asus Media Player“) um, weil mein Mediaplayer das Audioformat EAC3 nicht beherrscht. Dazu verwende ich ffmpeg mit folgenden Optionen: ffmpeg -i <videofile> -c:v copy -c:s copy -c:a ac3 <outfile> Allerdings kopiert das nur je einen Audio- und Untertitel-Stream. Ich möchte aber gerne alle Untertitel bewahren, um den Film im Zweifelsfall auch mit deutschen Untertiteln abspielen zu können. Wie mache ich das? Dazu müssen Sie ffmpeg explizit ein Mapping übergeben. Das geht einfach, indem Sie -map 0 vor dem -c:v einfügen. Damit kopiert ffmpeg alle Streams. Alternativ können Sie auch gezielt Untertitel auswählen. Allerdings schaltet das explizite Mapping die automatische Auswahl komplett ab, sodass Sie dann auch Audio- und Video-Streams spezifizieren müssen. Mit diesem Aufruf kopieren Sie beispielsweise den ersten Video-Stream, konvertieren die erste Audiospur und kopieren die englischen und die deutschen Untertitel: ffmpeg -i <video> -map 0:v -map 0:a -map 0:s:0 -map 0:s:15 -c:v copy -c:s copy -c:a ac3 <outfile> Das ergibt dann folgendes Mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (eac3 (native) -> ac3 (native)) Stream #0:2 -> #0:2 (copy) Stream #0:17 -> #0:3 (copy) Zu beachten ist dabei, dass ffmpeg die Streams nach Typen getrennt zählt und dabei jeweils bei 0 beginnt. Aufgrund der vorangestellten Video- (0) und Audio-Streams (1) muss man den Stream Nummer 17 mit den deutschen Texten deshalb als 15. Untertitel-Stream (s:15) spezifizieren. Ein Aufruf von ffmpeg -i <videofile> zeigt Ihnen übrigens, was sich in welchen Streams befindet. (ju@ct.de)Gnome: Strg+Alt+Shift+R
- gsettings get org.gnome.settings-daemon.plugins.media-keys max-screencast-length
- gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 7200
- https://askubuntu.com/questions/229352/how-to-record-output-to-speakers
- Command line: https://askubuntu.com/a/850174
# lookup where the output is sent to # pacmd list-sinks | grep -e 'name:' -e 'index' -e 'Speakers' parec -d alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | lame -r -V0 - recorded.mp3
mplayer -af scaletempo <file> mplayer -af scaletempo -speed 2.0 <file> mplayer -af scaletempo -speed 0.5 <file>
increase/decrease playing speed +/-10% [ ]
, by factor 2, 1/2 { }
https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
ffmpeg -i infile.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" outfile.mp4
# detect volume ffmpeg -i infile.mp4 -af "volumedetect" -f null /dev/null # adjust volume ffmpeg -i infile.mp4 -vcodec copy -af "volume=20dB" output_20dB.mp4
# convert mp4 to ts for i in *.mp4;do ffmpeg -i $i -c copy -bsf:v h264_mp4toannexb -f mpegts "${i%.*}.ts"; done # concatenate ts and write mp4 ffmpeg -i "concat:1.ts|2.ts|3.ts|4.ts|5.ts|6.ts|7.ts|8.ts" -c copy -bsf:a aac_adtstoasc temp.mp4 # timelapse 50% ffmpeg -i temp.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" out.mp4 # keyframes every 5th frame: ffmpeg -i in.mp4 -x264-params keyint=5:scenecut=0 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" out.mp4
ffmpeg -i in.mp4 -filter:v "crop=550:720:500:0,transpose=1" -c:a copy out.mp4
- https://stackoverflow.com/questions/3937387/rotating-videos-with-ffmpeg
- https://gist.github.com/cmlewis/f950d876171a11703f89
ffmpeg -i in.mp4 -metadata:s:v rotate="-90" -codec copy out.mp4
ffmpeg -i "video.mpg.AVI" -acodec libfaac -ac 2 -ab 128k -vcodec libx264 -crf 21 -threads 0 "video.mp4"
https://twitter.com/Wikinaut/status/1074964714675994624
How to extract every frame
ffmpeg -i in.mp4 img%04d.jpg
How to extract every n-th frame, every keyframe, or frames every n-th second:
- https://superuser.com/questions/170619/how-to-extract-frames-using-ffmpeg
- https://www.bugcodemaster.com/article/extract-images-frame-frame-video-file-using-ffmpeg
- https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video
ffmpeg -i in.mp4 -vf fps=1/5 img%04d.jpg -hide_bannerAdd an overlay.png (here: the mask with a transparent background) to a movie (in.mp4):
ffmpeg -i in.mp4 %04d.split.png for i in *.split.png; do composite -gravity center overlay.png $i $i.png;done ffmpeg -pattern_type glob -i '*.png.png' -c:v libx264 -r 25 -pix_fmt yuv420p "out.mp4"
Single line version:
- https://twitter.com/Wikinaut/status/1340931518479409153
- https://video.stackexchange.com/questions/12105/add-an-image-overlay-in-front-of-video-using-ffmpeg
ffmpeg -i in.mp4 -i overlay.png -filter_complex "[0:v][1:v] overlay=0:0" -pix_fmt yuv420p -c:a copy ou
- https://superuser.com/questions/377343/cut-part-from-video-file-from-start-position-to-end-position-with-ffmpeg
- https://trac.ffmpeg.org/wiki/Seeking
ffmpeg -ss starttime -i in.mp4 -t length -c copy out.mp4 ffmpeg -ss 2640 -i in.mp4 -t 00:05:20 -c copy out.mp4
ffmpeg -i in.mp4 -filter_complex '[0:v]scale=ih*16/9:-1,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,crop=h=iw*9/16' out.mp4
- https://www.rigacci.org/wiki/doku.php/doc/appunti/linux/video/fix_smartphone_portrait_videos
- Glove and Boots: "Say 'no' to vertical videos" https://www.youtube.com/watch?v=Bt9zSfinwFA
echo $(sox audio.mp3 -n stat 2>&1 | sed -n 's#^Length (seconds):[^0-9]*\([0-9.]*\)$#\1#p')
ffmpeg -i "video.mp4" -vn -codec:a copy -f mp3 "audio-track.mp3" or ffmpeg -i "video.mp4" -vn -ar 44100 -ac 2 -ab 192k -f mp3 "audio-track.mp3"
make sure that ffmpeg only extracts and does not re-encode https://askubuntu.com/a/437799 https://askubuntu.com/questions/437798/how-to-extract-aac-audio-from-an-mp4-file-to-m4a
ffmpeg -i input.mp4 -vn -c:a copy output.m4a
Export cover image
ffmpeg -i file.mp3 cover-image.jpg
Import cover image
ffmpeg -i "infile.mp3" -i "cover-image.jpg" -codec:a copy -map_metadata 0 -map 0 -map 1 "outfile-with-image.mp3"
cat Track{1..4}.mp3 > GESAMT.mp3 ffmpeg -i GESAMT.mp3 -acodec copy Code or bash sniplets and useful scripts
Rename files "from-*.*" to "to-*.*" using Regular Expressions
for i in *; do mv "$i" "`echo $i | sed "s/from-/to-/"`"; doneIf you are interested in moving all files (but not folders) from Downloads folder to Videos folder, use this command
find ~/Downloads/ -type f -print0 | xargs -0 mv -t ~/Videos
find . -type f -iname "*.umap" -print0 | xargs -0 -i md5sum {} | sort | uniq -w 32 --all-repeated=separate | uniq -w 32 | awk 'NF {print $2}' | xargs -I{} echo mv {} {}.keep
for folder in *; do if [ -d "$folder" ]; then cd "$folder" for file in *; do mv -- "$file" "${folder}_$file" done cd .. fi done
j=0;for i in *;do ((j++));mv $i $(printf "%04d\n" $j).jpg; done
for i in *; do mv "$i" "`echo $i | sed -e "s/^\(.*\)\([0-9]\{2\}\)\.\([0-9]\{2\}\)\.\([0-9]\{4\}\)\(.*\)$/\4\3\2_\0/;s/PDF/pdf/"`"; done
IFS=$'\n';for i in $(find . -type f -iname "*.pdf"); do cp "$i" .; donerequires /usr/bin/rename (a Perl script):
sudo find . -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;
nl -w4 -n rz -s ' ' text.txt -w4: 4 digits -n rz: leading zeroes -s ' ': separated by a single space
Delete files older than 30 days
find . -mtime +30 -print0 | xargs -0 rm find . -mtime +30 -print0 | xargs -0 rm -Rf (recursive, force = dangerous)
See http://stackoverflow.com/questions/16758525/use-xargs-with-filenames-containing-whitespaces for the use of -print0 and -0 options to allow filenames with white spaces.
find . -type f -name "*" -newermt 2016-01-17 ! -newermt 2016-01-18 -print0 | xargs -0 --no-run-if-empty ls -lsa
Edit the /etc/updatedb.conf file. Add the paths to the PRUNEPATHS line and then re-run updatedb. For example:
PRUNEPATHS="/tmp /timeshift /var/spool /media /mnt"
find . -name "*.gz" -print0 | xargs -0 zgrep -i -E "(ne.dle1|needle2)"
Show "heavy" directories deeper than /this-dir.... ordered by size, show size in Megabytes (M) or Gigabytes (G)
sudo du -BM / | sort -nr | head -n 40 sudo du -BG / | sort -nr | head -n 40
du -h --max-depth=1 | lpr
find /this-dir -type f | wc -l find . -type f | wc -l
ls -p | grep -v /
find . -maxdepth 1 -type d
cat `ls -- files*.ext | sort -V` > files-all.ext
ls | sed -e 's/^\(.*\)\([0-9]\{2\}\)\.\([0-9]\{2\}\)\.\([0-9]\{4\}\)\(.*\)$/\4\3\2_\0/;s/PDF/pdf/' | sort -r
sort infile | uniq > outfile
comm -23 <(sort file1) <(sort file2)
Zip (or zip and move) all files older than x days
Usage:
./zip-all-files-older-than.sh number-of-days [move]
#!/bin/bash # 20121217 if [ $1 ] ; then UNTIL="$(date "+%Y%m%d" -d "$1 days ago")" if [ $2 ] && [ $2 == move ] ; then echo "zip and move all files older than $1 days (until $UNTIL)" find . -daystart -mtime +$(($1-1)) | xargs zip -m files-$UNTIL.zip ls -lh files-$UNTIL.zip df -h else echo "zip all files older than $1 days (until $UNTIL)" find . -daystart -mtime +$(($1-1)) | xargs zip files-$UNTIL.zip ls -lh files-$UNTIL.zip df -h fi else echo zip all files older than n days echo Usage: $0 n [move] fi exit
echo; echo "PHYSICAL CPUs:"; grep "physical id" /proc/cpuinfo | sort | uniq | wc -l; echo; echo "CPU Cores:"; grep "cpu cores" /proc/cpuinfo | uniq; echo; echo "VIRTUAL PROCESSORS:"; grep "^processor" /proc/cpuinfo
- see also http://www.sysadminslife.com/linux/quicktipp-installierte-linux-distribution-anzeigen-und-version-herausfinden/
- https://linuxconfig.org/check-what-debian-version-you-are-running-on-your-linux-system
cat /proc/version cat /etc/os-release uname -a uname -mrs lsb_release -a hostnamectl
sudo dmidecode -t bios
mount -o remount,rw /media/user/device /media/user/device
sudo systemd-resolve --flush-caches
time echo "scale=4000; a(1)*4" | bc -l
or use sysbench, see http://developer-blog.net/hardware/benchmark/
sysbench --test=cpu --cpu-max-prime=20000 run
or vanitygen.
Rsync has two major modes of operation: the modes are dependent on the absence or presence of the trailing slash on the source directory. You need to add the trailing slash, otherwise, a folder called "x" is created inside the "x" folder that we specify as destination.
- https://serverfault.com/questions/529287/rsync-creates-a-directory-with-the-same-name-inside-of-destination-directory
- http://www.jveweb.net/en/archives/2010/11/synchronizing-folders-with-rsync.html
-
https://wiki.archlinux.org/index.php/Full_system_backup_with_rsync
; show overall progress info and transfer speed instead of huge list of files. rsync -aAX --info=progress2 --log-file="/home/benutzer/rsync.log" --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /path-to-backup/ /path/to/backup/folder ; show huge list of files rsync -aAXv --log-file="/home/benutzer/rsync.log" --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /path-to-backup/ /path/to/backup/folder sudo rsync --dry-run -aAXv --log-file="/root/rsync.log" --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/home/**/.thumbnails/*","/home/**/Trash/*","/home/**/.cache"} / . ; Using rsync to move (not copy) files between directories ; https://unix.stackexchange.com/questions/43957/using-rsync-to-move-not-copy-files-between-directories ; https://wiki.ubuntuusers.de/rsync/ ; https://wiki.archlinux.org/index.php/rsync rsync -avh -e ssh --progress --log-file="/home/benutzer/rsync.log" --remove-source-files /home/user/mystuff/* user@external.server:/path/to/backup find . -depth -type d -empty -delete
- https://github.com/laurent22/rsync-time-backup
- https://github.com/thomas-mc-work/rtb-wrapper rtb-wrapper: Allows creating backup profiles in config files. Handles both backup and restore operations.
- for x64 CPUs and with execution of embedded scripts
sudo alien -c --target=amd64 package.rpm
https://linuxprograms.wordpress.com/2010/05/12/remove-packages-marked-rc/
just use sudo timeshift --list-devices to list availables devices (including raid partitions) and then sudo timeshift --snapshot-device /dev/mdXXX with correct device name to set your backup destination The interface still doesn't list the partition but the backup seems ok
- https://www.howtoforge.com/tutorial/linux-raid-replace-failed-harddisk/
- https://blog.stefan-betz.net/2015/09/06/defekte-festplatten-im-linux-software-raid-ersetzen/
- https://wiki.ubuntuusers.de/gdisk/
shell> mysql -u root -p mysql> CREATE USER 'ownclouduser'@'localhost' IDENTIFIED BY 'password'; CREATE DATABASE IF NOT EXISTS owncloud; GRANT ALL PRIVILEGES ON owncloud.* TO 'ownclouduser'@'localhost' IDENTIFIED BY 'password'; or GRANT CREATE,ALTER,SELECT,INSERT,UPDATE,DELETE ON owncloud.* TO 'ownclouduser'@'localhost' IDENTIFIED BY 'password'; FLUSH PRIVILEGES; EXIT;
mysqldump -u root -p --no-data dbname > schema.sql
#!/bin/bash echo dump and zip all databases # http://serverfault.com/questions/331057/mysqldump-unknown-table-engine-performance-schema # http://www.sysadminslife.com/linux/mysql-warning-skipping-the-data-of-table-mysql-event-debian-ubuntu/ NOW="$(date "+%Y%m%d")" mysqldump -u root -p \ --all-databases \ --events \ --default-character-set=utf8 --skip-set-charset \ --ignore-table=performance_schema.cond_instances \ --ignore-table=performance_schema.events_waits_current \ --ignore-table=performance_schema.cond_instances \ --ignore-table=performance_schema.events_waits_history \ --ignore-table=performance_schema.events_waits_history_long \ --ignore-table=performance_schema.events_waits_summary_by_instance \ --ignore-table=performance_schema.events_waits_summary_by_thread_by_event_name \ --ignore-table=performance_schema.events_waits_summary_global_by_event_name \ --ignore-table=performance_schema.file_instances \ --ignore-table=performance_schema.file_summary_by_event_name \ --ignore-table=performance_schema.file_summary_by_instance \ --ignore-table=performance_schema.mutex_instances \ --ignore-table=performance_schema.performance_timers \ --ignore-table=performance_schema.rwlock_instances \ --ignore-table=performance_schema.setup_consumers \ --ignore-table=performance_schema.setup_instruments \ --ignore-table=performance_schema.setup_timers \ --ignore-table=performance_schema.threads | gzip - > mysqldump-alldatabases_$NOW.gz
- https://www.spiller.me/error-error-running-shared-postrotate-script-for-varlogmysqllog/
- http://www.electrictoolbox.com/restore-debian-sys-maint-mysql-user/
Sequence to generate a compressed and encrypted database dump:
mysqldump <dbname> -u root -p | gzip - | openssl aes-256-cbc -salt -k <password> -out <dbdump>
Example:
mysqldump test -u root -p | gzip - | openssl aes-256-cbc -salt -k SeCrEt -out test.gz.aes
This creates test.gz.aes.
To decode this on our server use
gunzip <dbdump> --stdout | openssl aes-256-cbc -d -k <password> > <dbname>.sql
Example:
gunzip test.gz.aes --stdout | openssl aes-256-cbc -d -k SeCrEt > test.sql
Import the database dump in MySQL:
mysql <dbname> -u root -p < <dbname>.sql
or, run the command directly in MySQL:
mysql> use <dbname>; mysql> SOURCE <dbname>.sql
git checkout --orphan newBranch git add -A # Add all files and commit them git commit git branch -D master # Deletes the master branch git branch -m master # Rename the current branch to master git push -f origin master # Force push master branch to github git gc --aggressive --prune=all # remove the old files
for i in $(borg list --short $repo);do borg list --short $repo::$i "re:.*$pattern";done for i in $(borg list --short $repo);do borg list --format="{archivename} {mode} {user:6} {group:6} {size:8d} {isomtime} {path}{extra}{NEWLINE}" $repo::$i "re:.*$pattern";done
borg mount -o versions $repo /tmp/mountpoint
Read https://github.com/owncloud/core/issues/5139#issuecomment-28285731 about resulting issues "Failed to update | Multiple primary key for oc_locks table" from the Sqlite to MySQL conversion:
# show all built-in options (~320 options) gpg --dump-options gpg --dump-options | wc -l # show the fingerprint of a keyfile without importing it first # --with-fingerprint is an option, and not a regular command. But the default command (list key data) is used for the keyfile gpg --with-fingerprint KEYFILE # show internal key structures gpg --list-packets KEYFILE # generate public key from imported old PGP private keys gpg --import --allow-non-selfsigned-uid KEYFILE # use an old key for encryption gpg --e --allow-non-selfsigned-uid recipient # generate message digests (checksum, file hashes) in all available formats # the "*" must be quoted to avoid command line expansion (globbing) on operating systems like Linux gpg --print-md "*" FILENAME # set better hash defaults in ~/.gnupg/gpg.conf personal-digest-preferences SHA512 cert-digest-algo SHA512 default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed # create and verify a detached ascii armored signature file for FILENAME gpg --detach-sign -a FILENAME gpg --verify -v FILENAME.asc # clear the passphrase cache. Call that before leaving the computer. gpgconf --reload gpg-agentThis requires automake version 1.11 (see http://lists.gnupg.org/pipermail/gnupg-devel/2014-June/028537.html and see inside the script how to compile automake 1.11). The exemplary script shows what you need to compile GnuPG; a few commands require
root
privileges.
#!/bin/bash echo clone GnuPG with all dependencies from git and compile # Before actually starting the compilation, # the following two lines can create an ad-hoc backup of the libraries # with the date-time as part of the backup filename. # These files can be deleted afterwards if everything went fine. # # NOW="$(date "+%Y%m%d")" # tar -czf git-$NOW.tgz npth libgpg-error libgcrypt libassuan libksba pinentry gnupg # GnuPG compilation requires automake version 1.11 # # please make sure that automake 1.11 is installed (automake-1.11 on Debian). # Newer automakes are not compatible, because # - these have parallel regression tests enabled by default # - old automakes do not have an option for disabling # # if you have a recent automake: # for compiling GnuPG install automake 1.11 using the following steps: # # wget http://ftp.gnu.org/gnu/automake/automake-1.11.6.tar.gz # wget http://ftp.gnu.org/gnu/automake/automake-1.11.6.tar.gz.sig # wget ftp://ftp.gnu.org/gnu/gnu-keyring.gpg # gpg --verify --keyring ./gnu-keyring.gpg automake-1.11.6.tar.gz.sig # tar -xzf automake-1.11.6.tar.gz # cd automake-1.11.6/ # ./configure # make # AUTOMAKE_SUFFIX=1.11 # check if automake version == 1.11 # automake --version rm -rf npth libgpg-error libgcrypt libassuan libksba pinentry gnupg for i in npth libgpg-error libgcrypt libassuan libksba pinentry gnupg ; do git clone --depth 1 git://git.gnupg.org/$i.git # Alternative location in case the other cannot be accessed: # git clone http://git.spodhuis.org/gnupg.org/$i.git cd $i ./autogen.sh if [ $i -eq gnupg ] ; then ./configure --enable-maintainer-mode else ./configure --enable-maintainer-mode fi make sudo make install cd .. done sudo pkill gpg-agent
cd /usr/local/src ./make-gnupg.sh # check the compiled gpg2 version cd /usr/local/src/gnupg/g10 ./gpg2 --version
(not tested)
- backup the .gnupg directory
- export your key and store it in a safe place
- start key-editor: gpg --edit-key YourID
- selected expired subkeys (e.g. key 1), the selected subkey is marked with "*"
- delete this subkey with "delkey"
- remove with "uid number" and "deluid" not needed further User-IDs
- exit the gpg key-editor
- re-import your own key which is now of minimal size
- re-import your own private key from step 2
- check whether your key is complete. If not: restore the backup from step 1
- see https://admin.hostpoint.ch/pipermail/enigmail-users_enigmail.net/2014-January/001262.html
- see https://www.enigmail.net/download/source.php
git clone git://git.code.sf.net/p/enigmail/source enigmail ; or git clone --branch enigmail-1-4-3 git://git.code.sf.net/p/enigmail/source enigmail make distclean ./configure make make xpi
# this is no longer needed for cross-compilation (since 28.01.2014) # ./configure --host=i686-pc-mingw32 ; for cross-compilation with http://mxe.cc/ # # make distclean # ./configure --host=i686-pc-mingw32 ; for cross-compilation with http://mxe.cc/ # make # make xpi # # When cross-compiling for windows: # the problem is that install.rdf file is not adapted properly. # You'll have to unzip enigmail.xpi # remove a line in file install.rdf: # # # cd build # unzip enigmail-1.6-win32-x86-msvc.xpi # ( edit install.rdf ) # ( remove the line "<em:targetPlatform>...</em:platform>" ) # zip -r enigmail-1.6-win32-x86-msvc.xpi * # ^these steps are no longer needed.
- OpenPGP Encryption for Webmail (client-side encryption, encryption in the browser)
- https://github.com/toberndo/mailvelope
#!/bin/bash # based on https://github.com/toberndo/mailvelope NOW="$(date "+%Y%m%d-%H%M%S")" echo Make a fresh and shallow clone of Mailvelope with all dependencies from git and compile echo Create a backup of local repositories in mailvelope-$NOW.tgz tar -czf mailvelope-$NOW.tgz mailvelope addon-sdk rm -r mailvelope addon-sdk git clone --depth 1 git://github.com/toberndo/mailvelope.git cd mailvelope git submodule init git submodule update make build cd .. git clone --depth 1 git://github.com/mozilla/addon-sdk.git cd addon-sdk source bin/activate cd ../mailvelope make dist-ff
cd /usr/local/src ./make-mailvelope.sh # check the resulting file dir /usr/local/src/mailvelope/dist/mailvelope.firefox.xpi
# script: # ogg2mp3.sh ogg123 -d wav x.ogg -f out.wav ogg123 -d wav x.ogg -f - | lame -q0 -V2 -ms - out.mp3 ogg123 -d wav x.ogg -f - | lame -q0 -b 256 -ms - out.mp3
# use mplayer! # script wma2wav.bat mplayer -vc null -vo null -af resample=44100 -ao pcm:fast -ao pcm:waveheader -ao pcm:file="out.wav" "in.wma" mplayer -vc null -vo null -af resample=44100 -ao pcm:fast -ao pcm:waveheader -ao pcm:file="out.wav" "in.mp3"
# use wma2ogg.pl which is an mplayer tool script in /usr/lib/mplayer # see https://help.ubuntu.com/community/MPlayerTips # script wma2ogg.pl /usr/lib/mplayer/wma2ogg.pl -lame -t mp3 -f <filename.WMA>
ffmpeg -i input.mp4 -c copy -map 0:a:0 output.aac (or output.m4a)
ffmpeg -f concat -safe 0 -i <(for f in ./*.mp4; do echo "file '$PWD/$f'"; done) -c copy temp.mp4; ffmpeg -r 25 -i temp.mp4 -strict -2 -c copy out.mp4
ffmpeg -i in.mp4 -movflags faststart -acodec copy -vcodec copy out.mp4The -movflags faststart parameter is what tells ffmpeg to reorder the MP4 video atoms so that moov is at the start. We are also instructing ffmpeg to copy the video and audio data instead of re-encoding them, so nothing gets altered.
- https://trac.ffmpeg.org/ticket/6507 ffmpeg always leaves "encoder: Lavf57.75.100"
ffmpeg -i in.mp4 -c:v copy -c:a copy -metadata encoder="" -fflags +bitexact out.mp4
ffmpeg -i in.mov -vcodec libx264 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -pix_fmt yuv420p -strict experimental -r 30 -t 2:20 -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100 -ac 2 out.mp4
- https://twitter.com/Wikinaut/status/1355314141519618051
- use I-frames only to minimize play length; apply filte option to enable loop-playing
- bash script: https://gist.github.com/Wikinaut/fa5145684e6943a4fd7eecc5ac271957
ffmpeg -loop 1 -i stillimage.png -i audio.mp3 -filter_complex "loop=-1:1:0" -c:v libx264 -x264-params keyint=1 -shortest -pix_fmt yuv420p -c:a aac video-for-twitter.mp4
fmpeg -loop 1 -framerate 25 -i stillimage.png -i audio.wav -filter_complex "loop=-1:1:0" -c:v libx264 -x264-params keyint=100 -shortest -pix_fmt yuv420p -c:a aac video-for-twitter.mp4
ffmpeg -r 25 -i in.webm -strict -2 -c copy out.mp4Here's another fun variation if you like ocean wave sounds (it's not perfect).
play -n synth brownnoise synth pinknoise mix synth 0 0 0 15 40 80 trapezium amod 0.2 20
play -n synth sin 900 bend 0.3,800,1 bend 1.2,-150,1 trim 0 3.5 reverb -w
play -n synth 0.5 saw 300-2000 repeat - vol 0.5
espeak -f <filename.txt> -s 150 -vde --stdout | lame -h -V2 - "filename.mp3"
Google Android TTS https://elinux.org/RPi_Text_to_Speech_(Speech_Synthesis)
sudo apt-get install libttspico-utils pico2wave -w out.wav -l de-DE "Deutschlandradio Kultur" && aplay out.wav
Filme transkodieren
- http://www.zoharbabin.com/build-and-install-ffmpeg-and-x264-on-debian-squeeze-the-dumb-guide
- http://ubuntuforums.org/showthread.php?t=1564791
- http://www.ffmpeg.org/documentation.html
cat /media/DVD_VIDEO_RECORDER/VIDEO_TS/VTS_01_*.VOB | ffmpeg -i - -strict -2 -vcodec libx264 /work/video_all.mp4
mp4 to ogg vorbis audio and video https://trac.ffmpeg.org/wiki/TheoraVorbisEncodingGuide
ffmpeg -i input.mp4 -codec:v libtheora -qscale:v 7 -codec:a libvorbis -qscale:a 5 output.ogv
# transcoding to "-V2 -q0 -ms" example lame -ms -V2 -q0 -mp3input in.mp3 out.mp3 # -mp3input is default for mp3 input files. so we can use lame -ms -V2 in.mp3 out.mp3
Use ffmpeg with vidstab: https://github.com/georgmartius/vid.stab
# pass1 ffmpeg -i input.mp4 -vf vidstabdetect -f null - # pass2 ffmpeg -i input.mp4 -vf vidstabtransform=crop=black:smoothing=20,unsharp=5:5:0.8:3:3:0.4 output.mp4
https://www.martin-riedl.de/2019/08/10/remove-station-logo-from-video-using-ffmpeg/
How to remove two station logos, starting at 10' and processing 15 seconds only:
ffmpeg -i in.mp4 -ss 00:10:00 -vf "delogo=x=1100:y=47:w=121:h=46,delogo=x=87:y=47:w=46:h=56" -t 15 out.mp4
https://stackoverflow.com/questions/8672809/use-ffmpeg-to-add-text-subtitles http://stackoverflow.com/a/13125122/731798
Requirements:
Install Aegisub program http://www.aegisub.org/ for editing subtitles. Install ffmpeg as the "Swiss Army Knife" for video processing including "hard-subbing" (to burn subtitles into the video).
# if you have an srt file, then convert to ass ffmpeg -i 1.srt 1.ass # use yuv420 for compatibility with old decoders ffmpeg -i "video-without-subtitles.mp4" -vf ass="subtitle-textfile.ass" -c:v libx264 -r 25 -pix_fmt yuv420p "video-with-subtitles.mp4"
ffmpeg -i in.mp4 -vf subtitles=in.srt out.mp4
!#/bin/bash for i in *.ass do # encode ("burn") subtitle files into video files # use yuv420 for compatibility with old decoders ffmpeg -i 1.mp4 -vf ass=$i -c:v libx264 -r 25 -pix_fmt yuv420p ${i%.*}.mp4 done
sed -e "0,/^Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text/d;s/^Dialogue:.*\([0-9]\+:[0-9]\+:[0-9]\+.[0-9]\+\).*Default.*0,,\(.*\)/\1 \2/g;s/{\\\i1}/<i>/g;s/{\\\i0}/<\/i>/g;s/\\\N/<br>/g" $1 $2
mplayer -vc null -vo null -ao pcm:fast:waveheader:file="out.wav" rtsp://stream4.rbb-online/.... mplayer -dumpstream -dumpfile out.mp3 http://kulturradio.de/livemp3
Videos mit Untertiteln umkodieren Ich kodiere meine Videos regelmäßig gemäß Ihrer Anleitung aus c’t 13/2019, Seite 174 („Stummfilm auf dem Asus Media Player“) um, weil mein Mediaplayer das Audioformat EAC3 nicht beherrscht. Dazu verwende ich ffmpeg mit folgenden Optionen: ffmpeg -i <videofile> -c:v copy -c:s copy -c:a ac3 <outfile> Allerdings kopiert das nur je einen Audio- und Untertitel-Stream. Ich möchte aber gerne alle Untertitel bewahren, um den Film im Zweifelsfall auch mit deutschen Untertiteln abspielen zu können. Wie mache ich das? Dazu müssen Sie ffmpeg explizit ein Mapping übergeben. Das geht einfach, indem Sie -map 0 vor dem -c:v einfügen. Damit kopiert ffmpeg alle Streams. Alternativ können Sie auch gezielt Untertitel auswählen. Allerdings schaltet das explizite Mapping die automatische Auswahl komplett ab, sodass Sie dann auch Audio- und Video-Streams spezifizieren müssen. Mit diesem Aufruf kopieren Sie beispielsweise den ersten Video-Stream, konvertieren die erste Audiospur und kopieren die englischen und die deutschen Untertitel: ffmpeg -i <video> -map 0:v -map 0:a -map 0:s:0 -map 0:s:15 -c:v copy -c:s copy -c:a ac3 <outfile> Das ergibt dann folgendes Mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (eac3 (native) -> ac3 (native)) Stream #0:2 -> #0:2 (copy) Stream #0:17 -> #0:3 (copy) Zu beachten ist dabei, dass ffmpeg die Streams nach Typen getrennt zählt und dabei jeweils bei 0 beginnt. Aufgrund der vorangestellten Video- (0) und Audio-Streams (1) muss man den Stream Nummer 17 mit den deutschen Texten deshalb als 15. Untertitel-Stream (s:15) spezifizieren. Ein Aufruf von ffmpeg -i <videofile> zeigt Ihnen übrigens, was sich in welchen Streams befindet. (ju@ct.de)Gnome: Strg+Alt+Shift+R
- gsettings get org.gnome.settings-daemon.plugins.media-keys max-screencast-length
- gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 7200
- https://askubuntu.com/questions/229352/how-to-record-output-to-speakers
- Command line: https://askubuntu.com/a/850174
# lookup where the output is sent to # pacmd list-sinks | grep -e 'name:' -e 'index' -e 'Speakers' parec -d alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | lame -r -V0 - recorded.mp3
mplayer -af scaletempo <file> mplayer -af scaletempo -speed 2.0 <file> mplayer -af scaletempo -speed 0.5 <file>
increase/decrease playing speed +/-10% [ ]
, by factor 2, 1/2 { }
https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
ffmpeg -i infile.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" outfile.mp4
# detect volume ffmpeg -i infile.mp4 -af "volumedetect" -f null /dev/null # adjust volume ffmpeg -i infile.mp4 -vcodec copy -af "volume=20dB" output_20dB.mp4
# convert mp4 to ts for i in *.mp4;do ffmpeg -i $i -c copy -bsf:v h264_mp4toannexb -f mpegts "${i%.*}.ts"; done # concatenate ts and write mp4 ffmpeg -i "concat:1.ts|2.ts|3.ts|4.ts|5.ts|6.ts|7.ts|8.ts" -c copy -bsf:a aac_adtstoasc temp.mp4 # timelapse 50% ffmpeg -i temp.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" out.mp4 # keyframes every 5th frame: ffmpeg -i in.mp4 -x264-params keyint=5:scenecut=0 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" out.mp4
ffmpeg -i in.mp4 -filter:v "crop=550:720:500:0,transpose=1" -c:a copy out.mp4
- https://stackoverflow.com/questions/3937387/rotating-videos-with-ffmpeg
- https://gist.github.com/cmlewis/f950d876171a11703f89
ffmpeg -i in.mp4 -metadata:s:v rotate="-90" -codec copy out.mp4
ffmpeg -i "video.mpg.AVI" -acodec libfaac -ac 2 -ab 128k -vcodec libx264 -crf 21 -threads 0 "video.mp4"
https://twitter.com/Wikinaut/status/1074964714675994624
How to extract every frame
ffmpeg -i in.mp4 img%04d.jpg
How to extract every n-th frame, every keyframe, or frames every n-th second:
- https://superuser.com/questions/170619/how-to-extract-frames-using-ffmpeg
- https://www.bugcodemaster.com/article/extract-images-frame-frame-video-file-using-ffmpeg
- https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video
ffmpeg -i in.mp4 -vf fps=1/5 img%04d.jpg -hide_bannerAdd an overlay.png (here: the mask with a transparent background) to a movie (in.mp4):
ffmpeg -i in.mp4 %04d.split.png for i in *.split.png; do composite -gravity center overlay.png $i $i.png;done ffmpeg -pattern_type glob -i '*.png.png' -c:v libx264 -r 25 -pix_fmt yuv420p "out.mp4"
Single line version:
- https://twitter.com/Wikinaut/status/1340931518479409153
- https://video.stackexchange.com/questions/12105/add-an-image-overlay-in-front-of-video-using-ffmpeg
ffmpeg -i in.mp4 -i overlay.png -filter_complex "[0:v][1:v] overlay=0:0" -pix_fmt yuv420p -c:a copy ou
- https://superuser.com/questions/377343/cut-part-from-video-file-from-start-position-to-end-position-with-ffmpeg
- https://trac.ffmpeg.org/wiki/Seeking
ffmpeg -ss starttime -i in.mp4 -t length -c copy out.mp4 ffmpeg -ss 2640 -i in.mp4 -t 00:05:20 -c copy out.mp4
ffmpeg -i in.mp4 -filter_complex '[0:v]scale=ih*16/9:-1,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,crop=h=iw*9/16' out.mp4
- https://www.rigacci.org/wiki/doku.php/doc/appunti/linux/video/fix_smartphone_portrait_videos
- Glove and Boots: "Say 'no' to vertical videos" https://www.youtube.com/watch?v=Bt9zSfinwFA
echo $(sox audio.mp3 -n stat 2>&1 | sed -n 's#^Length (seconds):[^0-9]*\([0-9.]*\)$#\1#p')
ffmpeg -i "video.mp4" -vn -codec:a copy -f mp3 "audio-track.mp3" or ffmpeg -i "video.mp4" -vn -ar 44100 -ac 2 -ab 192k -f mp3 "audio-track.mp3"
make sure that ffmpeg only extracts and does not re-encode https://askubuntu.com/a/437799 https://askubuntu.com/questions/437798/how-to-extract-aac-audio-from-an-mp4-file-to-m4a
ffmpeg -i input.mp4 -vn -c:a copy output.m4a
Export cover image
ffmpeg -i file.mp3 cover-image.jpg
Import cover image
ffmpeg -i "infile.mp3" -i "cover-image.jpg" -codec:a copy -map_metadata 0 -map 0 -map 1 "outfile-with-image.mp3"
cat Track{1..4}.mp3 > GESAMT.mp3 ffmpeg -i GESAMT.mp3 -acodec copy GESAMT_KORRIGIERT.mp3 rm GESAMT.mp3 id3cp Track1.mp3 GESAMT_KORRIGIERT.mp3
- https://wiki.ubuntuusers.de/Skripte/MP3_Zusammenführen/
- www.heise.de/ct/hotline/MP3-Dateien-aneinanderhaengen-2734598.html use mp3wrap
# for datei in "/videos/*.mpg ; do dx=${datei##*/} ; d=${dx%.} ; ffmpeg -i $datei cat /video/*.VOB | ffmpeg -i - -str for datei in "/videos/*.mpg ; do dx=${datei##*/} ; d=${dx%.x} ; ffmpeg -i "$datei" -strict -2 -vcodec libx264 "$d" ; done
for i in *.flv;do ffmpeg -i "${i%.*}".flv -acodec copy -vcodec libx264 -threads 0 "${i%.*}".mp4;done
ffprobe video.mpg ffplay video.mpg
- https://forum.videolan.org/viewtopic.php?t=114141
- https://gist.github.com/Wikinaut/8207c752f3f60793989948a7775fbccd
Ich vergesse ständig, wie das Kommandozeilen-Tool zur Umwandlung von Webp-Bildern in ein richtiges Bildformat heißt. Ein Aufruf nach dem Muster man -k <stichwort> zeigt alle Befehle zu einem Stichwort an, so liefert etwa man -k webp unter anderem: cwebp (1) - compress an image file to a WebP file dwebp (1) - decompress a WebP file to an image file Der Suchbegriff funktioniert als regulärer Ausdruck, sodass Sie auch zum Beispiel nach web'.\*' suchen können. Alternativ zum man-Kommando können Sie auch den Befehl apropos verwenden. (ju@ct.de)
$ xclip -sel clip -t image/png -o > image.png
The -P option preserves the original file modification date.
alias r2d='exiftool -P -d %Y%m%d-%H%M%S%%-c.%%e "-FileName<DateTimeOriginal"'
exiftool -ext jpg '-FileName<CreateDate' -d %Y%m%d_%H%M%S%%-c.%%e .
montage *.jpg -thumbnail 1200x1200 -set caption %f -background grey40 -pointsize 40 +polaroid -background white -geometry +1+1 -tile 10x20 -title "caption text" polaroid.jpg montage *.jpg -thumbnail 1200x1200 -set caption %f -background grey40 -pointsize 40 -polaroid 0 -background white -geometry +1+1 -tile 10x20 -title "caption text" polaroid.jpg
for i in *.pdf; do convert -thumbnail "1000x1000>" $i[0] ${i%.pdf}.png; done
- https://stackoverflow.com/a/13784772
- https://stackoverflow.com/questions/6605006/convert-pdf-to-image-with-high-resolution
convert -density 300 -trim in.pdf -quality 100 %d.png
convert in.png -define jpeg:extent=2MB out-2MB.jpg mogrify -define jpeg:extent=2MB *.jpg
Determine the average color of an image and create a 32x32 square with that color.
- https://twitter.com/climagic/status/1310750853914071041 Determine the dominant color of .png images in your Pictures directory by reducing it's size to 1 pixel, do 4 images at once and save the text output.
- https://superuser.com/questions/576949/getting-the-predominant-colour-in-an-image
- https://legacy.imagemagick.org/Usage/quantize/
- https://github.com/culturevis/imageplot ImagePlot is a free software tool that visualizes collections of images and video of any size. It is implemented as a macro which works with the open source image processing program ImageJ.
convert input.png -colors 256 -scale 1x1\! -scale 32x32 average-color-tile-32x32.png
- https://itila.blogspot.de/2010/02/how-to-make-animated-gif-with-small.html
- https://www.imagemagick.org/Usage/anim_basics/
- https://www.imagemagick.org/Usage/anim_opt/#optimize
convert -delay 70 -loop 0 *.png anim.gif
Problem:
You have an animated gif and want to
- zoom into an area A in the source sequence bound by (xa1,ya1), (xa2,ya2)
- move and enlarge another area B (xb1,yb1), (xb2,yb2) ; and
- merge both parts into a new output sequence.
convert \( $1 -coalesce -crop (xa2-xa1)x(ya2-ya1)+x1a+y1a -resize 500x500 +repage \) -coalesce null: \( $1 -coalesce -crop (xb2-xb1)x(yb2-yb1)+xb1+yb1 +repage -resize 120x120 \) -geometry +40+90 -layers Composite $2
#!/bin/bash # see http://www.imagemagick.org/Usage/anim_mods/#merging # convert x.gif -coalesce -crop 125x135+250+200 -resize 500x500 +repage z.gif # convert x.gif -coalesce -crop 52x22+5+5 +repage z1.gif # convert z.gif -coalesce null: \( z1.gif -resize 120x120 -coalesce \) -geometry +40+90 -layers Composite z2.gif convert \( $1 -coalesce -crop 125x135+250+200 -resize 500x500 +repage \) -coalesce null: \( $1 -coalesce -crop 52x22+5+5 +repage -resize 120x120 \) -geometry +40+90 -layers Composite $2
create a movie from still images, add their directory and filenames as caption, make 10:6 and 4:3 movies
!#/bin/bash # rewrite filenames to contain parent directory name # for f in */* ; do cp $f "../all/$(dirname $f) - $(basename $f)"; done # rename filenames # for i in *; do mv "$i" "`echo $i | sed "s/from-/to-/"`"; done # sort # ls -ls | sort -k9 # if you need this # mogrify -format tif *.png # perspective control with Shift-N # Install http://www.shiftn.de/ . On Linux, use it under WINE ! # ShiftN can process jpg, tif, bmp but cannot process png! # for png input images: # env WINEPREFIX="/home/benutzer/.wine";for i in *.png;do convert "${i%.*}.png" -format tif "${i%.*}.tif";wine C:\\Program\ Files\ \(x86\)\\ShiftN\\ShiftN.exe "${i%.*}.tif" "${i%.*}" A4; done # or for tif input images (ShiftN "A4" output is tif, see http://www.shiftn.de/ShiftN_Funktionsweise.html ) env WINEPREFIX="/home/benutzer/.wine";for i in *.tif;do wine C:\\Program\ Files\ \(x86\)\\ShiftN\\ShiftN.exe "${i%.*}.tif" "${i%.*}" A4;done size="1920x1080" # size="1280x1024" # resize to letterbox format, preserve aspect ratio for f in *.tif; do convert "$f" -resize $size -background black -compose Copy -gravity center -extent $size "$f"; done # add filename as annotation. Use pointsize 40 for 1920x1080, pointsize 28 for 1280x1024 # to list the available font names, use $ convert -list font | grep Font for f in *.tif; do convert "$f" -gravity South -undercolor '#88888880' -font "Consolas" -pointsize 40 -fill yellow -annotate 0 "%t" "$f"; done # https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images # http://www.itforeveryone.co.uk/image-to-video.html # make movie from images (use pix_fmt to create a compatible stream for older decoders) ffmpeg -framerate 1/10 -pattern_type glob -i '*.tif' -c:v libx264 -r 25 -pix_fmt yuv420p "out-${size}.mp4"
#!/bin/bash if [ $# -lt 1 ]; then echo "extend-crop-background <imagefile> [modulus [extent]]" echo "Extend or crop image to a multiple of modulus ±'extent'" echo echo "modulus: default 32" echo "extent: default=modulus" echo echo "Examples:" echo "extend-crop-background in.jpg 32" echo "extend-crop-background in.jpg 32 -32" echo "extend-crop-background in.jpg 100 -32" exit fi magick "$1" \ -background none \ -gravity center \ -set option:xmod "${2:-32}" \ -set option:zz "$3" \ -set wx '%[fx:mod(w,xmod)==0?w:w-mod(w,xmod)+zz+xmod]' \ -set hx '%[fx:mod(h,xmod)==0?h:h-mod(h,xmod)+zz+xmod]' \ -extent '%[wx]x%[hx]' \ -set filename:mod '%[xmod]' \ -set filename:size '%wx%h' \ -set filename:name '%t' \ '%[filename:name]_mod%[filename:mod]-%[filename:size].png'
https://www.youtube.com/watch?v=KRkx8kjmXZw
* Select Path → Trace Bitmap → Colors: yes → Scans: 2 → ok * Drag it down to separate: → Top is the SVG → Bottom: PNG (delete)
- see also PDF Toolkit examples
Add several PDFs into a single output PDF
pdftk 1.pdf 2.pdf ... output collated.pdf
Sort by name and add all pdf files into a single output PDF
pdftk $(ls *.pdf | sort -n) cat output all.pdfhttps://stackoverflow.com/questions/14639206/how-can-i-pass-all-arguments-with-xargs-in-middle-of-command-in-linux
Shuffle (collate) two files with 1-sided scans to one 2-sided PDF. The "shuffle" command was introduced in PDFTK 1.44 - October 28, 2010, so you need at least that version (see http://www.pdflabs.com/docs/pdftk-version-history/)
file shuffle.bat:
pdftk A=1.pdf B=2.pdf shuffle A Bend-1 output collated.pdf
pdftk A=1.pdf cat Aend-1 output reversed.pdf
pdftk A=1.pdf cat Asouth output rotated.pdf
pdftk A=in.pdf shuffle AoddLeft AevenRight output out.pdf
"When you scanned the two-sided DIN-A4-sheets of a DIN-A5-booklet with your scanner, and you want its single pages in the correct sequence", or "How to split PDF pages with double page layout in two, down the middle. Splitting one A4 into two A5 pages is a great example." then use this code:
!/bin/bash # split pdf in half fn="${1%.*}" # mutool is part of mupdf-tools mutool poster -x 0.5 "$fn.pdf" "$fn.tmp.pdf" pdftk A="$fn.tmp.pdf" cat A1-endodd Aend-2even output "$fn.split.pdf" rm "$fn.tmp.pdf"
Other possibilities and sources:
- https://superuser.com/questions/505176/converting-a-multi-sheet-per-page-pdf-to-single-sheet-per-page
- https://www.sejda.com/split-pdf-down-the-middle
- https://superuser.com/questions/437148/how-to-split-a-pdf-onto-multiple-pages-on-command-line?noredirect=1&lq=1
mutool poster -x 0.5 singlepage.pdf twopages.pdf
pdfjam --keepinfo --trim "-10mm -15mm -10mm -15mm" --clip true --suffix "cropped" in.pdf
http://stackoverflow.com/a/14538863/731798 has a working one-liner, which simply can be used as an after-burner to the output of pdf-redact-tools -merge :
gs -o out.pdf -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.4 in.pdf
Example:
convert -density 300 -compress jpeg -quality 20 in.pdf out.pdf
Better Quality:
convert -density 300 -compress jpeg -quality 50 in.pdf out.pdf
- https://github.com/tavinus/pdfScale
- https://stackoverflow.com/questions/7446552/resizing-a-pdf-using-ghostscript
function pdfresize() {
gs -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dColorConversionStrategy=/LeaveColorUnchanged -dAutoRotatePages=/None \
-dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dFIXEDMEDIA -dPDFFitPage -dNOPAUSE -dQUIET -dBATCH \
-sOutputFile="${1%.*}.reduz.pdf" "${1}"
}
- see http://linux.die.net/man/1/pdfjam-pocketmod
- http://www2.warwick.ac.uk/fac/sci/statistics/staff/academic-research/firth/software/pdfjam
- debian users: https://packages.debian.org/search?keywords=pdfjam (install textlive-extra-utils)
pdfjam --help pdfjam-pocketmod --help pdfjam-pocketmod <in.pdf> --outfile <out.pdf>
echo "" | ps2pdf -sPAPERSIZE=a4 - blank.pdf
To get to the compare view, append /compare
to your repository's path.
Still a missing feature (I asked Github to implement a button, or show a link for that). The compare help article explains how to use the compare page.
git ls-files --others --ignored --exclude-standard
- → Source: http://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git http://stackoverflow.com/a/5201642
git reset --soft HEAD~3 git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
git ls-files -i -z --exclude-from=.gitignore | xargs -0 git rm --cached
touch README.md git init git add README.md git commit -m "first commit" git remote add origin git@github.com:username/repo.git git push -u origin master
git remote add origin git@github.com:username/repo.git git push -u origin master
Generate fully-flavoured apk filename with app_name, versionName, versionCode, git hash https://gist.github.com/Wikinaut/d3eb229e1dd1ec703f00
old: ./letsencrypt-auto renew --force-renewal --agree-tos --rsa-key-size 4096
http://www.robertecker.com/hp/research/leet-converter.php
- replace twitterurls
sed 'N;s/\npattern/pattern/;P;D' file
Jobs are killed after upgrade to 21?
- https://help.nextcloud.com/t/nach-update-auf-21-occ-auf-kommandozeile-ohne-funktion/109987/4
- https://help.nextcloud.com/t/solved-occ-command-php-fatal-error-allowed-memory-size-of-xxx-bytes-exhausted/108521/17
apc.enable_cli=1
or in /etc/php/7.3/cli/php.ini:
apc.enable_cli=1If you want to openWebsite a shared video on an NEXTCLOUD instance, a change is needed. Add the rC3-Domain/s!
In /lib/public/AppFramework/Http/ContentSecurityPolicy.php:
/** @var array Domains which can embed this Nextcloud instance */ protected $allowedFrameAncestors = [ '\'self\'', 'test.visit.at.wa-test.rc3.cccv.de', ];Source: https://return2.net/nextcloud-enable-external-iframe/
GESAMT_KORRIGIERT.mp3
rm GESAMT.mp3 id3cp Track1.mp3 GESAMT_KORRIGIERT.mp3
- https://wiki.ubuntuusers.de/Skripte/MP3_Zusammenführen/
- www.heise.de/ct/hotline/MP3-Dateien-aneinanderhaengen-2734598.html use mp3wrap
# for datei in "/videos/*.mpg ; do dx=${datei##*/} ; d=${dx%.} ; ffmpeg -i $datei cat /video/*.VOB | ffmpeg -i - -str for datei in "/videos/*.mpg ; do dx=${datei##*/} ; d=${dx%.x} ; ffmpeg -i "$datei" -strict -2 -vcodec libx264 "$d" ; done
for i in *.flv;do ffmpeg -i "${i%.*}".flv -acodec copy -vcodec libx264 -threads 0 "${i%.*}".mp4;done
ffprobe video.mpg ffplay video.mpg
ffmpeg -i in.mp3 -map_metadata -1 -write_xing 0 -id3v2_version 0 -c copy out.mp3
- https://forum.videolan.org/viewtopic.php?t=114141
- https://gist.github.com/Wikinaut/8207c752f3f60793989948a7775fbccd
Ich vergesse ständig, wie das Kommandozeilen-Tool zur Umwandlung von Webp-Bildern in ein richtiges Bildformat heißt. Ein Aufruf nach dem Muster man -k <stichwort> zeigt alle Befehle zu einem Stichwort an, so liefert etwa man -k webp unter anderem: cwebp (1) - compress an image file to a WebP file dwebp (1) - decompress a WebP file to an image file Der Suchbegriff funktioniert als regulärer Ausdruck, sodass Sie auch zum Beispiel nach web'.\*' suchen können. Alternativ zum man-Kommando können Sie auch den Befehl apropos verwenden. (ju@ct.de)
The -P option preserves the original file modification date.
alias r2d='exiftool -P -d %Y%m%d-%H%M%S%%-c.%%e "-FileName<DateTimeOriginal"'
montage *.jpg -thumbnail 1200x1200 -set caption %f -background grey40 -pointsize 40 +polaroid -background white -geometry +1+1 -tile 10x20 -title "caption text" polaroid.jpg montage *.jpg -thumbnail 1200x1200 -set caption %f -background grey40 -pointsize 40 -polaroid 0 -background white -geometry +1+1 -tile 10x20 -title "caption text" polaroid.jpg
for i in *.pdf; do convert -thumbnail "1000x1000>" $i[0] ${i%.pdf}.png; done
- https://stackoverflow.com/a/13784772
- https://stackoverflow.com/questions/6605006/convert-pdf-to-image-with-high-resolution
convert -density 300 -trim in.pdf -quality 100 %d.png
convert in.png -define jpeg:extent=2MB out-2MB.jpg mogrify -define jpeg:extent=2MB *.jpg
Determine the average color of an image and create a 32x32 square with that color.
- https://twitter.com/climagic/status/1310750853914071041 Determine the dominant color of .png images in your Pictures directory by reducing it's size to 1 pixel, do 4 images at once and save the text output.
- https://superuser.com/questions/576949/getting-the-predominant-colour-in-an-image
- https://legacy.imagemagick.org/Usage/quantize/
- https://github.com/culturevis/imageplot ImagePlot is a free software tool that visualizes collections of images and video of any size. It is implemented as a macro which works with the open source image processing program ImageJ.
convert input.png -colors 256 -scale 1x1\! -scale 32x32 average-color-tile-32x32.png
- https://itila.blogspot.de/2010/02/how-to-make-animated-gif-with-small.html
- https://www.imagemagick.org/Usage/anim_basics/
- https://www.imagemagick.org/Usage/anim_opt/#optimize
convert -delay 70 -loop 0 *.png anim.gif
Problem:
You have an animated gif and want to
- zoom into an area A in the source sequence bound by (xa1,ya1), (xa2,ya2)
- move and enlarge another area B (xb1,yb1), (xb2,yb2) ; and
- merge both parts into a new output sequence.
convert \( $1 -coalesce -crop (xa2-xa1)x(ya2-ya1)+x1a+y1a -resize 500x500 +repage \) -coalesce null: \( $1 -coalesce -crop (xb2-xb1)x(yb2-yb1)+xb1+yb1 +repage -resize 120x120 \) -geometry +40+90 -layers Composite $2
#!/bin/bash # see http://www.imagemagick.org/Usage/anim_mods/#merging # convert x.gif -coalesce -crop 125x135+250+200 -resize 500x500 +repage z.gif # convert x.gif -coalesce -crop 52x22+5+5 +repage z1.gif # convert z.gif -coalesce null: \( z1.gif -resize 120x120 -coalesce \) -geometry +40+90 -layers Composite z2.gif convert \( $1 -coalesce -crop 125x135+250+200 -resize 500x500 +repage \) -coalesce null: \( $1 -coalesce -crop 52x22+5+5 +repage -resize 120x120 \) -geometry +40+90 -layers Composite $2
create a movie from still images, add their directory and filenames as caption, make 10:6 and 4:3 movies
!#/bin/bash # rewrite filenames to contain parent directory name # for f in */* ; do cp $f "../all/$(dirname $f) - $(basename $f)"; done # rename filenames # for i in *; do mv "$i" "`echo $i | sed "s/from-/to-/"`"; done # sort # ls -ls | sort -k9 # if you need this # mogrify -format tif *.png # perspective control with Shift-N # Install http://www.shiftn.de/ . On Linux, use it under WINE ! # ShiftN can process jpg, tif, bmp but cannot process png! # for png input images: # env WINEPREFIX="/home/benutzer/.wine";for i in *.png;do convert "${i%.*}.png" -format tif "${i%.*}.tif";wine C:\\Program\ Files\ \(x86\)\\ShiftN\\ShiftN.exe "${i%.*}.tif" "${i%.*}" A4; done # or for tif input images (ShiftN "A4" output is tif, see http://www.shiftn.de/ShiftN_Funktionsweise.html ) env WINEPREFIX="/home/benutzer/.wine";for i in *.tif;do wine C:\\Program\ Files\ \(x86\)\\ShiftN\\ShiftN.exe "${i%.*}.tif" "${i%.*}" A4;done size="1920x1080" # size="1280x1024" # resize to letterbox format, preserve aspect ratio for f in *.tif; do convert "$f" -resize $size -background black -compose Copy -gravity center -extent $size "$f"; done # add filename as annotation. Use pointsize 40 for 1920x1080, pointsize 28 for 1280x1024 # to list the available font names, use $ convert -list font | grep Font for f in *.tif; do convert "$f" -gravity South -undercolor '#88888880' -font "Consolas" -pointsize 40 -fill yellow -annotate 0 "%t" "$f"; done # https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images # http://www.itforeveryone.co.uk/image-to-video.html # make movie from images (use pix_fmt to create a compatible stream for older decoders) ffmpeg -framerate 1/10 -pattern_type glob -i '*.tif' -c:v libx264 -r 25 -pix_fmt yuv420p "out-${size}.mp4"
#!/bin/bash if [ $# -lt 1 ]; then echo "extend-crop-background <imagefile> [modulus [extent]]" echo "Extend or crop image to a multiple of modulus ±'extent'" echo echo "modulus: default 32" echo "extent: default=modulus" echo echo "Examples:" echo "extend-crop-background in.jpg 32" echo "extend-crop-background in.jpg 32 -32" echo "extend-crop-background in.jpg 100 -32" exit fi magick "$1" \ -background none \ -gravity center \ -set option:xmod "${2:-32}" \ -set option:zz "$3" \ -set wx '%[fx:mod(w,xmod)==0?w:w-mod(w,xmod)+zz+xmod]' \ -set hx '%[fx:mod(h,xmod)==0?h:h-mod(h,xmod)+zz+xmod]' \ -extent '%[wx]x%[hx]' \ -set filename:mod '%[xmod]' \ -set filename:size '%wx%h' \ -set filename:name '%t' \ '%[filename:name]_mod%[filename:mod]-%[filename:size].png'
https://www.youtube.com/watch?v=KRkx8kjmXZw
* Select Path → Trace Bitmap → Colors: yes → Scans: 2 → ok * Drag it down to separate: → Top is the SVG → Bottom: PNG (delete)
- see also PDF Toolkit examples
Add several PDFs into a single output PDF
pdftk 1.pdf 2.pdf ... output collated.pdf
Sort by name and add all pdf files into a single output PDF
pdftk $(ls *.pdf | sort -n) cat output all.pdfhttps://stackoverflow.com/questions/14639206/how-can-i-pass-all-arguments-with-xargs-in-middle-of-command-in-linux
Shuffle (collate) two files with 1-sided scans to one 2-sided PDF. The "shuffle" command was introduced in PDFTK 1.44 - October 28, 2010, so you need at least that version (see http://www.pdflabs.com/docs/pdftk-version-history/)
file shuffle.bat:
pdftk A=1.pdf B=2.pdf shuffle A Bend-1 output collated.pdf
pdftk A=1.pdf cat Aend-1 output reversed.pdf
pdftk A=1.pdf cat Asouth output rotated.pdf
pdftk A=in.pdf shuffle AoddLeft AevenRight output out.pdf
"When you scanned the two-sided DIN-A4-sheets of a DIN-A5-booklet with your scanner, and you want its single pages in the correct sequence", or "How to split PDF pages with double page layout in two, down the middle. Splitting one A4 into two A5 pages is a great example." then use this code:
!/bin/bash # split pdf in half fn="${1%.*}" # mutool is part of mupdf-tools mutool poster -x 0.5 "$fn.pdf" "$fn.tmp.pdf" pdftk A="$fn.tmp.pdf" cat A1-endodd Aend-2even output "$fn.split.pdf" rm "$fn.tmp.pdf"
Other possibilities and sources:
- https://superuser.com/questions/505176/converting-a-multi-sheet-per-page-pdf-to-single-sheet-per-page
- https://www.sejda.com/split-pdf-down-the-middle
- https://superuser.com/questions/437148/how-to-split-a-pdf-onto-multiple-pages-on-command-line?noredirect=1&lq=1
mutool poster -x 0.5 singlepage.pdf twopages.pdf
pdfjam --keepinfo --trim "-10mm -15mm -10mm -15mm" --clip true --suffix "cropped" in.pdf
http://stackoverflow.com/a/14538863/731798 has a working one-liner, which simply can be used as an after-burner to the output of pdf-redact-tools -merge :
gs -o out.pdf -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.4 in.pdf
Example:
convert -density 300 -compress jpeg -quality 20 in.pdf out.pdf
Better Quality:
convert -density 300 -compress jpeg -quality 50 in.pdf out.pdf
- https://github.com/tavinus/pdfScale
- https://stackoverflow.com/questions/7446552/resizing-a-pdf-using-ghostscript
function pdfresize() {
gs -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dColorConversionStrategy=/LeaveColorUnchanged -dAutoRotatePages=/None \
-dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dFIXEDMEDIA -dPDFFitPage -dNOPAUSE -dQUIET -dBATCH \
-sOutputFile="${1%.*}.reduz.pdf" "${1}"
}
- see http://linux.die.net/man/1/pdfjam-pocketmod
- http://www2.warwick.ac.uk/fac/sci/statistics/staff/academic-research/firth/software/pdfjam
- debian users: https://packages.debian.org/search?keywords=pdfjam (install textlive-extra-utils)
pdfjam --help pdfjam-pocketmod --help pdfjam-pocketmod <in.pdf> --outfile <out.pdf>
echo "" | ps2pdf -sPAPERSIZE=a4 - blank.pdf
To get to the compare view, append /compare
to your repository's path.
Still a missing feature (I asked Github to implement a button, or show a link for that). The compare help article explains how to use the compare page.
git ls-files --others --ignored --exclude-standard
- → Source: http://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git http://stackoverflow.com/a/5201642
git reset --soft HEAD~3 git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
git ls-files -i -z --exclude-from=.gitignore | xargs -0 git rm --cached
touch README.md git init git add README.md git commit -m "first commit" git remote add origin git@github.com:username/repo.git git push -u origin master
git remote add origin git@github.com:username/repo.git git push -u origin master
Generate fully-flavoured apk filename with app_name, versionName, versionCode, git hash https://gist.github.com/Wikinaut/d3eb229e1dd1ec703f00
old: ./letsencrypt-auto renew --force-renewal --agree-tos --rsa-key-size 4096
http://www.robertecker.com/hp/research/leet-converter.php
- replace twitterurls
sed 'N;s/\npattern/pattern/;P;D' file
Jobs are killed after upgrade to 21?
- https://help.nextcloud.com/t/nach-update-auf-21-occ-auf-kommandozeile-ohne-funktion/109987/4
- https://help.nextcloud.com/t/solved-occ-command-php-fatal-error-allowed-memory-size-of-xxx-bytes-exhausted/108521/17
apc.enable_cli=1
or in /etc/php/7.3/cli/php.ini:
apc.enable_cli=1If you want to openWebsite a shared video on an NEXTCLOUD instance, a change is needed. Add the rC3-Domain/s!
In /lib/public/AppFramework/Http/ContentSecurityPolicy.php:
/** @var array Domains which can embed this Nextcloud instance */ protected $allowedFrameAncestors = [ '\'self\'', 'test.visit.at.wa-test.rc3.cccv.de', ];Source: https://return2.net/nextcloud-enable-external-iframe/