使用ffmpeg进行转换时覆盖文件的问题 [英] Issue with overwriting file while using ffmpeg for converting

查看:472
本文介绍了使用ffmpeg进行转换时覆盖文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ffpmeg将所有视频转换为mp4:

I'm using ffpmeg to convert all my videos to mp4:

 ffmpeg -i InpuFile -vcodec h264 -acodec aac -strict -2 OutputFile.mp4

问题是,如果我要覆盖输入文件,即输出和输入文件相同:

The problem is, if I'm overwriting the input file, i.e the output and input files are the same:

 ffmpeg -i InpuFile -vcodec h264 -acodec aac -strict -2 InpuFile.mp4 -y

 ffmpeg -i InpuFile -y -vcodec h264 -acodec aac -strict -2 InpuFile.mp4

新文件不好.他持续一秒钟,他的身材非常小.

the new file is not good. He lasts one second and his size is extremely small.

有什么想法吗?

我想将此代码用作服务器中的脚本,因此覆盖是对我来说最方便的方法,我更喜欢这种方法,而不是创建临时文件,然后用原始文件替换临时文件.

I want to use this as a script in my server so the overwriting is the most convinient way for me, I prefer that way instead of creating temporary files then replacting the temporary with original.

推荐答案

我遇到了同样的问题(令人沮丧),您可能已经注意到,这是因为ffmpeg正在覆盖正在读取的文件,您在破坏源之前过程完成... ffmpeg不会将文件放在某个缓冲区中,所以您不能这样做,您将不得不使用一个临时文件.

I had this same (frustrating) problem, you may have noticed that this happens because ffmpeg is writing over the file that it's reading, you are corrupting the source before the process finish... ffmpeg doesn't put the file in some buffer, so you can't do this way, you will have to use a temporary file.

以防万一

这篇关于使用ffmpeg进行转换时覆盖文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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