1、宝塔面板 Nginx-1.22.1 版服务器安装了支持视频播放的 nginx_http_flv_module 模块并测试成功,且根据网上查询的资料修改了 nginx.conf 配置文件,Nginx 也重新载入了,也重启了服务器;
2、PHP-7.2.33 版本也安装了 fileinfo 扩展并启用,重新载入并重启过;
3、Destoon B2B 程序网站视频文件网址路径正确,复制到浏览器可下载视频,就是不能播放,在电脑本地可用播放器播放,证明文件没坏,编码正确。
4、视频更新了缓存,浏览器也清除了缓存。flv 和 mp4 两种格式的视频文件始终不能播放,不知问题出在哪里,希望各位工程师能帮我解决这个问题,谢谢!
5、这个是配置文件在服务器上的路径:/www/server/nginx/src/conf/nginx.conf 我只要求能播放视频,并不需要推流、拉流等直播功能;
6、根据 ChatGPT 的聊天问答提示在 /www/server/nginx/conf/nginx.conf 这个文件加入过如下代码:
```bash
types {
video/mp4 mp4;
video/x-flv flv;
}
但提示错误,无法保存文件,最终放弃。
/www/server/nginx/conf/nginx.conf 这个配置文件的全部内容如下:
```bash
user www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
stream {
log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time';
access_log /www/wwwlogs/tcp-access.log tcp_format;
error_log /www/wwwlogs/tcp-error.log;
include /www/server/panel/vhost/nginx/tcp/*.conf;
}
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
#include luawaf.conf;
include proxy.conf;
default_type application/octet-stream;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
server_tokens off;
access_log off;
server
{
listen 888;
server_name phpmyadmin;
index index.html index.htm index.php;
root /www/server/phpmyadmin;
location ~ /tmp/ {
return 403;
}
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log /www/wwwlogs/access.log;
}
include /www/server/panel/vhost/nginx/*.conf;
}
7、/www/server/nginx/src/conf/nginx.conf 配置文件内容如下:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
rtmp {
out_queue 4096;
out_cork 8;
max_streams 128;
timeout 15s;
drop_idle_publisher 15s;
log_interval 5s; #log 模块在 access.log 中记录日志的间隔时间,对调试非常有用
log_size 1m; #log 模块用来记录日志的缓冲区大小
server {
listen 7933;
application myapp {
live on;
}
application hls {
live on;
hls on;
hls_path /tmp/hls;
}
application dash {
live on;
dash on;
dash_path /tmp/dash;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
flv_live_stream on;
flv_stream_copy_audio on;
flv_stream_copy_video on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
add_header 'Access-Control-Allow-Origin' '*';
root html;
index index.html index.htm;
}
location /live {
flv_live on;
chunked_transfer_encoding on; #支持'Transfer-Encoding: chunked'方式回复
add_header 'Access-Control-Allow-Origin' '*'; #添加额外的 HTTP 头
add_header 'Access-Control-Allow-Credentials' 'true'; #添加额外的 HTTP 头
}
location /flv {
add_header 'Access-Control-Allow-Origin' '*';
flv_live on;
chunked_transfer_encoding on;
}
# control控制器
location /control {
rtmp_control all;
}
location /stat {
#推流播放和录制统计数据的配置
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /usr/local/nginx-http-flv-module/; #指定 stat.xsl 的位置
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
types {
video/mp4 mp4;
video/x-flv flv;
}
}
```
可以使用支持 FLV 和 MP4 格式文件的插件,比如 Flowplayer 或者 JWPlayer。在安装这些插件之前,你还要检查 DesToon 当前的服务器是否已经安装了 Adobe Flash Player,以及网站服务器的配置文件是否支持 FLV 和 MP4 格式文件。安装上这类插件以后,通过修改网站的模板源代码来调用这些插件,以实现比较完美地播放 FLV 和 MP4 格式文件的功能。
从你提供的信息来看,您的问题可能出在 Nginx 配置文件中未正确配置视频文件的 MIME 类型。您可以尝试将以下代码添加到 Nginx 配置文件 /www/server/nginx/conf/nginx.conf 的 http 块中:
types {
video/mp4 mp4;
video/x-flv flv;
}
如果无法保存文件,请尝试使用 root 用户身份编辑该文件,或者尝试使用 sudo 命令。
添加完成后,重新启动 Nginx 服务器,然后再尝试播放视频文件,看是否可以解决问题。
以下答案基于ChatGPT与GISer Liu编写:
根据您提供的信息,您似乎已经尝试了多种方法,但仍然无法在Destoon B2B程序网站中播放FLV和MP4格式的视频文件。以下是您可以尝试的一些其他方法:
①确认您的视频文件路径是否正确,包括文件名是否正确。
②检查您的视频文件是否具有正确的文件权限,以便在Web服务器上读取它们。
③确认您的Nginx.conf文件中是否正确配置了文件类型。例如,您可以尝试使用以下代码来添加FLV和MP4格式的文件类型:
types {
video/mp4 mp4;
video/x-flv flv;
}
请确保此代码位于http块内。然后重新启动Nginx服务器以使更改生效。
④如果您尝试通过HTTPS连接访问视频文件,请确保您的SSL证书已正确配置。如果您使用的是自签名的SSL证书,则可能需要添加浏览器的例外。
⑤如果您使用的是防火墙,请确保端口7933(您的RTMP端口)未被阻止。
⑥ 确认您的Web服务器是否配置了足够的内存以处理视频文件。如果服务器上有其他应用程序正在运行,则可能需要增加服务器的内存。
如果以上方法仍然无法解决您的问题,请考虑咨询您的网络管理员或网站开发人员以获取更详细的帮助。
检查以下nginx.conf文件中的视频模块配置是否正确。确保您已将以下代码添加到nginx.conf文件中:
location ~ \.(flv|mp4)$ {
flv;
root /path/to/your/videos;
}
1:检查服务器MIME TYPE是否设置了.mp4扩展,MIME-Type应该设置为video/mp4
2:检查mp4文件的编码格式,不同软件环境生成的mp4文件,编码格式有差别,浏览器播放只支持H264视频编码和AAC音频编码的mp4文件。如果格式不正确,可以用转换编码的软件转换之后再上传。