Last active
June 1, 2021 20:00
-
-
Save salman2learn/6e1c4e163fea0dde7283889df2068ec4 to your computer and use it in GitHub Desktop.
Split a large file into smaller files based on some delimiter text line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the text files were later used to convert into images via pango-view and later via ffmpeg to vid | |
text = [] | |
filenumber = 1 | |
with open('51D.log', 'r') as f: | |
for line in f: | |
if line.startswith("-----"): | |
if len(text) > 0: | |
with open('text' + str(filenumber).zfill(4), 'w') as out: | |
out.writelines(text) | |
filenumber = filenumber+1 | |
text = [] | |
text.append(line) | |
''' | |
Text to Image: | |
pango-view --font=mono -qo img.png text1.txt | |
ref: https://unix.stackexchange.com/a/599254 | |
Images to video: | |
ffmpeg -framerate 1 -i img%03d.png output.mp4 | |
ref: https://stackoverflow.com/a/53974101/2612429 | |
If images are of different sizes: | |
ffmpeg -i text%04d.png -vf "scale=w=1380:h=761:force_original_aspect_ratio=1,pad=1380:761:(ow-iw)/2:(oh-ih)/2" output2.mp4 | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment