Advertisement
baggus

samsung mp4 fix

Feb 17th, 2012
989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.96 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Name:        samsuck
  3. # Purpose:     Some Samsung TVs cannot play past 2H:3M:19S on MP4 files using
  4. #              the built-in media player.
  5. #              This script will convert every MP4 file in the specified
  6. #              directory (and sub-directories) to a Samsung TV compatible
  7. #              MKV file.
  8. #
  9. # Usage:       1. Create samsuck.py in the same directory as mkvmerge.exe
  10. #              2. Paste this entire script in samsuck.py
  11. #              3. Change 3 variables below to suit your needs
  12. #              4. Run script.
  13. #              5. Enjoy watching the movie past 2H:3M:19S
  14. #
  15. # Requires:    Python 2.7 and MKVToolNix
  16. #
  17. # Author:      Tjerk Slaghek
  18. # Donations:   paypal tjerkslaghek@gmail.com
  19. #
  20. # Created:     17-02-2012
  21. # Copyright:   (c) Tjerk 2012
  22. # Licence:     WTFPL
  23. #-------------------------------------------------------------------------------
  24. #!/usr/bin/env python
  25. import os
  26. import sys
  27.  
  28. #CHANGE THESE 3 VARIABLES TO SUIT YOUR NEEDS:
  29.  
  30. #this directory and ALL subdirectories will be searched
  31. # USE DOUBLE BACKSLASH Z:\\DOWNLOADS\\PRON\\
  32. rootDir = 'Z:\\'
  33.  
  34. #True = delete the original MP4 file after converting
  35. deleteOriginalFilesAfterConverting = True
  36.  
  37. #False = skip already converted files
  38. overwriteAlreadyConvertedFiles = False
  39.  
  40. #-----------------------THOU SHALL NOT PASS THIS LINE---------------------------
  41. #                   (unless you know what your are doing)
  42. def main():
  43.     for root, subFolders, files in os.walk(rootDir):
  44.         for file in files:
  45.             inputFile = os.path.join(root,file)
  46.             if (inputFile.endswith(".mp4")):
  47.  
  48.                 templist = inputFile.rsplit('\\',1)
  49.                 templist[-1] = ("\\MKV_" + templist[-1])
  50.                 templist = ''.join(templist).rsplit('.',1)
  51.                 templist[-1] = ".mkv"
  52.                 outputFile = ''.join(templist)
  53.  
  54.                 print "inputFile:  " + inputFile
  55.                 print "outputFile: " + outputFile
  56.  
  57.                 if (overwriteAlreadyConvertedFiles):
  58.                     deleteCommand = 'del "' + outputFile + "\""
  59.                     print ("deleteCommand: " + deleteCommand)
  60.                     os.system(deleteCommand)
  61.  
  62.                 if (not os.path.isfile(outputFile)):
  63.                     commandToBeExecuted = ('"mkvmerge.exe -o "' + outputFile + '" --compression -1:none "' + inputFile + '"')
  64.                     print ("commandToBeExecuted: " + commandToBeExecuted)
  65.                     os.system(commandToBeExecuted)
  66.  
  67.                     if (deleteOriginalFilesAfterConverting):
  68.                         deleteCommand = 'del "' + inputFile + "\""
  69.                         print ("deleteCommand: " + deleteCommand)
  70.                         os.system(deleteCommand)
  71.                 else:
  72.                     print ("ERROR: File already exists: " + outputFile)
  73.  
  74.     print "Finished!"
  75.     pass
  76.  
  77. if __name__ == '__main__':
  78.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement