ffmpeg将文件转码后推向服务器,使用ffmpeg进行转换时覆盖文件出现问题(Issue with overwriting file while using ffmpeg for convertin...

使用ffmpeg进行转换时覆盖文件出现问题(Issue with overwriting file while using ffmpeg for converting)

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

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

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

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

要么

ffmpeg -i InpuFile -y -vcodec h264 -acodec aac -strict -2 InpuFile.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

or

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.

Any ideas?

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.

原文:https://stackoverflow.com/questions/28877049

更新时间:2019-11-04 23:14

最满意答案

我有这个相同的(令人沮丧的)问题,你可能已经注意到,这是因为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正在写它正在读取的文件,在进程完成之前你正在损坏源文件... 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, y

...

您只需暂停并恢复ffmpeg子进程本身。 主要问题是:没有SuspendProcess API函数。 并没有记录或安全的方式来做到这一点。 这样做的唯一简单方法是通过SuspendThread / ResumeThread。 请参阅有关如何执行此操作的codeproject上的这篇文章 。 All you need to do is suspend and resume the ffmpeg child process itself. The main problem is: there is n

...

看看下面 ffmpeg -i movie.mov -vcodec copy -acodec cop out.mp4

一定是 ffmpeg -i movie.mov -vcodec copy -acodec copy out.mp4

它看起来像一个拼写错误。 The command to just stream it to a new container (mp4) needed by some applications like premiere without encoding (fast)

...

你的命令揭示了这个 Option 'sameq' was removed. If you are looking for an option to preserve the

quality (which is not what -sameq was for), use -qscale 0 or an equivalent

quality factor option.

这对我有用 ffmpeg -i input.mp4 -vcodec flv -q:a 0 -q:v 0 -ar 22050 -f

...

没有x264支持 您的ffmpeg未编译为通过libx264支持编码:它在配置行中缺少--enable-gpl --enable-libx264 。 最简单的解决方法是下载已编译的ffmpeg二进制文件并将脚本指向它。 其他的东西 你的ffmpeg有--disable-yasm 。 这很糟糕,会让事情变得缓慢。 你的命令很乱,看起来像2006年的东西。你应该使用x264编码预设,而不是试图声明一大堆选项。 删除-refs , -coder , -sc_threshold , -flags +loo

...

一个接一个地处理文件,一个简单for做法是: for %%a in (*.wav) do (

echo processing %%a

REM your ffmpeg command; Input file will be: %%a

REM If you need some output file name: %%~na.mp3

)

看到for /? 求助。 to process files one after the other, a simple for will do: for

...

您可以尝试使用分段多路复用器输出,然后缝合各个分段。 第1步 : ffmpeg -i input.mkv -i logo.png -filter_complex "overlay=20:15,subtitles='sub.srt'"

-c:a copy -f segment -segment_time 600 out%d.ts

第2步 : 如果你有三个片段,它会是这样的 ffmpeg -i "concat:out1.ts|out2.ts|out3.ts" -c copy outpu

...

首先,我使用Swift 2和xCode 7.2 ...... 解决方案是将Context格式创建为“UnsafeMutablePointer ” ,然后通过avformat_open_input方法传递其地址。 这是适合我的代码: var formatContext = UnsafeMutablePointer()

if avformat_open_input(&formatContext, path, nil, nil) !=

...

首先,您应该将ffmpeg逻辑从控制器移动到服务。 使用新的“未转换”标记清除“上传”。 新服务应该通过传递的id(在刷新后生成)获得“上传”实体 然后你应该创建一个控制台命令来获取该服务并调用“转换”公共方法,并将传递的id作为param。 该服务将使您在控制器中具有相同的ffmpeg逻辑+更新“未转换”标志(如果您需要跟踪此状态,则为ofc) 您的控制器应该在后台调用新的控制台命令,有关详细信息,您可以在此答案中看到我的建议在Symfony2中异步调用命令 First you should t

...

您不能使用单一格式,特别是如果您希望在iOS上播放视频。 HLS 是一个很好的折衷方案,但你需要桌面浏览器上的播放器。 您可以找到像hls.js这样的HTML5 /媒体源扩展(MSE)解决方案 使用ffmpeg您可以生成HLS EVENT播放列表,类似于直播和VOD的组合:媒体段在转换时附加到播放列表,当输入结束时,它仍然可用作VOD。 它可以通过HTTP与任何Web服务器一起提供。 ffmpeg -i [...] -f hls -hls_playlist_type event /

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值