#!/usr/bin/env python3
import os
import os.path as osp
import re
import subprocess

p = re.compile("'.+?.mp4'")

video_paths = input()
video_paths = p.findall(video_paths)
# Remove single quotation marks on both ends
video_paths = list(map(lambda path: path[1:-1], video_paths))

print(video_paths)

first_video = video_paths[0]
execution_dir = osp.dirname(first_video)

# Fixing the code to an intermediate format
for i, path in enumerate(video_paths):
    name, ext = osp.splitext(path)
    fixed_path = name + "_fixed.mp4"
    proc = subprocess.Popen(
        ["ffmpeg", "-i", path, "-video_track_timescale", "90000", fixed_path, "-y"])
    proc.communicate()
    video_paths[i] = fixed_path

mylist_path = osp.join(execution_dir, "mylist.txt")
with open(mylist_path, "w") as f:
    for path in video_paths:
        f.write("file " + path + "\n")

output_path = osp.join(
    execution_dir,
    osp.splitext(
        osp.basename(first_video))[0] +
    "_concatenated.mp4")

proc = subprocess.Popen(["ffmpeg", "-f", "concat", "-safe", "0", "-i",
                         mylist_path, "-c", "copy", output_path, "-y"])
proc.communicate()
print(f"return code: {proc.returncode}")

os.remove(mylist_path)
for path in video_paths:
    os.remove(path)

a28da7bfef5703899b234b8271404fb887d89753
<mask token>

<mask token>
print(video_paths)
<mask token>
for i, path in enumerate(video_paths):
    name, ext = osp.splitext(path)
    fixed_path = name + '_fixed.mp4'
    proc = subprocess.Popen(['ffmpeg', '-i', path, '-video_track_timescale',
        '90000', fixed_path, '-y'])
    proc.communicate()
    video_paths[i] = fixed_path
<mask token>
with open(mylist_path, 'w') as f:
    for path in video_paths:
        f.write('file ' + path + '\n')
<mask token>
proc.communicate()
print(f'return code: {proc.returncode}')
os.remove(mylist_path)
for path in video_paths:
    os.remove(path)

<mask token>
p = re.compile("'.+?.mp4'")
video_paths = input()
video_paths = p.findall(video_paths)
video_paths = list(map(lambda path: path[1:-1], video_paths))
print(video_paths)
first_video = video_paths[0]
execution_dir = osp.dirname(first_video)
for i, path in enumerate(video_paths):
    name, ext = osp.splitext(path)
    fixed_path = name + '_fixed.mp4'
    proc = subprocess.Popen(['ffmpeg', '-i', path, '-video_track_timescale',
        '90000', fixed_path, '-y'])
    proc.communicate()
    video_paths[i] = fixed_path
mylist_path = osp.join(execution_dir, 'mylist.txt')
with open(mylist_path, 'w') as f:
    for path in video_paths:
        f.write('file ' + path + '\n')
output_path = osp.join(execution_dir, osp.splitext(osp.basename(first_video
    ))[0] + '_concatenated.mp4')
proc = subprocess.Popen(['ffmpeg', '-f', 'concat', '-safe', '0', '-i',
    mylist_path, '-c', 'copy', output_path, '-y'])
proc.communicate()
print(f'return code: {proc.returncode}')
os.remove(mylist_path)
for path in video_paths:
    os.remove(path)

import os
import os.path as osp
import re
import subprocess
p = re.compile("'.+?.mp4'")
video_paths = input()
video_paths = p.findall(video_paths)
video_paths = list(map(lambda path: path[1:-1], video_paths))
print(video_paths)
first_video = video_paths[0]
execution_dir = osp.dirname(first_video)
for i, path in enumerate(video_paths):
    name, ext = osp.splitext(path)
    fixed_path = name + '_fixed.mp4'
    proc = subprocess.Popen(['ffmpeg', '-i', path, '-video_track_timescale',
        '90000', fixed_path, '-y'])
    proc.communicate()
    video_paths[i] = fixed_path
mylist_path = osp.join(execution_dir, 'mylist.txt')
with open(mylist_path, 'w') as f:
    for path in video_paths:
        f.write('file ' + path + '\n')
output_path = osp.join(execution_dir, osp.splitext(osp.basename(first_video
    ))[0] + '_concatenated.mp4')
proc = subprocess.Popen(['ffmpeg', '-f', 'concat', '-safe', '0', '-i',
    mylist_path, '-c', 'copy', output_path, '-y'])
proc.communicate()
print(f'return code: {proc.returncode}')
os.remove(mylist_path)
for path in video_paths:
    os.remove(path)

#!/usr/bin/env python3
import os
import os.path as osp
import re
import subprocess

p = re.compile("'.+?.mp4'")

video_paths = input()
video_paths = p.findall(video_paths)
# Remove single quotation marks on both ends
video_paths = list(map(lambda path: path[1:-1], video_paths))

print(video_paths)

first_video = video_paths[0]
execution_dir = osp.dirname(first_video)

# Fixing the code to an intermediate format
for i, path in enumerate(video_paths):
    name, ext = osp.splitext(path)
    fixed_path = name + "_fixed.mp4"
    proc = subprocess.Popen(
        ["ffmpeg", "-i", path, "-video_track_timescale", "90000", fixed_path, "-y"])
    proc.communicate()
    video_paths[i] = fixed_path

mylist_path = osp.join(execution_dir, "mylist.txt")
with open(mylist_path, "w") as f:
    for path in video_paths:
        f.write("file " + path + "\n")

output_path = osp.join(
    execution_dir,
    osp.splitext(
        osp.basename(first_video))[0] +
    "_concatenated.mp4")

proc = subprocess.Popen(["ffmpeg", "-f", "concat", "-safe", "0", "-i",
                         mylist_path, "-c", "copy", output_path, "-y"])
proc.communicate()
print(f"return code: {proc.returncode}")

os.remove(mylist_path)
for path in video_paths:
    os.remove(path)
