PDF Editing
Extracting and rotating pages
Extract pages:
qpdf [INPUT] --pages . [start]-[end] -- [OUTPUT]
run with the option --replace-input
and without [OUTPUT]
to substitute the [INPUT]
file.
Rotate pages:
qpdf [INPUT] [OUTPUT] --rotate=[+|-][ANGLE]:[PAGE_RANGE]
Compression + Monochromize
- Split pages with
qpdf --split-pages in.pdf out.pdf
- Compress each page with
convert -monochrome -compress lzw -density 300 [INPUT] [OUTPUT]
(useparallel
, withseq -w [1 801]
) - Merge outpus with
qpdf --empty --pages *.pdf -- out.pdf
A better alternative to 2. convert -density 300 out-017.pdf -threshold 90% -type bilevel -compress fax try.pdf
OCR
ocrmypdf -l [LANG] --optimize [1,2,3] [INPUT] [OUTPUT]
Run tesseract --list-langs
to see all available languages
Removing text
gs -o no-more-texts.pdf -sDEVICE=pdfwrite -dFILTERTEXT Original.pdf
FFmpeg
Querying Available Codecs and Formats
ffmpeg -codecs
ffmpeg -formats
Extracting Streams
ffmpeg -i [INPUT] [-map 0:1 -map 0:2] -c:a [AUDIO CODEC] -c:v [VIDEO CODEC] 01_1.mkv
Cutting
ffmpeg -ss [TIME_START] -i [FILE] -ss [+TIME_START] -t [TIME_DURATION] -c copy [OUTPUT]
or
ffmpeg -i [FILE] -ss [TIME_START] -to [TIME_END] -c copy [OUTPUT]
Adding Subtitles
Add Subtitle with
ffmpeg -i [VIDEO_FILE] -vf subtitles=[.ASS_FILE] -c:a copy [OUTPUT]
.ass
format example:
[Script Info]
Title: [TITLE]
Original Script: RoRo
Script Updated By: version 2.8.01
ScriptType: v4.00+
Collisions: Normal
PlayResY: 600
PlayDepth: 0
Timer: 100,0000
Video Aspect Ratio: 0
Video Zoom: 6
Video Position: 0
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: DefaultVCD, Arial,28,&H00B4FCFC,&H00B4FCFC,&H00000008,&H80000008,-1,0,0,0,100,100,0.00,0.00,1,1.00,2.00,2,30,30,30,0
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:01.18,0:00:06.85,DefaultVCD, NTP,0000,0000,0000,,{\pos(400,570)}The first line\NThe second line in subtitle
Downsampling FLAC
For instance,
ffmpeg -i input.flac -af "aresample=44100:resampler=soxr:precision=33:osf=s16:dither_method=shibata" -acodec flac output.m4a
Changing Audio Quality for mp3
To 320k
ffmpeg -i input -c:a libmp3lame -b:a 320k -o output.mp3
Stripping metadata
ffmpeg -i in.mkv -map_metadata -1 -c:v copy -c:a copy out.mkv
ffmpeg -i tagged.mp3 -write_xing 0 -id3v2_version 0 untagged.mp3
or use
id3v2 -D input.mp3