Skip to content

Instantly share code, notes, and snippets.

@echo OFF
set gs="C:\Program Files\gs\gs10.03.1\bin\gswin64c.exe"
set qpdf="D:\Downloads\qpdf\bin\qpdf.exe"
for %%A in (%*) do (
::%gs% -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dEmbedAllFonts=true -dCompressFonts=true -dSubsetFonts=true -dDetectDuplicateImages=true -dDownsampleColorImages=true -dColorImageDownsampleType=/Bicubic -dColorImageResolution=25 -dDownsampleGrayImages=true -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=25 -dDownsampleMonoImages=true -dMonoImageDownsampleType=/Subsample -dMonoImageResolution=25 -dColorImageDownsampleThreshold=1.0 -dGrayImageDownsampleThreshold=1.0 -dMonoImageDownsampleThreshold=1.0 -sOutputFile=%~n1_out.pdf %%A
)
:: Extract pdf
:: gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=22 -dLastPage=36 -sOutputFile=outfile_p22-p36.pdf 100p-inputfile.pdf
@shinchiro
shinchiro / mpv_log
Last active November 15, 2024 00:12
2024-11-14T23:59:57.9248237Z Current runner version: '2.320.0'
2024-11-14T23:59:57.9271148Z ##[group]Operating System
2024-11-14T23:59:57.9271803Z Ubuntu
2024-11-14T23:59:57.9272113Z 22.04.5
2024-11-14T23:59:57.9272557Z LTS
2024-11-14T23:59:57.9272897Z ##[endgroup]
2024-11-14T23:59:57.9273286Z ##[group]Runner Image
2024-11-14T23:59:57.9273774Z Image: ubuntu-22.04
2024-11-14T23:59:57.9274190Z Version: 20241103.1.0
2024-11-14T23:59:57.9275204Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20241103.1/images/ubuntu/Ubuntu2204-Readme.md
#Encode HDR video from Samsung:
* Encode and crop 100px from top
ffmpeg.exe -hide_banner -i input -vf scale=-2:480:flags=spline,crop=out_h=in_h-80:y=in_h-80 -an -c:v libx264 -pix_fmt yuv420p -preset veryslow -tune film out.mpv
ffmpeg.exe -hide_banner -i input -vf scale=-2:1080:flags=spline -c:v libx264 -pix_fmt yuv420p -preset veryslow -tune film -crf 18 -c:a aac -b:a 192k out.mp4
*Test encode first frame pic
ffmpeg.exe -hide_banner -i input.mp4 -vf scale=-1:360:flags=spline,zscale=transfer=linear:npl=100,format=gbrpf32le,zscale=primaries=bt709,tonemap=hable:desat=0,zscale=transfer=bt709:matrix=bt709:range=limited,format=yuv420p -vframes 1 output.png
ffmpeg.exe -hide_banner -i input.mp4 -vf scale=-1:720:flags=spline,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -map 0 -c copy -c:v libx264 -pix_fmt yuv420p -preset medium -tune film -crf 20 -c:a copy output.mp4
@shinchiro
shinchiro / rename.bat
Last active January 7, 2019 10:03
mkvpropedit's usage
@echo OFF
set mkvpropedit="D:\mkvtoolnix\mkvpropedit.exe"
for %%A in (%*) do (
::%mkvpropedit% "%%~fA" --delete-attachment name:"Impress BT.ttf"
::%mkvpropedit% "%%~fA" --chapters "%%~nA_chapter.xml"
:: Comment should be placed above.
::
:: This will select first video/subtitle tracks to rename name and make first subtitle as default.
:: Adding fonts to the mkv.
%mkvpropedit% "%%~fA" --edit track:v1 --set name="[LowPower-Raws]" --set language=jpn ^
@shinchiro
shinchiro / git_config.txt
Last active November 18, 2017 13:21
git config
$ git config -l
user.name=shinchiro
[email protected]
user.signingkey <ID>
commit.gpgsign=true
core.editor=nano
credential.helper=wincred # works only on git for windows
sendemail.smtpserver=smtp.googlemail.com
sendemail.smtpencryption=tls
sendemail.smtpserverport=587
@shinchiro
shinchiro / widl
Created September 18, 2017 12:53
cd /git/mingw-w64
widl -I./include -I./direct-x/include -DBOOL=WINBOOL -h -o d3d11.h ./direct-x/include/d3d11.idl
@shinchiro
shinchiro / make_x265_vc.bat
Last active March 25, 2017 15:21
x265 Compilation with Visual Studio 2017
@echo OFF
set PATH=%~dp0\win_tools;%~dp0\win_tools\cmake\bin;%~dp0\win_tools\mercurial;%PATH%
cd "%~dp0\x265"
patch -p1 < %~dp0\patches\watermark.diff
patch -p1 < %~dp0\patches\optimization.diff
mkdir "%~dp0\x265\build\vc14-x86_64"
cd "%~dp0\x265\build\vc14-x86_64"
@shinchiro
shinchiro / compile.sh
Created February 18, 2017 21:50
Compile MEGAcli
#!/bin/bash
export PATH="/shinchiro/build32/install/bin:$PATH"
export PKG_CONFIG_LIBDIR="/d/MSYS/mega-sdk/build/install/lib/pkgconfig"
export PKG_CONFIG="pkg-config --static"
INSTALL_PATH="/d/MSYS/mega-sdk/build/install"
# LDFLAGS='-static -lpthread'
./autogen.sh
./configure --disable-shared --enable-static --disable-silent-rules --without-openssl --with-cryptopp=$INSTALL_PATH --without-sodium --with-zlib=$INSTALL_PATH --with-sqlite=$INSTALL_PATH --without-cares --without-curl --with-winhttp=/d/MSYS/mega-sdk/build --without-freeimage --with-readline=$INSTALL_PATH --with-termcap=$INSTALL_PATH --prefix=$INSTALL_PATH && make -j9 && make install
@shinchiro
shinchiro / git_tricks.txt
Last active April 25, 2020 04:03
Git's trick
1. Clone specific branch
git clone --single-branch -b new_branch git_url
2. Remove/clean git history log
git pull --depth 1
git gc --aggressive --prune=now
3. Export commit as patch
git format-patch -1
@shinchiro
shinchiro / FFmpegMapping.txt
Created December 19, 2016 06:32
FFmpeg mapping tricks
# Mapping can also be know selecting in ffmpeg.
# http://stackoverflow.com/a/12943003
1. Select only video and audio from mkv .Mux into mp4
ffmpeg -i input.mkv -map 0:v -map 0:a -c copy test.mp4