How to convert multiple video files (one directory) by FFMpeg on command line

for %a in ("*.3gp") do ffmpeg -i "%a" -c:v libx264 -c:a copy -q:v 0 -y "newfiles\%~na.mp4"
  • *.3gp – input files; what you want to convert
  • ffmpeg – ffmpeg executable; if you haven’t it in PATH, you have to insert absolut path to the ffmpeg (eg. c:\XXX\YYY\ffmpeg.exe)
  • -c:v libx264 – video codec – H.264 in this example
  • -c:a copy – audio code – „copy original audio stream“ in this example
  • -q:v 0 –  „same video quality“
  • newfiles\%~na.mp4 – output files; original file extension will be removed; directory must exists (newfiles in this example)

For more details and options, please use Google 🙂

Base64 decode/encode in Windows command line

For Base64 file encode/decode you can use built-in utillity certutil.exe (in c:\windows\system32):

certutil.exe -encode InFile OutFile
certutil.exe -decode InFile OutFile

Note: because its for certificates … certutil add line „—–BEGIN CERTIFICATE—–“ (as first line of OutFile) and „—–END CERTIFICATE—–“ (as last line) when you encode some file

Simple timestamp in Windows command line

@echo off

SET NOWTIME=%time%
echo NOWTIME=#%NOWTIME%#
SET NOWDATE=%date%
echo NOWDATE=#%NOWDATE%#

FOR /F "tokens=1 delims= " %%x in ("%NOWTIME%") do SET TIME2=%%x
FOR /F "tokens=1-4 delims=:.," %%a in ("%TIME2%") do SET STAMPT=%%a%%b%%c%%d
echo STAMPT=%STAMPT%

FOR /F "tokens=2 delims= " %%x in ("%NOWDATE%") do SET DATE2=%%x
FOR /F "tokens=1-3 delims=:-.,/" %%a in ("%DATE2%") do SET STAMPD=%%c%%b%%a
echo STAMPD=%STAMPD%

SET TIMESTAMP=%STAMPD%%STAMPT%
echo TIMESTAMP=%TIMESTAMP%

openssl PKCS12

Mám neustále problém si zapamatovat příkaz na vytvoření souboru p12 s certifikáty, tak je třeba si to poznamenat.

openssl pkcs12 -export -in certifikat-serveru.pem -inkey priv-klic-serveru.pem -certfile ca-bundle.pem -out vystup.p12

Vytvořena p12 se zašifrovává, takže se objeví výzva k zadání hesla (Enter Export Password) – pokud je zašifrován privátní klíč (heslo se zadávalo při generování), objeví se nejprve výzva k zadání tohoto hesla.