Opened 8 months ago

#9157 new defect

FFmpeg's “file:” is not the standard “file:”

Reported by: Nicolas George Owned by:
Priority: minor Component: avformat
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: yes

Description

If I have a file with special characters in its name, for example /tmp/Mona Lisa.jpg, I can open it in a web browser as file:///tmp/Mona%20Lisa.jpg. This is standard.

Unfortunately, FFmpeg does not obey that standard:

$ ffprobe file:///tmp/Mona%20Lisa.jpg
ffprobe version git-2021-01-12-ca21cb1 Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-3)
  configuration: --prefix=/opt/ffmpeg-20210112 --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-pthreads --enable-libfreetype --enable-fontconfig --enable-libass --enable-gnutls --enable-librtmp --enable-libxcb --enable-libmp3lame --enable-libvorbis --enable-libspeex --enable-libcelt --enable-libopus --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libfdk-aac --enable-libx264 --enable-libxvid --enable-libtheora --enable-libvpx --enable-libopenjpeg --enable-frei0r --enable-libflite --enable-libmodplug --enable-libzmq --enable-ladspa --enable-libssh --enable-libzvbi --enable-libgme --enable-libwebp --enable-libx265 --enable-opengl --enable-librubberband --enable-libxml2
  libavutil      56. 63.100 / 56. 63.100
  libavcodec     58.116.100 / 58.116.100
  libavformat    58. 65.101 / 58. 65.101
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7. 95.100 /  7. 95.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
file:///tmp/Mona%20Lisa.jpg: No such file or directory

That's because FFmpeg's “file:” is not standard, it uses raw filenames without URL percent escaping:

$ ffprobe file:'/tmp/Mona Lisa.jpg'  
ffprobe version git-2021-01-12-ca21cb1 Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-3)
  configuration: --prefix=/opt/ffmpeg-20210112 --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-pthreads --enable-libfreetype --enable-fontconfig --enable-libass --enable-gnutls --enable-librtmp --enable-libxcb --enable-libmp3lame --enable-libvorbis --enable-libspeex --enable-libcelt --enable-libopus --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-libfdk-aac --enable-libx264 --enable-libxvid --enable-libtheora --enable-libvpx --enable-libopenjpeg --enable-frei0r --enable-libflite --enable-libmodplug --enable-libzmq --enable-ladspa --enable-libssh --enable-libzvbi --enable-libgme --enable-libwebp --enable-libx265 --enable-opengl --enable-librubberband --enable-libxml2
  libavutil      56. 63.100 / 56. 63.100
  libavcodec     58.116.100 / 58.116.100
  libavformat    58. 65.101 / 58. 65.101
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7. 95.100 /  7. 95.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, image2, from 'file:/tmp/Mona Lisa.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 18862094 kb/s
    Stream #0:0: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 7479x11146, 25 fps, 25 tbr, 25 tbn, 25 tbc

To fix this, I propose the following steps:

  1. Introduce “fs:” as a synonym for “file:”.
  1. For a reasonable time, warn users who write “file:” and not “fs:” that the behavior will change.
  1. Change “file:” (but not “fs:”; they cease to be synonyms) to handle “file://” in a standard-compliant way. It includes ignoring the host, query and fragment part of the URL and de-escaping.
  1. For a reasonable time, if “file:” is used without the double slash, keep it a synonym for “fs:”, but warn the user.
  1. Remove the compatibility fallback.

Change History (0)

Note: See TracTickets for help on using tickets.