몇일 전에 연애시대 2006년작을 다운로드 받아 비디오스테이션에 올렸다.
avi 파일이라 그런가? 재생이 안된다.
헤놀로지라 그런가? 트랜스코딩이 안된다.
putty 로 터미널 접속해서 변경했다.
ffmpeg를 사용했다.
ffmpeg -i *E01* -acodec ac3 -vcodec libx264 Alone.in.Love.2006.XViD.AC3.E01-WAF.mp4
참고 사이트
참고 사이트 글 내용
1. avi 파일을 플래쉬 파일 포맷인 flv로 변환할때 사용하는 명령어
ffmpeg -i filename.avi -ar 22050 -ab 32 -f flv -s 320x240 filename.flv
2. 변환된 flv 파일에서 원하는 순간의 스크린샷 이미지 추출
ffmpeg -i filename.flv -f image2 -t 0.001 -ss 3 filename.jpg - 3초 경과 시점의 스크린샷 추출
3. 여러개의 동영상을 하나로 합치기
ffmpeg -i test1.avi -i test2.avi -vcodec copy -acodec copy -vcodec copy -acodec copy test12.avi -newvideo -newaudio
[기타 옵션 설명]
-i = Input file name
-ar = Audio sampling rate in Hz (audio sampling frequency. default = 44100 Hz)
-ab = Audio bitrate in kbit/s (default = 64k)
-an = Disable audio recording.
-f = format (Force format)
-s = Frame size (가로x세로)
-t = 레코딩 시간 (hh:mm:ss[.xxx])
-ss = 이미지 캡쳐 시간 (초)
-fs = 파일 사이즈 제한
-vframes = 레코딩하는 비디오 프레임의 수
-r = Frame Rate (Hz, Default=25)
ffmpeg -i [인코딩할파일이름] -t 300 -acodec ac3 -ar 48000 -ab 640k -ac 6 -vcodec libx264 -b 3695k -r 24 [저장할파일이름]
ex)ffmpeg -i e:video2001.720p.x264.mkv -t 300 -acodec ac3 -ar 48000 -ab 640k -ac 6 -vcodec libx264 -b 3695k -r 24 E:91217_trans2001_h264_ac3.mp4
옵션
-i e:video2001.720p.x264.mkv – 인코딩할 파일
-t 300 – 동영상 처음부터 시간 300초
-acodec ac3 – 오디오코덱 ac3
-ar 48000 – 샘플링레이드 48.0Khz
-ab 640k – 오디오비트레이트 640k
-ac 6 – 오디오체널 6체널
-vcodec libx264 – 비디오 코덱 h264
-b 3695k – 비트레이트 3695k
-r 24 – 프레임레이트 24
E:91217_trans2001_h264_ac3.mp4 – 컨테이너= mp4 ,저장할 파일이름
기타 옵션
-aspect 16:9
화면비율을 16:9로 만든다.
-s 1280x720
해상도를 1280x720으로 만든다. –aspect 옵션과 같이 사용 해야 적당히 맞춰진다. 정확히 1280x720으로 맞춰지지 않는 경우가 많다.
-ss 00:07:30
인코딩시작시간을 00:07:30으로 맞춘다.
-ss 00:07:30
–t 00:05:00
인코딩시작시간을 00:07:30으로 맞추고 그 지점부터 5분을 인코딩한다.(00:07:30 ~ 00:12:30)
-sn
mkv파일을 mkv로 인코딩할 때 필요한 옵션.
-acodec libmp3lame
오디오코덱 mp3 사용
-acodec libfaac
오디오코덱 aac 사용
-acodec ac3
오디오코덱 ac3 사용
-vcodec libx264
비디오코덱 h264 사용
-vcodec mpeg4
비디오코덱 mpeg4
xxxxx.mp4
컨테이너를 mp4로 인코딩한다.
xxxxx.avi
컨테이너를 avi로 인코딩한다.
xxxxx.mkv
컨테이너를 mkv로 인코딩한다.
Ffmpeg 옵션 페이지 - http://ffmpeg.org/ffmpeg-doc.html" target="_blank" style="color: rgb(102, 102, 102); font-family: 굴림, arial, 서울, helvetica; line-height: 18.6666660308838px;">http://ffmpeg.org/ffmpeg-doc.html
출처 : https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/
H.264 Web Video Encoding Tutorial With FFmpeg
Web is full of articles about encoding videos with FFmpeg, however most of them are obsolete and use old non-working FFmpeg parameters. So here’s my guide for encoding web videos using recent FFMpeg versions for Flash and HTML5.
Step 1: Get a new build of FFmpeg
Most distribution builds are very old, buggy and have numerous issues. Don’t use them.Ubuntu users: http://ubuntuforums.org/showthread.php?t=786095" title="HOWTO: Install and use the latest FFmpeg and x264 " style="font-size: 16px; line-height: 2; text-align: justify; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 300; margin: 0px; padding: 0px; outline-width: 0px; color: rgb(33, 129, 166); background-color: rgb(250, 250, 250);">UbuntuForums has a great guide for compiling newest FFMpeg build. I strongly suggest you use a stable FFmpeg build (that’s 0.9 at the moment) instead of git master. Don’t forget libx264 for H.264 and libvpx for VP8/WEBM if you want that support.
Windows users: http://ffmpeg.zeranoe.com/builds/" style="font-size: 16px; line-height: 2; text-align: justify; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 300; margin: 0px; padding: 0px; outline-width: 0px; color: rgb(33, 129, 166); background-color: rgb(250, 250, 250);">Zeranoe has great static builds of FFmpeg for Windows with libx264 and libvpx included. Use those for encoding.
OS X users: MacPorts should be able to compile and install FFmpeg with libvpx and libx264. As I don’t use any machines with OS X you’ll have to check for yourself.
If you already know what “bitrates, profiles etc.” are and just want the command lines https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/#step4" style="margin: 0px; padding: 0px; outline-width: 0px; color: rgb(33, 129, 166);">skip to step 4 or https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/#samples" style="margin: 0px; padding: 0px; outline-width: 0px; color: rgb(33, 129, 166);">sample command lines.
Step 2: Choose resolution, bitrate and profile
Now you’ll have to decide on two things - the resolution, bitrate and profile you want those videos in.
Resolution gives “sharpness” to the overall image. If you choose a low resolution, the video will be small and it will be blurry when users will put it full-screen. Typically people use 360p (that’s a shorthand naming made popular by HD televison, meaning picture has height of 360 with width corresponding to wanted aspect ratio), 480p, 720p and 1080p resolutions, as those correspond to common screen sizes, which avoids excessive blurriness.
Contrary to popular belief, resolution does not affect file size.
Bitrate tells the encoder about how many bits should each second of video have. It directly determines file size of the video along with the quality. Set too low, it will cause the video to look very blocky (especially in fast-moving scenes) and set too high will make your files excessively large.
When choosing bitrate you need to remember, it is directly connected to resolution - storing pictures of certain resolution requires more bits, so if you want higher resolution videos, you’ll have to choose higher bitrate for them to not look like garbage.
A rule of thumb to calculate file size from bitrate is:
filesize (in MB) = (bitrate in Mbit/s * 8) * (video length in seconds)
Some general resolution/bitrate guidelines that we’ve found to work well http://www.viidea.com/" title="Viidea" style="font-size: 16px; line-height: 2; text-align: justify; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 300; margin: 0px; padding: 0px; outline-width: 0px; color: rgb(33, 129, 166); background-color: rgb(250, 250, 250);">at Viidea
Resolution | Bitrate | Approximate size of 10 min video |
---|---|---|
320p (for mobile phones) | 180 kbit/s | ~13 MB |
360p | 300 kbit/s | ~22 MB |
480p | 500 kbit/s | ~37 MB |
576p (SD/PAL) | 850 kbit/s | ~63 MB |
720p | 1000 kbit/s | ~75 MB |
The values in the table were optimized for lecture-type content recorded with SD cameras, so if you want to encode something more dynamic (like Transformers ;) ) I suggest you bump the bitrate up a little.
Profile constrains H.264 to a subset of features - higher profiles require more CPU power to decode and are able to generate better looking videos at same bitrate. You should always choose the best profile your target devices support.
Basic support matrix for devices:
Device | Max supported profile |
---|---|
Desktop browsers, iPhone 4S+, iPad 2+, Android 4.x+ tablets, Xbox 360, Playstation 3 | High profile |
iPhone 3GS, iPhone 4, iPad, low-end Android phones | Main profile |
iPhone, iPhone 3G, old low-end Android devices, other embedded players | Baseline profile |
Remember, most devices also have a maximum resolution and bitrate they can handle. That is usually expressed in as a http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels" style="margin: 0px; padding: 0px; outline-width: 0px; color: rgb(33, 129, 166);">H.264 level and can be set in FFmpeg with -level parameter (this will make FFmpeg abort encoding of videos which couldn’t be played on the device).
Step 3: Choose audio format and bitrate
For audio, the choice is a lot simpler - if you want to encode for mobile devices I strongly suggest you use AAC+, which has a very noticeable improvement of audio quality at the same bitrate.With that in mind, AAC+ is perfect for podcasts, lectures and other speech content, since it retains quality even at low bitrates (difference between “normal” LC-AAC at 96 kbit/s vs. AAC+ at 64kbit/s is practically not noticeable). You will need libfdk_aac
compiled into your version of ffmpeg to encode into AAC+ profile and pass -profile:a aac_he_v2
as a parameter. Otherwise, rule of thumb is to take around 128 kbit/s for standard quality material and 192kbit/s for something more complex.
Step 4: Encode!
So, you made all the hard choices and now it’s time to encode your video. FFmpeg command line to encode a standard web video looks like this:
ffmpeg -i input_file.avi -codec:v libx264 -profile:v high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -codec:a libfdk_aac -b:a 128k output_file.mp4
You can also encode the video in two-passes, which gives the added benefit of quality increase and more accurate file size for given bitrate
1st pass
|
|
|
|
Scary isn’t it?
Warning: ffmpeg command line arguments are position sensitive - make sure you don’t mix up the order. Good rule of thumb to prevent mistakes is to keep the order of
ffmpeg [input options] -i [input filename] -codec:v [video options] -codec:a [audio options] [output file options] [output filename]
Let’s break down all those parameters:
-i [input file] - this specifies the name of input file
-codec:v libx264 - tells FFmpeg to encode video to H.264 using libx264 library
-profile:v high - sets H.264 profile to “High” as per Step 2. Other valid options are baseline, main
-preset slow - sets encoding preset for x264 – slower presets give more quality at same bitrate, but need more time to encode. “slow” is a good balance between encoding time and quality.
Other valid options are: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo (never use this one)
-b:v - sets video bitrate in bits/s
-maxrate and -bufsize - forces libx264 to build video in a way, that it could be streamed over 500kbit/s line considering device buffer of 1000kbits. Very useful for web - setting this to bitrate and 2x bitrate gives good results.
-vf scale - applies “scale” filter, which resizes video to desired resolution. “720:480” would resize video to 720x480, “-1” means “resize so the aspect ratio is same.” Usually you set only height of the video, so for 380p you set “scale=-1:380”, for 720p “scale=-1:720” etc.
-threads 0 - tells libx264 to choose optimal number of threads to encode, which will make sure all your processor cores in the computer are used
-codec:a libfdk_aac - tells FFmpeg to encode audio to AAC using libfdk-aac library
-b:a - sets audio bitrate in bits/s
-pass [1|2] - tells FFmpeg to process video in multiple passes and sets the current pass
-an - disables audio, audio processing has no effect on first pass so it’s best to disable it to not waste CPU
That’s basically all there is to it.
Some sample command lines:
|
|
|
|
|
|
|
|
If you’re interested in encoding WebM instead of H.264, read the http://www.virag.si/2012/01/webm-web-video-encoding-tutorial-with-ffmpeg-0-9/" title="WebM web video encoding tutorial with FFMpeg 0.9" style="margin: 0px; padding: 0px; outline-width: 0px; color: rgb(33, 129, 166);">next article :)
이상입니다.
퍼가기 하실때는 출처 꼭 같이 남겨주시면 감사하겠습니다.
출처: 코키티비, http://cocatv.tistory.com/267
'동영상편집 > 변환툴' 카테고리의 다른 글
FFMPEG 옵션 설명 참고 사이트 ospace (0) | 2020.05.09 |
---|---|
재인코딩 없이 AVI를 MP4로 변환하기 (0) | 2020.05.09 |
FFmpeg 실행 중 mpeg4_unpack_bframes to fix 발생시 (0) | 2020.05.09 |
동영상 인강 수업 영상 용량 줄이기 (0) | 2020.05.09 |
동영상 일부분 저장 쉽고 빠르게 하는 방법 - Avidemux (0) | 2020.05.09 |
댓글