Skip to content

Commit bd43a92

Browse files
authored
Merge pull request #1 from Reza-Rezvan/master
Python 3 Compatibility Update for video-transcoder-py3.py
2 parents 4326b27 + a102a9b commit bd43a92

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ This file converts a Plex DVR recorded TS file to an MP4 container file. In my
44
## Usage
55
To use the script copy it to whatever directory you want to run the folllowing command
66

7-
`python video-transcode.py /path/to/ts/files`
7+
`python video-transcode-py3.py /path/to/ts/files`
88

99
The script will find all the `.ts` files in that directory (NO SUBFOLDERS), then, using the `ffmpy` module in python, run `ffmpeg` on all the files to convert them to `mp4` files. It will put the transcoded file in the same directory as the original file. The script does NOT remove the original file. If you want to delete the original file, you can add the `--deleteOriginal` parameter to the command and if the transcoded file is between 0.25 and 1.2 times the size of the original it will delete the original.
1010

11-
## Tested
12-
I've test this on Python 2.7.5 as that is what I have on my server. Feel free to post any bugs AND SOLUTIONS if there are problems with other versions.
11+
## Updates
12+
13+
### Python 3 Compatibility Update
14+
- Updated the `video-transcoder-py3.py` script to be compatible with Python 3.
15+
- Fixed syntax issues, primarily by modifying `print` statements to use parentheses.
16+
- This update ensures compatibility with modern Python versions while maintaining the existing functionality.
17+
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import ffmpy
88

99
def create_arg_parser():
10-
""""Creates and returns the ArgumentParser object."""
10+
"""Creates and returns the ArgumentParser object."""
1111

1212
parser = argparse.ArgumentParser(description='This script allows you to find all .ts files in the inputDirectory and convert them to mp4 files using ffmpeg')
1313
parser.add_argument('inputDirectory',
@@ -25,7 +25,7 @@ def transcode_file(inputFile):
2525
inputs={inputFile: None},
2626
outputs={outputFile: '-c:v libx264 -strict -2'},
2727
)
28-
print ff.cmd
28+
print(ff.cmd) # Updated to use parentheses
2929
ff.run()
3030

3131
def check_file(inputFile, deleteOriginal):
@@ -38,13 +38,13 @@ def check_file(inputFile, deleteOriginal):
3838
size_max = ofs * 1.2
3939

4040
if (tfs < size_min) or (tfs > size_max):
41-
print "Transcoded file not within reasonable size limits"
42-
print "Transcoded file size: " + tfs + " bytes"
43-
print "Limits:\nMin: " + size_min + "\nMax: " + size_max
44-
print "Original file size: " + ofs + " bytes"
41+
print("Transcoded file not within reasonable size limits")
42+
print("Transcoded file size: " + str(tfs) + " bytes")
43+
print("Limits:\nMin: " + str(size_min) + "\nMax: " + str(size_max))
44+
print("Original file size: " + str(ofs) + " bytes")
4545
os._exit(1)
4646
elif tfs >= size_min and tfs <= size_max:
47-
print "Transcoded file within reasonable size limits"
47+
print("Transcoded file within reasonable size limits")
4848
if deleteOriginal:
4949
os.remove(inputFile)
5050

0 commit comments

Comments
 (0)