Can I delete both ends of a large file without copying?

I would like to know if it is possible, using Windows and C ++, to take a large video file (several gigabytes in length) and delete the first and last several hundred megabytes from it “in place”.

The traditional approach to copying useful data to a new file often takes 20 minutes of seemingly unnecessary copying.

Is there anything clever that can be done at a low level using a disk to make this happen?

+3
source share
5 answers

Of course, this is possible in theory. But if your file system is NTFS, be prepared to spend several months examining all the data structures that you will need to update. (All of them are officially undocumented by BTW.)

In addition, you will need

  • Somehow turn off the volume and make changes; or
  • Learn how to write a kernel file system driver, buy a license from MS, develop a driver and use it to make changes to a live file system.

It is a little easier if your file system is simpler than FAT32. But in any case: in short, it is possible, but even if it takes years from your life. My advice: do not worry.

: . avisynth script, .

+6

? , .

, , , , . , , , , , .

, , Windows .

+4

, "" , (, ) . , .

+2

, , NTFS.

, SetFileLength.

, . "" , .

, , , .

+2
source

Even if low-level file system operations were easy, editing a video file is not just deleting unnecessary megabytes. You still need to consider concepts such as compression, frames, audio and video multiplexing, multimedia file containers, and many others ...

The best solution is to simply take your downtime for twenty minutes.

+1
source

Source: https://habr.com/ru/post/1706278/


All Articles