# Creating a video from a stack of Images

**URL:** <https://discourse.julialang.org/t/creating-a-video-from-a-stack-of-images/646>\
**Category:** Signal and Image Processing\
**Created:** [November 30, 2016, 4:28am UTC](https://discourse.julialang.org/t/creating-a-video-from-a-stack-of-images/646 "2016-11-30T04:28:11Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [May 7, 2018, 11:50pm UTC](https://discourse.julialang.org/t/creating-a-video-from-a-stack-of-images/646/8 "2018-05-07T23:50:55Z")

</div>

Further modified (after much head-bashing) to allow for near-universally-compatible output:

```julia
using Images

function writevideo(fname, imgstack::Array{<:Color,3};
                    overwrite=true, fps=30::UInt, options=``)
    ow = overwrite ? `-y` : `-n`
    h, w, nframes = size(imgstack)

    open(`ffmpeg
            -loglevel warning
            $ow
            -f rawvideo
            -pix_fmt rgb24
            -s:v $(h)x$(w)
            -r $fps
            -i pipe:0
            $options
            -vf "transpose=0"
            -pix_fmt yuv420p
            $fname`, "w") do out
        for i = 1:nframes
            write(out, convert.(RGB{N0f8}, clamp01.(imgstack[:,:,i])))
        end
    end
end

```

@kevin.squire: worth making a PR to VideoIO?

---

_[View the full topic](https://discourse.julialang.org/t/creating-a-video-from-a-stack-of-images/646)._
