我正在使用 FFMPEG 将 .asf 流保存到 Ubuntu 计算机上的 mp4 中,输出文件名是时间戳。代码如下:
current_time=$(date "+%m/%d/%Y_%H:%M:%S")
ffmpeg -i http://username:password@IP:Port/videostream.asf -r 10 -vcodec copy -an -t 60 $current_time.mp4
但是,我收到“.mp4 没有此类文件或目录”错误。
最佳答案
bash
does not allow to you create file-names with/
presentAccording to POSIX "[t]he characters composing the [file] name may be selected from the set of all character values excluding the slash character and the null byte". In other words, every string between two slashes ([except the empty string]) is another directory, and you cannot create a file with a name containing slashes.
创建时不带斜杠,
ffmpeg -i http://username:password@IP:Port/videostream.asf -r 10 -vcodec copy -an -t 60 "${current_time//\//_}".mp4
(或)将时间字符串更改为在时间戳映射中不包含“/”,
current_time="$(date "+%m_%d_%Y_%H:%M:%S")"
ffmpeg -i http://username:password@IP:Port/videostream.asf -r 10 -vcodec copy -an -t 60 "${current_time}".mp4
关于 bash FFMPEG - ".mp4 no such file or directory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42061657/