ffmpeg
делает реальную работу.
ffmpeg -i input.mp4 -an -ss '00:11:02.5' -to '00:11:05' output.gif
ffmpeg -i input.mpg -vf 'scale=iw*0.5:ih*0.5' output.mp4
ffmpeg -i input.mpg -vf 'scale=360:288' output.mp4
ffmpeg -i input.mpg -vf 'scale=360:288' output.mp4
ffmpeg version 5.0.1-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11.2.0 (Rev7, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Input #0, mpeg, from 'input.mpg':
Duration: 02:26:12.00, start: 0.193178, bitrate: 6296 kb/s
Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 90k tbn
Side data:
cpb: bitrate max/min/avg: 8500000/0/0 buffer size: 1835008 vbv_delay: N/A
Stream #0:1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 224 kb/s
File 'output.mp4' already exists. Overwrite? [y/N] n
Not overwriting - exiting
PS D:\> .\ffmpeg -i input.mpg -vf 'scale=360:288' output.mp4
ffmpeg version 5.0.1-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11.2.0 (Rev7, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Input #0, mpeg, from 'input.mpg':
Duration: 02:26:12.00, start: 0.193178, bitrate: 6296 kb/s
Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 90k tbn
Side data:
cpb: bitrate max/min/avg: 8500000/0/0 buffer size: 1835008 vbv_delay: N/A
Stream #0:1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 224 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (mp2 (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 00000202ddab6e80] using SAR=16/15
[libx264 @ 00000202ddab6e80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 00000202ddab6e80] profile High, level 2.1, 4:2:0, 8-bit
[libx264 @ 00000202ddab6e80] 264 - core 164 r3094 bfc87b7 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 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, mp4, to 'output.mp4':
Metadata:
encoder : Lavf59.16.100
Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt470bg, top coded first (swapped)), 360x288 [SAR 16:15 DAR 4:3], q=2-31, 25 fps, 12800 tbn
Metadata:
encoder : Lavc59.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc59.18.100 aac
frame=219300 fps=209 q=-1.0 Lsize= 711087kB time=02:26:12.01 bitrate= 664.1kbits/s speed=8.35x
video:566821kB audio:137780kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.920495%
[libx264 @ 00000202ddab6e80] frame I:1143 Avg QP:22.93 size: 10857
[libx264 @ 00000202ddab6e80] frame P:59982 Avg QP:25.64 size: 5013
[libx264 @ 00000202ddab6e80] frame B:158175 Avg QP:29.16 size: 1690
[libx264 @ 00000202ddab6e80] consecutive B-frames: 2.9% 1.9% 2.9% 92.3%
[libx264 @ 00000202ddab6e80] mb I I16..4: 5.2% 71.9% 22.9%
[libx264 @ 00000202ddab6e80] mb P I16..4: 2.2% 13.8% 3.0% P16..4: 40.6% 26.7% 12.7% 0.0% 0.0% skip: 1.1%
[libx264 @ 00000202ddab6e80] mb B I16..4: 0.3% 1.1% 0.2% B16..8: 43.7% 11.8% 2.6% direct:14.1% skip:26.3% L0:38.2% L1:42.7% BI:19.1%
[libx264 @ 00000202ddab6e80] 8x8 transform intra:72.0% inter:73.2%
[libx264 @ 00000202ddab6e80] coded y,uvDC,uvAC intra: 75.8% 92.3% 56.3% inter: 31.9% 62.8% 4.8%
[libx264 @ 00000202ddab6e80] i16 v,h,dc,p: 30% 26% 3% 40%
[libx264 @ 00000202ddab6e80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 22% 12% 5% 7% 9% 7% 8% 7%
[libx264 @ 00000202ddab6e80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 26% 11% 5% 8% 9% 7% 7% 5%
[libx264 @ 00000202ddab6e80] i8c dc,h,v,p: 47% 21% 20% 11%
[libx264 @ 00000202ddab6e80] Weighted P-Frames: Y:31.1% UV:22.8%
[libx264 @ 00000202ddab6e80] ref P L0: 48.6% 19.1% 20.9% 9.5% 1.9%
[libx264 @ 00000202ddab6e80] ref B L0: 89.7% 8.4% 1.8%
[libx264 @ 00000202ddab6e80] ref B L1: 96.4% 3.6%
[libx264 @ 00000202ddab6e80] kb/s:529.34
[aac @ 00000202ddab8780] Qavg: 356.888
ffmpeg -i input.mpg -map 0:1 bbb_audio.mp3
ffmpeg -i input.mpg -map 0:1 bbb_audio.mp3
ffmpeg version 5.0.1-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11.2.0 (Rev7, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
Input #0, mpeg, from 'input.mpg':
Duration: 02:26:12.00, start: 0.193178, bitrate: 6296 kb/s
Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bt470bg, top first), 720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 90k tbn
Side data:
cpb: bitrate max/min/avg: 8500000/0/0 buffer size: 1835008 vbv_delay: N/A
Stream #0:1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 224 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (mp2 (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, mp3, to 'bbb_audio.mp3':
Metadata:
TSSE : Lavf59.16.100
Stream #0:0: Audio: mp3, 48000 Hz, stereo, s16p
Metadata:
encoder : Lavc59.18.100 libmp3lame
size= 137063kB time=02:26:12.00 bitrate= 128.0kbits/s speed=31.5x
video:0kB audio:137063kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000169%
-ss
можно вырезать нужный фрагмент аудиодорожки.
ffmpeg \
-f pulse \
-i alsa_output.platform-snd_aloop.0.analog-surround-51.monitor \
-f kmsgrab \
-thread_queue_size 64 \ # уменьшает задержку ввода
-i - \
# Capture and downscale frames on the GPU:
-vf 'hwmap=derive_device=vaapi,scale_vaapi=1280:720,hwdownload,format=bgr0' \
-c:v libx264 \
-preset:v superfast \ # максимально быстрое кодирование видео
-tune zerolatency \ # настройка кодека на нулевую задержку
-intra-refresh 1 \ # уменьшает задержку и уменьшает потери пакетов
-f mpegts \ # объединение в поток mpegts, который хорошо подходит для данного случая
-b:v 3M \ # целевая полоса пропускания для итогового видео
udp://$hackerspace:41841
ffmpeg -y \
-ss 20 -t 60 -i bbb_sunflower_1080p_60fps_normal.mp4 \
-i train.jpg \
-ss 4 -i voice_recording.wav \
-filter_complex "[0:v]hue=h=80:s=1[main] ; [1:v]crop=w=382:h=304:x=289:y=227[train] ; [main][train]overlay=x=200:y=200,vignette=PI/4[video] ; [2:a]volume=1.5,aecho=0.8:0.9:100:0.3[speech] ; [0:a][speech]amix=duration=shortest,asplit[audio1][audio2]" \
-map '[video]' -map '[audio1]' -metadata title="Editor's cut" bbb_edited.mp4 \
-map '[audio2]' bbb_edited_audio_only.wav
-ss 20 -t 60
).train.jpg
.crop
).hue
).voice_recording.wav
.на главную сниппетов