我有一个 wowza 服务器,我在其中播放使用 jwplayer 播放的直播。 不过,一切都可以在 Android 和其他系统上完美运行。 (在 android 4.4 和 jwplayer (!) 中与 rtmp 和 hls 一起工作)。 流被发送到我的 wowza 服务器,avconv 在 linux pc 上运行,这工作正常。
但是当我尝试使用 avconv(与上述情况相同但目的地不同的命令)直接从 linux pc 发送我的流到本地服务器时,它在 android 上失败,我尝试过所有基于浏览器的播放器,包括jw播放器。尽管使用 jwplayer,流在其他系统上工作,例如 linux、chromebook。我在 Android 中从 jwplayer 得到的错误是“找不到可播放的源”
我尝试过使用 crtmp rtmp,以及用于 rtmp 和 hls 的 nginx rtp 模块。始终具有相同的结果,android 失败。为什么这些流在使用 wowza 时在 android 上运行时会失败?
我目前的设置是带有 rtmp 模块的 nginx,这里是 nginx.conf:
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
location / {
add_header Access-Control-Allow-Origin *;
root html;
index index.html index.htm;
}
location /hls {
# Serve HLS fragments
types {
add_header Access-Control-Allow-Origin *;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
}
location /dash {
# Serve DASH fragments
root /tmp;
add_header Cache-Control no-cache;
}
}
}
rtmp {
server {
listen 1935;
chunk_size 4000;
application hls {
live on;
hls on;
hls_path /tmp/hls;
}
# MPEG-DASH is similar to HLS
application dash {
live on;
dash on;
dash_path /tmp/dash;
}
}
}
这是 avconv 命令:
avconv -g 40 -threads 4 -f video4linux2 -video_size $SIZE -r 15 -i /dev/video0 -itsoffset -3.35 -i audio0.fifo -re -vcodec libx264 -r 15 -preset veryfast -tune zerolatency -aq 0 -q 3 -vbr 3 -maxrate 3M -threads 4 -f flv rtmp://192.168.0.6/hls/mycam
当通过 wowza 而不是本地主机 (!92.168.0.6) 使用上面的命令时,它可以在带有 jwplayer 的 android 上运行。
所以只有在使用 wowza 时,只有通过本地服务器的 android 才成功......奇怪,有什么想法吗?我的 android 是运行 android 4.4 的平板电脑,但我也尝试了其他几个 android 版本。我当然愿意使用其他播放器进行故障排除,但最终结果必须是一些基于浏览器的播放器。
最佳答案
您还可以使用 Wowza 的 MPEG-DASH 输出,并使用 bitdash HTML5 MPEG-DASH 播放器在 Android 上以 HTML5 播放:http://www.dash-player.com
关于android - 在 Android 上播放 hls/rtmp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29809560/