使用ffpmeg+nginx倍速播放

问题描述 投票:0回答:1

我想实现2倍的播放速度。 有一个流媒体服务A,我想在本地架设一个流媒体服务器B,从A获取流并以2倍速播放。为了实现这个功能,首先使用命令让服务器A以两倍的速度推流。本地服务器B将流移除后,使用以下命令进行转码播放。但是发现流太滞后了。我不知道为什么。命令如下: 转码:

ffmpeg -re -i 'http://ServerAPlaybackUrl' \
    -filter_complex "[0:v]setpts=0.5*PTS[v]" -map "[v]" \
    -r 25 \
    -c:v libx264 \
    -c:a aac \
    -b:a 128k \
    -maxrate 3000k \
    -bufsize 6000k \
    -pix_fmt yuv420p \
    -g 50 \
    -f flv \
    -threads 4 \
    rtmp://NginxUrl

播放视频:

ffplay -fflags nobuffer http://localhost/hls/placeToM3u8.m3u8

本地 nginx:

# nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}

#rtmp {
#    server {
#        listen 1935;
#        chunk_size 4096;
#
#        application live {
#            live on;
#            record off;
#        }
#    }
#}

rtmp {
    server {
        listen 1935;
        chunk_size 4096;

        application live {
            live on;
            record off;
            hls on;
            hls_path /tmp/hls;
            #hls_cleanup on;
            hls_fragment 3s;
            hls_playlist_length 60s;
        }
    }
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }

        location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
                ./ ts;
            }
            root /tmp;
            add_header Cache-Control no-cache;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

有什么问题吗?

nginx ffmpeg playback-rate
1个回答
0
投票

服务器B转换服务处理,向前跳过x段,xxxx

© www.soinside.com 2019 - 2024. All rights reserved.