나는 두 개의 입력 받아 FFMPEG에 대한 bash는 스크립트가 Awoo.mkv
와 Awoo1.mkv
.
./ffmpeg -y \
-i Awoo.mkv \
-i Awoo2.mkv \
이 두 파일은 복잡한 필터를 사용하여 연결됩니다. 향후 코덱이 다른 파일도 연결되기 때문입니다. 이 필터로부터 두 개의 출력이 생성된다 [outv]
하고 [outa]
.
-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]" \
-map '[outv]' -map '[outa]' \
그런 다음 비디오는 다양한 설정으로 두 개의 별도 스트림으로 다시 인코딩됩니다. 스트림 v : 0 및 a : 0은 1080, 스트림 v : 1 및 a : 1은 720입니다.
-c:v:0 libx264 -b:v:0 4000k -s:v:0 1920x1080 -r:v:0 30 -g:v:0 90 -preset:v:0 superfast -tune:v:0 zerolatency -level:v:0 4 -pix_fmt:v:0 yuv420p -c:a:0 aac -b:a:0 512k \
-c:v:1 libx264 -b:v:1 2500k -s:v:1 1280x720 -r:v:1 30 -g:v:1 90 -preset:v:1 superfast -tune:v:1 zerolatency -level:v:1 4 -pix_fmt:v:1 yuv420p -c:a:1 aac -b:a:1 256k \
최종 출력은 HLS에 있으므로 일부 세부 정보가 포함됩니다.
-hls_time 6 \
-hls_list_size 2 \
-hls_flags delete_segments \
-f hls -master_pl_name "${name}.m3u8" \
그런 다음 다시 인코딩 된 출력 스트림이 매핑됩니다.이 시점에서 서로 다른 품질 설정에 대한 두 개의 출력이 있습니다.
-map 0:v -map 0:a -map 0:v -map 0:a \
그런 다음 변형 스트림 매핑이 정의되어 m3u8 재생 목록에 두 출력 스트림이 모두 포함됩니다.
-var_stream_map "v:0,a:0 v:1,a:1" \
그리고 마지막으로 HLS에 대한 추가 정보가 있습니다.
-hls_segment_filename "sequence/${name}_%v-%d.ts" \
"sequence/${name}_%v.m3u8"
전체 스크립트입니다.
name=gw
./ffmpeg -y \
-i Awoo.mkv \
-i Awoo2.mkv \
-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]" \
-map '[outv]' -map '[outa]' \
-c:v:0 libx264 -b:v:0 4000k -s:v:0 1920x1080 -r:v:0 30 -g:v:0 90 -preset:v:0 superfast -tune:v:0 zerolatency -level:v:0 4 -pix_fmt:v:0 yuv420p -c:a:0 aac -b:a:0 512k \
-c:v:1 libx264 -b:v:1 2500k -s:v:1 1280x720 -r:v:1 30 -g:v:1 90 -preset:v:1 superfast -tune:v:1 zerolatency -level:v:1 4 -pix_fmt:v:1 yuv420p -c:a:1 aac -b:a:1 256k \
-hls_time 6 \
-hls_list_size 2 \
-hls_flags delete_segments \
-f hls -master_pl_name "${name}.m3u8" \
-map 0:v -map 0:a -map 0:v -map 0:a \
-var_stream_map "v:0,a:0 v:1,a:1" \
-hls_segment_filename "sequence/${name}_%v-%d.ts" \
"sequence/${name}_%v.m3u8"
연결 필터와 단일 입력이 없으면이 스크립트가 제대로 작동한다는 것을 알고 있습니다. 연결 필터를 정확히 어떻게 사용할 수 있는지, 특히 매핑 명령과 작동 방식을 사용하여 연결 필터를 정확하게 작동시키는 데 문제가 있습니다.
이 스크립트를 현재 상태로 실행하려고하면 오류가 발생합니다.
[hls @ 0x6a30180] Unable to find mapping variant stream
av_interleaved_write_frame(): Cannot allocate memory
이것은 전체 출력입니다.
ffmpeg version 4.0.3-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, matroska,webm, from 'Awoo.mkv':
Metadata:
COMPATIBLE_BRANDS: iso6avc1mp41
MAJOR_BRAND : dash
MINOR_VERSION : 0
ENCODER : Lavf56.40.101
Duration: 00:02:24.35, start: 0.000000, bitrate: 1114 kb/s
Stream #0:0(und): Video: h264 (Main), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 29 fps, 29 tbr, 1k tbn, 58 tbc (default)
Metadata:
CREATION_TIME : 2017-01-27 05:02:53
LANGUAGE : und
HANDLER_NAME : VideoHandler
DURATION : 00:02:24.310000000
Stream #0:1(eng): Audio: vorbis, 44100 Hz, stereo, fltp (default)
Metadata:
LANGUAGE : eng
DURATION : 00:02:24.348000000
Input #1, matroska,webm, from 'Awoo2.mkv':
Metadata:
COMPATIBLE_BRANDS: iso6avc1mp41
MAJOR_BRAND : dash
MINOR_VERSION : 0
ENCODER : Lavf56.40.101
Duration: 00:02:24.35, start: 0.000000, bitrate: 1114 kb/s
Stream #1:0(und): Video: h264 (Main), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 29 fps, 29 tbr, 1k tbn, 58 tbc (default)
Metadata:
CREATION_TIME : 2017-01-27 05:02:53
LANGUAGE : und
HANDLER_NAME : VideoHandler
DURATION : 00:02:24.310000000
Stream #1:1(eng): Audio: vorbis, 44100 Hz, stereo, fltp (default)
Metadata:
LANGUAGE : eng
DURATION : 00:02:24.348000000
Stream mapping:
Stream #0:0 (h264) -> concat:in0:v0 (graph 0)
Stream #0:1 (vorbis) -> concat:in0:a0 (graph 0)
Stream #1:0 (h264) -> concat:in1:v0 (graph 0)
Stream #1:1 (vorbis) -> concat:in1:a0 (graph 0)
concat:out:v0 (graph 0) -> Stream #0:0 (libx264)
concat:out:a0 (graph 0) -> Stream #0:1 (aac)
Stream #0:0 -> #0:2 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:3 (vorbis (native) -> aac (native))
Stream #0:0 -> #0:4 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:5 (vorbis (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x6a35bc0] using SAR=1/1
[libx264 @ 0x6a35bc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x6a35bc0] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x6a35bc0] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x3 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 lookahead_threads=4 sliced_threads=1 slices=4 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=90 keyint_min=9 scenecut=40 intra_refresh=0 rc=abr mbtree=0 bitrate=2500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[libx264 @ 0x6a02980] using SAR=1/1
[libx264 @ 0x6a02980] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x6a02980] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x6a02980] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - 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
[libx264 @ 0x6b72640] using SAR=1/1
[libx264 @ 0x6b72640] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x6b72640] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x6b72640] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x3 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 lookahead_threads=4 sliced_threads=1 slices=4 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=90 keyint_min=9 scenecut=40 intra_refresh=0 rc=abr mbtree=0 bitrate=4000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[hls @ 0x6a30180] Opening 'sequence/gw_0-0.ts' for writing
[hls @ 0x6a30180] Opening 'sequence/gw_1-0.ts' for writing
Output #0, hls, to 'sequence/gw_%v.m3u8':
Metadata:
COMPATIBLE_BRANDS: iso6avc1mp41
MAJOR_BRAND : dash
MINOR_VERSION : 0
encoder : Lavf58.12.100
Stream #0:0: Video: h264 (libx264), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 4000 kb/s, 30 fps, 90k tbn, 30 tbc
Metadata:
encoder : Lavc58.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/4000000 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 512 kb/s
Metadata:
encoder : Lavc58.18.100 aac
Stream #0:2(und): Video: h264 (libx264), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2500 kb/s, 30 fps, 90k tbn, 30 tbc (default)
Metadata:
CREATION_TIME : 2017-01-27 05:02:53
LANGUAGE : und
HANDLER_NAME : VideoHandler
DURATION : 00:02:24.310000000
encoder : Lavc58.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/2500000 buffer size: 0 vbv_delay: -1
Stream #0:3(eng): Audio: aac (LC), 44100 Hz, stereo, fltp, 256 kb/s (default)
Metadata:
LANGUAGE : eng
DURATION : 00:02:24.348000000
encoder : Lavc58.18.100 aac
Stream #0:4(und): Video: h264 (libx264), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 29 fps, 29 tbn, 29 tbc (default)
Metadata:
CREATION_TIME : 2017-01-27 05:02:53
LANGUAGE : und
HANDLER_NAME : VideoHandler
DURATION : 00:02:24.310000000
encoder : Lavc58.18.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:5(eng): Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
LANGUAGE : eng
DURATION : 00:02:24.348000000
encoder : Lavc58.18.100 aac
frame= 41 fps=0.0 q=18.0 q=17.0 q=0.0 size=N/A time=00:00:01.46 bitrate=N/A du
[hls @ 0x6a30180] Unable to find mapping variant stream
av_interleaved_write_frame(): Cannot allocate memory