Debian에서 FFmpeg를 사용한 대규모 디인터레이싱

Debian에서 FFmpeg를 사용한 대규모 디인터레이싱

데비안 서버에는 약 300개의 비디오가 다음과 같이 저장되어 있습니다:

/mediaroot/1/m32.mp4
/mediaroot/2/m421.mp4
/mediaroot/n/mx.mp4

모두 디인터레이스되어야 하며 이를 위해 FFmpeg를 사용하고 싶습니다.

또 다른 유용한 밑창의 도움으로 다음 단계를 통해 어느 정도 수용 가능한 결과를 얻었습니다.

  1. 오디오 추출
  2. 트랜스코딩 비디오, 예

    ffmpeg -y -i m148.mp4 -pix_fmt yuv420p -an -pass 1 -passlogfile m148.x600.1351896878.log -an -vcodec libx264 -b:v 600k -preset medium -tune film -threads 0 m148.x600.1351896878.mp4
    ffmpeg -y -i m148.mp4 -pix_fmt yuv420p -an -pass 2 -passlogfile m148.x600.1351896878.log -an -vcodec libx264 -b:v 600k -preset medium -tune film -threads 0 m148.x600.1351896878.video.mp4
    
  3. 1단계에서 추출한 오디오와 새 비디오를 믹싱합니다.

  4. qt-faststart를 사용하여 원자 이동

    ffmpeg/qt-faststart m148.x600.1351896878.mp4 m148.x600.1351896878.atom.mp4
    

내 질문은: 자동으로 인터레이스를 해제하고 모든 비디오를 교체하려면 어떻게 해야 합니까?

답변1

디인터레이스하려면 다음을 사용하십시오.YADIF 필터. -filter:v yadif명령줄에서 조금 뒤에 추가하면 됩니다 -i input.mp4.

오디오를 추출하여 재사용할 필요가 없습니다. FFMPEG는 사용자가 -acodec copy요청하는 경우 encode 명령에 소스 오디오를 추가하여 입력 스트림의 소스 오디오를 출력으로 복사합니다. 다시 말하지만 옵션 뒤에 나타나야 -i input.mp4하며 어쩌면 뒤에 나타나야 합니다. -f container나는 그것을 모든 비디오 옵션 뒤에 두는 경향이 있습니다. 그것은 단지 개인적인 스타일의 문제일 뿐입니다.

입력 파일 교체에 관해서는 이것이 명확해야 합니다. 임시 출력 파일에 코딩한 다음 성공하면 스크립트에 다음과 같은 내용이 표시됩니다 mv /tmp/whatever.mp4 input.mp4.

답변2

간단한 쉘 스크립트를 작성하십시오 - 기본적으로 모든 작업이 완료되었습니다. 모든 것을 "한 지붕 아래"(하나의 스크립트 파일에) 넣기만 하면 됩니다.

#!/bin/bash

# loop over all arguments to the script - place each single
# one into variable f (further referenced to by $f) and execute
# the commands in the loop
for f in "$@"; do
    # create new variable holding filename without the extension
    n=${m%.mp4}

    # commands you mentioned above go here, you only need to
    # replace the strings that correspond to actual filename
    # with "$f" or "$n". Use the quotes around in case your
    # filenames contained spaces. e.g.:
    ffmpeg -y -i "$f" -pix_fmt yuv420p -an -pass 1 -passlogfile "$n".x600.1351896878.log -an -vcodec libx264 -b:v 600k -preset medium -tune film -threads 0 "$n".x600.1351896878.mp4
    ffmpeg -y -i "$f" -pix_fmt yuv420p -an -pass 2 -passlogfile "$n".x600.1351896878.log -an -vcodec libx264 -b:v 600k -preset medium -tune film -threads 0 "$n".x600.1351896878.video.mp4

    # more commands...
done

그런 다음 인수로 변환할 파일 이름을 사용하여 스크립트를 실행합니다.

script.sh file1.mp4 /another/directory/file2/mp4 ...

실행 가능하게 만들 chmod a+x script.sh거나 쉘 인터프리터를 통해 명시적으로 실행해야 합니다.bash script.sh ...

관련 정보