FFmpeg如何使用bash生成一系列视频 [英] FFmpeg how generate a sequence of videos with bash

查看:118
本文介绍了FFmpeg如何使用bash生成一系列视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试编写一个.sh来读取一个文件夹,以创建mp4文件的播放列表,然后生成一个唯一的大视频,并在该文件夹中找到所有视频的序列,并将其编码为破折号:

i try to write an .sh that read a folder create a playlist of mp4 files and then generate an only big video with a sequence of all videos find in the folder, and encode it for dash:

printf "file '%s'\n" ./*.mp4 > playlist.sh
ffmpeg -f concat -safe 0 -i playlist.sh -c copy concat.mp4

直到现在,我仍然按照Demux Concat官方guido访问ffmpeg网站.没有结果,以下内容也会给我序列视频之间重复的1000帧以上"

Till now i follow the demux concat official guido to ffmpeg website. Without result, also the following give me "more than 1000 frames duplicated between videos of the sequence"

ffmpeg -f concat -i playlist.sh -c:a aac -b:a 384k -ar 48000 -ac 2 -c:v libx264 -x264opts 'keyint=50:min-keyint=50:no-scenecut' -r 25 -b:v 2400k -maxrate 2400k -bufsize 1200k -vf "scale=-1:432 " out.mp4

非常感谢

推荐答案

对不起,还不能发表评论...

Sry, cannot comment (yet)...

您的命令是正确的,我可以连接一些示例视频.您是否总是收到所提到的错误,还是其他错误?视频是否正常工作,或者没有创建视频?在大多数情况下,输入视频不正确.输入格式错误(不适合文件扩展名),或更糟糕的是,例如以错误的帧结尾.也许您可以提供视频?

Your commands are correct, I could just concat some sample videos. Do you always get the mentioned error, or also something else? And is the video working, or no video is created? In most cases, the input video is incorrect. Wrong input format (not fitting to file extension) or worse like ending at wrong frame. Perhaps you can make the video available?

PS:需要在第二个命令中添加 -safe 0 以避免错误 [concat @ 0x7fbfd1000000]不安全的文件名'./small.mp4'

PS: Needed to add -safe 0 to the second command to avoid error [concat @ 0x7fbfd1000000] Unsafe file name './small.mp4'

提示:不要将扩展名 .sh 用于视频文件列表.此扩展名用于Shell脚本,因此可能会造成混淆.只需使用 .txt .

Hint: Do not use file extension .sh for your list of video files. This extension is used for shell scripts, so it can be confusing. Just use .txt.

更新@Massimo Vantaggio

我们不应该创建新的答案,但是我无法评论您的答案,而且我也不知道如何继续我们的讨论,所以我编辑我的答案.

您的视频看起来并没有太大不同.看不到,第一个有什么问题.

Your videos don't look very different. Can't see, what's wrong with the first one.

也许您可以使用 ffprobe -report input.mp4 来获取更多信息.查找错误或警告.

Perhaps you could use ffprobe -report input.mp4 to get more informations. Look for errors or warnings.

我的假设仍然是视频(通过转换软件)被硬剪切,因此关键帧被弄乱了或其他.

My assumption is still that the video was cut in a hard way (by conversion software), so keyframes are messed up or something else.

您还可以尝试先使用ffmpeg重新编码视频.之后,它应该与ffmpeg完全兼容;)

You can also try to first reencode your video with ffmpeg. After that, it should be complete compatible with ffmpeg ;)

类似这样的东西:

ffmpeg -i small.mp4 -acodec aac -ab 192k -vcodec libx264 -vb 1024k -f mp4 output.mp4

使用输入视频中的 -ab -vb ,或至少使用输入中的比特率.质量会有所下降,文件大小会增加,但是应该可以.

Use -ab and -vb from your input video, or at least the bitrate from input. Quality will decrease a little bit and file size increase, but it should be okay.

这篇关于FFmpeg如何使用bash生成一系列视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆