I am using libvlc 2.2.1 and qt 4.8.2, both in 32 bit.
I'm trying to display a marquee on a video, display that video to the screen, and record that video. I can render a marquee on a video if I am not recording but if I add the option that changes the sout chain to duplicate and display + save it to a file, then enabling the marquee wont work. I know if I want to do this, I need to transcode the video, otherwise libvlc can't add the filter to the compressed stream. I have seen examples do that like this:
Code: Select all
const char * media_args = "sout=#transcode{sfilter=marq{marquee=text,x=10,y=10},venc=x264}:duplicate{dst=display,dst=standard{access=file,mux=mp4,dst=C:/Test/vlctest2.mp4}}";
libvlc_media_add_option(media, media_args);
I have also seen it like this:
Code: Select all
const char * media_args = "sout=#transcode{sfilter=marq,venc=x264}:duplicate{dst=display,dst=standard{access=file,mux=mp4,dst=C:/Test/vlctest2.mp4}}";
libvlc_media_add_option(m, media_args);
libvlc_video_set_marquee_string(mp, libvlc_marquee_Text, "TEST TEXT");
libvlc_video_set_marquee_int(mp, libvlc_marquee_Size, 40);
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_Enable, 1);
This is an example qt console project to demonstrate what I am talking about.
Code: Select all
#include <QtCore/QCoreApplication>
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <vlc/vlc.h>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
char* args[] = { "--sub-filter=marq",
"--verbose=2"};
inst = libvlc_new (2, args);
m = libvlc_media_new_location (inst, "rtsp/h264://username:password@192.168.2.236:554/axis-media/media.amp");
const char * media_args = "sout=#transcode{soverlay,sfilter=marq{marquee=HELLO,size=24}}:duplicate{dst=display,dst=standard{access=file,mux=mp4,dst=C:/Test/vlctest2.mp4}}";
libvlc_media_add_option(m, media_args);
mp = libvlc_media_player_new_from_media (m);
libvlc_media_release (m);
libvlc_media_player_play (mp);
//
// It looks like vlc engine needs some time to open file and start playing
// At least when it isn't done through the transcode
//
Sleep(2500);
libvlc_video_set_marquee_string(mp, libvlc_marquee_Text, "Hello- Marquee");
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, 3000); // 3 secs duration
libvlc_video_set_marquee_int(mp, libvlc_marquee_Size, 40);
libvlc_video_set_marquee_int(mp, libvlc_marquee_Color, 0xFF0000);
libvlc_video_set_marquee_int(mp, libvlc_marquee_Enable, 1);
Sleep (30000);
libvlc_media_player_stop (mp);
libvlc_media_player_release (mp);
libvlc_release (inst);
return a.exec();
}