ffmpeg 编码 bing 像视频预览
我想模仿 bing 视频预览功能,使用缩略图预览,然后在鼠标悬停时加载并播放视频文件。我计划使用 VideoJS (html5 + flash) 进行视频播放。我需要使用 ffmpeg 来生成这些视频文件。
如何使用 php + ffmpeg 命令行创建仅包含视频的 mp4 预览,其中包含整个剪辑每隔一分钟的 1 秒,并将分辨率缩小到固定宽度(保持纵横比,最好使用缩放裁剪)?
我假设它可以以某种方式沿着切割 1s 剪辑的方式完成,然后组合较小的剪辑,并重新编码以获得最终的重新缩放的输出。
*编辑:使用ffmpeg是设计要求。拉出 1s 剪辑应该相当容易,但是用 ffmpeg 将它们组合起来似乎有点复杂。我不需要循环缩略图,我想要包含许多 1 秒剪辑的视频预览。例如。运行时间(以秒为单位):100-101 和 200-201 组合在严重压缩的剪辑中。我要求提供一个命令行示例,说明如何有效地执行此操作。
I want to mimic the bing video preview functionality, with a thumbnail preview, then onMouseOver, load and play a video file. I plan to use VideoJS (html5 + flash) for the video playback. I need to use ffmpeg to produce these video files.
How can I create a mp4 preview with video only, which contains 1s of every other minute of the full clip, and shrink resolution to a fixed width (maintaining aspect ratio, preferably with zoom crop) using php + ffmpeg command line?
I'm assuming it can be done somehow along the lines of cutting 1s clips, then combine the smaller clips, and re-encode for a final rescaled output.
*Edit: Using ffmpeg is a design requirement. Pulling out 1s clips, should be fairly easy, but combining them seems to be somewhat complex with ffmpeg. I don't want cycling thumbnails, I want a video preview which contains a number of 1s clips. Eg. runtime in seconds: 100-101, and 200-201 combined in a heavily compressed clip. I am asking for a command line example of how to do this in an efficient manner.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Windows(或 wine)中执行此操作的一种方法是使用 Avisynth 脚本。这将允许您一步完成所有您想要的转换。自从我使用 Avisynth 以来已经有一段时间了,但一个非常简单的脚本可能看起来像这样:
这可以扩展以支持各种帧速率和宽高比,而不是对所有内容进行硬编码。生成的 .avs 文件可以用作 ffmpeg 的输入文件,前提是该文件已使用 --enable-avisynth 进行编译。
One way to do this in Windows (or wine) would be to use an Avisynth script. This would allow you to do all your desired transformations in one step. It's been a little while since I've used Avisynth but a very simple script might look like:
This could be extended to support various framerates and aspect ratios instead of hardcoding everything. The resulting .avs file can then be used as an input file to ffmpeg, provided that it has been compiled with --enable-avisynth.
我有一个方法,我认为这会起作用...
使用 ffmpeg 您可以按特定时间间隔获取视频的缩略图。
因此,我将在 2 秒的时间间隔内拍摄大约 5 到 10 个缩略图,并将它们存储在我的服务器上,并使用标识视频的唯一名称。
因此,当我将鼠标悬停在上面时,我会调用将按顺序加载这些图像的函数(这使用户感觉视频正在快进..)
但是在这种格式中,当我们将鼠标悬停在上面时我们无法播放声音..
我不这样做知道这是否好,但我知道这会起作用。
更新:
我认为最好使用提取的图像使用 ffmpeg 创建视频,并在鼠标悬停时播放它们。这将是比加载图像序列要快得多。 ffmpeg 可用于从图像列表创建新视频。
I've an approach and i think that will work...
Using ffmpeg you can get thumbnails of the video at specific intervals.
So i will take about 5 to 10 thumbnails in the interval of 2 seconds and store them on my server with a unique name that identifies the video.
So when I mouse over i call the function which will load these images sequentially(which makes the user feel the video is fast forwarding..)
But in this format, we can't play sound when we mouse over ..
I don't know whether this is good but i know this will work..
Update:
I think it will be better to create a video using ffmpeg using the extracted images and play them while we mouse over.. This will be quite faster than loading a sequence of images. ffmpeg can be used to create a new video from a list of images.
我现在设法做到了这一点,通过拉出 1s 剪辑,并将它们转换为 mpeg。然后将这些 mpeg 文件合并到一个文件中。然后将 mpeg 文件转换为 mp4
I managed to do this now, by pulling out 1s clips, and convert them to mpeg. Then combine these mpeg files, by appending them into a single file. Then convert til mpeg file to mp4