Sample Header Ad - 728x90

H.264/MPEG-4 from PNG frames: how to, and how to tune compression

0 votes
1 answer
1743 views
I often create digital animations by preparing all the frames in .png format (with minimal compression), that I need to convert to video format for upload to websites such as reddit, instagram, gfycat. I know very little of all the different standards of compression, and these websites aren't very clear as to what format they accept, but I've found a recipe that usually works for me, and that creates files that get accepted by these websites: # step 1 mencoder mf://frame*.png -mf w=$WIDTH:h=$HEIGHT:fps=$FPS:type=png \ -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=16000:keyint=15:mbd=2:trell \ -oac copy -o step1.avi # step 2 mencoder step1.avi -o step2.mp4 -of lavf -lavfopts format=mp4 -ovc x264 -sws 9 \ -x264encopts nocabac:level_idc=30:bframes=0:bitrate=2048:threads=auto:turbo=1:global_header:threads=auto:subq=5:frameref=6:partitions=all:trellis=1:chroma_me:me=umh However I'm not completely sure what it does*, therefore I'm not able to: - make it a single instruction - tune the compression rate. Indeed, I'd often prefer a less compressed result. **What route can I follow to go from PNG frames to** a web-friendly video file (that I believe is a **H.264/MPEG-4 MP4**) that gives me the ability to tune compression? ---- \* for instance: this is an example frame enter image description here (note: honestly it seems to me that it looks much worse when watching it in VLC than when taking a snapshot through the VLC tool - this makes it very difficult to make the question understandable and the results comparable) Even if in *step 1* I have specified $WIDTH and $HEIGHT to match the ones of the original image, it has apparently changed both, and not preserved the aspect ratio. There is also more blur to the final image, that might be just an effect of such resize. ---- **edit:** see the actual system screenshot of the mplayer window below (would be the same with VLC). The tile grouts are very blurred compared to both the PNG source and the VLC "internal" screenshot feature enter image description here Detail: enter image description here
Asked by Nicola Sap (111 rep)
Jan 7, 2018, 06:06 PM
Last activity: Jan 9, 2018, 09:21 AM