ffmpeg not working with filenames that have whitespace
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
To make ffmeg works with filename/path that have whitespaces, you should:
1) set the working directory with Pushd
2) put your filename inside quote ""
here is a working example:
cls
REM ++++++++++++++++++++++++++
REM Cut an audio file by right-cliking it (works also on multiple selected audio)
REM 1) save this file
REM 2) open registry, browse to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\audio\shell. On the left panel, right-click on "shell" and select "New", then "Key". Type "Cut audio 5min". Right click on the newly created folder "Cut audio 5min" and select again "New" and then "Key". Type “command”. On the right pane, double-click the "(default)" value name and type the following: "C:\Users\Me\Cut audio.cmd" "%1"
REM optional: if you want an Icon : in the left pane, right click "Cut audio 5min", and select String value, then in the right pane, rename the new value to Icon, then double click on it and past this "%SystemRoot%\\System32\\shell32.dll,186" (; list icon: https://diymediahome.org/windows-icons-reference-list-with-details-locations-images/ )
REM 3) right click an audio file and select "Cut audio 5min": the chunks will be created in the same folder.
REM because ffmpeg has trouble with path/filename with space, we set the working directory to the folder of the audio file and the we run the command not on a full path but just on the filename, with "" around it
REM get https://stackoverflow.com/a/15568171/3154274
REM fullpath of rightclicked file %1
REM full path (letter drive + path ithout letter drive) %~d1%~p1
REM filename (filename + extension) %~n1%~x1
REM https://windowsloop.com/split-mp3-files-with-ffmpeg/
REM ffmpeg -i "input_audio_file.mp3" -f segment -segment_time 300 -c copy output_audio_file_%%03d.mp3
REM 300= 5min chunk
REM ++++++++++++++++++++++++++
REM set working directory
Pushd %~d1%~p1
REM to let the windows open cmd /k ffmpeg -i "%~n1%~x1" -f segment -segment_time 300 -c copy "%~n1"_%%03d.mp3
cmd /k ffmpeg -i "%~n1%~x1" -f segment -segment_time 300 -c copy "%~n1"_%%03d.mp3
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
^^^ ^^^