Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert .MTS files
#4
Thanks all. I decided to use FFMPEG and altered the code above to the following. First though I installed the Zerano build of FFMPEG.

Here's my code

import subprocess
import os

path = 'C:/test'
for file in os.scandir('.'):
if file.name.endswith('MTS'):
#print(file.name)
file_path = os.path.join(path, file.name)
subprocess.run(['ffmpeg', '-i', f'{file_path}', '-c:v', 'copy', f'{os.path.splitext(file.name)[0]}.mp4'])

In the subdirectory c:/test I have a small file called 00020.MTS which is a brief video. When I run the above script I get the following response before being returned to Idle.

>>>
== RESTART: C:/Users/Peter/AppData/Local/Programs/Python/Python36-32/t1.py ==
>>>

I then uncommented the command

#print(file.name)

and ran the script again but got the same result. The If.. command did not seem to be being triggered, In other words the python program was not seeing the . MTS file.

Why is this so? How can this be fixed.

That aside I must say I like the efficient way that files can be converted using FFMPEG.

cheers Peter
Reply


Messages In This Thread
Convert .MTS files - by pberrett - Apr-14-2017, 11:06 AM
RE: Convert .MTS files - by sparkz_alot - Apr-14-2017, 01:01 PM
RE: Convert .MTS files - by snippsat - Apr-14-2017, 07:14 PM
RE: Convert .MTS files - by pberrett - Apr-15-2017, 05:55 AM
RE: Convert .MTS files - by pberrett - Apr-15-2017, 07:40 AM
RE: Convert .MTS files - by pberrett - Apr-15-2017, 11:53 AM
RE: Convert .MTS files - by zivoni - Apr-15-2017, 12:19 PM
RE: Convert .MTS files - by pberrett - Apr-15-2017, 01:56 PM
RE: Convert .MTS files - by snippsat - Apr-15-2017, 02:16 PM
RE: Convert .MTS files - by pberrett - Apr-15-2017, 02:38 PM
RE: Convert .MTS files - by snippsat - Apr-15-2017, 02:44 PM
RE: Convert .MTS files - by pberrett - Apr-15-2017, 02:50 PM
RE: Convert .MTS files - by snippsat - Apr-15-2017, 03:40 PM
RE: Convert .MTS files - by snippsat - Apr-15-2017, 07:05 PM
RE: Convert .MTS files - by zivoni - Apr-15-2017, 07:50 PM
RE: Convert .MTS files - by snippsat - Apr-15-2017, 08:12 PM
RE: Convert .MTS files - by pberrett - Apr-16-2017, 03:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python convert multiple files to multiple lists MCL169 6 1,747 Nov-25-2023, 05:31 AM
Last Post: Iqratech
  Separate text files and convert into csv marfer 6 3,033 Dec-10-2021, 12:09 PM
Last Post: marfer
  Convert a PDF files to HTML files Underground 4 12,548 Oct-25-2020, 09:12 PM
Last Post: Larz60+
  convert old excel files(xls) to xlsm zarize 1 3,474 Jul-14-2020, 02:12 PM
Last Post: DeaD_EyE
  How to convert python files from 32 bits tto 64 bits sylas 2 5,185 Oct-29-2017, 03:51 AM
Last Post: Larz60+
  Convert grib files to text files tuxman 6 9,465 Sep-15-2017, 03:26 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020