0

import os

segmentbytes = 5242880
fullbytes = os.path.getsize("Wildlife.wmv")
numframe = fullbytes / segmentbytes
remainder = fullbytes % segmentbytes

parts = [open("Wildlife_Part%i.wmv" %i ,'wb') for i in range(numframe)]
with open("Wildlife.wmv",'rb') as f:

    segment = f.read(segmentbytes)


for j in range(numframe):
    parts[j].write(segment)
    f = open("Segment.txt", "wb")
    for i in range(numframe):
        f.write("Wildlife_Part%i.wmv" %i  + "\r\n")

for f in parts:

`    f.close()`

I am working on a project that enables file segmentation. The problem is that when the video get segment into parts, each and every parts shows the same output, when the output is suppose to be each part would show only 1 part of the video.

2
Contributors
2
Replies
29
Views
4 Years
Discussion Span
Last Post by pythonforlife
0
  • The line:
    segment = f.read(segmentbytes)

should be in the "for j in range(numframe)" loop.

  • Your numframe is not correct. Shoult be +1.

Edited by slate: number 2

0

It managed to segment the first part of the video out but after that for the next four parts it failed to segment and nothing appeared.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.