gstreamer播放教程二:字幕

参考:https://blog.youkuaiyun.com/sakulafly/article/list/2

https://gstreamer.freedesktop.org/documentation/tutorials/playback/subtitle-management.html

如何获取字幕、音轨、视频流个数,及其具体信息

如何切换字幕,切换音轨,切换视频流

如何外挂一个字幕

如何设置字幕的字体

下面结合播放教程一,实现了以上功能。

#include "pch.h"

//如何选择字幕
//如何添加字幕
//如何定制字幕的字体

#include<string.h>
#include<stdio.h>
#include <gst/gst.h>

typedef struct _CustomData{
	GstElement *playbin;

	gint n_video;
	gint n_audio;
	gint n_text;

	gint current_video;
	gint current_audio;
	gint current_text;

	GMainLoop *main_loop;
}CustomData;

typedef enum {
	GST_PLAY_FLAG_VIDEO = (1 << 0), //we want video output
	GST_PALY_FLAG_AUDIO = (1 << 1),
	GST_PALY_FLAG_TEXT = (1 << 2)
}GstPlayFlags;

static gboolean handle_message(GstBus *bus, GstMessage *msg, CustomData *data);
static gboolean handle_keyboard(GIOChannel *source, GIOCondition cond, CustomData *data);

int main(int argc, char *argv[]) {
	CustomData data;
	GstBus *bus;
	GstStateChangeReturn ret;
	gint flags;
	GIOChannel *io_stdin;

	gst_init(&argc, &argv);

	data.playbin = gst_element_factory_make("playbin", "playbin");
	if (!data.playbin) {
		g_printerr("could not create playbin\n");
		return -1;
	}
	g_object_set(data.playbin, "uri", "file:///C:/Users/lenovo/Desktop/testVideo/[PGS][Tintin-004][DTS-AC3][5PGS].mkv", NULL);
	//外挂字幕地址
	g_object_set(data.playbin, "suburi", "file:///C:/Users/lenovo/Desktop/testVideo/shenhua_waigua.srt", NULL);
	//设置字幕的字体
	g_object_set(data.playbin, "subtitle-font-desc", "Sans,18"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值