[FFmpeg-trac] #9157(avformat:new): FFmpeg's “file:” is not the standard “file:”

FFmpeg trac at avcodec.org
Sun Mar 21 20:38:03 EET 2021


#9157: FFmpeg's “file:” is not the standard “file:”
--------------------------------------+----------------------------------
               Reporter:  Cigaes      |                  Owner:
                   Type:  defect      |                 Status:  new
               Priority:  minor       |              Component:  avformat
                Version:  git-master  |               Keywords:
             Blocked By:              |               Blocking:
Reproduced by developer:  0           |  Analyzed by developer:  1
--------------------------------------+----------------------------------
 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:”.

 2. For a reasonable time, warn users who write “file:” and not “fs:” that
 the behavior will change.

 3. 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.

 4. For a reasonable time, if “file:” is used without the double slash,
 keep it a synonym for “fs:”, but warn the user.

 5. Remove the compatibility fallback.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/9157>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list