Захват и обработка видео

Кодирование видео

Софт

Для перекодирования видео

Следует избегать перекодирование видео из одного цветового пространства в другое. Так, например, почти все фильтры VirtualDub работают только с RGB видео, соответственно для их работы нужно включать режим Full processing mode. Плагины же AviSynth умеют работать с большинством цветовых форматов, поэтому можно оставить режим Fast recompress (видео передаётся на вход видео компрессора без изменений). Также желательно оставаться в пространстве YUV, которое является единственным для семейства кодеков MPEG. Я рекомендую использовать цветовое пространство YV24 при работе с кодеком x264, если есть необходимость попискельной обработки видео (crop, border, etc).

Для перекодирования видео из DVD

Для перекодирования видео из MPEG/VOB

Используя плагин ffms2 (остальное – как выше):

file.avs

LoadPlugin("C:\Programs\AviSynth\plugins\ffms2.dll")
 
file="A1.MP4"
FFIndex(file) # создаёт индекс (выполняется один раз)
AudioDub(FFVideoSource(file), FFAudioSource(file))
 
# [optional as plugin already works in this color space] Convert to YV 4:2:0 to enable fast processing:
#ConvertToYV12()
 
#Levels(10, 1, 200, 0, 255)
 
#Turn180()
#FadeIn(15)
#FadeOut(15)
 
LanczosResize(960, 540)

Для перекодирования видео из Blue-Ray

Смотри также:

Настройки кодека X.264 v54.606

Закладка 1 Закладка 2 Закладка 3

Обработка звука и микширование

Захват видео

Ссылки

Обработка видео

AviSynth

x264

Разное

Questions answered

How to blur a particular part of video in AviSynth?

function BlurBox(clip v, int x, int y, int w, int h, int "blur_factor")
{
    blur_factor = Default(blur_factor, 1)
    sx = Max(v.width / blur_factor * 2, 12) # Spline36Resize() requires at least 12 pixels width
    sy = Max(v.height / blur_factor * 2, 12) # Spline36Resize() requires at least 12 pixels height
    w = w / 2 * 2 # force even for YV12, YUY2
    h = h / 2 * 2 # force even for YV12
 
    Spline36Resize(v, sx, sy)
    Blur(1.0)
    Spline36Resize(v.width, v.height)
    Spline36Resize(w,h,x,y,w,h) # alternate for Crop(x/2*2, y/2*2, w, h), allows odd x,y values
    Overlay(v, last, x, y)
}
...
video.BlurBox(600, 345, 80, 20, 20)

Why some DVD rips have 23.976 fps, and some 25 fps?

If rip was created from DVD for countries with PAL encoding system (Europe), then fps rate will be 25. For NTSC (USA) it will be 23.976.

See also:

Что такое GOP?

GOP (Group Of Pictures) – consists of all the pictures that follow a GOP header before another GOP header. See also the description of I- P- and B- frames.

Что такое X.264 profile?

How to display progress bar for ffpeg?

Probably pv would be more universal, but won't work for .avs input.

Как перекодировать 3D SBS в анаглиф?

Рядом с myvideo.avi создать файл myvideo.avs:

file.avs

c = ConvertToRGB32()
w = c.width()/2
h = c.height()/2
LeftRight3DToRCAnaglyph(c).Lanczos4Resize(w, h)

When trying to encode from AVS, the error avs [error]: failed to load avisynth is reported

From here:

×64 version of x264 can work only with ×64 version of AviSynth.

How to rotate MP4 videos without re-encoding?

  • ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4
  • exiftool -rotation=270 input.mp4

How to convert a series of images into video?

$ for i in `seq 1 10`; do gm convert -pointsize 500 -gravity center label:$i -geometry 400x400 -extent 400x400 image_$i.jpg; done

$ ffmpeg -framerate 1 -i image_%d.jpg -vcodec libx264 -profile:v high422 -preset veryslow -refs 16 -vf "fps=25,format=yuv420p" out.mkv
ffmpeg version 3.2.10-1~deb9u1 Copyright (c) 2000-2018 the FFmpeg developers
Input #0, image2, from 'image_%d.png':
  Duration: 00:00:10.00, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgb48be(pc), 400x400, 1 fps, 1 tbr, 1 tbn, 1 tbc
[libx264 @ 0x1fb63c0] using cpu capabilities: MMX2 SSE Cache64
[libx264 @ 0x1fb63c0] profile High, level 3.1
[libx264 @ 0x1fb63c0] 264 - core 148 r2748 97eaef2 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=16 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=10 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=24 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=8 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'demo.mkv':
  Metadata:
    encoder         : Lavf57.56.101
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 400x400, q=-1--1, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.64.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame=   75 fps=0.0 q=28.0 size=       1kB time=00:00:00.00 bitrate=5912.0kbits/s speed=0.0011x
frame=  100 fps= 54 q=28.0 size=       1kB time=00:00:01.00 bitrate=   5.9kbits/s speed=0.543x
frame=  125 fps= 43 q=28.0 size=       1kB time=00:00:02.00 bitrate=   3.0kbits/s speed=0.687x
frame=  150 fps= 35 q=28.0 size=       8kB time=00:00:03.00 bitrate=  23.1kbits/s speed=0.694x
frame=  175 fps= 30 q=28.0 size=       8kB time=00:00:04.00 bitrate=  17.3kbits/s speed=0.682x
frame=  200 fps= 29 q=28.0 size=       8kB time=00:00:05.00 bitrate=  13.9kbits/s speed=0.725x
frame=  225 fps= 27 q=28.0 size=      17kB time=00:00:06.00 bitrate=  22.8kbits/s speed=0.73x
frame=  225 fps= 23 q=28.0 size=      17kB time=00:00:06.00 bitrate=  22.8kbits/s speed=0.617x
frame=  226 fps= 19 q=-1.0 Lsize=      29kB time=00:00:08.92 bitrate=  26.2kbits/s speed=0.737x
video:26kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.342590%
[libx264 @ 0x1fb63c0] frame I:4     Avg QP:15.23  size:  2370
[libx264 @ 0x1fb63c0] frame P:27    Avg QP:15.90  size:   403
[libx264 @ 0x1fb63c0] frame B:195   Avg QP:18.88  size:    31
[libx264 @ 0x1fb63c0] consecutive B-frames:  1.8%  1.8%  0.0%  0.0%  2.2%  2.7%  0.0%  0.0% 91.6%
[libx264 @ 0x1fb63c0] mb I  I16..4: 30.5% 60.7%  8.8%
[libx264 @ 0x1fb63c0] mb P  I16..4:  0.5%  0.7%  0.8%  P16..4:  2.2%  0.7%  2.7%  0.1%  0.0%    skip:92.2%
[libx264 @ 0x1fb63c0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  2.2%  0.0%  0.0%  direct: 0.0%  skip:97.8%  L0:47.8% L1:52.2% BI: 0.0%
[libx264 @ 0x1fb63c0] 8x8 transform intra:57.8% inter:8.3%
[libx264 @ 0x1fb63c0] direct mvs  spatial:97.9% temporal:2.1%
[libx264 @ 0x1fb63c0] coded y,uvDC,uvAC intra: 21.2% 0.8% 0.8% inter: 0.1% 0.0% 0.0%
[libx264 @ 0x1fb63c0] i16 v,h,dc,p: 34% 11% 55%  0%
[libx264 @ 0x1fb63c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 11% 49%  2%  0%  0%  0%  0%  0%
[libx264 @ 0x1fb63c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 14% 37%  9%  3%  3%  3%  5%  4%
[libx264 @ 0x1fb63c0] i8c dc,h,v,p: 29% 71%  1%  0%
[libx264 @ 0x1fb63c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x1fb63c0] ref P L0: 80.2%  0.9%  9.6%  1.8%  0.4%  1.3%  4.8%  0.6%  0.3%
[libx264 @ 0x1fb63c0] ref B L0: 69.1% 15.4%  6.6%  3.6%  1.8%  2.1%  0.8%  0.2%  0.2%  0.0%  0.1%  0.1%
[libx264 @ 0x1fb63c0] ref B L1: 90.8%  9.2%
[libx264 @ 0x1fb63c0] kb/s:23.29
  • To change the image size use the following filter:
    -vf scale=-1:1080
  • To force baseline X.264 profile / level:
    -profile:v baseline -level:v 2.1

To convert a series of images into animated GIF:

# Cygwin:
$ bash -x -c "cat ""$@"" | ffmpeg -hide_banner -loglevel error -y -f image2pipe -framerate 1 -i - all.flv && ffmpeg -hide_banner -loglevel error -y -i all.flv all.gif && rm all.flv" -- image_a.png image_b.png
# Linux:
$ cat image_a.png image_b.png | ffmpeg -hide_banner -loglevel error -y -f image2pipe -framerate 1 -i - all.flv && ffmpeg -hide_banner -loglevel error -y -i all.flv all.gif && rm all.flv

Смотри также:

Программы по автоматическому созданию DVD рипов

Программа/функции AviSynth2 VirtualDubMod GordianKnot SUPER MeGUI FairUse Ghost AutoMKV Handbrake
Поддерживаемые видео кодеки любой vfw установленный в системе XVid, DivX, X.264
Поддерживаемые аудио кодеки любой установленный в системе MP3, OGG
Поддерживаемые входящие контейнеры AVI, MPG, MKV AVI, OGM, MKV
Поддерживаемые результирующие контейнеры AVI, MPG, MKV
Задание языка для аудио/видео поддержка есть, но не работает
Главы
Субтитры
Просмотр исходного видео + +
Просмотр видео после наложения фильтров/эффектов +
Задание интервалов для кодирования +
Cropping + +
Adding borders +
Наложение простых аудио эффектов (fade-in/fade-out) +
Наложение простых видео эффектов (fade-in/fade-out) +