# Example to stream video via ffmpeg

Source: https://forum.modalai.com/topic/126/example-to-stream-video-via-ffmpeg
Category: VOXL SDK and Software (https://forum.modalai.com/category/47/voxl-sdk-and-software)
Posted: 2021-02-05 05:29:28 UTC by Ruijie Geng
Replies: 8 · Views: 2753

## Ruijie Geng · 2021-02-05 05:29:28 UTC

In this documentation(https://docs.modalai.com/docker-on-voxl/#access-to-mipi-cameras), last part, I get this code
```
ffmpeg -an -sn -f rawvideo -pix_fmt nv21 -s:v 640x480 -i /opt/frame0 <output options>
```
I already set up the docker with roskinetic-xenial_v1_0. Would you like to give an example to use FFmpeg? I want to stream the visual data and view such data on my laptop.

I tried to save the video locally. but the system give me error
```
ffmpeg -an -sn -f rawvideo -pix_fmt nv21 -s:v 640x480 -i /opt/frame0 output.mov
```
```
/opt/frame0: Is a directory
```

Thank you!

## Reply by tom (ModalAI staff) · 2021-02-05 18:44:05 UTC

@Ruijie-Geng In order to stream video to your ground control station you can do something similar to the following

```
ffmpeg -an -sn -f rawvideo -pix_fmt nv21 -s:v 640x480 -i /opt/frame0 -f mpegts udp://GCS_IP:4242
```

Where `GCS_IP` is the IP address of the ground control station (laptop) that you are connecting to.

## Reply by Eric Katzfey (ModalAI staff) · 2021-02-06 18:22:53 UTC

Also, you have to start the camera application that creates /opt/frame0 before starting the docker. Otherwise the docker will create /opt/frame0 itself as a directory and not as a pipe. If this happens, exit the docker, delete /opt/frame0, start the camera application, then start docker.

## Reply by Ruijie Geng · 2021-02-08 16:38:45 UTC

Thank you! I will have a trial to do that!

## Reply by Ruijie Geng · 2021-02-08 16:51:50 UTC

I meet another question that I try to run `hello_hal3_camera -l /dev/frame0` before starting docker, but gives the error 
```
~ # hello_hal3_camera -l /dev/frame0

Camera id: 0
Image width: 640
Image height: 480
Number of frames to dump: 0
Frame FIFO: /dev/frame0
Camera mode: preview
SUCCESS: Camera module opened
Camera Id: 0 Facing: 0
Camera Id: 1 Facing: 1

Error: Could not open named FIFO /dev/frame0
Camera Id: 2 Facing: 1

Camera HAL3 test is now running
```

## Reply by Eric Katzfey (ModalAI staff) · 2021-02-08 17:36:43 UTC (in reply to Ruijie Geng)

@Ruijie-Geng Can you please show the output of "ls -l /dev/frame0"?

## Reply by Ruijie Geng · 2021-02-14 06:25:47 UTC

Sorry for the late reply. I try the code again, the bug is gone. I can open /dev/frame0 correctly.

Thank you very much

## Reply by Ruijie Geng · 2021-02-14 07:49:04 UTC

Hello, I can use FFmpeg to stream the data from `/opt/frame0`. And I can view something on my laptop. But the stream is something with green background. Do you meet a similar issue before?
Does something wrong with my camera or the type of visual stream is not correct?

![stream-bug.png](https://forum.modalai.com/assets/uploads/files/1613288942353-stream-bug.png)

## Reply by Eric Katzfey (ModalAI staff) · 2021-02-15 17:28:49 UTC

Can you please send us the output of "ls -l /dev/frame0", the output showing hello_hal3_camera, and also ffmpeg?
