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

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

    <tfoot id='DV8dk'></tfoot>
      1. <small id='DV8dk'></small><noframes id='DV8dk'>

        PHP 和 FFMPEG - 执行智能视频转换

        时间:2023-09-20
      2. <i id='STdiV'><tr id='STdiV'><dt id='STdiV'><q id='STdiV'><span id='STdiV'><b id='STdiV'><form id='STdiV'><ins id='STdiV'></ins><ul id='STdiV'></ul><sub id='STdiV'></sub></form><legend id='STdiV'></legend><bdo id='STdiV'><pre id='STdiV'><center id='STdiV'></center></pre></bdo></b><th id='STdiV'></th></span></q></dt></tr></i><div id='STdiV'><tfoot id='STdiV'></tfoot><dl id='STdiV'><fieldset id='STdiV'></fieldset></dl></div>

            <tfoot id='STdiV'></tfoot>
            <legend id='STdiV'><style id='STdiV'><dir id='STdiV'><q id='STdiV'></q></dir></style></legend>

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

                <tbody id='STdiV'></tbody>

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

                1. 本文介绍了PHP 和 FFMPEG - 执行智能视频转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一项异常艰巨的任务要执行.本以为很容易,结果一切努力都没有结果.

                  I have an oddly difficult task to perform. I thought it would be easy, but all my efforts have been fruitless.

                  我正在将上传到 php 脚本的各种格式(.avi、.mpg、.wmv、.mov 等)的视频转换为单一的 .flv 格式.转换效果很好,但我遇到的问题是视频的分辨率.

                  I'm converting videos uploaded to a php script from various formats (.avi, .mpg, .wmv, .mov, etc.) to a single .flv format. The conversion is working great but what I'm having trouble with is the resolution of the videos.

                  这是我当前正在运行的命令(使用 PHP 变量):

                  This is the command I'm currently running (with PHP vars):

                  ffmpeg -i $original -ab 96k -b 700k -ar 44100 -s 640x480 -acodec mp3 $converted

                  $original 和 $converted 都包含这些文件的完整路径.我的问题是,即使源较小,它也总是会转换为 640x480(就像我告诉它的那样).显然,这是在下载视频时浪费磁盘空间和带宽.此外,这不考虑输入视频的宽高比为 4:3 以外的任何情况,如果我上传 16:9 视频,则会导致压缩"转换.

                  Both $original and $converted contain the full paths to those files. My problem is that this always converts to 640x480 (like I'm telling it to) even when the source is smaller. Obviously, this is a waste of disk space and bandwidth when the video is downloaded. Also, this doesn't account for input videos being in any aspect ratio other than 4:3, resulting in a "squished" conversion if I upload a 16:9 video.

                  我需要做三件事:

                  1. 确定原始视频的纵横比.
                  2. 如果不是 4:3,用黑条填充顶部和底部.
                  3. 如果原件的尺寸较大或与原件的宽度/高度相关的宽高比为 4:3(以更接近 640x480 的为准),则转换为 640x480.

                  我已经在一些视频上运行了 ffmpeg -i,但我没有看到一致的格式或位置来查找原始分辨率.一旦我能够弄清楚这一点,我知道我可以做数学"来找出正确的尺寸并指定填充以使用 -padttop、-padbottom 等来固定纵横比.

                  I've run ffmpeg -i on a few videos, but I don't see a consistent format or location to find the original's resolution from. Once I'm able to figure that out, I know I can "do the math" to figure out the right size and specify padding to fix the aspect ratio with -padttop, -padbottom, etc.

                  推荐答案

                  这对我有用:

                  $data = 'ffmpeg output';
                  $matches = array();
                  
                  if (!preg_match('/Stream #(?:[0-9.]+)(?:.*): Video: (?P<videocodec>.*) (?P<width>[0-9]*)x(?P<height>[0-9]*)/',$data,$matches)
                     preg_match('/Could not find codec parameters (Video: (?P<videocodec>.*) (?P<width>[0-9]*)x(?P<height>[0-9]*))/',$data,$matches)
                  

                  这可能不总是有效,但它在大多数情况下都有效,这对我来说已经足够了:)

                  This might not always work, but it works most of the times, which was good enough in my case :)

                  这篇关于PHP 和 FFMPEG - 执行智能视频转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 PHP 和 ffmpeg 在后台转换视频 下一篇:如何在没有 $_SERVER['HTTPS'] 的情况下确定您

                  相关文章

                  最新文章

                2. <tfoot id='Gj54D'></tfoot>

                  <legend id='Gj54D'><style id='Gj54D'><dir id='Gj54D'><q id='Gj54D'></q></dir></style></legend>
                  1. <small id='Gj54D'></small><noframes id='Gj54D'>

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

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