python - Assemble mpeg file unable to play in mediaplayer -
I am currently working on a school project and I think that is to gather some problems with the MPEG file I The scope of my project is:
1) Split the MPEG file into pieces of many fixed sizes.
2) Collecting some of them and leaving some part.
Problem 1:
When I run the file in the media player, it will play the video until it reaches that segment which I left Give it Example:
Chunk = ["yui_1", "yui_2", "yui_3", "yui_5", "yui_6"] Duration of each segment: 1 second < / Code> * If you think I have left the "yui_4" section. *
If I went to collect all the parts except "yui_4", then the video will play the first 2 seconds before being hanged throughout the period.
Problem 2: When I gather the first part off the part, it is unable to run the full MPEG file is. Duration of each piece: 1 second
Example:
wheel = ["yui_2", "yui_3", "yui_4", "yui_5", "yui_6" code>
Below is a part of my code (hardcod): def splitFile (inputFile, chunkSize): Splittext = string.split (filename, ". Open the contents of the file = F = Open (inputfile, 'rb') data = f.read () # of the file's name = spilix [0] extension = spiltex [1] OSCADDR (". /" + Media_dir) Read the full content f.close () # Get the length of the data, i.e. Byte Bytes = The size of the input file in the LAN (data) can be increased to # number of quantities noOfChunks = bytes / chunk if size (bytes% checksize): noOfChunks + = 1 # Metadata F = Open ('info.txt', 'W') to create an info.txt file for f.write (inputFile + ',' + (0, bytes + 1, chunk size) = 1] = '+' + '+', '+ Str (noOfChunks) + ',' + str (chunky)) f.close () chunk name = [] calculation = 1: fn1 = name + _% S "% count chunkname.ampaign (FN1) F = open (FN1 , 'Wiib') F. Litat (Data [I: I + Chuck Secure]) + = 1 F.Close () def (): data = ["yui_1", "yui_2", "yui_3", "yui_4" datafile In the "yui_5", "yui_6", "yui_7"] output = open ("output.mpeg", "wb") for the item: read data = open (this M, "RB"). ) Output.close ()
MPEG video files that have "encoded video data" Which means that it is compressed. The lower line is that the video can be cut in different parts or played separately is not trivial. Both of your problems will not be solved unless you carefully read MPEG2 transport stream explanations and understand that the point Where to remove, which you can cut and "buntu" and yet an obedient MPEG stream can output. My guess is that this is not what you want to do for a school project.
Perhaps you should try using FFMPEG () for cutting and applying video files.
> Best wishes on your project.
Comments
Post a Comment