ffmpeg concat: “Unsafe file name”

牧云@^-^@ 提交于 2019-11-28 19:04:14
sers

The answer stated by @Mulvya (thank you!) works: "Add -safe 0 before -i". Then another problem appeared with find STREAM -name '*' -printf "file '$PWD/%p'\n" which returns the empty path as first entry. Changed this for for f in ./*.wav; do echo "file '$PWD/$f'"; done (see https://trac.ffmpeg.org/wiki/Concatenate) and now it seems to work. Hurray!

To answer why, from https://ffmpeg.org/ffmpeg-all.html#Options-35:

This demuxer accepts the following option:

safe If set to 1, reject unsafe file paths. A file path is considered safe if it does not contain a protocol specification and is relative and all components only contain characters from the portable character set (letters, digits, period, underscore and hyphen) and have no period at the beginning of a component.

If set to 0, any file name is accepted.

The default is 1.

-1 is equivalent to 1 if the format was automatically probed and 0 otherwise.

It turns out find . puts a ./ in front of the file. See How to strip leading "./" in unix "find"? for solutions if you don't want to use -safe 0.

About answer is totally right i just show you command so you don't put -safe 0 at anywhere else.

ffmpeg.exe -f concat -safe 0 -i "clips.txt" -c copy "video.mp4"

In my case, double quotes causes the error.

I use ffmpeg -f concat -i concat.txt -c copy output.m4a command, which the concat.txt contains list of input file to concat.

Unsafe file name (double quotes):

file "song1.m4a"
file "song2.m4a"

Safe file name (single quotes):

file 'song1.m4a'
file 'song2.m4a'

Safe file name (without quotes):

file song1.m4a
file song2.m4a

Note that single quotes and without quotes only works if no space('/' is fine), you still need -safe 0 if the filename/path contains space.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!