비디오를 고정 크기가 아닌 GOP로 분할하고 비디오의 각 부분 (GOP)을 개별적으로 트랜스 코딩하려고합니다. HLS (HTTP Streaming Protocol)를 사용하려고하므로 이러한 비디오 덩어리는 MPEG2-TS (.ts)입니다.
비디오 분할이 제대로 작동하는 것 같습니다. manifest (.m3u8) 파일을 만들고 VLC에서 정상적으로 실행됩니다. 그러나 비디오를 트랜스 코딩 한 후에는 세그먼트 전환, 지연 (회색 화면)에 문제가있는 것으로 보입니다.
다음은 비디오를 분할하는 데 사용하는 명령입니다
ffmpeg.exe -i videotest.mp4 -vcodec copy -reset_timestamps 1 -map 0 -hls_list_size 0 out.m3u8
이 명령은 비디오를 10 개 부분 (.ts 파일)으로 분할하고 매니페스트 파일 (.m3u8)을 생성합니다
이것은 출력입니다.
ffmpeg version N-81045-g450cf40 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-
version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-
nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-
fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-
libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-
libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-
libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-
librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr -
-enable-libspeex --enable-libtheora --enable-libtwolame --enable-
libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --
enable-decklink --enable-zlib
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 50.100 / 57. 50.100
libavformat 57. 42.100 / 57. 42.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 47.100 / 6. 47.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'videotest.mp4':
Metadata:
major_brand : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2015-09-03 15:02:55
title : Fantastic Four: Rise of the Silver Surfer - Theatrical Trailer
artist : 20th Century Fox
date : 2007
encoder : HandBrake 0.10.2 2015061100
genre : Trailer
Duration: 00:00:25.07, start: 0.000000, bitrate: 1884 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x544 [SAR 1:1 DAR 40:17], 1742 kb/s, 23.90 fps, 23.98 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2015-09-03 15:02:55
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 135 kb/s (default)
Metadata:
creation_time : 2015-09-03 15:02:55
handler_name : Stereo
[hls @ 000000000127c340] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
Last message repeated 1 times
Output #0, hls, to 'out.m3u8':
Metadata:
major_brand : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
genre : Trailer
title : Fantastic Four: Rise of the Silver Surfer - Theatrical Trailer
artist : 20th Century Fox
date : 2007
encoder : Lavf57.42.100
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x544 [SAR 1:1 DAR 40:17], q=2-31, 1742 kb/s, 23.90 fps, 23.98 tbr, 90k tbn, 90k tbc (default)
Metadata:
creation_time : 2015-09-03 15:02:55
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2015-09-03 15:02:55
handler_name : Stereo
encoder : Lavc57.50.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored bitrate=N/A speed=29.3x
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
frame= 599 fps=0.0 q=-1.0 Lsize=N/A time=00:00:25.02 bitrate=N/A speed= 29x
video:5333kB audio:314kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[aac @ 000000000127f620] Qavg: 17473.217
지금까지 m3u8 파일을 실행하면 정상적으로 작동합니다.
다음은 비디오의 각 세그먼트를 인코딩하는 데 사용하는 명령입니다
ffmpeg.exe -i segment0.ts -vcodec libx264 -s 640:480 -map 0 outputEncoded0.ts
스크립트를 사용하여 각 세그먼트에 대해이 명령을 실행하고 있습니다.
#/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for file in /home/pi/Desktop/videoExamples/videosTranscode/*;
do
echo "doing stuff"
filename="${file##*/}"
filename="${filename%.*}"
ffmpeg.exe -i $file -vcodec libx264 -s 640:480 -map 0 $filename.ts
done
IFS=SAVEIFS
출력은 다음과 같습니다
ffmpeg version N-81045-g450cf40 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-
version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-
nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-
fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-
libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-
libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-
libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-
librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr -
-enable-libspeex --enable-libtheora --enable-libtwolame --enable-
libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --
enable-decklink --enable-zlib
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 50.100 / 57. 50.100
libavformat 57. 42.100 / 57. 42.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 47.100 / 6. 47.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mpegts, from 'out0.ts':
Duration: 00:00:05.69, start: 1.503789, bitrate: 215 kb/s
Program 1
Metadata:
service_name : Fantastic Four: Rise of the Silver Surfer - Theatrical Trailer
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1280x544 [SAR 1:1 DAR 40:17], 23.98 tbr, 90k tbn, 180k tbc
Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 11 kb/s
fixme:msvcrt:MSVCRT__wsopen_s : pmode 0x01b6 ignored
[libx264 @ 0000000001244ae0] using SAR=30/17
[libx264 @ 0000000001244ae0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0000000001244ae0] profile High, level 3.0
[mpegts @ 00000000012433e0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mpegts, to 'outputEncoded0.ts':
Metadata:
encoder : Lavf57.42.100
Stream #0:0: Video: h264 (libx264), yuv420p, 640x480 [SAR 30:17 DAR 40:17], q=-1--1, 23.98 fps, 90k tbn, 23.98 tbc
Metadata:
encoder : Lavc57.50.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
Metadata:
encoder : Lavc57.50.100 mp2
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> mp2 (native))
Press [q] to stop, [?] for help
frame= 116 fps=0.0 q=28.0 size= 174kB time=00:00:04.90 bitrate= 291.0kbits/frame= 135 fps=0.0 q=-1.0 Lsize= 344kB time=00:00:05.60 bitrate= 503.0kbits/s speed=7.82x
video:28kB audio:263kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 18.113007%
[libx264 @ 0000000001244ae0] frame I:1 Avg QP:15.64 size: 16539
[libx264 @ 0000000001244ae0] frame P:36 Avg QP:13.14 size: 201
[libx264 @ 0000000001244ae0] frame B:98 Avg QP:18.22 size: 52
[libx264 @ 0000000001244ae0] consecutive B-frames: 3.0% 0.0% 2.2% 94.8%
[libx264 @ 0000000001244ae0] mb I I16..4: 21.8% 65.8% 12.3%
[libx264 @ 0000000001244ae0] mb P I16..4: 0.7% 1.9% 0.0% P16..4: 2.1% 0.2% 0.1% 0.0% 0.0% skip:95.0%
[libx264 @ 0000000001244ae0] mb B I16..4: 0.0% 0.2% 0.0% B16..8: 1.7% 0.0% 0.0% direct: 0.0% skip:98.1% L0:47.1% L1:52.9% BI: 0.0%
[libx264 @ 0000000001244ae0] 8x8 transform intra:71.6% inter:84.1%
[libx264 @ 0000000001244ae0] coded y,uvDC,uvAC intra: 17.1% 18.0% 7.8% inter: 0.1% 0.1% 0.0%
[libx264 @ 0000000001244ae0] i16 v,h,dc,p: 61% 33% 4% 2%
[libx264 @ 0000000001244ae0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 47% 9% 41% 1% 0% 1% 0% 1% 1%
[libx264 @ 0000000001244ae0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 51% 20% 5% 2% 3% 4% 4% 3% 7%
[libx264 @ 0000000001244ae0] i8c dc,h,v,p: 81% 10% 9% 1%
[libx264 @ 0000000001244ae0] Weighted P-Frames: Y:5.6% UV:5.6%
[libx264 @ 0000000001244ae0] ref P L0: 79.4% 1.1% 12.6% 6.9%
[libx264 @ 0000000001244ae0] ref B L0: 52.6% 40.8% 6.6%
[libx264 @ 0000000001244ae0] ref B L1: 84.0% 16.0%
[libx264 @ 0000000001244ae0] kb/s:40.72
제시된 오류는 한 세그먼트에서 다음 세그먼트로의 전환이 지연되는 것입니다. 때때로 발생하는 또 다른 오류가 있습니다. 첫 번째 세그먼트는 정상적으로 재생되지만 두 번째 세그먼트가 시작되면 실제로 빠르게 재생되며 다른 모든 세그먼트는 동시에 재생되는 것처럼 보입니다.
https://drive.google.com/open?id=0B2kwpgNH6c0AMy0zemxuUk84clU 원본 비디오 및 생성 된 매니페스트와 함께이 예제에서 사용하고 만든 파일은 다음과 같습니다.
나는 FFmpeg를 처음 사용하고 포럼에도 익숙하지 않으므로 내가 잘못한 경우 알려주십시오.
누구든지 저를 도울 수 있습니까?