简体   繁体   English

libVLC无法一起叠加和录制视频流

[英]libVLC can't do overlay and record video stream together

I'm using libVLC to process and record video from an IP camera but can't get the overlay to work while recording. 我正在使用libVLC来处理和录制来自IP摄像机的视频,但是在录制时无法使叠加层正常工作。
Meaning if I comment out the code that duplicates the stream for saving it to a file - the overlay works. 意思是,如果我注释掉复制流以将其保存到文件的代码,则覆盖层有效。 But if I leave the code in - the video is recorded but no overlay is on the rendered video either on the screen or in the file. 但是,如果我保留代码,则将录制视频,但在屏幕或文件中呈现的视频上没有覆盖。

Using libVLC 2.06 on Windows 7 (x64). 在Windows 7(x64)上使用libVLC 2.06。 But this problem is unchanged with the 32 bit version. 但是,对于32位版本,此问题不变。

Source for Console Project in Visual Studio: Visual Studio中控制台项目的源:

// Vlc_ConsoleApp.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <stdio.h>
#include <stdlib.h>
#include <vlc/vlc.h>
#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{          
    libvlc_instance_t * inst;
    libvlc_media_player_t *mp;
    libvlc_media_t *m;
    char* arguments[] = { "-I", 
        "dummy", 
        "--ignore-config", 
        "--no-video-title", 
        "--sub-filter=marq", 
        "--plugin-path=C:/Software_Development/Software_Libraries/VLC/vlc-2.0.6_x64/plugins"};

    char* duplicateStreamOption = ":sout=#stream_out_duplicate{dst=display,dst=std{access=file,sub-filter=marq,mux=ts,dst=c:/temp/test_go.mpg}}";

    /* Load the VLC engine */   
    inst = libvlc_new (6, arguments);

    /* Create a new item */
    m = libvlc_media_new_location (inst, "rtsp://@192.168.2.168");

    /* add option to record duplicate stream to file */
    /* if I comment this out - then marquee works */
    //libvlc_media_add_option(m, duplicateStreamOption);

    /* Create a media player playing environement */
    mp = libvlc_media_player_new_from_media (m);

    /* No need to keep the media now */
    libvlc_media_release (m);

    /* play the media_player */
    libvlc_media_player_play (mp);

    Sleep (10000); /* Let it play for 10 seconds */

    /* throw up a marquee */
    libvlc_video_set_marquee_int(mp, libvlc_marquee_Enable, 1);
    libvlc_video_set_marquee_string(mp, libvlc_marquee_Text, "Hello- Marquee");
    libvlc_video_set_marquee_int(mp, libvlc_marquee_Opacity, 50);
    libvlc_video_set_marquee_int(mp, libvlc_marquee_X, 10);
    libvlc_video_set_marquee_int(mp, libvlc_marquee_Y, 10);             
    libvlc_video_set_marquee_int(mp, libvlc_marquee_Timeout, 4000); // 4 secs
    libvlc_video_set_marquee_int(mp, libvlc_marquee_Size, 40);
    libvlc_video_set_marquee_int(mp, libvlc_marquee_Color, 0xFF0000);

    Sleep (10000); /* play some more */

    /* Stop playing */
    libvlc_media_player_stop (mp);

    /* Free the media_player */
    libvlc_media_player_release (mp);

    libvlc_release (inst);

    return 0;
}

在选项中尝试使用"--sub-source=marq" ,而不是"--sub-filter=marq"

Why are you using the mux=ts option when the file extension is .mpg? 文件扩展名为.mpg时,为什么要使用mux = ts选项? In this link https://wiki.videolan.org/Documentation:Streaming_HowTo/Receive_and_Save_a_Stream/ you can see some of the muxer options. 在此链接https://wiki.videolan.org/Documentation:Streaming_HowTo/Receive_and_Save_a_Stream/中,您可以看到一些混合器选项。 For your issue i whould recommend creating different media players. 对于您的问题,我建议创建其他媒体播放器。 Create a media player with just the rtsp link and the overlay and then create another media player giving again the rtsp link but adding the save to file option. 创建仅带有rtsp链接和覆盖图的媒体播放器,然后创建另一个提供rtsp链接但添加“保存到文件”选项的媒体播放器。 Then in the second media player you dont have to duplicate. 然后,在第二个媒体播放器中,您不必复制。 Use the example in the link. 在链接中使用示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM