• <tfoot id='Ooc2Y'></tfoot>
        <bdo id='Ooc2Y'></bdo><ul id='Ooc2Y'></ul>

      1. <small id='Ooc2Y'></small><noframes id='Ooc2Y'>

      2. <i id='Ooc2Y'><tr id='Ooc2Y'><dt id='Ooc2Y'><q id='Ooc2Y'><span id='Ooc2Y'><b id='Ooc2Y'><form id='Ooc2Y'><ins id='Ooc2Y'></ins><ul id='Ooc2Y'></ul><sub id='Ooc2Y'></sub></form><legend id='Ooc2Y'></legend><bdo id='Ooc2Y'><pre id='Ooc2Y'><center id='Ooc2Y'></center></pre></bdo></b><th id='Ooc2Y'></th></span></q></dt></tr></i><div id='Ooc2Y'><tfoot id='Ooc2Y'></tfoot><dl id='Ooc2Y'><fieldset id='Ooc2Y'></fieldset></dl></div>
      3. <legend id='Ooc2Y'><style id='Ooc2Y'><dir id='Ooc2Y'><q id='Ooc2Y'></q></dir></style></legend>

      4. FFMPEG :在视频上添加固定大小的图像,而不管视频

        时间:2023-09-20
        <legend id='JDKx1'><style id='JDKx1'><dir id='JDKx1'><q id='JDKx1'></q></dir></style></legend>
          <bdo id='JDKx1'></bdo><ul id='JDKx1'></ul>
            <tbody id='JDKx1'></tbody>

          <small id='JDKx1'></small><noframes id='JDKx1'>

          • <tfoot id='JDKx1'></tfoot>
            1. <i id='JDKx1'><tr id='JDKx1'><dt id='JDKx1'><q id='JDKx1'><span id='JDKx1'><b id='JDKx1'><form id='JDKx1'><ins id='JDKx1'></ins><ul id='JDKx1'></ul><sub id='JDKx1'></sub></form><legend id='JDKx1'></legend><bdo id='JDKx1'><pre id='JDKx1'><center id='JDKx1'></center></pre></bdo></b><th id='JDKx1'></th></span></q></dt></tr></i><div id='JDKx1'><tfoot id='JDKx1'></tfoot><dl id='JDKx1'><fieldset id='JDKx1'></fieldset></dl></div>

                  本文介绍了FFMPEG :在视频上添加固定大小的图像,而不管视频宽度&amp;高度(分辨率)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这是我通过 PHP 运行的向视频添加图像的代码:

                  exec('ffmpeg -i input.mp4 -i logo.png -filter_complex"[0:v][1:v] overlay=10:10" -pix_fmt yuv420p -c:a copy output.mp4');

                  它运行良好,但问题是,图像在视频分辨率上被缩小或放大.例如,在以下图像中,徽标宽度为 50px,但视频分辨率不同:

                  还有这个

                  如何防止图像缩小/放大?

                  <小时>

                  更新

                  感谢

                  还有这个

                  是否可以改进此解决方案?

                  解决方案

                  您可以使用 scale2ref 过滤器.

                  ffmpeg -i input.mp4 -i logo.png -filter_complex[1:v][0:v]scale2ref=(W/H)*ih/8/sar:ih/8[wm][base];[base][wm]overlay=10:10"-pix_fmt yuv420p -c:a copy output.mp4

                  这会将徽标的高度调整为视频高度的 1/8.

                  您必须将 W/H 替换为图像的值,例如如果 PNG 是 320x270,那么它应该是 scale2ref=(320/270)*ih/8:ih/8

                  This is my code that adds an image to videos, running via PHP:

                  exec('ffmpeg -i input.mp4 -i logo.png -filter_complex 
                  "[0:v][1:v] overlay=10:10"  -pix_fmt yuv420p -c:a copy output.mp4');
                  

                  It works well but the problem is, the image is scaled down or up, up on the video resolution. For example in the following images the logo width is 50px but videos resolution are different:

                  and this one

                  How can I prevent the image from scaling down/up ?


                  Update

                  Thanks to Mulvya, he proposed these codes

                  ffmpeg -i input.mp4 -i logo.png -filter_complex 
                  "[1:v][0:v]scale2ref=(W/H)*ih/8:ih/8[wm][base];[base][wm]overlay=10:10"
                  -pix_fmt yuv420p -c:a copy output.mp4
                  

                  and

                  ffmpeg -i input.mp4 -i logo.png -filter_complex 
                  "[1:v][0:v]scale2ref=(W/H)*ih/8:ih/8[wm][base];[wm]setsar=1[wmsar];
                  [base][wmsar]overlay=10:10"
                  -pix_fmt yuv420p -c:a copy output.mp4
                  

                  that works very well, but it doesn't keep the logo aspect ratio. I tried this code on two videos with different resolution and this is the result

                  and this one

                  Is it possible to improve this solution?

                  解决方案

                  You can use the scale2ref filter.

                  ffmpeg -i input.mp4 -i logo.png -filter_complex 
                  "[1:v][0:v]scale2ref=(W/H)*ih/8/sar:ih/8[wm][base];[base][wm]overlay=10:10"
                  -pix_fmt yuv420p -c:a copy output.mp4
                  

                  This will resize the logo's height to 1/8th of the height of the video.

                  You have to replace W/H with the values for the image e.g. if the PNG is 320x270, then it should be scale2ref=(320/270)*ih/8:ih/8

                  这篇关于FFMPEG :在视频上添加固定大小的图像,而不管视频宽度&amp;高度(分辨率)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:复制在 stackoverflow 上编写的步骤以在 wamp 上安装 下一篇:ffmpeg 从cropdetect 中获取值

                  相关文章

                  最新文章

                  <small id='j28DB'></small><noframes id='j28DB'>

                  <i id='j28DB'><tr id='j28DB'><dt id='j28DB'><q id='j28DB'><span id='j28DB'><b id='j28DB'><form id='j28DB'><ins id='j28DB'></ins><ul id='j28DB'></ul><sub id='j28DB'></sub></form><legend id='j28DB'></legend><bdo id='j28DB'><pre id='j28DB'><center id='j28DB'></center></pre></bdo></b><th id='j28DB'></th></span></q></dt></tr></i><div id='j28DB'><tfoot id='j28DB'></tfoot><dl id='j28DB'><fieldset id='j28DB'></fieldset></dl></div>
                • <legend id='j28DB'><style id='j28DB'><dir id='j28DB'><q id='j28DB'></q></dir></style></legend>

                      <tfoot id='j28DB'></tfoot>
                      • <bdo id='j28DB'></bdo><ul id='j28DB'></ul>