# Video Processing

**URL:** <https://discourse.julialang.org/t/video-processing/96490>\
**Category:** General Usage\
**Tags:** package, video\
**Created:** [March 23, 2023, 4:51am UTC](https://discourse.julialang.org/t/video-processing/96490 "2023-03-23T04:51:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Desmond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/desmond/32/47964_2.png) [@Desmond](https://discourse.julialang.org/u/Desmond)\
**Post date:** [March 23, 2023, 4:51am UTC](https://discourse.julialang.org/t/video-processing/96490/1 "2023-03-23T04:51:51Z")

</div>

So, I took a video and svd decomposition on all the frames and I have got all my frames together. I am to look for a package that can help me put the frames together back in a video.

But i can seem to find any. VideoIO,jl ain’t helping

Any help?

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [March 23, 2023, 8:41am UTC](https://discourse.julialang.org/t/video-processing/96490/2 "2023-03-23T08:41:41Z")

</div>

> [@Desmond](#):
>
> VideoIO,jl ain’t helping

Perhaps explain why? - using this or FFMPEG.jl is the logical solution to this task.

---

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [March 23, 2023, 8:41am UTC](https://discourse.julialang.org/t/video-processing/96490/3 "2023-03-23T08:41:54Z")

</div>

What about `record` function from Makie?  
[https://docs.makie.org/stable/documentation/animation/index.html](https://docs.makie.org/stable/documentation/animation/index.html)

---

<div class="post-metadata">

**Author:** ![Desmond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/desmond/32/47964_2.png) [@Desmond](https://discourse.julialang.org/u/Desmond)\
**Post date:** [March 23, 2023, 9:45am UTC](https://discourse.julialang.org/t/video-processing/96490/4 "2023-03-23T09:45:26Z")

</div>

Well, I wrote a function and it keeps running into an error using VideoIO.jl  
I use the VideoWriter method but it doesn’t work  
Here is the code

```julia
function create_video1(frames, filename="my_video.mp4")
    height, width = size(frames[1])
    
    writer = VideoIO.VideoWriter(filename)

    for frame in frames
        write(writer, frame)
    end
    close(writer)
end

```

and here is the error

```julia
MethodError: no method matching VideoIO.VideoWriter(::String)
Closest candidates are:
  VideoIO.VideoWriter(::Any, ::AbstractMatrix{T}; kwargs...) where T at ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:379
  VideoIO.VideoWriter(::AbstractString, ::Type{T}, ::Tuple{Integer, Integer}; codec_name, framerate, scanline_major, container_options, container_private_options, encoder_options, encoder_private_options, swscale_options, target_pix_fmt, pix_fmt_loss_flags, input_colorspace_details, allow_vio_gray_transform, sws_color_options, thread_count) where T at ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:234
  VideoIO.VideoWriter(::VideoIO.NestedCStruct{VideoIO.libffmpeg.AVFormatContext}, ::VideoIO.NestedCStruct{VideoIO.libffmpeg.AVCodecContext}, ::T, ::VideoIO.NestedCStruct{VideoIO.libffmpeg.AVPacket}, ::Int64, ::Bool, ::Int64) where T<:Union{VideoIO.GrayTransform, VideoIO.NestedCStruct{VideoIO.libffmpeg.AVFrame}, VideoIO.SwsTransform} at ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:4

Stacktrace:
 [1] create_video1(frames::Vector{Any}, filename::String)
   @ Main ./In[49]:4
 [2] create_video1(frames::Vector{Any})
   @ Main ./In[49]:2
 [3] top-level scope
   @ In[50]:1

```

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [March 23, 2023, 9:53am UTC](https://discourse.julialang.org/t/video-processing/96490/5 "2023-03-23T09:53:19Z")

</div>

Does a simple `VideoIO.save(filename::String, imgstack::Array)` approach work?

---

<div class="post-metadata">

**Author:** ![ianshmean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ianshmean/32/216042_2.png) [@ianshmean](https://discourse.julialang.org/u/ianshmean)\
**Post date:** [March 23, 2023, 11:23am UTC](https://discourse.julialang.org/t/video-processing/96490/6 "2023-03-23T11:23:53Z")

</div>

Where did you get your code from?

The docs have examples to follow

[https://juliaio.github.io/VideoIO.jl/stable/writing/#Iterative-Encoding](https://juliaio.github.io/VideoIO.jl/stable/writing/#Iterative-Encoding)

---

<div class="post-metadata">

**Author:** ![Desmond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/desmond/32/47964_2.png) [@Desmond](https://discourse.julialang.org/u/Desmond)\
**Post date:** [March 23, 2023, 11:24am UTC](https://discourse.julialang.org/t/video-processing/96490/7 "2023-03-23T11:24:59Z")

</div>

I had this error

```julia
ArgumentError: Encoding arrays with eltype RGB{Float32} not yet supported

Stacktrace:
  [1] VideoIO.VideoWriter(filename::String, ::Type{RGB{Float32}}, sz::Tuple{Int64, Int64}; codec_name::Nothing, framerate::Int64, scanline_major::Bool, container_options::NamedTuple{(), Tuple{}}, container_private_options::NamedTuple{(), Tuple{}}, encoder_options::NamedTuple{(), Tuple{}}, encoder_private_options::NamedTuple{(), Tuple{}}, swscale_options::NamedTuple{(), Tuple{}}, target_pix_fmt::Nothing, pix_fmt_loss_flags::Int64, input_colorspace_details::Nothing, allow_vio_gray_transform::Bool, sws_color_options::NamedTuple{(), Tuple{}}, thread_count::Nothing)
    @ VideoIO ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:265
  [2] VideoWriter
    @ ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:234 [inlined]
  [3] #VideoWriter#46
    @ ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:379 [inlined]
  [4] VideoWriter
    @ ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:379 [inlined]
  [5] #open_video_out#47
    @ ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:473 [inlined]
  [6] open_video_out
    @ ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:473 [inlined]
  [7] open_video_out(f::VideoIO.var"#50#51"{Vector{Any}}, s::String, args::Matrix{RGB{Float32}}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ VideoIO ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:476
  [8] open_video_out(f::Function, s::String, args::Matrix{RGB{Float32}})
    @ VideoIO ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:475
  [9] save(filename::String, imgstack::Vector{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ VideoIO ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:501
 [10] save(filename::String, imgstack::Vector{Any})
    @ VideoIO ~/.julia/packages/VideoIO/3Y2nb/src/encoding.jl:500
 [11] top-level scope
    @ In[52]:1

```

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [March 23, 2023, 11:45am UTC](https://discourse.julialang.org/t/video-processing/96490/8 "2023-03-23T11:45:37Z")

</div>

Oh, it doesn’t support some of the RGB types… ☹

This works:

```julia
using Images
using VideoIO

imgstack = [
        [RGB{N0f8}(rand(), rand(), rand()) 
            for r in 1:10, c in 1:10]
        for i in 1:100
        ]

save("/tmp/movie.mp4", imgstack)

```

so perhaps you’ll have to tweak the images into an acceptable format. The documentation may have more information…
