GNOME Bugzilla – Bug 682172
qtdemux: avoid reading parts of file not used (skip reading video data if only audio is active)
Last modified: 2018-11-03 14:47:27 UTC
Currently Gstreamer will read all of a file from disk even if certain streams are not needed and could be skipped. This can be an issue when, for example, one wants to process only the audio stream from a file containing both audio and high-bitrate video, since performance will be bottlenecked by hard disk throughput. If elements like qtdemux could determine which streams aren't being used, avoid reading data for unused streams, and instead only read the index and the streams which are being used; this would hugely increase performance in those use cases. A good test uses footage from a Canon DSLR, which is commonly used for professional video. One 12 minute file is 4GB in size, of which less than 150MB is audio. The following pipeline takes approximately as long as simply reading the entire file from disk. (about 40 seconds *uncached* on a Sandybridge laptop using the file below) time gst-launch-1.0 filesrc location="$INPUT_FILE" ! qtdemux ! audioconvert ! filesink location="OUTPUT_FILE" When I profiled it, most time was spent in functions for reading from disk (kernel -> system_call_fastpath -> sys_read), with CPU usage remaining low. After extracting the audio only and placing it in another qt container, the time required was dramatically reduced. Example DLSR file can be found here (about 4GB). http://uds-o.novacut.com/GWQ5M6GPPNVEY3SAGUORKMLUAMQGD6O4.mov We should figure out a way to signal this behavior properly for elements like qtdemux.
An alternative solution for this would be to have mmap-ed GstMemory. If the memory is not used => not hit on harddrive.
Related to that is this bug btw https://bugzilla.gnome.org/show_bug.cgi?id=691299 (although slightly different)
No, that's not what this is about or how it should be done. Too specific, and the benefit is especially large when doing things over the network. This bug depends primarily on the stream activation API IMHO, so the demuxer can skip reading chunks for tracks that aren't active.
The problem is also having a system by which the demuxer can "reliably" know that some streams are not needed by downstream. The GST_EVENT_SELECT_STREAM *partially* solves this issue, but isn't enough to know that unselected streams will *never* be needed.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/71.