nschlia / ffmpegfs

FUSE-based transcoding filesystem with video support from many formats to FLAC, MP4, TS, WebM, OGG, MP3, HLS, and others.
https://nschlia.github.io/ffmpegfs/
GNU General Public License v3.0
198 stars 14 forks source link

MOV support and copy mode #9

Closed mufunyo closed 5 years ago

mufunyo commented 6 years ago

Hi,

I hope I'm not too forward with this feature request. Since ffmpegfs currently outputs MP4, I don't think this would be too difficult to pull off, as MP4 and MOV are basically the same format.

A lot of editing software has very extensive QuickTime support but almost no AVI support and certainly no MKV support or other more obscure formats. I'd like to ask for a MOV mode where the filesystem is presented as virtual MOV files, with transcoding only enabled for those formats that can't be directly copied into MOV. For h.264 MP4 and MKV files for instance, transcoding is completely unnecessary as MOV supports wrapping h.264. For all other formats, it would be immensely powerful to use ffmpeg to transcode into ProRes as it is extremely fast and random-access.

Let me know what you think and thanks in advance.

nschlia commented 6 years ago

Good ideas:

Copy of streams is one of the features already on my list. MOV was not planned yet because I thought that MP4 would be enough. If there's a need for MOV target I could add it.

I also did not have the idea of confining the file set to those that do not need transcoding. Nice feature, too, but probably will slow down ffmegfs as it requires scanning every file to find out the codecs. But I suppose I need to try if its too slow or not.

I'll add to the TODO list:

"Do not need recode" is a little tricky, i.e., when transcoding from a transport stream (TS) this would be no problem if the source is H.264 and AAC, but sometimes it contains MPEG-2 or MP3 or incompatible derivates so at least partial recoding would be required. But I guess I could add an option to allow recode, partial recode or just stream copy.

I am not sure if MOV works at all because the format must be streamable. If MOV supports the necessary extensions it could be done. I can't promise that the format is possible but I'll give it at try.

mufunyo commented 6 years ago

Awesome that you think it's a good idea!

As far as I know MOV is a superset of MP4, so it should support streaming. When you export a MOV file from QuickTime Pro, you get the option to "Optimise for fast start" which I think is Apple-speak for a streamable file. FFmpeg source/docs should provide a decisive answer on the matter.

To clarify what would be most useful:

As an extra you could have different prores quality levels depending on the source pixformat, for instance ProRes 4:4:4 if the source is RGB and ProRes 4:2:2 if the source is YUV.

nschlia commented 6 years ago

I've added that to the TODO list. I cannot say when I will get to it and how long it will take. I usually need to dive quite deep into the target format to be able to adopt it to fast starting and live streaming.

nschlia commented 6 years ago

As a first step I added MOV and AIFF as target option. Both seem to work so far, but both need two passes (first copy creates an invalid file, when transcoding has finished a second copy operation gets a correct file).

Needs some efforts still but looks good so far :)

nschlia commented 5 years ago

Work on smart conversion now in progress.

mufunyo commented 5 years ago

Great news! I'm still monitoring this and look forward to testing soon.

nschlia commented 5 years ago

Great news! I'm still monitoring this and look forward to testing soon.

I'll soon have a new version ready for testing. It supports what I call "Smart Transcode", adaptive recoding of video/audio+video sources to MOV (or another video format) and audio only sources to AIFF (or another audio format). I would like to send you a test version before I push it to git. Please email me at nschlia@oblivion-software.de so I can send you a copy.

At the moment, potential video sources, e.g. MP4, will be recoded to MOV, even if they do actually not have a video stream. FLAC, WAV, MP3 will be recoded to AIFF, which is fine in any case.

Reason being that for performance reasons, I cannot scan all files when a directory is listed. Opening and scanning each file would take far too long. So the decision is made by the file extension - e.g. MP3 -> AIFF, MP4/MPG/AVI -> MOV.

The changes are quite extensive, I converted the whole project to C++ and recoded a lot of the procedural stuff to OOP. Most of the C code has been updated to C++ (e.g. std::string instead of char) to avoid memory leaks because of unmatched malloc/free pairs.

This makes an effective breeding ground for nice bugs, so I want to do some testing first before I push it to github.

nschlia commented 5 years ago

Additionally, my testing showed that it is actually necessary to properly detect audio files, e.g mp4 or ogg with audio streams only. This requires some changes in the processing order. I will do that later.

nschlia commented 5 years ago

Split the task into smaller ones, see #16, #17, #18, #19. Closing this one now.