VLC桌面流媒体传输

5
编辑
我停止使用VLC并转而使用GMax FLV Encoder,我认为这样做更好。 原始帖子
我将我的桌面(屏幕)作为H264视频流发送到另一台机器,该机器使用以下命令将其保存到文件中:
发送流的命令:
vlc -I dummy
    --sout='#transcode{vcodec=h264,vb=512,scale=0.5}
            :rtp{mux=ts,dst=192.168.0.1,port=4444}'

流的接收者:

vlc -I rc
    rtp://@:4444
    --sout='#std{access=file,mux=ps,dst=/home/user/output.mp4}'
    --ipv4

这个方法是可以工作的,但存在几个问题:
  • 大多数播放器无法播放该文件。
  • VLC 能够播放该文件,但有些奇怪的问题:
  • => 播放开始前需要约 10 秒钟的时间。
  • => 快进操作无效。
请问有人能指导我如何解决这些问题吗? 编辑:我取得了一些进展。
播放开始时的初始延迟是因为播放器在等待关键帧。通过强制流的发送者每 4 秒创建一个新的关键帧,我可以减少延迟:
:screen-fps=10
--sout='#transcode{vcodec=h264,venc=x264{keyint=40},vb=512,scale=0.5}
       :rtp{mux=ts,dst=192.168.0.1,port=4444}'

寻求问题尚未解决,不过我对它的理解更深了。RTP流以其原始流格式保存为文件,通常无法作为普通视频文件播放。VLC可以播放此文件,但大多数其他播放器不能。因此,我需要将其转换为普通视频文件。我目前正在调查是否可以通过为记录的流提供SDP文件来使用ffmpeg来完成此操作。欢迎任何帮助!

我不知道如何回答这个问题,但你尝试使用视频编辑器并将文件保存为不同格式了吗? - Mottie
是的,我尝试使用ffmpeg进行修复,但似乎会将整个输出减少到几帧,因此最终只得到了1秒的视频。 - StackedCrooked
2
这与编程有什么关系? - Pascal Thivent
2个回答

6

使用以下命令更新发件人命令行:

venc=x264{scenecut=20,bframes=0}

你的客户端命令行如下:

vlc -I rc rtp://@:4444 --sout='#std{access=file,mux=mp4,dst=/tmp/output.mp4}' --ipv4

应该可以解决你的问题。你测试了哪些播放器?

设置mux=mp4非常有帮助,可惜文档中没有提到(http://www.videolan.org/doc/streaming-howto/en/ch03.html)。 今天我发现设置bframes=0会导致一个可以用ffmpeg修复的文件,但现在由于mux=mp4设置,这也不再需要了。 然而,scenecut=20如何帮助解决我的问题?还是只是一种优化? - StackedCrooked
还有一个问题:为什么您省略了x264的keyint=40设置? - StackedCrooked
顺便说一下,我在我的Mint vbox上使用了Movie Player和GNOME Player进行测试。由于您提供的设置,这两个播放器现在都能够播放我的录像了。另外,回答上面的问题,赏金就是你的了。 - StackedCrooked
"scenecut" 启用场景切换检测,控制插入额外 I-帧的侵略性。您可以将该值从 -1(禁用)更改为 100。更改此值可以帮助编码器找到更好的 I-帧位置。我不需要 "keyint",较大的值可能会导致不精确的查找。 - Derfel

0

发送者:

$ vlc screen:// :screen-fps=5 :screen-caching=100 --sout='#transcode{vcodec=h264,venc=x264{scenecut=20,bframes=0},vb=512,scale=0.5}:rtp{mux=ts,dst=127.0.0.1,port=1234}'
VLC media player 1.1.11 The Luggage (revision exported)
Blocked: call to unsetenv("DBUS_ACTIVATION_ADDRESS")
Blocked: call to unsetenv("DBUS_ACTIVATION_BUS_TYPE")
[0x9caf8fc] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Blocked: call to setlocale(6, "")
Warning: call to srand(1314435080)
Warning: call to rand()
Blocked: call to setlocale(6, "")

(process:11597): Gtk-WARNING **: Locale not supported by C library.
    Using the fallback 'C' locale.
x264 [info]: using cpu capabilities: MMX2 Cache64
x264 [info]: profile High, level 3.2
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 Cache64
x264 [info]: profile High, level 4.0
x264 [info]: frame I:1     Avg QP:16.44  size: 57235
x264 [info]: frame P:152   Avg QP:10.01  size:  2747
x264 [info]: mb I  I16..4: 33.8%  2.7% 63.5%
x264 [info]: mb P  I16..4:  0.9%  0.0%  0.9%  P16..4:  2.1%  0.4%  0.3%  0.0%  0.0%    skip:95.4%
x264 [info]: 8x8 transform intra:1.8% inter:44.3%
x264 [info]: coded y,uvDC,uvAC intra: 45.5% 42.9% 40.5% inter: 1.5% 1.5% 1.4%
x264 [info]: i16 v,h,dc,p: 45% 54%  0%  0%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 41% 22%  2%  2%  2%  4%  1%  3%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 49% 13%  2%  3%  3%  5%  2%  7%
x264 [info]: i8c dc,h,v,p: 43% 49%  7%  2%
x264 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x264 [info]: ref P L0: 85.8%  4.5%  9.1%  0.7%
x264 [info]: kb/s:124.12
^C[0x9d4ee6c] signals interface error: Caught Interrupt signal, exiting...

接收者:

$ vlc udp://:1234
VLC media player 1.1.11 The Luggage (revision exported)
Blocked: call to unsetenv("DBUS_ACTIVATION_ADDRESS")
Blocked: call to unsetenv("DBUS_ACTIVATION_BUS_TYPE")
[0x8c728fc] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Blocked: call to setlocale(6, "")
Warning: call to srand(1314469032)
Warning: call to rand()
Blocked: call to setlocale(6, "")

(process:11707): Gtk-WARNING **: Locale not supported by C library.
    Using the fallback 'C' locale.
libdvbpsi error (PSI decoder): TS discontinuity (received 1, expected 0) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 1, expected 0) for PID 66
libdvbpsi error (PSI decoder): TS discontinuity (received 6, expected 5) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 8, expected 7) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 10, expected 9) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 14, expected 13) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 0, expected 15) for PID 66
libdvbpsi error (PSI decoder): TS discontinuity (received 2, expected 1) for PID 66
libdvbpsi error (PSI decoder): TS discontinuity (received 12, expected 11) for PID 66
libdvbpsi error (PSI decoder): TS discontinuity (received 14, expected 13) for PID 66
libdvbpsi error (PSI decoder): TS discontinuity (received 0, expected 15) for PID 66
libdvbpsi error (PSI decoder): TS discontinuity (received 2, expected 1) for PID 66
libdvbpsi error (PSI decoder): TS discontinuity (received 7, expected 6) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 9, expected 8) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 11, expected 10) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 13, expected 12) for PID 66
libdvbpsi error (PSI decoder): TS discontinuity (received 15, expected 14) for PID 66
libdvbpsi error (PSI decoder): TS discontinuity (received 1, expected 0) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 8, expected 7) for PID 66
libdvbpsi error (PSI decoder): TS discontinuity (received 11, expected 10) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 13, expected 12) for PID 66
libdvbpsi error (PSI decoder): TS discontinuity (received 4, expected 3) for PID 0
libdvbpsi error (PSI decoder): TS discontinuity (received 8, expected 7) for PID 66
[0xb740070c] main input error: ES_OUT_SET_(GROUP_)PCR  is called too late (pts_delay increased to 300 ms)
^C[0x8d11cec] signals interface error: Caught Interrupt signal, exiting...

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接