Skip to content

Commit b59a978

Browse files
add logging
1 parent 9fa6c94 commit b59a978

15 files changed

Lines changed: 53 additions & 74 deletions

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,13 @@ See **[HLS examples](https://github.com/aminyazdanpanah/python-ffmpeg-video-stre
165165
You can get realtime information about transcoding by passing a callable method to the `package` method:
166166
```python
167167
import sys
168-
import time
169-
import logging
170168

171169
import ffmpeg_streaming
172170

173171

174-
start_time = time.time()
175-
logging.basicConfig(filename='Transcoding-' + str(start_time) + '.log', level=logging.DEBUG)
176-
177172
def progress(percentage, ffmpeg):
178173
# You can update a field in your database
179174
# You can also create a socket connection and show a progress bar to users
180-
logging.debug(ffmpeg)
181175
sys.stdout.write("\rTranscoding...(%s%%)[%s%s]" % (percentage, '#' * percentage, '-' * (100 - percentage)))
182176
sys.stdout.flush()
183177

@@ -220,7 +214,7 @@ It can also be null. The default path to save files is the input path.
220214
**NOTE:** If you open a file from a cloud and do not pass a path to save the file to your local machine, you will have to pass a local path to the `package` method.
221215

222216
#### 2. To Clouds
223-
You can save your files to a cloud by passing an array of cloud configuration to the `package` method.
217+
You can save your files to clouds by passing an array of clouds configuration to the `package` method.
224218

225219
In **[this page](https://video.aminyazdanpanah.com/python/start/clouds?r=save)**, you will find some examples of saving files to **[Amazon S3](https://aws.amazon.com/s3)**, **[Google Cloud Storage](https://console.cloud.google.com/storage)**, **[Microsoft Azure Storage](https://azure.microsoft.com/en-us/features/storage-explorer/)**, and a custom cloud.
226220

examples/clouds/aws_cloud.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def aws_cloud(bucket_name, key):
7777
return from_aws_cloud, to_aws_cloud
7878

7979

80+
logging.basicConfig(filename='streaming.log', level=logging.NOTSET, format='[%(asctime)s] %(levelname)s: %(message)s')
8081
start_time = time.time()
81-
logging.basicConfig(filename='Transcoding-' + str(start_time) + '.log', level=logging.DEBUG)
8282

8383

8484
def per_to_time_left(percentage):
@@ -93,9 +93,9 @@ def per_to_time_left(percentage):
9393

9494

9595
def transcode_progress(per, ffmpeg):
96-
# You can update a field in your database or can log it to a file
96+
# You can update a field in your database or log it to a file
9797
# You can also create a socket connection and show a progress bar to users
98-
logging.debug(ffmpeg)
98+
logging.info(ffmpeg)
9999
sys.stdout.write("\rTranscoding...(%s%%) %s [%s%s]" % (per, per_to_time_left(per), '#' * per, '-' * (100 - per)))
100100
sys.stdout.flush()
101101

examples/clouds/azure_cloud.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def azure_cloud(container, blob):
6666
return from_azure_cloud, to_azure_cloud
6767

6868

69+
logging.basicConfig(filename='streaming.log', level=logging.NOTSET, format='[%(asctime)s] %(levelname)s: %(message)s')
6970
start_time = time.time()
70-
logging.basicConfig(filename='Transcoding-' + str(start_time) + '.log', level=logging.DEBUG)
7171

7272

7373
def per_to_time_left(percentage):
@@ -82,9 +82,9 @@ def per_to_time_left(percentage):
8282

8383

8484
def transcode_progress(per, ffmpeg):
85-
# You can update a field in your database or can log it to a file
85+
# You can update a field in your database or log it to a file
8686
# You can also create a socket connection and show a progress bar to users
87-
logging.debug(ffmpeg)
87+
logging.info(ffmpeg)
8888
sys.stdout.write("\rTranscoding...(%s%%) %s [%s%s]" % (per, per_to_time_left(per), '#' * per, '-' * (100 - per)))
8989
sys.stdout.flush()
9090

examples/clouds/cloud.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ def cloud():
109109
return from_cloud, to_cloud
110110

111111

112+
logging.basicConfig(filename='streaming.log', level=logging.NOTSET, format='[%(asctime)s] %(levelname)s: %(message)s')
112113
start_time = time.time()
113-
logging.basicConfig(filename='Transcoding-' + str(start_time) + '.log', level=logging.DEBUG)
114114

115115

116116
def per_to_time_left(percentage):
@@ -125,9 +125,9 @@ def per_to_time_left(percentage):
125125

126126

127127
def transcode_progress(per, ffmpeg):
128-
# You can update a field in your database or can log it to a file
128+
# You can update a field in your database or log it to a file
129129
# You can also create a socket connection and show a progress bar to users
130-
logging.debug(ffmpeg)
130+
logging.info(ffmpeg)
131131
sys.stdout.write("\rTranscoding...(%s%%) %s [%s%s]" % (per, per_to_time_left(per), '#' * per, '-' * (100 - per)))
132132
sys.stdout.flush()
133133

examples/clouds/custom_cloud.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def custom_cloud():
4646
return from_custom_cloud, to_custom_cloud
4747

4848

49+
logging.basicConfig(filename='streaming.log', level=logging.NOTSET, format='[%(asctime)s] %(levelname)s: %(message)s')
4950
start_time = time.time()
50-
logging.basicConfig(filename='Transcoding-' + str(start_time) + '.log', level=logging.DEBUG)
5151

5252

5353
def per_to_time_left(percentage):
@@ -62,9 +62,9 @@ def per_to_time_left(percentage):
6262

6363

6464
def transcode_progress(per, ffmpeg):
65-
# You can update a field in your database or can log it to a file
65+
# You can update a field in your database or log it to a file
6666
# You can also create a socket connection and show a progress bar to users
67-
logging.debug(ffmpeg)
67+
logging.info(ffmpeg)
6868
sys.stdout.write("\rTranscoding...(%s%%) %s [%s%s]" % (per, per_to_time_left(per), '#' * per, '-' * (100 - per)))
6969
sys.stdout.flush()
7070

examples/clouds/google_cloud.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def google_cloud(bucket_name, object_name):
6969
return from_google_cloud, to_google_cloud
7070

7171

72+
logging.basicConfig(filename='streaming.log', level=logging.NOTSET, format='[%(asctime)s] %(levelname)s: %(message)s')
7273
start_time = time.time()
73-
logging.basicConfig(filename='Transcoding-' + str(start_time) + '.log', level=logging.DEBUG)
7474

7575

7676
def per_to_time_left(percentage):
@@ -85,9 +85,9 @@ def per_to_time_left(percentage):
8585

8686

8787
def transcode_progress(per, ffmpeg):
88-
# You can update a field in your database or can log it to a file
88+
# You can update a field in your database or log it to a file
8989
# You can also create a socket connection and show a progress bar to users
90-
logging.debug(ffmpeg)
90+
logging.info(ffmpeg)
9191
sys.stdout.write("\rTranscoding...(%s%%) %s [%s%s]" % (per, per_to_time_left(per), '#' * per, '-' * (100 - per)))
9292
sys.stdout.flush()
9393

examples/clouds/multiple_clouds.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
from examples.clouds.google_cloud import google_cloud
2222

2323

24+
logging.basicConfig(filename='streaming.log', level=logging.NOTSET, format='[%(asctime)s] %(levelname)s: %(message)s')
2425
start_time = time.time()
25-
logging.basicConfig(filename='Transcoding-' + str(start_time) + '.log', level=logging.DEBUG)
2626

2727

2828
def per_to_time_left(percentage):
@@ -37,13 +37,12 @@ def per_to_time_left(percentage):
3737

3838

3939
def transcode_progress(per, ffmpeg):
40-
# You can update a field in your database or can log it to a file
40+
# You can update a field in your database or log it to a file
4141
# You can also create a socket connection and show a progress bar to users
42-
logging.debug(ffmpeg)
42+
logging.info(ffmpeg)
4343
sys.stdout.write("\rTranscoding...(%s%%) %s [%s%s]" % (per, per_to_time_left(per), '#' * per, '-' * (100 - per)))
4444
sys.stdout.flush()
4545

46-
4746
def main():
4847
from_aws_cloud, to_aws_cloud = aws_cloud('bucket_name', 'key')
4948
from_azure_cloud, to_azure_cloud = azure_cloud('container', 'blob')

examples/dash/dash.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import ffmpeg_streaming
2121

2222

23+
logging.basicConfig(filename='streaming.log', level=logging.NOTSET, format='[%(asctime)s] %(levelname)s: %(message)s')
2324
start_time = time.time()
24-
logging.basicConfig(filename='Transcoding-' + str(start_time) + '.log', level=logging.DEBUG)
2525

2626

2727
def per_to_time_left(percentage):
@@ -36,9 +36,9 @@ def per_to_time_left(percentage):
3636

3737

3838
def transcode_progress(per, ffmpeg):
39-
# You can update a field in your database or can log it to a file
39+
# You can update a field in your database or log it to a file
4040
# You can also create a socket connection and show a progress bar to users
41-
logging.debug(ffmpeg)
41+
logging.info(ffmpeg)
4242
sys.stdout.write("\rTranscoding...(%s%%) %s [%s%s]" % (per, per_to_time_left(per), '#' * per, '-' * (100 - per)))
4343
sys.stdout.flush()
4444

@@ -51,9 +51,6 @@ def main():
5151

5252
args = parser.parse_args()
5353

54-
logging.debug("input: " + args.input
55-
+ ", output: " + str(args.output)
56-
+ ", datetime: " + str(datetime.datetime.now()))
5754
(
5855
ffmpeg_streaming
5956
.dash(args.input, adaption='"id=0,streams=v id=1,streams=a"')

examples/dash/dash_manual.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121

2222
from ffmpeg_streaming import Representation
2323

24-
start_time = time.time()
25-
logging.basicConfig(filename='Transcoding-' + str(start_time) + '.log', level=logging.DEBUG)
26-
27-
24+
logging.basicConfig(filename='streaming.log', level=logging.NOTSET, format='[%(asctime)s] %(levelname)s: %(message)s')
2825
start_time = time.time()
2926

3027

@@ -40,9 +37,9 @@ def per_to_time_left(percentage):
4037

4138

4239
def transcode_progress(per, ffmpeg):
43-
# You can update a field in your database or can log it to a file
40+
# You can update a field in your database or log it to a file
4441
# You can also create a socket connection and show a progress bar to users
45-
logging.debug(ffmpeg)
42+
logging.info(ffmpeg)
4643
sys.stdout.write("\rTranscoding...(%s%%) %s [%s%s]" % (per, per_to_time_left(per), '#' * per, '-' * (100 - per)))
4744
sys.stdout.flush()
4845

@@ -55,10 +52,6 @@ def main():
5552

5653
args = parser.parse_args()
5754

58-
logging.debug("input: " + args.input
59-
+ ", output: " + str(args.output)
60-
+ ", datetime: " + str(datetime.datetime.now()))
61-
6255
rep1 = Representation(width=256, height=144, kilo_bitrate=200, audio_k_bitrate=64)
6356
rep2 = Representation(width=854, height=480, kilo_bitrate=500, audio_k_bitrate=128)
6457
rep3 = Representation(width=1080, height=720, kilo_bitrate=1000, audio_k_bitrate=320)

examples/hls/hls.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919

2020
import ffmpeg_streaming
2121

22-
start_time = time.time()
23-
logging.basicConfig(filename='Transcoding-' + str(start_time) + '.log', level=logging.DEBUG)
24-
25-
22+
logging.basicConfig(filename='streaming.log', level=logging.NOTSET, format='[%(asctime)s] %(levelname)s: %(message)s')
2623
start_time = time.time()
2724

2825

@@ -38,9 +35,9 @@ def per_to_time_left(percentage):
3835

3936

4037
def transcode_progress(per, ffmpeg):
41-
# You can update a field in your database or can log it to a file
38+
# You can update a field in your database or log it to a file
4239
# You can also create a socket connection and show a progress bar to users
43-
logging.debug(ffmpeg)
40+
logging.info(ffmpeg)
4441
sys.stdout.write("\rTranscoding...(%s%%) %s [%s%s]" % (per, per_to_time_left(per), '#' * per, '-' * (100 - per)))
4542
sys.stdout.flush()
4643

@@ -53,10 +50,6 @@ def main():
5350

5451
args = parser.parse_args()
5552

56-
logging.debug("input: " + args.input
57-
+ ", output: " + str(args.output)
58-
+ ", datetime: " + str(datetime.datetime.now()))
59-
6053
(
6154
ffmpeg_streaming
6255
.hls(args.input, hls_time=20)

0 commit comments

Comments
 (0)