Linux 터미널에서 비디오 및 오디오를 녹음, 변환 및 추출하는 11 개의 'Avconv'명령


이전 기사에서는 'Avconv'도구를 사용하여 데스크톱 비디오 및 오디오를 녹화하는 방법 에 대해 설명했습니다. 멀티미디어 스트림 및 파일을 처리하기 위해 \" avconv \"도구를 사용하는 다른 방법이 많이 있다고 언급했습니다.

  1. Record Your Desktop Video and Audio Using ‘Avconv’ Command

이 기사에서는 \"avconv\"프로그램과 함께 사용할 가장 중요한 10 가지 명령을 살펴 보겠습니다.

확인하려면 \" avconv \"도구가 설치되어 있어야합니다. Debian/Ubuntu/Mint에 설치하려면 다음 명령을 실행하십시오.

$ sudo apt-get update
$ sudo apt-get install libav-tools

1. 비디오 및 오디오 파일 정보 얻기

멀티미디어 파일에 대한 정보를 얻으려면 avcon 명령과 함께‘-i‘(정보) 옵션을 사용하여 다음 명령을 실행하고 오디오 또는 비디오 파일을 입력하십시오.

$ avconv -i Michael-Jackson-You-Rock-My-World-HD.mp4 

avconv version 11-6:11-1, Copyright (c) 2000-2014 the Libav developers
  built on Sep 26 2014 14:34:54 with gcc 4.9.1 (Ubuntu 4.9.1-15ubuntu1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Michael-Jackson-You-Rock-My-World-HD.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2013-12-04 15:45:45
  Duration: 00:09:43.05, start: 0.000000, bitrate: 1898 kb/s
    Stream #0.0(und): Video: h264 (High), yuv420p, 1280x720, 1703 kb/s, 29.97 fps, 60k tbn, 59.94 tbc (default)
    Stream #0.1(und): Audio: aac, 44100 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      creation_time   : 2013-12-04 15:46:06
At least one output file must be specified

2. 비디오 파일에서 오디오 추출

비디오 파일에서만 오디오를 추출하고 다른 파일로 출력하려면 다음 명령을 실행할 수 있습니다.

$ avconv -i Michael-Jackson-You-Rock-My-World-HD.mp4 -vn -f wav sound.wav

위 명령에 대한 몇 가지 사항 :

  1. Don’t forget to replace the input file name with your video file name.
  2. -vn is an option that we use to remove the video from the multimedia file.
  3. -f wav is the format we want our output file to use it, you can switch to “mp3” or “webm” if you want.
  4. sound.wav is the name of the output file.

3. 오디오 파일에서 비디오 추출

다음 명령을 사용하여 비디오와 오디오가 모두 포함 된 멀티미디어 파일에서만 비디오를 추출 할 수도 있습니다.

$ avconv -i You-Rock-My-World.avi -vcodec libx264 -an -f mp4 video.mp4

위 명령에 대한 설명 :

  1. -an is an option to drop the audio from the file.
  2. mp4 is the format we want to use for our new file, you can change to “mkv”, “ogg”.. etc, remember, you will have to change the “video.mp4” to “video.mkv” as well.

4. .avi를 .mkv 형식으로 변환

.avi 파일을 .mkv 형식으로 변환하려면 다음 명령을 사용하십시오.

$ avconv -i You-Rock-My-World.avi -vcodec libx264 You-Rock-My-World.mkv
  1. -i source-file.avi is the file that we want to convert (-i = -input).
  2. -vcodec is an option that we use to choose a video codec to use while processing the conversion, in our case it is “libx264”, this option is important in order to keep the video quality as it is.
  3. newfile.mkv is the output file name.

5. .mp4를 avi 형식으로 변환

n .mp4 파일을 .avi 형식으로 변환하려면 다음 명령을 실행하십시오.

$ avconv -i Michael-Jackson-You-Rock-My-World-HD.mp4 -vcodec libx264 newfile.avi

6. .mp3를 .wav 형식으로 변환

여기에 새로운 것은 없습니다. 파일을 입력하고 다른 것을 출력했습니다. :) 여기서는 오디오 파일을 다른 오디오로 변환하기 때문에 -vcodec libx264 옵션을 사용할 필요가 없습니다. "파일, 여기에 비디오가 없습니다.

$ avconv -i michael-jackson-dangerous.mp3 newfile.wav

7. .yuv를 .avi 형식으로 변환

원하는 경우 이전 명령에서 필요에 따라 형식을 변경할 수 있습니다. 선택한 형식이 Libav에서 지원되는지 확인하십시오.

$ avconv -i oldfile.yuv newfile.avi

8. 비디오와 오디오를 함께 병합

비디오 파일을 오디오 파일과 병합하려면 다음 명령을 실행하십시오.

$ avconv -i the-sound-file.wav -i the-video-file.avi the-output-file.mkv

the-output-file.mkv ”를“ the-output-file.avi ”또는 Libav에서 지원하는 다른 형식으로 바꿀 수 있습니다 ( 직접 시도해보세요!).

9. 비디오를 이미지로 변환

비디오 파일을 여러 이미지로 변환하려면 다음 명령을 실행할 수 있습니다.

$ avconv -i Michael-Jackson-You-Rock-My-World-HD.mp4 -r 1 -s 1366x768 -f image2 image-%03d.png
  1. -r 1: is the number of frames you want per image, the more it is, the more images are created.
  2. 1366×768: is the width and height you want for the images, you may replace it with any other size you want.
  3. image-%03d.png: is the image name format, if you tried the command, it’ll create many images like “image-001.png” , “image-002.png”.. etc, you can replace “png” with “jpg” or “jpeg” if you like.

10. Libav와 함께 사용할 수있는 추가 옵션

Libav 에는“ 필터 ”라는 놀라운 기능이 있습니다. 필터를 사용하면 멀티미디어 파일에 많은 일을 할 수 있습니다. 예를 들어, 다음 명령을 사용하십시오.

$ avconv -i input-video.avi -vcodec libx264 -vf "drawbox=x=50:y=50:width=400:height=300:[email protected]" output-video.avi
  1. -vf: is an option to apply a video filter (If you want to use an audio filter, replace it with -af).
  2. drawbox=x=50:y=50:width=400:height=300:[email protected]: Here we applied a filter called “drawbox” which draws a red box with 400 width and 300 height at x=50 and y = 50.

다음은 위 명령의 결과입니다.

예를 들어 다음 명령을 사용하십시오.

$ avconv -i input-file.avi -vcodec libx264 -vf "transpose=cclock" output-file.avi
  1. transpose=cclock is a video filter that rotates the video by 90 degree clockwise.

여기에 얻을 수있는 이미지가 있습니다.

11. tty를 비디오로 녹화

이 명령은 루트 사용자가 사용해야합니다. 프레임 버퍼 장치 (fbdev)에 액세스해야하므로 sudo 없이는 작동하지 않습니다. fbdev는 Linux 프레임 버퍼 입력 장치이며이 장치는 콘솔에 그래픽을 표시하는 책임이있는 장치입니다.

$ sudo avconv -f fbdev -r 30 -i /dev/fb0 out.avi
  1. * -r 30: is the number of frames per second.
  2. * -i /dev/fb0: is the running file device node, by using this option, we’ll be able to capture the video from the tty.

놀랍지 않나요? " avconv 에 대한 다른 많은 사용 방법 외에 멀티미디어 파일에 사용할 수있는 다른 많은 좋은 필터가 있습니다. 다음의 공식 문서에서 모두 확인할 수 있습니다.

Avconv 명령 사용법

전에 Libav의 사전 사용을 시도해 보셨습니까? 당신이 그것에 대해 어떻게 생각하십니까? avconv에 대한 다른 중요한 명령이 있습니까? 댓글에서 우리와 공유하십시오!