Skippy VonDrake
Skippy VonDrake

Reputation: 846

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.
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). But this problem is unchanged with the 32 bit version.

Source for Console Project in 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;
}

Upvotes: 1

Views: 2502

Answers (2)

k_kaz
k_kaz

Reputation: 606

Why are you using the mux=ts option when the file extension is .mpg? In this link https://wiki.videolan.org/Documentation:Streaming_HowTo/Receive_and_Save_a_Stream/ you can see some of the muxer options. 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. Then in the second media player you dont have to duplicate. Use the example in the link.

Upvotes: 1

Ibrahim Al-tiay
Ibrahim Al-tiay

Reputation: 21

Try "--sub-source=marq" in your options instead of "--sub-filter=marq"

Upvotes: 1

Related Questions