ffplay 指定窗口显示

实现效果如下:

 当前 再播放按钮下添加一个窗口, 点击播放, 此时 ffplay播放视频显示在 特定窗口上.

   主要是修改了 ffplay源码添加了一个参数接收 窗口句柄

  

ffplay.exe -i "D:\left\tz_g.mp4" -window_host 527658  -autoexit 

 实现原理就是ffplay 创建窗口方式 使用API :

window = SDL_CreateWindowFrom(window_host_handle);

具体内容可以参考如下dif:

 code/FFmpeg/fftools/ffplay.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/code/FFmpeg/fftools/ffplay.c b/code/FFmpeg/fftools/ffplay.c
index 6a195e55..894dee8f 100644
--- a/code/FFmpeg/fftools/ffplay.c
+++ b/code/FFmpeg/fftools/ffplay.c
@@ -310,6 +310,7 @@ typedef struct VideoState {
 static AVInputFormat *file_iformat;
 static const char *input_filename;
 static const char *window_title;
+static int window_host_handle = 0; // host 窗口句柄
 static int default_width  = 640;
 static int default_height = 480;
 static int screen_width  = 0;
@@ -3599,6 +3600,7 @@ static const OptionDef options[] = {
     { "framedrop", OPT_BOOL | OPT_EXPERT, { &framedrop }, "drop frames when cpu is too slow", "" },
     { "infbuf", OPT_BOOL | OPT_EXPERT, { &infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" },
     { "window_title", OPT_STRING | HAS_ARG, { &window_title }, "set window title", "window title" },
+    { "window_host", OPT_INT | HAS_ARG, { &window_host_handle }, "set window host handle", "window handle" },
     { "left", OPT_INT | HAS_ARG | OPT_EXPERT, { &screen_left }, "set the x position for the left of the window", "x pos" },
     { "top", OPT_INT | HAS_ARG | OPT_EXPERT, { &screen_top }, "set the y position for the top of the window", "y pos" },
 #if CONFIG_AVFILTER
@@ -3727,7 +3729,14 @@ int main(int argc, char **argv)
             flags |= SDL_WINDOW_BORDERLESS;
         else
             flags |= SDL_WINDOW_RESIZABLE;
-        window = SDL_CreateWindow(program_name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, default_width, default_height, flags);
+
+        if (window_host_handle != 0) {
+          window = SDL_CreateWindowFrom(window_host_handle);
+          SDL_HideWindow(window);
+        } else {
+          window = SDL_CreateWindow(program_name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, default_width, default_height, flags);
+        }
+
         SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
         if (window) {
             renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值