ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • AVCCAM Restorer 이용해서 MTS, M2TS 복원하기
    Tech/Computer 2014. 3. 27. 14:00

    최근에 Sony 캠으로 영상을 촬영하고 편집할 일이 있었다. 촬영 후 자연스럽게 메모리의 동영상 파일(MTS 확장자를 가진다)만 USB에 옮겨담았는데, 나중에 편집하려고 열어보니 Final cut pro 같은 동영상 편집 프로그램에서 불러올 수가 없었다! 메모리 카드의 폴더 구조도 동영상에 대한 정보를 포함하고 있기 때문에, MTS 파일만 가져와서는 불러올 수가 없다고 한다.

    즉, 동영상 편집 프로그램에서 불러오려면 캠을 직접 연결해서 Import하는 것이 가장 좋다. 하지만 상황이 여의치않아 MTS 파일만 달랑 남았을 경우에는 Panasonic에서 제공하는 AVCCAM Restorer를 이용해서 복원해도 된다. 여기에서 다운받을 수 있다.

    그런데, 주의할 점은 mts, m2ts의 파일명이 5자리 숫자로 순서대로 이어져있어야 위 프로그램을 통한 복원이 가능하다. 만약 숫자가 순서대로 이어져있지 않다면 일일이 파일 이름을 바꿔주지 않는 한 위 프로그램은 동작하지 않는다. 정말 대충 짠 프로그램이라고 볼 수 있다. MTS 파일이 꽤 많았기에 노가다를 하기 싫어 이 작업을 대신할 python 코드를 작성했다.

    # Title: mts, m2ts file renamiong scripts
    # Author: thinkpiece
    # Description:
    #  AVCCAM requires:
    #   1) 5 digit numbered filename
    #   2) .MTS or .M2TS
    #   3) consecutive number
    
    import os, sys
    
    if len(sys.argv) != 2 :
        print("usage: " + sys.argv[0] + " [path]")
        raise SystemExit(1)
    
    pathname = sys.argv[1]
    print("Trying to rename files in " + pathname + "...")
    newname = 0
    iterask = True      # true : ask, false : no ask
    iterrun = True      # true : rename, false : remain
    
    for filename in os.listdir(pathname):
        if filename.endswith("MTS"):
            if iterask:
                print(filename + " is found. Are you sure to rename this file?")        
                usercmd = raw_input("[yes(Y)/no(N)/all(A)/not all(Q)? ")
                if usercmd.startswith("Y") or usercmd.startswith("y"):
                    iterrun = True
                elif usercmd.startswith("A") or usercmd.startswith("a"):
                    iterrun = True
                    iterask = False
                elif usercmd.startswith("Q") or usercmd.startswith("q"):
                    break
                else:
                    iterrun = False
    
            if iterrun:
                oldfilename = os.path.join(pathname,filename)
                newfilename = os.path.join(pathname,format(newname,"05d")+".M2TS")
                os.rename(oldfilename, newfilename)
                print(oldfilename + " --> " + newfilename)
                newname = newname + 1
        # end if
    # end for
    

    댓글

Copyright 2022 JY