我正在尝试使用 FFMPEG 和 MPlayer 通过 TCP 传输 MPEG-TS 流来设置超低 p2p 流。由于aac
编解码器会带来明显的额外延迟,因此我想改用libopus
。当我这样做时,MPlayer 行为异常并拒绝播放音频,但似乎检测到流中的编解码器正确。
这是我正在使用的 ffmpeg 命令:
ffmpeg -f x11grab -s 1920x1080 -framerate 60 -i :0.0 -f pulse -ac 2 -i Virtual1.monitor -c:v h264_nvenc -preset llhq -b:v 8000k -profile:v high -rc:v cbr_ld_hq -c:a libopus -b:a 224k -ar 48000 -f mpegts tcp://127.0.0.1:2000
以下是 MPlayer 及其输出:
v@v-home:~$ mplayer -benchmark -demuxer lavf ffmpeg://tcp://127.0.0.1:2000?listen
MPlayer 1.3.0 (Debian), built with gcc-9 (C) 2000-2016 MPlayer Team
do_connect: could not connect to socket
connect: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing ffmpeg://tcp://127.0.0.1:2000?listen.
libavformat version 58.29.100 (external)
libavformat file format detected.
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (opus), -aid 0
LAVF: Program 1
VIDEO: [H264] 1920x1080 0bpp 60.000 fps 0.0 kbps ( 0.0 kbyte/s)
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 58.54.100 (external)
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
==========================================================================
Cannot find codec for audio format 0x7375704F.
Audio: no sound
Starting playback...
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [vdpau] 1920x1080 => 1920x1080 Planar YV12
V: 32.1 0/ 0 22% 7% 0.0% 0 0
MPlayer interrupted by signal 2 in module: video_read_frame
V: 32.1 0/ 0 22% 7% 0.0% 0 0
Exiting... (Quit)
指定-ac libopus
MPlayer 没有帮助,只是添加了一行强制使用编解码器。aac
并且libmp3lame
编解码器工作正常,而speex
MPlayer 根本无法检测到音频。
该流也可以正常播放ffplay
(带音频),但由于与 MPlayer 相比延迟较高,因此不适合我的使用情况。