# Play video and sound

**URL:** <https://discourse.julialang.org/t/play-video-and-sound/6498>\
**Category:** Visualization\
**Tags:** question, video, sound\
**Created:** [October 17, 2017, 11:02am UTC](https://discourse.julialang.org/t/play-video-and-sound/6498 "2017-10-17T11:02:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [October 17, 2017, 11:02am UTC](https://discourse.julialang.org/t/play-video-and-sound/6498/1 "2017-10-17T11:02:02Z")

</div>

Is there a way we can play a video _and_ its sound currently in Julia?

The excellent [VideoIO.jl](https://github.com/kmsquire/VideoIO.jl) package doesn’t play sound.

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [October 18, 2017, 1:06am UTC](https://discourse.julialang.org/t/play-video-and-sound/6498/2 "2017-10-18T01:06:58Z")

</div>

As far as I know there isn’t currently a way. There’s been some discussion in the FileIO package about handling container types, and that would probably be my preferred way to handle this. When you open a `.avi`, `.mov`, `.mkv`, etc file, FileIO could recognize it as a container that has encoded audio and video streams within, and then dispatch those streams to their appropriate decoders.

Given that VideoIO already has ffmpeg bindings, it might not be too hard to plug into their audio decoders, but I don’t know anything about the ffmpeg API and how hard it is to get the audio.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [October 18, 2017, 8:11am UTC](https://discourse.julialang.org/t/play-video-and-sound/6498/3 "2017-10-18T08:11:29Z")

</div>

Cool. Sounds like a good way of doing it. Synchronization of the two streams though is important.

Right now I plan to “solve” this by spawning `mpv` and using its [command interface](https://mpv.io/manual/master/#command-interface) to control and communicate with that specific instance.

---

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)\
**Post date:** [September 14, 2026, 8:28pm UTC](https://discourse.julialang.org/t/play-video-and-sound/6498/4 "2026-09-14T20:28:02Z")

</div>

Any update on extracting audio from video files?

---

<div class="post-metadata">

**Author:** ![kahliburke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kahliburke/32/208472_2.png) [@kahliburke](https://discourse.julialang.org/u/kahliburke)\
**Post date:** [September 14, 2026, 9:02pm UTC](https://discourse.julialang.org/t/play-video-and-sound/6498/5 "2026-09-14T21:02:46Z")

</div>

Wow talk about reviving a thread from the past!!

The answer seems to still be somewhat “no”, at least when it comes to 100% Julia native code.

However, here is a notebook which demonstrates some solutions using all Julia code:

> **[Extracting audio from video files in Julia](https://discourse-answers.pages.dev/extracting-audio-from-video-files-in-julia/)**

---

<div class="post-metadata">

**Author:** ![JamesNZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jamesnz/32/35361_2.png) [@JamesNZ](https://discourse.julialang.org/u/JamesNZ)\
**Post date:** [September 15, 2026, 9:35am UTC](https://discourse.julialang.org/t/play-video-and-sound/6498/6 "2026-09-15T09:35:11Z")

</div>

This post was temporarily hidden by the community for possibly being off-topic, unfocused, inappropriate, or spammy.

---

<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:** [September 15, 2026, 2:07pm UTC](https://discourse.julialang.org/t/play-video-and-sound/6498/8 "2026-09-15T14:07:00Z")

</div>

@Jake it’s been long on the feature request list for VideoIO so here’s a go at adding it. Please try it out and comment on the PR how you get on [audio: add openaudio, loadaudio and extract\_audio - Pull Request #466 - JuliaIO/VideoIO.jl - GitHub](https://github.com/JuliaIO/VideoIO.jl/pull/466)

---

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)\
**Post date:** [September 15, 2026, 3:54pm UTC](https://discourse.julialang.org/t/play-video-and-sound/6498/9 "2026-09-15T15:54:19Z")

</div>

I think I should be able to install it with `] add VideoIO#466` but this is not working. What am I missing?

Edit: never mind, this works `add https://github.com/JuliaIO/VideoIO.jl/pull/466`

---

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)\
**Post date:** [September 15, 2026, 5:58pm UTC](https://discourse.julialang.org/t/play-video-and-sound/6498/10 "2026-09-15T17:58:20Z")

</div>

This works, thank you for the enhancement.

```julia-auto
julia> using VideoIO

julia> file = "20260908_162227.mp4"
"20260908_162227.mp4"

julia> samples, fs = VideoIO.loadaudio(file)
(Float32[0.0 0.0; 0.0 0.0; … ; 0.006339062 0.59741265; 0.051741634 0.6391921], 12000)

julia> using Sound

julia> sound(samples, fs)
3822592

```

Note that using MATLAB’s help for `Sound.jl` was really helpful, as this package is very similar to the MATLAB commands.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [September 15, 2026, 8:23pm UTC](https://discourse.julialang.org/t/play-video-and-sound/6498/11 "2026-09-15T20:23:33Z")

</div>

> [@yakir12](#):
>
> Is there a way we can play a video _and_ its sound currently in Julia?

Yes and no, I could do it with:

```julia-auto
julia> video_path = ".vscode/extensions/openai.chatgpt-26.715.31925-linux-x64/webview/assets/appshot-demo-DcV9m9GT.mp4";

julia> # wait=false runs it in the background so your Julia REPL doesn't freeze!
       p = run(`mpv --vo=x11 --hwdec=no --autofit=1280x720 $video_path`, wait=false);

julia> # You can stop or kill the playback programmatically from Julia at any time:
       # kill(p)

```

[You might not actually need some options, like that `-vo=x11` (or `--hwdec=no`) for me without it I got a segfault “Aborted (core dumped)”); I was just using it for my broken Linux setup (apparently EGL and GLX is broken for me). I’m not sure what this does on non-Linux, hopefully ignored.]

needing first setup (this might be different across different Linux, even if you have apt-get):

```julia-auto
$ sudo apt install mpv libmpv-dev

```

Note the file I found and used above DOES have audio, just not much, so at first I though I also had audio issues… trying to debug `pulse`, for audio, that was never broken…

See (–ao=help and):  
$ mpv --vo=help

Apparently --vo=sixel might work for you, for me I could see the video in the terminal with (but not from within Julia):

```julia-auto
mpv --vo=tct .vscode/extensions/openai.chatgpt-26.715.31925-linux-x64/webview/assets/appshot-demo-DcV9m9GT.mp4

```

That will **decode and play the audio while not creating a video window** , which is also why it avoided my current (Linux) GLX graphics problem:

```julia-auto
ffplay -nodisp -autoexit video.mp4

```

Something like this might also work for you, please confirm and on which platform (probably works on all non-Linux, and Linux without my Nvidia userspace/kernel driver mismatch problems, that disabled GLX, ~~not~~ EGL):

```julia-auto
using FFplay_jll, FFMPEG_jll # the latter just for some workarounds I was trying for paths/dependencies

julia> env = Dict(
           "DISPLAY" => get(ENV, "DISPLAY", ""),
           "XAUTHORITY" => get(ENV, "XAUTHORITY", ""),
           "PULSE_SERVER" => get(ENV, "PULSE_SERVER", ""),
           "LD_LIBRARY_PATH" => joinpath(FFMPEG_jll.artifact_dir, "lib"),
       );

run(setenv(`$(FFplay_jll.ffplay()) -autoexit "vscode/extensions/openai.chatgpt-26.715.31925-linux-x64/webview/assets/appshot-demo-DcV9m9GT.mp4"`));

# Maybe just: run(setenv(`$(FFplay_jll.ffplay()) -autoexit ".vscode/extensions/openai.chatgpt-26.715.31925-linux-x64/webview/assets/appshot-demo-DcV9m9GT.mp4"`,
    "LD_LIBRARY_PATH" => joinpath(FFMPEG_jll.artifact_dir, "lib")))

```

Make sure it first works for you from the shell (the problems I had were not Julia problems, nor even arguably `ffplay` problems, which is cross-platform):

Since I get:

```julia-auto
$ glxinfo -B
name of display: :0
X Error of failed request: BadValue (integer parameter out of range for operation)
  Major opcode of failed request: 152 (GLX)
  Minor opcode of failed request: 24 (X_GLXCreateNewContext)
  Value in failed request: 0x0
  Serial number of failed request: 69
  Current serial number in output stream: 70

```

It also ruled out for me (since it uses GLX, not EGL, and I spent a lot of time how to look into fixing my GLX install…):

```julia-auto
ffplay -vn -autoexit \
  .vscode/extensions/openai.chatgpt-26.715.31925-linux-x64/webview/assets/appshot-demo-DcV9m9GT.mp4

```

Showing videos (with or without audio) is a can of worms. You can decode video separately with Julia or the audio, but what does it mean to get both (or only video), and to the screen? It implies a GUI application (or popup window from other process, just invoked by Julia as above). And that GUI application needs to work with Linux, EGL or GLX or whatever you have and can use, and ideally this application is cross-platform to e.g. Windows.

Out of the scope how to do a GUI (without or) with web tech. It might be simplest that way with something like Electron.jl or:

> [@\[ANN\] Webviews.jl - a tiny library for creating web-based desktop GUIs](https://discourse.julialang.org/t/ann-webviews-jl-a-tiny-library-for-creating-web-based-desktop-guis/91406):
>
> Hi there, I’d like to share with you [Webviews.jl](https://github.com/sunoru/Webviews.jl), a Julia implementation of webview for creating web-based desktop GUIs. Hope you find it interesting and useful. Its usage is very simple: # Julia v1.8+ on Windows/macOS or v1.9+ on Linux using Webviews w = Webview(320, 320, debug=true) navigate!(w, "https://julialang.org") run(w) A new window with a given size will be created and a Webview is attached/embedded in it. debug=true enables the dev tools, navigate! sets it to view Julia’s homepag…
