# Media could not be loaded, either because the server or network failed or the format is not supported ERROR while I'm trying to stream my cam with OBS



## ziomario (Jan 15, 2022)

Hello.

I would like to stream the content of my webcam on my personal web server,located on the same PC that I use everyday. To do that I've used *FreeBSD 13p6 ; obs 27.1.3 and nginx vers. 1.20.2*

Below you can see all the commands that I have issued and I've also attached a list of screenshots,to explain better what happens. Infact it does not work : when I open the http address I'm not able to see my face. So,something is not working great. (I'm running apache on port 80) ;

on the router opened these ports : *443;80;4000;1935;8080;81 tcp/udp*


```
gedit /etc/rc.conf

webcamd_0_flags="-N Generic-USB2-0-PC-CAMERA -S 20100331010203 -M 0"

killall webcamd
service webcamd start
obs

The video tutorial that I've watched :

https://www.youtube.com/watch?v=fW2kLd6INyQ&t=145s

commands taken from the video tutorial,modified by me :

cd /usr/ports/www/nginx
make install clean
(enable RTMP)
mkdir /mnt/hls
chown www:www /mnt/hls
mkdir /usr/local/www/stream
service nginx start

gedit /usr/local/etc/nginx/nginx.conf

load_module /usr/local/libexec/nginx/ngx_stream_module.so;
load_module /usr/local/libexec/nginx/ngx_rtmp_module.so;

#user nobody
worker_processes  1;
events {
worker_connections  1024;
}

# RTMP configuration
rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;

application live {
live on;
# Turn on HLS
hls on;
hls_path /mnt/hls/;
hls_fragment 3;
hls_playlist_length 60;
# disable consuming the stream from nginx as rtmp
deny play all;
}
}
}

http {
sendfile off;
tcp_nopush on;
aio on;
directio 512;
default_type application/octet-stream;

# GTV Player
server {
listen       81;
server_name  ziomario;

location / {
root    /usr/local/www/stream;
#root /usr/local/www/apache24/data;
index    index.html index.htm;
}
}


server {
listen 81;

location / {
# Disable cache
add_header 'Cache-Control' 'no-cache';

# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';

# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}

types {
application/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}

root /mnt/;
}
}
}


gedit /usr/local/www/stream/index.html


<html>
<head>
<title>ZioMario Player</title>
<link href="https://vjs.zencdn.net/7.5.6/video-js.css" rel="stylesheet">

<!-- If you'd like to support IE8 (for Video.js versions prior to v7) -->
<script src="https://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
</head>

<body>
<video id='my-video' class='video-js vjs-big-play-centered' controls preload='auto'
width='1440'
height='900'
poster='gtv-poster.png' data-setup='{}'>
<source src='http://ziomario.ns0.it:8080/hls/test.m3u8'
type='application/x-mpegURL'>
<p class='vjs-no-js'>
To view this video please enable JavaScript, and consider upgrading to
a web browser that
<a href='https://videojs.com/html5-video-support/'
target='_blank'>supports HTML5 video</a>
</p>
</video>

<script src='https://vjs.zencdn.net/7.5.6/video.js'></script>
</body>
</html>

nano /etc/rc.conf

nginx_enable="YES"


on OBS :


Streaming Service: Custom
Server: rtmp://ziomario.ns0.it/live
Stream Key: test
```


error : *The media could not be loaded, either because the server or network failed or because the format is not supported.*

Screenshots :

https://ibb.co/cwFzCz2
https://ibb.co/LrjsY23
https://ibb.co/DrzrnJ2
https://ibb.co/9wXV0wS
https://ibb.co/Sx41cFJ
https://ibb.co/H7mjFCv
https://ibb.co/300wT1k
https://ibb.co/zFBNTRJ

Can u understand where is the error ? very thanks.


----------



## eternal_noob (Jan 15, 2022)

ziomario said:


> http://ziomario.ns0.it:8080/hls/test.m3u8


So you want us all to watch your appointment with Eva? At what time is it?


----------



## covacat (Jan 15, 2022)

afaik hls is only supported on safari and android/chrome
i tried some plugins from chrome desktop but they suck


----------



## ziomario (Jan 15, 2022)

eternal_noob said:


> So you want us all to watch your appointment with Eva? At what time is it?



I'll use skipe, but if that doesn't work (Infact I don't understand why,but sometime Skipe for Windows closes its process), I'm preparing plan B. You won't be able to see anything because mine and your different time zones.


----------



## ziomario (Jan 15, 2022)

covacat said:


> afaik hls is only supported on safari and android/chrome
> i tried some plugins from chrome desktop but they suck



can u give a look at video tutorial that I've posted ? because it worked like a charm for him.


----------



## eternal_noob (Jan 15, 2022)

ziomario said:


> You won't be able to see anything because mine and your different time zones.


Is that your only sEcUrItY mEaSuRe? 

Dude... Talk to her in person. This is the best advice you can get.
If you can't, for whatever reason, use Skype on Windows, but please, for the sake of the holy kernel, don't use a public stream.


----------



## ziomario (Jan 15, 2022)

but no,it isn't. I don't talk about my security measurements,because if I do that,they will be not security measurements anymore. The most effective security measurement is not technological,but psychological. At least in our cultural timeframe. I can't talk with her in person. Her room is not secure because Omicron is very dangerous. In the recent past someone blame me for being selfish because I didn't get vaccinated. Well, the vaccine is not the only measure of defense. There is another one,even more powerful, it's to stay away physically from risks and dangers. So,no I'm not selfish. I'm differently protected.


----------



## eternal_noob (Jan 15, 2022)

ziomario said:


> I don't talk about my security measurements,because if I do that,they will be not security measurements anymore.


Security through obscurity doesn't work.


ziomario said:


> The most effective security measurement is not technological,but psychological.


A stop sign? These don't work either.

I won't comment on you other statement otherwise this thread gets deleted too.


----------



## ziomario (Jan 15, 2022)

eternal_noob said:


> Security through obscurity doesn't work.
> 
> A stop sign? These don't work either.
> 
> I won't comment on you other statement before this thread gets deleted too.



Security by obscurity doesn't work : that's a nice argument to talk about : I'm intrigued to know more.


----------



## covacat (Jan 15, 2022)

i suppose that video.js will play hls on other browsers
but if the .ts files are created then it should work with your phone without that video.js
i use a similiar setup for security cameras but i just create the hls stuff with ffmpeg from the nvr rtsp stream


----------



## ziomario (Jan 15, 2022)

maybe it works on Chromium,but there is some wrong setting on my configuration :


----------



## ziomario (Jan 15, 2022)

now it changed behavior. It runs idle :


----------



## ziomario (Jan 15, 2022)

this is the reason :


```
info: [rtmp stream: 'simple_stream'] Connecting to RTMP URL rtmp://ziomario.ns0.it/live...
info: [rtmp stream: 'simple_stream'] Connection to rtmp://ziomario.ns0.it/live successful
info: ==== Streaming Start ===============================================
error: v4l2-input: /dev/video0: select timed out
error: v4l2-input: /dev/video0: failed to log status
error: v4l2-input: /dev/video0: select timed out
error: v4l2-input: /dev/video0: failed to log status
```


----------



## eternal_noob (Jan 15, 2022)

I get a CORS request did not succeed error.


----------



## ziomario (Jan 15, 2022)

eternal_noob said:


> I get a CORS request did not succeed error.
> 
> View attachment 12620



don't use Firefox,it does not work for sure. It seems chromium is better. At least it gives a more promising error.


----------



## eternal_noob (Jan 15, 2022)

A failed cross-origin request doesn't work in any browser. Fix it.


----------



## ziomario (Jan 15, 2022)

I don't know how !


----------



## eternal_noob (Jan 15, 2022)

Good. Because THAT's a security measure.





__





						Cross-origin resource sharing - Wikipedia
					






					en.wikipedia.org


----------



## drhowarddrfine (Jan 15, 2022)

eternal_noob said:


> Good. Because THAT's a security measurement.


That cracked me up.


----------



## ziomario (Jan 15, 2022)

So,its better if I stay ignorant ? The ignorance as a good security measurement ? Think carefully at this.


----------



## eternal_noob (Jan 15, 2022)

I want to help you. That's why i don't tell you how you can livestream your appointment with your psycho doc.


----------



## ziomario (Jan 15, 2022)

You aren't helping me and you aren't helping yourself,too. If I'm not able to fix this error I will use skype for sure,so : 1) I will stay ignorant 2)
you are losing the chance to watch Eva,in this way. Not a good move. This made me laugh,because psychological usually wins over technological.


----------



## Geezer (Jan 16, 2022)

If you are going to all this effort to see your therapist, then you need to see a therapist.

I am sure that when you eventually do get through to her, going via Mars and Venus, she will say to you, "Ziomario, keep it simple!"

And are you aware that your local ISP has probably blocked port 80, even if you do have port forwarding on your modem.


----------



## covacat (Jan 16, 2022)

JS Bin
					

A live pastebin for HTML, CSS & JavaScript and a range of processors, including SCSS, CoffeeScript, Jade and more...




					jsbin.com
				



this worked for me with hls


----------



## ziomario (Jan 16, 2022)

Geezer said:


> If you are going to all this effort to see your therapist, then you need to see a therapist.
> 
> I am sure that when you eventually do get through to her, going via Mars and Venus, she will say to you, "Ziomario, keep it simple!"
> 
> And are you aware that your local ISP has probably blocked port 80, even if you do have port forwarding on your modem.



I do all this effort because I like to solve problems and I like to enjoy myself with the achieved goal. What it seems to me is that you are too tired to do this. How many reasons did u find for me to see a therapist ? I've lost the number. My port 80 works good because apache says "it works!" ; anyway I've disabled apache and I left enabled only the nginx parameter to "yes" on rc.conf.


----------



## ziomario (Jan 16, 2022)

covacat said:


> JS Bin
> 
> 
> A live pastebin for HTML, CSS & JavaScript and a range of processors, including SCSS, CoffeeScript, Jade and more...
> ...



can u elaborate more ? how can your "JS bin" help me ? what should I do with it ?


----------



## zirias@ (Jan 16, 2022)

eternal_noob said:


> I won't comment on you other statement otherwise this thread gets deleted too.


I wouldn't mind, it's still the same anti-social bullshit. Yes, that's all I have to say about that thread, so, just waiting for my comment to be deleted again


----------



## covacat (Jan 16, 2022)

ziomario said:


> can u elaborate more ? how can your "JS bin" help me ? what should I do with it ?


that html/js example actually works with hls video


----------



## ziomario (Jan 16, 2022)

covacat said:


> that html/js example actually works with hls video



what should I do ? I should change this :


```
http-streaming
```

with this ?


```
http://ziomario.ns0.it:8080/hls/test.m3u8
```

so it becomes :


```
<script src="https://unpkg.com/@videojs/http://ziomario.ns0.it:8080/hls/test.m3u8@0.9.0/dist/videojs-http-streaming.js"></script>
```


----------



## covacat (Jan 16, 2022)

change this line with your video source
<source src="https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8" type="application/x-mpegURL">
the rest works unchanged

also make sure the webpage and the video come from the same port / site so you don't have to mess with cross origin


----------



## ziomario (Jan 16, 2022)

covacat said:


> change this line with your video source
> <source src="https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8" type="application/x-mpegURL">
> the rest works unchanged
> 
> also make sure the webpage and the video come from the same port / site so you don't have to mess with cross origin



---> also make sure the webpage and the video come from the same port / site so you don't have to mess with cross origin

explain to me what I should do to fix this error. at the moment it does not work :


----------



## ziomario (Jan 16, 2022)

Chromium is more explicative about the error :

HLS playlist request error at URL: http://ziomario.ns0.it:8080/hls/test.m3u8.


----------



## covacat (Jan 16, 2022)

fix this
<source src="http://ziomario.ns0.it:8080/hls/test.m3u8" type="application/x-mpegURL">
make the m3u8 file reachable via port 80


----------



## ziomario (Jan 16, 2022)

http://ziomario.ns0.it/hls/test.m3u8 = not found ;
http://ziomario.ns0.it + firefox = The media could not be loaded, either because the server or network failed or because the format is not supported.
http://ziomario.ns0.it + chromium = cyclic loading


----------



## eternal_noob (Jan 16, 2022)

Yeah, that's a 404.


----------



## ziomario (Jan 16, 2022)

this is the nginx.conf file :


```
load_module /usr/local/libexec/nginx/ngx_stream_module.so;
load_module /usr/local/libexec/nginx/ngx_rtmp_module.so;

#user nobody
worker_processes  1;
events {
    worker_connections  1024;
}

# RTMP configuration
rtmp {
    server {
        listen 1935; # Listen on standard RTMP port
        chunk_size 4000;

        application live {
            live on;
            # Turn on HLS
            hls on;
            hls_path /mnt/hls/;
            hls_fragment 3;
            hls_playlist_length 60;
            # disable consuming the stream from nginx as rtmp
            deny play all;
        }
    }
}

http {
    sendfile off;
    tcp_nopush on;
    aio on;
    directio 512;
    default_type application/octet-stream;

    # ZioMario Player
    server {
        listen       80;
        server_name  ziomario;
   
    location / {
    root    /usr/local/www/stream;
    #root /usr/local/www/apache24/data;
    index    index.html index.htm;
    }
    }


    server {
        listen 80;

        location / {
            # Disable cache
            add_header 'Cache-Control' 'no-cache';

            # CORS setup
            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Expose-Headers' 'Content-Length';

            # allow CORS preflight requests
            if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Max-Age' 1728000;
                add_header 'Content-Type' 'text/plain charset=UTF-8';
                add_header 'Content-Length' 0;
                return 204;
            }

            types {
                application/dash+xml mpd;
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }

            root /mnt;
        }
    }
}
```

do u see some error inside it ? the video files are inside /mnt/hls :


```
marietto:/usr/local/etc/nginx # ls /mnt/hls

test-208.ts     test-211.ts     test-214.ts     test-217.ts     test-220.ts     test-223.ts     test.m3u8
test-209.ts     test-212.ts     test-215.ts     test-218.ts     test-221.ts     test-224.ts
test-210.ts     test-213.ts     test-216.ts     test-219.ts     test-222.ts     test-225.ts
```


----------



## ziomario (Jan 19, 2022)

Fixed. The problem was that I kept apache24 disabled. Infact I had read that apache wasn't needed. But its not true.


----------



## hselasky@ (Jan 22, 2022)

ziomario said:


> this is the reason :
> 
> 
> ```
> ...



What does usbconfig() say about your device? Are you sure there is enough USB capacity to run the desired resolution? Are you running the latest version of webcamd()?


----------



## ziomario (Jan 22, 2022)

I have 3 webcams + one kinect 2. None of these are working great. For the 3 webcams there is a bug in OBS,that u can see here :






						258694 – multimedia/obs-ndi cannot find libndi
					






					bugs.freebsd.org
				




the kinect 2 needs a special driver (for linux only) like this :  https://github.com/jm2/gspca-kinect2

that should be ported in FreeBSD.


----------

