# From a Julia program, run a ffmpeg shell command on a folder of files to make a mp4 movie

**URL:** <https://discourse.julialang.org/t/from-a-julia-program-run-a-ffmpeg-shell-command-on-a-folder-of-files-to-make-a-mp4-movie/65910>\
**Category:** General Usage\
**Tags:** question, shell\
**Created:** [August 5, 2021, 9:18pm UTC](https://discourse.julialang.org/t/from-a-julia-program-run-a-ffmpeg-shell-command-on-a-folder-of-files-to-make-a-mp4-movie/65910 "2021-08-05T21:18:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nelsonah](https://avatars.discourse-cdn.com/v4/letter/n/7993a0/32.png) [@nelsonah](https://discourse.julialang.org/u/nelsonah)\
**Post date:** [August 5, 2021, 9:18pm UTC](https://discourse.julialang.org/t/from-a-julia-program-run-a-ffmpeg-shell-command-on-a-folder-of-files-to-make-a-mp4-movie/65910/1 "2021-08-05T21:18:45Z")

</div>

Presently I have a Julia script file that generates a folder of jpeg files.  
Then I launch Windows PowerShell in that folder and execute my ffmpeg command such as:  
ffmpeg -r 50 -start\_number 10001 -i i\_%5d.jpeg -c:v libx264 -crf 23 -pix\_fmt yuv420p run\_id\_and\_parameters.mp4

This works great but requires that I separately run my Julia program to generate the list of files. And then separately render the files into a movie using ffmpeg.

Is there a way to build my ffmpeg command (no problem) and then launch it from my Julia program?

---

<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:** [August 5, 2021, 9:29pm UTC](https://discourse.julialang.org/t/from-a-julia-program-run-a-ffmpeg-shell-command-on-a-folder-of-files-to-make-a-mp4-movie/65910/2 "2021-08-05T21:29:39Z")

</div>

Take a look at:

- [GitHub - JuliaIO/FFMPEG.jl: Julia Package for the FFMPEG builder binaries](https://github.com/JuliaIO/FFMPEG.jl)
- [https://github.com/JuliaIO/VideoIO.jl](https://github.com/JuliaIO/VideoIO.jl)

I’d recommend trying to use [iterative encoding](https://juliaio.github.io/VideoIO.jl/latest/writing/#Iterative-Encoding) to build the video in place, which avoids the unnecessary round trip of JPEGs to & from your hard drive.  
If you want to stick to your strategy of calling FFMPEG from the shell within Julia, see this old post: [Creating a video from a stack of Images - #8 by stillyslalom](https://discourse.julialang.org/t/creating-a-video-from-a-stack-of-images/646/8)

---

<div class="post-metadata">

**Author:** ![nelsonah](https://avatars.discourse-cdn.com/v4/letter/n/7993a0/32.png) [@nelsonah](https://discourse.julialang.org/u/nelsonah)\
**Post date:** [August 6, 2021, 4:10pm UTC](https://discourse.julialang.org/t/from-a-julia-program-run-a-ffmpeg-shell-command-on-a-folder-of-files-to-make-a-mp4-movie/65910/3 "2021-08-06T16:10:53Z")

</div>

Thank you very much for your suggestions. I will definitely investigate both options. It may take a little time as this will push my Julia expertise, which is good.

BTW: I’m just doing this for fun. I spent my 50 year career in scientific computing, primarily aerospace simulations. I’m playing with Mandelbrot & Filled Julia Sets. I started with Python and then switched to Julia for the incredible speed. High res frames with up to 9K iterations per pixel take less than a second. I’m getting 1e12 zooms before 64 bit limitations start to impact my plots. Thanks again.
