no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | libav [2018/02/28 18:43] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== libav ====== | ||
+ | * [[faac]] | ||
+ | * [[mp4box]] | ||
+ | * [[x264]] | ||
+ | * [[Video Conversion]] | ||
+ | |||
+ | === Examples === | ||
+ | |||
+ | == Ask for help == | ||
+ | |||
+ | The help file seems to be more up-to-date than the man. Also has a section for x264 encoding options. | ||
+ | |||
+ | < | ||
+ | |||
+ | == Simple x264 encoding, copy audio == | ||
+ | |||
+ | < | ||
+ | avconv -i input.mp4 -c:v libx264 -c:a copy output.mp4 | ||
+ | </ | ||
+ | |||
+ | == Set frame size == | ||
+ | |||
+ | < | ||
+ | avconv -i input.mp4 -c:v libx264 -s < | ||
+ | </ | ||
+ | |||
+ | == Set aspect ratio == | ||
+ | |||
+ | < | ||
+ | avconv -i input.mp4 -c:v libx264 -aspect < | ||
+ | </ | ||
+ | |||
+ | == x264 encoding, set CRF == | ||
+ | |||
+ | < | ||
+ | avconv -i input.mp4 -c:v libx264 -crf 20 -c:a copy output.mp4 | ||
+ | </ | ||
+ | |||
+ | == x264 encoding, set CRF == | ||
+ | |||
+ | < | ||
+ | avconv -i input.mp4 -c:v libx264 -crf 20 -c:a copy output.mp4 | ||
+ | </ | ||
+ | |||
+ | == x264 encoding, set to baseline video profile == | ||
+ | |||
+ | < | ||
+ | avconv -i input.mp4 -c:v libx264 -profile:v baseline output.mp4 | ||
+ | </ | ||
+ | |||
+ | === Video Sizes === | ||
+ | |||
+ | < | ||
+ | avconv -i input.mp4 -s hd1080 output.mp4 | ||
+ | </ | ||
+ | |||
+ | * hd480 (854x480) | ||
+ | * hd720 (1280x720) | ||
+ | * hd1080 (1920x1080) | ||
+ | * vga (640x480) | ||
+ | * qvga (320x240) | ||
+ | * qqvga (160x120) | ||
+ | |||
+ | === Aspect Ratios === | ||
+ | |||
+ | < | ||
+ | avconv -i input.mp4 -s hd480 -aspect 16:9 output.mp4 | ||
+ | </ | ||
+ | |||
+ | * 4:3 | ||
+ | * 16:9 | ||
+ | * 1.3333 | ||
+ | * 1.7777 | ||
+ | |||
+ | == Metadata == | ||
+ | |||
+ | MP4 files generated by libav are not, by default, setup for streaming over HTTP. The reason for this is that part of the metadata is located at the end of the file. When that happens, the client needs to download the entire video before playback. | ||
+ | |||
+ | qt-faststart (libav) will fix that. | ||
+ | |||
+ | < | ||
+ | qt-faststart input.mp4 output.mp4 | ||
+ | </ | ||
+ | |||
+ | Alternatively, | ||
+ | |||
+ | < | ||
+ | qtfaststart input.mp4 output.mp4 | ||
+ | </ | ||
+ | |||
+ | To copy metadata when encoding a file: | ||
+ | |||
+ | < | ||
+ | avconv -i source.mp3 -map_metadata 0 output.m4a | ||
+ | </ | ||
+ | |||
+ | === libx264 encoding === | ||
+ | |||
+ | * [[x264]] | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | == Encoding Raw Video == | ||
+ | |||
+ | If you want to use x264 to encode the video, it's simple to use libav to re-encode the original source to raw video, and then encode using x264, then remux using libav again. | ||
+ | |||
+ | If you need your video resized, use libav, since x264 does not support that feature. | ||
+ | |||
+ | An example: | ||
+ | |||
+ | < | ||
+ | avconv -i input.mp4 -s hd480 -an input.y4m | ||
+ | avconv -i input.mp4 -vn -c copy input.aac | ||
+ | x264 -o input.264 input.y4m | ||
+ | avconv -i input.264 -i input.aac -c copy output.mp4 | ||
+ | </ | ||
+ | |||
+ | == Presets == | ||
+ | |||
+ | Use '' | ||
+ | |||
+ | < | ||
+ | avconv -i video.mpg -c:v libx264 -preset medium x264.mp4 | ||
+ | </ | ||
+ | |||
+ | == Profiles == | ||
+ | |||
+ | Main profile, 3.1 requires at least 720×[email protected] (?) | ||
+ | |||
+ | === Gotchas === | ||
+ | |||
+ | == Lowering bitrate of AAC == | ||
+ | |||
+ | On one sample, libav had difficulty creating a new AAC container from a source AAC file when lowering the bitrate (say, 256k to 96k). Playback with MPlayer would squelch and terminate quickly. | ||
+ | |||
+ | < | ||
+ | avconv -i input.aac -ab 96k output.aac.mp4 | ||
+ | </ | ||
+ | |||
+ | == Preset speeds == | ||
+ | |||
+ | The '' | ||
+ | |||
+ | == MP3 encoding == | ||
+ | |||
+ | Sometimes libav will have issues encoding MP3s, where the length is incorrectly read in some players. | ||
+ | |||
+ | < | ||
+ | avconv -i audio.mp3 audio.wav | ||
+ | lame audio.wav | ||
+ | </ | ||
+ | |||
+ | Lame will encode at 128k by default. |