ffmpegfs is a file system based on FUSE, used to transcode video and audio instantly when opened

I recently stumbled upon ffmpegfs and found it very useful, so I wanted to publish an article on it, especially since there are no other articles about it.ffmpegfs It is a free and open source read-only transcoding file system based on FUSE, which can convert audio and video formats in real time when it is opened and read. It supports multiple formats, including MP4, WebM, OGG, MP3, OPUS, MOV, ProRes (MOV container for Apple Prores video and PCM audio), WAV, etc.
This is useful if you have many files in your media collection that cannot be played directly by some hardware or software (for example, DaVinci Resolve, which has limited codec support in the free Linux version)-not for the entire media collection Transcoding When accessing/playing files, you can use ffmpegfs to dynamically transcode them. You can also use this code to easily transcode files: just put some files into the folder used as the ffmpegfs input directory, then copy the files from the ffmpegfs output folder, and the resulting files will be transcoded for you The required format specifies ve for ffmpegfs.

ffmpegfs is written in C and C++ and uses the FUSE library. It also requires FFmpeg to work. Libav is also supported, but because it does not seem to work properly, it is currently disabled. Libav support may drop soon.
This is how this tool works. ffmpegfs command to mount a directory IN_DIR (Which contains your media collection) OUT_DIR. Accessing OUT_DIR Display content IN_DIR, All supported media files will be transparently renamed and transcoded into one of the supported target formats after being accessed.
ffmpegfs function:

  • Smart code conversion can create different output formats for video and audio files. For example, you can convert video files to MOV and audio files to AIFF. Specify the video and audio file types separated by a + sign (for example: --desttype=mov+aiff)
  • “Auto Copy” performs smart stream copying. For example, if you transcode a transport stream that already represents H264 video and/or AAC audio streams, you can simply repackage it into an mp4 container without re-encoding. Automatic copy options: OFF (do not copy the stream, always transcode), MATCH (if the target supports the codec, copy the stream), MATCHLIMIT (same as MATCH, only copy when the target is not large, otherwise transcode) , STRICT (if the codec matches the desired target, copy the stream, otherwise transcode) and STRICTLIMIT (same as STRICT, copy only when the target is not large, otherwise transcode)
  • Built-in transcoding profile, optimized for web browsers such as Firefox, MS Edge and IE 11+, Chrome, Safari, Opera or Maxthon
  • Specify video and audio bitrates, video width and height, de-interlace, enable album art to output files, etc.
  • Various options cache
  • DVD/Blu-ray support
  • Specify the number of transcoder threads

Microsoft Windows support is planned for future versions.
You may like other articles related to FFmpeg on Linux Uprising:

  • FFmpeg: How to crop video by example
  • FFmpeg: Extract audio from video in original format or convert it to MP3 or Ogg Vorbis
  • How to use youtube-dl (command line) to download YouTube playlists and convert them to MP3

Let’s look at some ffmpegfs examples. #1 Use ffmpegfs to come from ~/Videos Folder to ~/ffmpegfs Enter WebM (allow_other Allow all users (including root users) to access files; ro Install it as read-only):

ffmpegfs --desttype=webm ~/Videos/Movies ~/ffmpegfs -o allow_other,ro

By default, --desttype set as mp4.
caution allow_other By default, the FUSE option can only be used by the root user. You must run ffmpegfs as root user or better add user_allow_other to /etc/fuse.conf. #2 Use ffmpegfs to transcode all music files ~/Music Use ~/ffmpegfs As an output directory, to MP3 with an audio bit rate of 256K:

ffmpegfs --audiobitrate=256K --desttype=mp3 ~/Music ~/ffmpegfs2 -o allow_other,ro

#3 Transcode all video files from ~/media Copy MOV and all audio files from the same folder to AIFF ~/transcoded As the output folder, the log level is set to DEBUG (in debug mode, log messages are output to stderr by default), and the case is located in /tmp/cache:

ffmpegfs --desttype=mov+aiff --log_maxlevel=DEBUG --cachepath=/tmp/cache ~/media ~/transcoded

You can also mount the file system by /etc/fstab. For more information about using ffmpegfs, see its help (ffmpegfs --help) And the man page (man ffmpegfs). You can also visit Online documentation, But please note that some bits are outdated.

Install ffmpegfs

For most Linux distributions, ffmpegfs is not available in the official repository. Debian recently added ffmpegfs to the Bullseye and Sid repositories, so the package is now also available in the Ubuntu 20.04 repositories and Linux distributions based on the package, such as Pop! _OS 20.04. Install them in the following Linux distributions from the repository:

sudo apt install ffmpegfs

For Arch Linux and Manjaro, you can get ffmpegfs from the following URL: Arch user repository (AUR), you can get the latest stable version or the latest code from Git.
On other Linux distributions, you need to install it from source. See Official installation instructions For more information.