Displaying a marquee on screen and recording it

This forum is about all development around libVLC.
mmacintosh
New Cone
New Cone
Posts: 4
Joined: 16 Jun 2015 00:27

Displaying a marquee on screen and recording it

Postby mmacintosh » 16 Jun 2015 01:14

Hey, I'm new to the VLC forums, and libvlc in general. I think I am mostly getting hung up on the syntax of adding a marquee. I have seen many examples of how to add marquees on these forums, but all of them seem to be using different syntax, so some clarification would be nice.

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);
Basically, transcode{marq} -> duplicate{ display, file out }.

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);
I guess this assumes that vlc will just wait for a marq sub-picture filter to be declared later on?

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(); }
So, some clarification would be nice, as the documentation isn't too clear on how to do this, so far I know that you can pass arguments to the marq sub-filter, it doesn't do anything, but you can pass arguments to it. So, let me know what I am doing wrong, thanks in advance.

mmacintosh
New Cone
New Cone
Posts: 4
Joined: 16 Jun 2015 00:27

Re: Displaying a marquee on screen and recording it

Postby mmacintosh » 17 Jun 2015 21:39

Seems like I was on the right track, I got marq to display and record from files using this:

Code: Select all

libvlc_instance_t * inst; libvlc_media_player_t *mp; libvlc_media_t *m; // VLC options char* args[] = { //"--sub-filter=marq{marquee=texttexttext,x=640,y=480,size=40}", "--verbose=2" }; inst = libvlc_new (sizeof(args) / sizeof(args[0]), args); //rtsp source //m = libvlc_media_new_location (inst, "rtsp/h264://username:password@192.168.2.237:554/axis-media/media.amp"); //file source m = libvlc_media_new_path(inst, "testfile.mp4"); //for rtsp //const char * buffersize = "rtsp-frame-buffer-size=200000"; //libvlc_media_add_option(m, buffersize); const char * media_args = "sout=#transcode{vcodec=h264,venc=x264{preset=ultrafast,tune=zerolatency},channels=2,sfilter=marq}:duplicate{dst=display,dst=std{access=file,mux=mp4,dst='C:/DIMSProc/DIMSAVCapture/123/20150605-15107-5A/sweetvideoout.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); 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);
Now it seems like the problem isn't displaying the marquee, its getting the transcode to not crash. For some reason in VLC Player (through convert/save) and in libvlc, if you transcode with an rtsp stream as a source, it seems to not work. Right now though, I am still unsure if it is an issue with my code / setup, or if it is a bug in VLC.

This is the pastebin of the libvlc debug log,
http://pastebin.com/cyJ1ugUh

mmacintosh
New Cone
New Cone
Posts: 4
Joined: 16 Jun 2015 00:27

Re: Displaying a marquee on screen and recording it

Postby mmacintosh » 17 Jun 2015 23:14

Never mind, seems like I fixed it by going back to version 2.1.5. Seems like it is a bug vlc.


Return to “Development around libVLC”

Who is online

Users browsing this forum: Google [Bot] and 23 guests