Best way to compress Fraps video

Для сильного сжатия видео, записанного с помощью утилиты Fraps, можно использовать набор библиотек ffmpeg. При этом ролики сжимаются с размера порядка 1ГБ до 50МБ без особо заметных потерь качества картинки и звука.

Для Windows

Упёрто здесь.

I’ve written a couple bat files that I use for encoding my Fraps recordings (quickly and well). First up, I have the lossless variation incase I’m doing mostly static desktop recordings:

SETLOCAL ENABLEDELAYEDEXPANSION
SETLOCAL ENABLEEXTENSIONS
for /F "delims=;" %%A IN ('dir /b *.avi') DO (
ffmpeg -i "%%A" -acodec ac3 -ab 192000 "%%~nA.ac3"
ffmpeg -i "%%A" -vcodec rawvideo -f yuv4mpegpipe -an -pix_fmt yuv420p - | x264.x64 - --stdin y4m --crf 0 --bframes 5 --b-adapt 2 --ref 4 --mixed-refs --no-fast-pskip --direct auto --deblock -3:-3 --subme 10 --trellis 2 --analyse all --8x8dct --me umh --output "%%~nA.noaudio.mkv"
mkvmerge -o "%%~nA - lossless.mkv" --forced-track 1:no -d 1 -A -S "%%~nA.noaudio.mkv" --forced-track 0:no -a 0 -D -S "%%~nA.ac3" --track-order 0:1,1:0
del "%%~nA.ac3"
del "%%~nA.noaudio.mkv"
)
pause

For the other one, I use a lossy mode that’s pretty indistinguishable between the source and the encode in motion:

SETLOCAL ENABLEDELAYEDEXPANSION
SETLOCAL ENABLEEXTENSIONS
for /F "delims=;" %%A IN ('dir /b *.avi') DO (
ffmpeg -i "%%A" -acodec ac3 -ab 192000 "%%~nA.ac3"
ffmpeg -i "%%A" -vcodec rawvideo -f yuv4mpegpipe -an -pix_fmt yuv420p - | x264.x64 - --stdin y4m --crf 19 --bframes 5 --b-adapt 2 --ref 4 --mixed-refs --no-fast-pskip --direct auto --deblock -3:-3 --subme 10 --trellis 2 --analyse all --8x8dct --me umh --output "%%~nA.noaudio.mkv"
mkvmerge -o "%%~nA.final.mkv" --forced-track 1:no -d 1 -A -S "%%~nA.noaudio.mkv" --forced-track 0:no -a 0 -D -S "%%~nA.ac3" --track-order 0:1,1:0
del "%%~nA.ac3"
del "%%~nA.noaudio.mkv"
)
pause

Both use the same process. Convert the PCM that Fraps records to 192kbps AC3 using ffmpeg, convert the video to H.264 using x264 (fed by ffmpeg), then mux the audio and video using mkvmerge. Of course, you can easily change most settings in here. Want an MP4 instead? No problem, just replace a couple lines to use mp4box instead of mkvmerge. The only thing you don’t want to do is replace x264 as it’s one of, if not the best video encoder there is in terms of quality and speed.

Now, since I don’t do any post processing, I don’t have to worry about compatibility issues when trying to open the files.. but if you are, use ffmpeg to convert the video to HuffYUV so that you can more easily edit it, and then after you’ve exported the final product, a run of either of those bats should suffice.

Для Unix-подобных систем

Я немного изменил скрипт под *никсовый шелл, проверялось на OS X 10.6.8:

#!/bin/bash
 
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
 
for filename in $(find . -maxdepth 1 -iname '*.avi')
do
#       filteredname=${filename/.avi}
        filteredname=$(echo "${filename}" | perl -pe 's/\.avi$//i')
        echo "Working on: ${filename}, filteded name is: ${filteredname}"
 
        ffmpeg -i "${filename}" -acodec ac3 -ab 192000 "${filteredname}.ac3"
        ffmpeg -i "${filename}" -vcodec rawvideo -f yuv4mpegpipe -an -pix_fmt yuv420p - | x264 - --stdin y4m --crf 19 --bframes 5 --b-adapt 2 --ref 4 --mixed-refs --no-fast-pskip --direct auto --deblock -3:-3 --subme 10 --trellis 2 --analyse all --8x8dct --me umh --output "${filteredname}.noaudio.mkv"
        mkvmerge -o "${filteredname}.final.mkv" --forced-track 1:no -d 1 -A -S "${filteredname}.noaudio.mkv" --forced-track 0:no -a 0 -D -S "${filteredname}.ac3" --track-order 0:1,1:0
 
        echo "Removing temporary files"
        rm "${filteredname}.ac3"
        rm "${filteredname}.noaudio.mkv"
done
 
IFS=$SAVEIFS

Пример

Оригинальное видео
Размер: 1402683512 (1,3G)
gta_sa 2011-07-24 22-14-11-02.avi: RIFF (little-endian) data, AVI, 1920 x 1080, 30.00 fps, video: uncompressed, audio: uncompressed PCM (stereo, 48000 Hz)

Fraps uncompressed frame

Fraps uncompressed frame

Сжатое видео
Размер: 18076996 (17M)
gta_sa 2011-07-24 22-14-11-02.final.mkv: EBML file, creator matroska
Track 1: video, codec ID: V_MPEG4/ISO/AVC (h.264 profile: High @L4.0), default duration: 33.333ms (30.000 fps for a video track), pixel width: 1920, pixel height: 1080, display width: 1920, display height: 1080
Track 2: audio, codec ID: A_AC3, default duration: 32.000ms (31.250 fps for a video track), language: und, sampling freq: 48000, channels: 2
Скачать ролик целиком.

Fraps compressed frame

Fraps compressed frame

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *