<legend id='fEsgy'><style id='fEsgy'><dir id='fEsgy'><q id='fEsgy'></q></dir></style></legend>

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

      • <bdo id='fEsgy'></bdo><ul id='fEsgy'></ul>

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

        在php中使用ffmpeg为视频添加水印

        时间:2023-09-20

        <tfoot id='XTuxK'></tfoot>

          <bdo id='XTuxK'></bdo><ul id='XTuxK'></ul>

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

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

                  <tbody id='XTuxK'></tbody>
                1. 本文介绍了在php中使用ffmpeg为视频添加水印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我创建了一个包含一组图像和 mp3 的视频.但我想为该视频添加水印文本.我正在使用以下代码添加文本.

                  I created a video with group of images and mp3. But i want to add a watermark text to that video .i am using the below code to add the text.

                  exec('/usr/local/bin/ffmpeg -y -i output.mov -acodec libmp3lame -vcodec msmpeg4 
                  -b:a 192k -b:v 1000k -ar 44100 
                  -vf "drawtext=text=string1 string2 string3 string4 string5 string6 string7 :expansion=normal:fontfile=/usr/bin/DejaVuSerif-BoldItalic-webfont.ttf: y=0:x=h-(2*lh)-n: fontcolor=white: fontsize=40: box=1: boxcolor=0x00000000@1" 
                  -an IMG_0696.avi');
                  

                  这个问题是视频文件以零大小创建.任何人都可以帮助我.或者建议我任何其他命令来向视频添加水印文本.提前谢谢你...

                  The issue with this is that the video file is creating with zero size. Can any one help me please. Or else Suggest me any other command to add watermark text to video. Thank you in advance...

                  推荐答案

                  我正在使用 php-ffmpeg [Below : Composer Json]:

                  I am using php-ffmpeg [Below : Composer Json]:

                  {
                      "require": {
                          "php-ffmpeg/php-ffmpeg": "^0.6.1"
                      }
                  }
                  

                  并且使用这个 php-ffmpeg 库,您可以使用以下代码添加水印:

                  and Using this php-ffmpeg library you can add watermark's using the following codes:

                  <?php
                  
                  function processVideo($videoSource,$reqExtension, $watermark = "")
                  {
                      $ffmpeg = FFMpegFFMpeg::create();
                  
                      $video = $ffmpeg->open($videoSource);
                  
                      $format = new FFMpegFormatVideoX264('libmp3lame', 'libx264');
                  
                      if (!empty($watermark))
                      {
                          $video  ->filters()
                                  ->watermark($watermark, array(
                                      'position' => 'relative',
                                      'top' => 25,
                                      'right' => 50,
                                  ));
                      }
                  
                      $format
                      -> setKiloBitrate(1000)
                      -> setAudioChannels(2)
                      -> setAudioKiloBitrate(256);
                  
                      $randomFileName = rand().".$reqExtension";
                      $saveLocation = getcwd(). '/video/'.$randomFileName;
                      $video->save($format, $saveLocation);
                  
                      if (file_exists($saveLocation))
                          return "http://localhost/test/video/$randomFileName";
                      else
                          return "http://localhost/test/thumb/404.png";
                  
                  }
                  
                  echo $videoLocation =  processVideo("sample.mp4","mp4","favicon.png");
                  
                  ?>
                  

                  [请根据需要更新位置.]

                  [Please, update the location according to your need.]

                  这篇关于在php中使用ffmpeg为视频添加水印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:查询音频/视频文件的信息 下一篇:FFmpeg 可以连接来自不同域的文件吗?

                  相关文章

                  最新文章

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

                2. <small id='YnBDH'></small><noframes id='YnBDH'>

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