I'm using FFMPEG to measure the duration of videos stored in an Amazon S3 Bucket.
I've read the FFMPEG docs, and they explicitly state that all whitespace and special characters need to be escaped, in order for FFMPEG to handle them properly:
See docs 2.1 and 2.1.1: https://ffmpeg.org/ffmpeg-utils.html
However, when dealing with files whose filenames contain whitespace, ffmpeg fails to render a result.
I've tried the following, with no success
ffmpeg -i "http://s3.mybucketname.com/videos/my\ video\ file.mov" 2>&1 | grep Duration | awk '{print $2}' | tr -d
ffmpeg -i "http://s3.mybucketname.com/videos/my video file.mov" 2>&1 | grep Duration | awk '{print $2}' | tr -d
ffmpeg -i "http://s3.mybucketname.com/videos/my'\' video'\' file.mov" 2>&1 | grep Duration | awk '{print $2}' | tr -d
ffmpeg -i "http://s3.mybucketname.com/videos/my\ video\ file.mov" 2>&1 | grep Duration | awk '{print $2}' | tr -d
However, if I strip out the whitespace in the filename – all is well, and the duration of the video is returned.
If you happen to have spaces in your file name, just quote them:
ffmpeg -i "my video file.mov"
In a URL, a space cannot be there. Most probably you have to replace every single space with a %20
, so that you get:
ffmpeg -i http://myurl.com/my%20video%20file.mov
^^^ ^^^
ffmpeg uses % to define a pattern and handle multiple files. For instance if your filename is URI encoded you must use "-pattern_type none" to avoid misinterpretation from ffmpeg:
ffmpeg -pattern_type none -i file%20name.mp4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With