Skip to content

Commit 977a59a

Browse files
Merge pull request HarshCasper#2 from HarshCasper/master
Getting changes from master of Harsh
2 parents d648a9e + ebdce7e commit 977a59a

File tree

12 files changed

+134
-20
lines changed

12 files changed

+134
-20
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@
209209
"code",
210210
"doc"
211211
]
212+
},
213+
{
214+
"login": "avishmehta68710",
215+
"name": "avish mehta",
216+
"avatar_url": "https://avatars0.githubusercontent.com/u/69706506?v=4",
217+
"profile": "https://github.com/avishmehta68710",
218+
"contributions": [
219+
"code"
220+
]
212221
}
213222
],
214223
"contributorsPerLine": 7,

Frames_to_Video_converter/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Convert Frames to Video
2+
3+
This python script will convert all the frames from a folder into a video. This is accomplished using OpenCV, a highly optimized library for computer vision applications. Specifically, we use the VideoWriter function to combine images(in a particular fps) and obtain a video.
4+
5+
## Setting up:
6+
7+
- Create a virtual environment and activate it
8+
9+
- Install the requirements
10+
``` sh
11+
$ pip install opencv-python
12+
```
13+
14+
## Running the script:
15+
``` sh
16+
$ python frames_to_vid.py [image_folder_path] #without the brackets
17+
```
18+
The script will ask you for the needed 'fps' and a video name.
19+
## Note:
20+
21+
The images in the folder should be numbered in the order in which they appear in the video.
22+
23+
![Pendulum frames images](frames.JPG)
24+
25+
After running the script, the video will be created in the directory where the script is running.
26+
27+
![frames_video](frames.gif)

Frames_to_Video_converter/frames.JPG

135 KB
Loading

Frames_to_Video_converter/frames.gif

1 MB
Loading
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import os
2+
import sys
3+
import cv2
4+
5+
# We store all the images in the folder into a variable(here images).
6+
# Then get the height, and width required for the frames from any image
7+
# Use VideoWriter function to initialize a video variable. The four arguments
8+
# in VideoWriter is the video file name, fourcc code, fps and dimensions
9+
# video.write() writes all the images into the video.
10+
def convert_frames_to_video(img_folder_path, fps):
11+
images = [img for img in os.listdir(img_folder_path)]
12+
frame = cv2.imread(os.path.join(img_folder_path, images[0]))
13+
height, width, layers = frame.shape
14+
15+
video_name = input('Enter the video name(just the filename): ')
16+
if not video_name.endswith('.avi'):
17+
video_name = video_name + '.avi'
18+
video = cv2.VideoWriter(video_name, 0, fps, (width, height)) #fourcc code = 0 gives no warning with files other than .avi
19+
20+
for image in images:
21+
video.write(cv2.imread(os.path.join(img_folder_path, image)))
22+
23+
cv2.destroyAllWindows()
24+
video.release()
25+
26+
if __name__ == "__main__":
27+
if len(sys.argv)>1:
28+
img_folder_path = str(" ".join(sys.argv[1:]))
29+
fps = int(input('Enter the fps needed: '))
30+
convert_frames_to_video(img_folder_path, fps)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Rotten Scripts
22

33
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4-
[![All Contributors](https://img.shields.io/badge/all_contributors-20-orange.svg?style=flat-square)](#contributors-)
4+
[![All Contributors](https://img.shields.io/badge/all_contributors-21-orange.svg?style=flat-square)](#contributors-)
55
<!-- ALL-CONTRIBUTORS-BADGE:END -->
66

77
[![forthebadge](https://forthebadge.com/images/badges/built-by-developers.svg)](https://forthebadge.com)
@@ -90,6 +90,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
9090
<td align="center"><a href="http://avinashkranjan.github.io"><img src="https://avatars2.githubusercontent.com/u/55796944?v=4" width="100px;" alt=""/><br /><sub><b>Avinash Kr. Ranjan</b></sub></a><br /><a href="https://github.com/HarshCasper/Rotten-Scripts/commits?author=avinashkranjan" title="Documentation">📖</a> <a href="https://github.com/HarshCasper/Rotten-Scripts/commits?author=avinashkranjan" title="Code">💻</a></td>
9191
<td align="center"><a href="https://www.kaustubhgupta.xyz/"><img src="https://avatars3.githubusercontent.com/u/43691873?v=4" width="100px;" alt=""/><br /><sub><b>Kaustubh </b></sub></a><br /><a href="https://github.com/HarshCasper/Rotten-Scripts/commits?author=kaustubhgupta" title="Code">💻</a> <a href="https://github.com/HarshCasper/Rotten-Scripts/commits?author=kaustubhgupta" title="Documentation">📖</a></td>
9292
<td align="center"><a href="http://www.linkedin.com/in/aditya-jetely"><img src="https://avatars3.githubusercontent.com/u/42397096?v=4" width="100px;" alt=""/><br /><sub><b>Aditya Jetely</b></sub></a><br /><a href="https://github.com/HarshCasper/Rotten-Scripts/commits?author=AdityaJ7" title="Code">💻</a> <a href="https://github.com/HarshCasper/Rotten-Scripts/commits?author=AdityaJ7" title="Documentation">📖</a></td>
93+
<td align="center"><a href="https://github.com/avishmehta68710"><img src="https://avatars0.githubusercontent.com/u/69706506?v=4" width="100px;" alt=""/><br /><sub><b>avish mehta</b></sub></a><br /><a href="https://github.com/HarshCasper/Rotten-Scripts/commits?author=avishmehta68710" title="Code">💻</a></td>
9394
</tr>
9495
</table>
9596

Test-Typing-Speed/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
s = "this is a simple paragraph that is meant to be nice and" \
88
" easy to type which is why there will be no commas no periods " \
99
"or any capital letters so i guess this means that it cannot really " \
10-
"be considered a paragraph but just a series of sentences
11-
"
10+
"be considered a paragraph but just a series of sentences"
1211

1312
words = (len(s.split()))
1413

@@ -27,7 +26,8 @@
2726
total = round(end - start, 2)
2827
print("\nVoila you typed that correctly")
2928
print("Your time was %s seconds" % total)
30-
total = int(total) / 60 print("Speed was %s wpm" % (str(words // total)))
29+
total = int(total) / 60
30+
print("Speed was %s wpm" % (str(words // total)))
3131

3232
else:
3333
print("\nWrongly entered")

Times of India/toi.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,40 @@
44
sock=urllib.urlopen("http://timesofindia.indiatimes.com/")
55
htmlSrc=sock.read()
66
soup=BeautifulSoup(htmlSrc)
7-
print "The Times of India\n"
7+
print("The Times of India\n")
88
today = datetime.date.today()
9-
print today.strftime('The date %d, %b %Y')
10-
print "\t\t****Flash news****"
9+
print(today.strftime('The date %d, %b %Y'))
10+
print("\t\t****Flash news****")
1111
for div in soup.findAll('div', attrs={'id':'featuredstory'}):
1212

1313
#for data in div.findNextSibling('div', attrs={'class':'data'}):
1414
for a in div.findAll('a'):
15-
print a.text
16-
print "\n"
17-
print "\t\t**** News in Bulletin ****"
18-
print "\n"
15+
print(a.text)
16+
print("\n")
17+
print("\t\t**** News in Bulletin ****")
18+
print("\n")
1919

2020
for div in soup.findAll('div', attrs={'class':'top-story'}):
2121
for a in div.findAll('a'):
22-
print a.text
22+
print (a.text)
2323

2424

25-
print "\n"
26-
print "\t\t**** Entertainment ****\t"
27-
print "\n"
25+
print("\n")
26+
print("\t\t**** Entertainment ****\t")
27+
print("\n")
2828

2929

3030
for div in soup.findAll('div', attrs={'class':'entrmnt-wdgt-outer'}):
3131
#for data in div.findNextSibling('div', attrs={'class':'data'}):
3232
for a in div.findAll('a'):
33-
print a.text
33+
print(a.text)
3434

3535

36-
print "\n"
37-
print "\t\t**** Latest News ****\t"
38-
print "\n"
36+
print("\n")
37+
print("\t\t**** Latest News ****\t")
38+
print("\n")
3939

4040
for div in soup.findAll('div', attrs={'id':'lateststories'}):
4141
#for data in div.findNextSibling('div', attrs={'class':'data'}):
4242
for a in div.findAll('a'):
43-
print a.text
43+
print(a.text)

Video-to-Frames/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# testing video
2+
video.mp4
3+
4+
# vscode
5+
.vscode

Video-to-Frames/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Video to Frames
2+
This is a basic script written in Python which converts the video file into images frame by frame.
3+
4+
# How to use?
5+
Just type:
6+
7+
```python app.py file-location```
8+
9+
Example 1: When file is located in the same directory as of the scrpit.
10+
11+
```python app.py video.mp4```
12+
13+
Example 2: When file is located in another location.
14+
15+
```python app.py D:\Projects\Contributor's Hack\Rotten-Scripts\Video-to-Frames\video.mp4```
16+
17+
# Requirements
18+
Before running the script, just install open-cv for python using this command:
19+
20+
```pip install opencv-python```
21+
22+
# Working Demo
23+
24+
![](preview.gif)
25+

0 commit comments

Comments
 (0)