{"id":2340,"date":"2013-01-21T21:05:04","date_gmt":"2013-01-22T05:05:04","guid":{"rendered":"http:\/\/owenmundy.com\/blog\/?p=2340"},"modified":"2015-07-08T12:46:22","modified_gmt":"2015-07-08T20:46:22","slug":"use-processing-and-ffmpeg-to-export-hd-video","status":"publish","type":"post","link":"https:\/\/owenmundy.com\/blog\/2013\/01\/use-processing-and-ffmpeg-to-export-hd-video\/","title":{"rendered":"Use Processing and FFmpeg to export HD video"},"content":{"rendered":"<p><a href=\"https:\/\/owenmundy.com\/blog\/wp-content\/uploads\/2013\/01\/p_000919.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/owenmundy.com\/blog\/wp-content\/uploads\/2013\/01\/p_000919-600x337.jpg\" alt=\"p_000919\" width=\"600\" height=\"337\" class=\"alignnone size-medium wp-image-2348\" srcset=\"https:\/\/owenmundy.com\/blog\/wp-content\/uploads\/2013\/01\/p_000919-600x337.jpg 600w, https:\/\/owenmundy.com\/blog\/wp-content\/uploads\/2013\/01\/p_000919-1024x576.jpg 1024w, https:\/\/owenmundy.com\/blog\/wp-content\/uploads\/2013\/01\/p_000919.jpg 1920w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>I\u2019ve been trying to find a dependable method for exporting HD video from Processing sketches that contain dynamic data and movement as well as complex 3-dimensional shapes rendered using OpenGL. QuickTime\u2019s screen recording option hogs memory and causes frames to skip, as does does ScreenFlow, my usual go-to for screen recording. The best way\u00a0I have found so far is to export actual resolution PNG files using \u201csave()\u201d and create an HD video using <a href=\"http:\/\/ffmpeg.org\/\" target=\"_blank\">FFmpeg<\/a>.<\/p>\n<p>FFmpeg is a very fast video and audio converter that can also grab from a live audio\/video sources or create and compress video from multiple still images. It is used from the command line and gives one control of bitrates, codecs, formats, resolution, quality, metadata, and many more options for working with video.<\/p>\n<p>To install FFmpeg with Macports<br \/>\n<code>sudo port install ffmpeg<\/code><\/p>\n<p># view help<br \/>\n<code>ffmpeg -h<\/code><\/p>\n<p># list encoders<br \/>\n<code>ffmpeg -encoders<\/code><\/p>\n<p># list codecs<br \/>\n<code>ffmpeg -codecs<\/code><\/p>\n<p># use format<br \/>\n<code>ffmpeg [global_options] {[input_options] -i \u2018input_file\u2019} ... {[output_options] \u2018output_file\u2019} ...<\/code><\/p>\n<p># make a movie from matching .png files, write over original, codec = libx264 (H.264), framerate = 30, 1 pass, resolution = 1920&#215;1080, video bitrate = 6Mbits, format = mp4<br \/>\n<code>ffmpeg -y -pattern_type glob -i 'p_*.png' -vcodec libx264 -r 30 -q 100 -pass 1 -s 1920x1080 -vb 6M -threads 0 -f mp4 file.mp4<\/code><\/p>\n<p># convert the video file to Apple ProRes codec for use in Final Cut<br \/>\n<code>ffmpeg -y -i file.mp4 -vcodec prores -vb 6M -r 30 -s 1920x1080 -f mov file.mov<\/code><\/p>\n<p># here&#8217;s another example conversion command. this one has a much higher bitrate <!-- used for spider_01_02.mp4 --><br \/>\n<code>ffmpeg -y -i file_01.mp4 -b:v 40M -vcodec libx264 -pass 1 file_02.mp4<\/code><\/p>\n<p>For example, <a href=\"https:\/\/gist.github.com\/omundy\/23c23a9c9623eb2b0abc\">using this Processing sketch<\/a>, you generate the PNG files, and then run the code above on the command line to make this file:<\/p>\n<div class=\"jetpack-video-wrapper\"><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/P6W2SJaxwMA?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span><\/div>\n<p>Also see <a href=\"http:\/\/vimeo.com\/57830021\">this video<\/a> for a more detailed example<\/p>\n<p><b>References<\/b><\/p>\n<ul>\n<li><a href=\"http:\/\/en.wikipedia.org\/wiki\/FFmpeg\" target=\"_blank\">FFmpeg on Wikipedia<\/a><\/li>\n<li><a href=\"http:\/\/ffmpeg.org\/ffmpeg.html\" target=\"_blank\">FFmpeg Documentation<\/a><\/li>\n<li><a href=\"http:\/\/nickhowell.co.uk\/2009\/03\/03\/high-quality-h264-mp4-videos-with-ffmpeg\" target=\"_blank\">High Quality h264 MP4 Videos with\u00a0FFmpeg<\/a><\/li>\n<li><a href=\"http:\/\/rodrigopolo.com\/ffmpeg\/cheats.html\" target=\"_blank\">Video\/Audio Encoding Cheat Sheet<\/a><\/li>\n<li><a href=\"http:\/\/www.catswhocode.com\/blog\/19-ffmpeg-commands-for-all-needs\" target=\"_blank\">19 FFmpeg commands for all needs<\/a><\/li>\n<li><a href=\"http:\/\/www.larryjordan.biz\/technique-choosing-the-best-videocodec\/\" target=\"_blank\">Choosing the Best Video Codec<\/a> by Larry Jordan<\/li>\n<li>I later found <a href=\"http:\/\/www.jeffreythompson.org\/blog\/2012\/01\/26\/creating-video-with-processing-and-ffmpeg\/\" target=\"_blank\">this page by Jeffrey Thompson<\/a> which combines the steps above into <a href=\"http:\/\/www.jeffreythompson.org\/downloads\/CreateVideoWithFFMPEG.pde\">a single Processing sketch<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019ve been trying to find a dependable method for exporting HD video from Processing sketches that contain dynamic data and movement as well as complex 3-dimensional shapes rendered using OpenGL. QuickTime\u2019s screen recording option hogs memory and causes frames to skip, as does does ScreenFlow, my usual go-to for screen recording. The best way\u00a0I have [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"https:\/\/owenmundy.com\/blog\/2013\/01\/use-processing-and-ffmpeg-to-export-hd-video\/\">Read More&#8230;<span class=\"screen-reader-text\"> from Use Processing and FFmpeg to export HD video<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[42],"tags":[],"class_list":["post-2340","post","type-post","status-publish","format-standard","hentry","category-code"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2ovQg-BK","_links":{"self":[{"href":"https:\/\/owenmundy.com\/blog\/wp-json\/wp\/v2\/posts\/2340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/owenmundy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/owenmundy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/owenmundy.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/owenmundy.com\/blog\/wp-json\/wp\/v2\/comments?post=2340"}],"version-history":[{"count":17,"href":"https:\/\/owenmundy.com\/blog\/wp-json\/wp\/v2\/posts\/2340\/revisions"}],"predecessor-version":[{"id":2793,"href":"https:\/\/owenmundy.com\/blog\/wp-json\/wp\/v2\/posts\/2340\/revisions\/2793"}],"wp:attachment":[{"href":"https:\/\/owenmundy.com\/blog\/wp-json\/wp\/v2\/media?parent=2340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/owenmundy.com\/blog\/wp-json\/wp\/v2\/categories?post=2340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/owenmundy.com\/blog\/wp-json\/wp\/v2\/tags?post=2340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}