Skip to content

Instantly share code, notes, and snippets.

@pavel-perina
Last active November 4, 2022 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavel-perina/24574e05912b8819c99322bad5bd7790 to your computer and use it in GitHub Desktop.
Save pavel-perina/24574e05912b8819c99322bad5bd7790 to your computer and use it in GitHub Desktop.
Video encoding (command line, batch files, ...)
d:\apps\mplayer\mencoder mf://out*.jpg -mf w=1024:h=896:fps=10:type=jpg -o out-lq.avi -nosound -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=3000
rem d:\apps\mplayer\mencoder mf://out*.jpg -mf w=1024:h=896:fps=10:type=jpg -o out.avi -nosound -ovc x264 -x264encopts subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid=normal:weight_b
d:\old-d\apps\mplayer\mencoder mf://vid00*.png -mf w=1280:h=720:fps=30:type=png -o vid00.avi -nosound -ovc x264 -x264encopts subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid=normal:weight_b
d:\old-d\apps\mplayer\mencoder mf://vid01*.png -mf w=1280:h=720:fps=30:type=png -o vid01.avi -nosound -ovc x264 -x264encopts subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid=normal:weight_b
d:\apps\mplayer\mencoder mf://@tissue-list.txt -mf w=1920:h=1200:fps=30:type=png -o out.avi -nosound -ovc x264 -x264encopts subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid=normal:weight_b
d:\apps\mplayer\mencoder mf://solder2-*.png -mf w=1280:h=720:fps=25:type=png -o out.avi -nosound -ovc x264 -x264encopts subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid=normal:weight_b
"d:\apps\mplayer\mencoder.exe" P1120851.mov P1120847.mov P1120846.mov P1120848.mov -o LoadLockHD.avi -nosound -ovc x264 -x264encopts pass=2:bitrate=6000:subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid=strict:weight_b -info "copyright=xxxx, a.s.:name=Load lock"
# remove audio (works on manjaro 17.03, does not work with avconv on ubuntu 14.04 on windows
ffmpeg -i VID_20170907_103806.mp4 -map 0:0 -vcodec copy out.avi
# loseless encoding of videos from PNG using FFV1 codec (https://trac.ffmpeg.org/wiki/Encode/FFV1)
# note: PNG files: 88.3MB (646files), FFV1l1 70.6MB, FFV1l3 69.3MB uncompressed PNGs 64.8MB (ffmpeg likely uses better PNG compression)
ffmpeg -framerate 30 -i vid00-%04d.png -an -vcodec ffv1 -level 1 -coder 1 -context 1 -g 1 vid00-ffv1.mkv
ffmpeg -framerate 30 -i vid00-%04d.png -an -vcodec ffv1 -level 3 -threads 2 -coder 1 -context 1 -g 1 -slices 4 -slicecrc 1 vid00-ffv1v3.mkv
# uncompressing files above
ffmpeg -i vid00-ffv1v3.mkv vid00-%04d.png
# maybe find more here: https://trac.ffmpeg.org/wiki/Encode/H.264
# http://www.ffmpeg-archive.org/Does-converting-to-yuv444p-by-default-make-sense-td4660219.html
# lossless 213MB
ffmpeg -framerate 30 -i %03d.bmp -an -vcodec ffv1 -level 3 -threads 2 -coder 1 -context 1 -g 1 -slices 4 -slicecrc 1 rp_ct.mkv
# great quality, not compatible with windows media player and movies&films cca 7.3MB
ffmpeg -i rp_ct.mkv -an -c:v libx264 -preset veryslow -crf 17 out5.mp4
# this works with windows media player (maybe -preset slow -crf 20) 7.6MB (4.5MB)
ffmpeg -i rp_ct.mkv -an -c:v libx264 -preset veryslow -crf 17 -pix_fmt yuv420p out6.mp4
# this may be needed (padding)
-vf "pad=width=1920:height=1200"
TODO: find ffmpeg/avconv? samples
#Images:
convert in.png -depth 16 -gamma 0.454545 -filter lanczos -resize 1024 -gamma 2.2 -depth 8 out.png
convert ResizeTestImage.png -gamma 0.5 -filter Mitchell -resize 800x200! -morphology Convolve "3x1: 0.33, 0.34, 0.33" -channel Red -morphology Convolve "3x1: 0.0, 0.0, 1.0" -channel Green -morphology Convolve "3x1: 0.0, 1.0, 0.0" -channel Blue -morphology Convolve "3x1: 1, 0, 0" +channel -filter Point -resize 267x200! -gamma 2.0 -depth 8 ResizeTestSubpixel.png
-------------------------
OpenSCAD animation (Python on WIN + LSOW)
--
#!/bin/python3
from subprocess import call
for frm in range(0,360):
cam = ("--camera=0,0,0,60,0,%d,10" % frm)
out = ("frame_%05d.png" % frm)
print(out)
call (["openscad.exe", "--imgsize=640,480", cam, "cube_without_corners2.scad", "--render", "-o", out])
---
convert -delay 4 frame_*.png -loop 0 movie.gif
# av1
1. How to convert PNGs to YUV ?
if you use e.g. `ffmpeg -i %05d.png -pix_fmt yuv420p out.yuv` you can play it back using: `ffplay -s WxH -pix_fmt yuv420p -f rawvideo out.yuv `
ffmpeg -i .... -f rawvideo -pix_fmt yuv420p ...
2. How to play yuv ?
vlc --demux rawvideo --rawvid-fps 25 --rawvid-width 1920 --rawvid-height 1080 --rawvid-chroma I420 input.yuv
3. How to encode yuv (ffmpeg, SvtAvt1EncApp) ?
// ffmpeg
c:\apps\ffmpeg -hide_banner -s:v 1280x720 -f rawvideo -pix_fmt yuv420p -framerate 60000/1001 -i out.yuv -c:v libx264 -preset veryslow -crf 17 out.mp4 (well, this is not av1)
// svt-av1
// as of 2019-10 format has to be yuv420p
c:\apps\ffmpeg.exe -i watch-drishti%d.png -pix_fmt yuv420p watch.yuv
c:\apps\SvtAv1EncApp.exe -i watch.yuv -w 1920 -h 1080 -fps-num 60000 -fps-denom 1001 -b watch.ivf
c:\apps\mkvmerge.exe watch.ivf -o watch-drishti.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment