Trying to solve drop in quality

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to solve drop in quality

FFmpeg-users mailing list
I've been trying to hit the specs we need to match for an HLS live stream and I’ve created an ffmpeg 2 pass command to convert some existing mp4 files into HLS so they can be used.

The mp4 test file I am using is http://fkwi.com/livestreams/test/currentweather.mp4 and it is 60 seconds long and 16,991,549 in size.

The converted HLS file is http://fkwi.com/livestreams/test/test1/video.m3u8 and it is (naturally) 60 seconds long and the .ts files add up to 17,584,392 bytes.

The quality of the HLS encode is horrible compared to the original and I can’t figure out where I am going sideways with it. I’m even trying a 2 pass encode. I convert our mp4’s to HLS all the time with no issues (but not to these specs.) We normally use 30FPS, VBR and VFR. You can see the items in the spec I am trying to hit in the mediainfo output at the end of this message.

Below is my ffmpeg command, my entire ffmpeg session output plus a mediainfo report on the HLS encode. In the mediainfo output I’ve added (<——REQUIRED BY SPEC) next to the items that are being required of our video.

I would appreciate any advice on how to maintain better quality on the HLS stream.


==========================ffmpeg command ==========================
/usr/bin/ffmpeg -i "$SOURCE" \
-profile:v main -level 3.1 -s 1280x720  -vf "fps=fps=30*1000/1001:round=zero" \
-c:v libx264 -pass 1 -preset slow -x264-params "nal-hrd=cbr:scenecut=0:ref=2:force-cfr=1" -g 2 \
-b:v 2M -maxrate 2.0M -minrate 2.0M -bufsize 8M \
-b:a 128k -ar 48000 -f hls logfile && /usr/bin/ffmpeg -i "$SOURCE" \
-profile:v main -level 3.1 -s 1280x720  -vf "fps=fps=30*1000/1001:round=zero" \
-c:v libx264 -pass 2 -preset slow -x264-params "nal-hrd=cbr:scenecut=0:ref=2:force-cfr=1" -g 2 \
-f segment -segment_list_type m3u8 -segment_list_size 0 -segment_time 6.006 -segment_time_delta 0.1 \
-b:v 2M -maxrate 2.0M -minrate 2.0M -bufsize 8M \
-b:a 128k -ar 48000 -start_number 0 \
-hls_time 6 -hls_list_size 0 -f hls \
-hls_base_url "$BASEURL" \
-hls_segment_filename "video%04d.ts

==========================  ffmpeg output =============================

ffmpeg version 3.4.8 Copyright (c) 2000-2020 the FFmpeg developers
 built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
 configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --disable-encoder=libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
 libavutil      55. 78.100 / 55. 78.100
 libavcodec     57.107.100 / 57.107.100
 libavformat    57. 83.100 / 57. 83.100
 libavdevice    57. 10.100 / 57. 10.100
 libavfilter     6.107.100 /  6.107.100
 libavresample   3.  7.  0 /  3.  7.  0
 libswscale      4.  8.100 /  4.  8.100
 libswresample   2.  9.100 /  2.  9.100
 libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://fkwi.com/currentweather.mp4':
 Metadata:
   major_brand     : isom
   minor_version   : 512
   compatible_brands: isomiso2avc1mp41
   encoder         : Lavf57.83.100
 Duration: 00:01:00.00, start: 0.000000, bitrate: 2265 kb/s
   Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2183 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
   Metadata:
     handler_name    : VideoHandler
   Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 81 kb/s (default)
   Metadata:
     handler_name    : SoundHandler
Stream mapping:
 Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
 Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x241d860] using SAR=1/1
[libx264 @ 0x241d860] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x241d860] profile Main, level 3.1
[libx264 @ 0x241d860] 264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x1:0 me=dia subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=22 lookahead_threads=5 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=1 b_pyramid=0 b_adapt=1 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=2 keyint_min=1 scenecut=0 intra_refresh=0 rc_lookahead=50 rc=cbr mbtree=1 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=2000 vbv_bufsize=8000 nal_hrd=cbr filler=1 ip_ratio=1.40 aq=1:1.00
[hls @ 0x2383440] Opening 'logfile0.ts' for writing
Output #0, hls, to 'logfile':
 Metadata:
   major_brand     : isom
   minor_version   : 512
   compatible_brands: isomiso2avc1mp41
   encoder         : Lavf57.83.100
   Stream #0:0(und): Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 29.97 fps, 90k tbn, 29.97 tbc (default)
   Metadata:
     handler_name    : VideoHandler
     encoder         : Lavc57.107.100 libx264
   Side data:
     cpb: bitrate max/min/avg: 2000000/0/2000000 buffer size: 8000000 vbv_delay: -1
   Stream #0:1(eng): Audio: aac (LC), 48000 Hz, mono, fltp, 128 kb/s (default)
   Metadata:
     handler_name    : SoundHandler
     encoder         : Lavc57.107.100 aac
[hls @ 0x2383440] Opening 'logfile1.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile2.ts' for writing9 bitrate=N/A speed=13.2x    
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile3.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile4.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile5.ts' for writing0 bitrate=N/A speed=12.3x    
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile6.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile7.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile8.ts' for writing2 bitrate=N/A speed=11.8x    
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile9.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile10.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile11.ts' for writing bitrate=N/A speed=11.7x    
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile12.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile13.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile14.ts' for writing bitrate=N/A speed=11.6x    
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile15.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile16.ts' for writing bitrate=N/A speed=11.3x    
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile17.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile18.ts' for writing bitrate=N/A speed=11.1x    
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile19.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile20.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile21.ts' for writing bitrate=N/A speed=  11x    
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile22.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile23.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile24.ts' for writing bitrate=N/A speed=  11x    
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile25.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile26.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile27.ts' for writing bitrate=N/A speed=  11x    
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile28.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile29.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
   Last message repeated 1 times
frame= 1798 fps=322 q=-1.0 Lsize=N/A time=00:00:59.92 bitrate=N/A speed=10.7x    
video:15041kB audio:886kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x241d860] frame I:899   Avg QP:41.41  size: 16733
[libx264 @ 0x241d860] frame P:899   Avg QP:48.09  size:   399
[libx264 @ 0x241d860] mb I  I16..4: 84.2%  0.0% 15.8%
[libx264 @ 0x241d860] mb P  I16..4:  0.2%  0.0%  0.0%  P16..4:  6.8%  0.0%  0.0%  0.0%  0.0%    skip:93.0%
[libx264 @ 0x241d860] coded y,uvDC,uvAC intra: 37.6% 30.1% 12.0% inter: 0.1% 0.4% 0.0%
[libx264 @ 0x241d860] i16 v,h,dc,p: 26% 49% 19%  6%
[libx264 @ 0x241d860] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 20% 20%  5%  5%  6%  5%  6%  4%
[libx264 @ 0x241d860] i8c dc,h,v,p: 69% 26%  4%  1%
[libx264 @ 0x241d860] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x241d860] kb/s:2053.70
[aac @ 0x23ea640] Qavg: 5516.975
+ /usr/bin/ffmpeg -i https://fkwi.com/currentweather.mp4 -profile:v main -level 3.1 -s 1280x720 -vf 'fps=fps=30*1000/1001:round=zero' -c:v libx264 -pass 2 -preset slow -x264-params nal-hrd=cbr:scenecut=0:ref=2:force-cfr=1 -g 2 -f segment -segment_list_type m3u8 -segment_list_size 0 -segment_time 6.006 -segment_time_delta 0.1 -b:v 2M -maxrate 2.0M -minrate 2.0M -bufsize 8M -b:a 128k -ar 48000 -start_number 0 -hls_time 6 -hls_list_size 0 -f hls -hls_base_url http://fkwi.com/livestreams/test/test1/ -hls_segment_filename video%04d.ts video.m3u8
ffmpeg version 3.4.8 Copyright (c) 2000-2020 the FFmpeg developers
 built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
 configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --disable-encoder=libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
 libavutil      55. 78.100 / 55. 78.100
 libavcodec     57.107.100 / 57.107.100
 libavformat    57. 83.100 / 57. 83.100
 libavdevice    57. 10.100 / 57. 10.100
 libavfilter     6.107.100 /  6.107.100
 libavresample   3.  7.  0 /  3.  7.  0
 libswscale      4.  8.100 /  4.  8.100
 libswresample   2.  9.100 /  2.  9.100
 libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://fkwi.com/currentweather.mp4':
 Metadata:
   major_brand     : isom
   minor_version   : 512
   compatible_brands: isomiso2avc1mp41
   encoder         : Lavf57.83.100
 Duration: 00:01:00.00, start: 0.000000, bitrate: 2265 kb/s
   Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2183 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
   Metadata:
     handler_name    : VideoHandler
   Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 81 kb/s (default)
   Metadata:
     handler_name    : SoundHandler
Stream mapping:
 Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
 Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x246cee0] using SAR=1/1
[libx264 @ 0x246cee0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x246cee0] profile Main, level 3.1
[libx264 @ 0x246cee0] x264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=22 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=1 b_pyramid=0 b_adapt=1 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=2 keyint_min=1 scenecut=0 intra_refresh=0 rc_lookahead=50 rc=2pass mbtree=1 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 cplxblur=20.0 qblur=0.5 vbv_maxrate=2000 vbv_bufsize=8000 nal_hrd=cbr filler=1 ip_ratio=1.40 aq=1:1.00
[hls @ 0x2444cc0] Opening 'video0000.ts' for writing
Output #0, hls, to 'video.m3u8':
 Metadata:
   major_brand     : isom
   minor_version   : 512
   compatible_brands: isomiso2avc1mp41
   encoder         : Lavf57.83.100
   Stream #0:0(und): Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 29.97 fps, 90k tbn, 29.97 tbc (default)
   Metadata:
     handler_name    : VideoHandler
     encoder         : Lavc57.107.100 libx264
   Side data:
     cpb: bitrate max/min/avg: 2000000/0/2000000 buffer size: 8000000 vbv_delay: -1
   Stream #0:1(eng): Audio: aac (LC), 48000 Hz, mono, fltp, 128 kb/s (default)
   Metadata:
     handler_name    : SoundHandler
     encoder         : Lavc57.107.100 aac
[hls @ 0x2444cc0] Opening 'video0001.ts' for writing bitrate=N/A speed=11.4x    
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0002.ts' for writing bitrate=N/A speed=11.2x    
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0003.ts' for writing bitrate=N/A speed=10.8x    
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0004.ts' for writing bitrate=N/A speed=10.5x    
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0005.ts' for writing bitrate=N/A speed=10.1x    
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0006.ts' for writing bitrate=N/A speed=9.99x    
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0007.ts' for writing bitrate=N/A speed=9.95x    
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0008.ts' for writing bitrate=N/A speed=9.83x    
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0009.ts' for writing bitrate=N/A speed=9.65x    
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writingitrate=N/A speed=9.49x    
frame= 1798 fps=287 q=-1.0 Lsize=N/A time=00:00:59.92 bitrate=N/A speed=9.56x    
video:15291kB audio:886kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x246cee0] frame I:899   Avg QP:42.31  size: 16121
[libx264 @ 0x246cee0] frame P:899   Avg QP:45.32  size:  1296
[libx264 @ 0x246cee0] mb I  I16..4: 69.9%  0.0% 30.1%
[libx264 @ 0x246cee0] mb P  I16..4:  0.4%  0.0%  0.0%  P16..4:  8.8%  0.6%  0.7%  0.0%  0.0%    skip:89.6%
[libx264 @ 0x246cee0] coded y,uvDC,uvAC intra: 29.7% 31.0% 12.5% inter: 0.0% 0.2% 0.0%
[libx264 @ 0x246cee0] i16 v,h,dc,p: 14% 61%  8% 17%
[libx264 @ 0x246cee0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19%  7% 20%  7%  9%  6%  8%  8% 16%
[libx264 @ 0x246cee0] i8c dc,h,v,p: 56% 37%  5%  2%
[libx264 @ 0x246cee0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x246cee0] kb/s:2087.90
[aac @ 0x246e8e0] Qavg: 5516.975


======================================== MEDIAINFO===========================

mediainfo video0000.ts
General
ID                                       : 1 (0x1)
Complete name                            : video0000.ts
Format                                   : MPEG-TS
File size                                : 1.52 MiB
Duration                                 : 5 s 939 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 2 125 kb/s

Video
ID                                       : 256 (0x100)
Menu ID                                  : 1 (0x1)
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3.1                <——REQUIRED BY SPEC
Format settings                          : CABAC / 2 Ref Frames     <——REQUIRED BY SPEC
Format settings, CABAC                   : Yes                      <——REQUIRED BY SPEC
Format settings, Reference frames        : 2 frames                 <——REQUIRED BY SPEC
Format settings, GOP                     : M=1, N=2
Codec ID                                 : 27                       <——REQUIRED BY SPEC
Duration                                 : 6 s 6 ms
Bit rate mode                            : Constant                 <——REQUIRED BY SPEC
Nominal bit rate                         : 2 000 kb/s               <——REQUIRED BY SPEC
Width                                    : 1 280 pixels             <——REQUIRED BY SPEC
Height                                   : 720 pixels               <——REQUIRED BY SPEC
Display aspect ratio                     : 16:9
Frame rate                               : 29.970 (30000/1001) FPS  <——REQUIRED BY SPEC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.072
Writing library                          : x264 core 148 r2795 aaa9aa8
Encoding settings                        : cabac=1 / ref=2 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=8 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=22 / lookahead_threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=1 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=2 / keyint_min=1 / scenecut=0 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=2000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=2000 / vbv_bufsize=8000 / nal_hrd=cbr / filler=1 / ip_ratio=1.40 / aq=1:1.00

Audio
ID                                       : 257 (0x101)
Menu ID                                  : 1 (0x1)
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Format version                           : Version 4
Muxing mode                              : ADTS
Codec ID                                 : 15-2
Duration                                 : 5 s 824 ms
Bit rate mode                            : Variable
Channel(s)                               : 1 channel
Channel layout                           : C
Sampling rate                            : 48.0 kHz                     <——REQUIRED BY SPEC
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Delay relative to video                  : -21 ms
Language                                 : English
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Trying to solve drop in quality

Marton Balint


On Tue, 3 Nov 2020, John Harlow via ffmpeg-user wrote:

> I've been trying to hit the specs we need to match for an HLS live stream and I’ve created an ffmpeg 2 pass command to convert some existing mp4 files into HLS so they can be used.
>
> The mp4 test file I am using is http://fkwi.com/livestreams/test/currentweather.mp4 and it is 60 seconds long and 16,991,549 in size.
>
> The converted HLS file is http://fkwi.com/livestreams/test/test1/video.m3u8 and it is (naturally) 60 seconds long and the .ts files add up to 17,584,392 bytes.
>
> The quality of the HLS encode is horrible compared to the original and I can’t figure out where I am going sideways with it. I’m even trying a 2 pass encode. I convert our mp4’s to HLS all the time with no issues (but not to these specs.) We normally use 30FPS, VBR and VFR. You can see the items in the spec I am trying to hit in the mediainfo output at the end of this message.
>
> Below is my ffmpeg command, my entire ffmpeg session output plus a mediainfo report on the HLS encode. In the mediainfo output I’ve added (<——REQUIRED BY SPEC) next to the items that are being required of our video.
>
> I would appreciate any advice on how to maintain better quality on the HLS stream.
>
>
> ==========================ffmpeg command ==========================
> /usr/bin/ffmpeg -i "$SOURCE" \
> -profile:v main -level 3.1 -s 1280x720  -vf "fps=fps=30*1000/1001:round=zero" \
> -c:v libx264 -pass 1 -preset slow -x264-params "nal-hrd=cbr:scenecut=0:ref=2:force-cfr=1" -g 2 \

-g 2 is very strange, it is GOP size and expressed in number of frames,
not seconds. That surely does not help with quality.

> -b:v 2M -maxrate 2.0M -minrate 2.0M -bufsize 8M \

Is CBR really a requirement? If not, use CRF mode, alternatively with a
bitrate cap.

Regards,
Marton

> -b:a 128k -ar 48000 -f hls logfile && /usr/bin/ffmpeg -i "$SOURCE" \
> -profile:v main -level 3.1 -s 1280x720  -vf "fps=fps=30*1000/1001:round=zero" \
> -c:v libx264 -pass 2 -preset slow -x264-params "nal-hrd=cbr:scenecut=0:ref=2:force-cfr=1" -g 2 \
> -f segment -segment_list_type m3u8 -segment_list_size 0 -segment_time 6.006 -segment_time_delta 0.1 \
> -b:v 2M -maxrate 2.0M -minrate 2.0M -bufsize 8M \
> -b:a 128k -ar 48000 -start_number 0 \
> -hls_time 6 -hls_list_size 0 -f hls \
> -hls_base_url "$BASEURL" \
> -hls_segment_filename "video%04d.ts
>
> ==========================  ffmpeg output =============================
>
> ffmpeg version 3.4.8 Copyright (c) 2000-2020 the FFmpeg developers
> built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
> configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --disable-encoder=libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-l
 ibvorbis --enable-libv4l2 --enable-libvidstab --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect

> libavutil      55. 78.100 / 55. 78.100
> libavcodec     57.107.100 / 57.107.100
> libavformat    57. 83.100 / 57. 83.100
> libavdevice    57. 10.100 / 57. 10.100
> libavfilter     6.107.100 /  6.107.100
> libavresample   3.  7.  0 /  3.  7.  0
> libswscale      4.  8.100 /  4.  8.100
> libswresample   2.  9.100 /  2.  9.100
> libpostproc    54.  7.100 / 54.  7.100
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://fkwi.com/currentweather.mp4':
> Metadata:
>   major_brand     : isom
>   minor_version   : 512
>   compatible_brands: isomiso2avc1mp41
>   encoder         : Lavf57.83.100
> Duration: 00:01:00.00, start: 0.000000, bitrate: 2265 kb/s
>   Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2183 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
>   Metadata:
>     handler_name    : VideoHandler
>   Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 81 kb/s (default)
>   Metadata:
>     handler_name    : SoundHandler
> Stream mapping:
> Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
> Stream #0:1 -> #0:1 (aac (native) -> aac (native))
> Press [q] to stop, [?] for help
> [libx264 @ 0x241d860] using SAR=1/1
> [libx264 @ 0x241d860] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
> [libx264 @ 0x241d860] profile Main, level 3.1
> [libx264 @ 0x241d860] 264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x1:0 me=dia subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=22 lookahead_threads=5 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=1 b_pyramid=0 b_adapt=1 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=2 keyint_min=1 scenecut=0 intra_refresh=0 rc_lookahead=50 rc=cbr mbtree=1 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=2000 vbv_bufsize=8000 nal_hrd=cbr filler=1 ip_ratio=1.40 aq=1:1.00
> [hls @ 0x2383440] Opening 'logfile0.ts' for writing
> Output #0, hls, to 'logfile':
> Metadata:
>   major_brand     : isom
>   minor_version   : 512
>   compatible_brands: isomiso2avc1mp41
>   encoder         : Lavf57.83.100
>   Stream #0:0(und): Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 29.97 fps, 90k tbn, 29.97 tbc (default)
>   Metadata:
>     handler_name    : VideoHandler
>     encoder         : Lavc57.107.100 libx264
>   Side data:
>     cpb: bitrate max/min/avg: 2000000/0/2000000 buffer size: 8000000 vbv_delay: -1
>   Stream #0:1(eng): Audio: aac (LC), 48000 Hz, mono, fltp, 128 kb/s (default)
>   Metadata:
>     handler_name    : SoundHandler
>     encoder         : Lavc57.107.100 aac
> [hls @ 0x2383440] Opening 'logfile1.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile2.ts' for writing9 bitrate=N/A speed=13.2x
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile3.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile4.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile5.ts' for writing0 bitrate=N/A speed=12.3x
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile6.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile7.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile8.ts' for writing2 bitrate=N/A speed=11.8x
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile9.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile10.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile11.ts' for writing bitrate=N/A speed=11.7x
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile12.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile13.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile14.ts' for writing bitrate=N/A speed=11.6x
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile15.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile16.ts' for writing bitrate=N/A speed=11.3x
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile17.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile18.ts' for writing bitrate=N/A speed=11.1x
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile19.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile20.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile21.ts' for writing bitrate=N/A speed=  11x
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile22.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile23.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile24.ts' for writing bitrate=N/A speed=  11x
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile25.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile26.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile27.ts' for writing bitrate=N/A speed=  11x
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile28.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
> [hls @ 0x2383440] Opening 'logfile29.ts' for writing
> [hls @ 0x2383440] Opening 'logfile.tmp' for writing
>   Last message repeated 1 times
> frame= 1798 fps=322 q=-1.0 Lsize=N/A time=00:00:59.92 bitrate=N/A speed=10.7x
> video:15041kB audio:886kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
> [libx264 @ 0x241d860] frame I:899   Avg QP:41.41  size: 16733
> [libx264 @ 0x241d860] frame P:899   Avg QP:48.09  size:   399
> [libx264 @ 0x241d860] mb I  I16..4: 84.2%  0.0% 15.8%
> [libx264 @ 0x241d860] mb P  I16..4:  0.2%  0.0%  0.0%  P16..4:  6.8%  0.0%  0.0%  0.0%  0.0%    skip:93.0%
> [libx264 @ 0x241d860] coded y,uvDC,uvAC intra: 37.6% 30.1% 12.0% inter: 0.1% 0.4% 0.0%
> [libx264 @ 0x241d860] i16 v,h,dc,p: 26% 49% 19%  6%
> [libx264 @ 0x241d860] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 20% 20%  5%  5%  6%  5%  6%  4%
> [libx264 @ 0x241d860] i8c dc,h,v,p: 69% 26%  4%  1%
> [libx264 @ 0x241d860] Weighted P-Frames: Y:0.0% UV:0.0%
> [libx264 @ 0x241d860] kb/s:2053.70
> [aac @ 0x23ea640] Qavg: 5516.975
> + /usr/bin/ffmpeg -i https://fkwi.com/currentweather.mp4 -profile:v main -level 3.1 -s 1280x720 -vf 'fps=fps=30*1000/1001:round=zero' -c:v libx264 -pass 2 -preset slow -x264-params nal-hrd=cbr:scenecut=0:ref=2:force-cfr=1 -g 2 -f segment -segment_list_type m3u8 -segment_list_size 0 -segment_time 6.006 -segment_time_delta 0.1 -b:v 2M -maxrate 2.0M -minrate 2.0M -bufsize 8M -b:a 128k -ar 48000 -start_number 0 -hls_time 6 -hls_list_size 0 -f hls -hls_base_url http://fkwi.com/livestreams/test/test1/ -hls_segment_filename video%04d.ts video.m3u8
> ffmpeg version 3.4.8 Copyright (c) 2000-2020 the FFmpeg developers
> built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
> configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --disable-encoder=libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-l
 ibvorbis --enable-libv4l2 --enable-libvidstab --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect

> libavutil      55. 78.100 / 55. 78.100
> libavcodec     57.107.100 / 57.107.100
> libavformat    57. 83.100 / 57. 83.100
> libavdevice    57. 10.100 / 57. 10.100
> libavfilter     6.107.100 /  6.107.100
> libavresample   3.  7.  0 /  3.  7.  0
> libswscale      4.  8.100 /  4.  8.100
> libswresample   2.  9.100 /  2.  9.100
> libpostproc    54.  7.100 / 54.  7.100
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://fkwi.com/currentweather.mp4':
> Metadata:
>   major_brand     : isom
>   minor_version   : 512
>   compatible_brands: isomiso2avc1mp41
>   encoder         : Lavf57.83.100
> Duration: 00:01:00.00, start: 0.000000, bitrate: 2265 kb/s
>   Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2183 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
>   Metadata:
>     handler_name    : VideoHandler
>   Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 81 kb/s (default)
>   Metadata:
>     handler_name    : SoundHandler
> Stream mapping:
> Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
> Stream #0:1 -> #0:1 (aac (native) -> aac (native))
> Press [q] to stop, [?] for help
> [libx264 @ 0x246cee0] using SAR=1/1
> [libx264 @ 0x246cee0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
> [libx264 @ 0x246cee0] profile Main, level 3.1
> [libx264 @ 0x246cee0] x264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=22 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=1 b_pyramid=0 b_adapt=1 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=2 keyint_min=1 scenecut=0 intra_refresh=0 rc_lookahead=50 rc=2pass mbtree=1 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 cplxblur=20.0 qblur=0.5 vbv_maxrate=2000 vbv_bufsize=8000 nal_hrd=cbr filler=1 ip_ratio=1.40 aq=1:1.00
> [hls @ 0x2444cc0] Opening 'video0000.ts' for writing
> Output #0, hls, to 'video.m3u8':
> Metadata:
>   major_brand     : isom
>   minor_version   : 512
>   compatible_brands: isomiso2avc1mp41
>   encoder         : Lavf57.83.100
>   Stream #0:0(und): Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 29.97 fps, 90k tbn, 29.97 tbc (default)
>   Metadata:
>     handler_name    : VideoHandler
>     encoder         : Lavc57.107.100 libx264
>   Side data:
>     cpb: bitrate max/min/avg: 2000000/0/2000000 buffer size: 8000000 vbv_delay: -1
>   Stream #0:1(eng): Audio: aac (LC), 48000 Hz, mono, fltp, 128 kb/s (default)
>   Metadata:
>     handler_name    : SoundHandler
>     encoder         : Lavc57.107.100 aac
> [hls @ 0x2444cc0] Opening 'video0001.ts' for writing bitrate=N/A speed=11.4x
> [hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
> [hls @ 0x2444cc0] Opening 'video0002.ts' for writing bitrate=N/A speed=11.2x
> [hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
> [hls @ 0x2444cc0] Opening 'video0003.ts' for writing bitrate=N/A speed=10.8x
> [hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
> [hls @ 0x2444cc0] Opening 'video0004.ts' for writing bitrate=N/A speed=10.5x
> [hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
> [hls @ 0x2444cc0] Opening 'video0005.ts' for writing bitrate=N/A speed=10.1x
> [hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
> [hls @ 0x2444cc0] Opening 'video0006.ts' for writing bitrate=N/A speed=9.99x
> [hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
> [hls @ 0x2444cc0] Opening 'video0007.ts' for writing bitrate=N/A speed=9.95x
> [hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
> [hls @ 0x2444cc0] Opening 'video0008.ts' for writing bitrate=N/A speed=9.83x
> [hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
> [hls @ 0x2444cc0] Opening 'video0009.ts' for writing bitrate=N/A speed=9.65x
> [hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
> [hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writingitrate=N/A speed=9.49x
> frame= 1798 fps=287 q=-1.0 Lsize=N/A time=00:00:59.92 bitrate=N/A speed=9.56x
> video:15291kB audio:886kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
> [libx264 @ 0x246cee0] frame I:899   Avg QP:42.31  size: 16121
> [libx264 @ 0x246cee0] frame P:899   Avg QP:45.32  size:  1296
> [libx264 @ 0x246cee0] mb I  I16..4: 69.9%  0.0% 30.1%
> [libx264 @ 0x246cee0] mb P  I16..4:  0.4%  0.0%  0.0%  P16..4:  8.8%  0.6%  0.7%  0.0%  0.0%    skip:89.6%
> [libx264 @ 0x246cee0] coded y,uvDC,uvAC intra: 29.7% 31.0% 12.5% inter: 0.0% 0.2% 0.0%
> [libx264 @ 0x246cee0] i16 v,h,dc,p: 14% 61%  8% 17%
> [libx264 @ 0x246cee0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19%  7% 20%  7%  9%  6%  8%  8% 16%
> [libx264 @ 0x246cee0] i8c dc,h,v,p: 56% 37%  5%  2%
> [libx264 @ 0x246cee0] Weighted P-Frames: Y:0.0% UV:0.0%
> [libx264 @ 0x246cee0] kb/s:2087.90
> [aac @ 0x246e8e0] Qavg: 5516.975
>
>
> ======================================== MEDIAINFO===========================
>
> mediainfo video0000.ts
> General
> ID                                       : 1 (0x1)
> Complete name                            : video0000.ts
> Format                                   : MPEG-TS
> File size                                : 1.52 MiB
> Duration                                 : 5 s 939 ms
> Overall bit rate mode                    : Variable
> Overall bit rate                         : 2 125 kb/s
>
> Video
> ID                                       : 256 (0x100)
> Menu ID                                  : 1 (0x1)
> Format                                   : AVC
> Format/Info                              : Advanced Video Codec
> Format profile                           : Main@L3.1                <——REQUIRED BY SPEC
> Format settings                          : CABAC / 2 Ref Frames     <——REQUIRED BY SPEC
> Format settings, CABAC                   : Yes                      <——REQUIRED BY SPEC
> Format settings, Reference frames        : 2 frames                 <——REQUIRED BY SPEC
> Format settings, GOP                     : M=1, N=2
> Codec ID                                 : 27                       <——REQUIRED BY SPEC
> Duration                                 : 6 s 6 ms
> Bit rate mode                            : Constant                 <——REQUIRED BY SPEC
> Nominal bit rate                         : 2 000 kb/s               <——REQUIRED BY SPEC
> Width                                    : 1 280 pixels             <——REQUIRED BY SPEC
> Height                                   : 720 pixels               <——REQUIRED BY SPEC
> Display aspect ratio                     : 16:9
> Frame rate                               : 29.970 (30000/1001) FPS  <——REQUIRED BY SPEC
> Color space                              : YUV
> Chroma subsampling                       : 4:2:0
> Bit depth                                : 8 bits
> Scan type                                : Progressive
> Bits/(Pixel*Frame)                       : 0.072
> Writing library                          : x264 core 148 r2795 aaa9aa8
> Encoding settings                        : cabac=1 / ref=2 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=8 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=22 / lookahead_threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=1 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=2 / keyint_min=1 / scenecut=0 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=2000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=2000 / vbv_bufsize=8000 / nal_hrd=cbr / filler=1 / ip_ratio=1.40 / aq=1:1.00
>
> Audio
> ID                                       : 257 (0x101)
> Menu ID                                  : 1 (0x1)
> Format                                   : AAC LC
> Format/Info                              : Advanced Audio Codec Low Complexity
> Format version                           : Version 4
> Muxing mode                              : ADTS
> Codec ID                                 : 15-2
> Duration                                 : 5 s 824 ms
> Bit rate mode                            : Variable
> Channel(s)                               : 1 channel
> Channel layout                           : C
> Sampling rate                            : 48.0 kHz                     <——REQUIRED BY SPEC
> Frame rate                               : 46.875 FPS (1024 SPF)
> Compression mode                         : Lossy
> Delay relative to video                  : -21 ms
> Language                                 : English
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Trying to solve drop in quality

FFmpeg-users mailing list
The -g is definitely the quality problem. I tried setting it various to 30*1000/1001, 60*1000/1001 120*1000/1001, 180*1000/1001, 360/1000/1001and even 15*1000/1001.



Any of those changes show up in mediainfo as:

Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames



I would have thought the interval for the ref frames was either 2 seconds (60*1000/1001) or 2 per ts segment

which would be (basically) 180*1000/1001.


I'm not sure how to get to Reference Frames 2.



On November 3, 2020 at 3:08 PM, Marton Balint <[hidden email]> wrote:




On Tue, 3 Nov 2020, John Harlow via ffmpeg-user wrote:


I've been trying to hit the specs we need to match for an HLS live stream and I’ve created an ffmpeg 2 pass command to convert some existing mp4 files into HLS so they can be used.


The mp4 test file I am using is http://fkwi.com/livestreams/test/currentweather.mp4 and it is 60 seconds long and 16,991,549 in size.


The converted HLS file is http://fkwi.com/livestreams/test/test1/video.m3u8 and it is (naturally) 60 seconds long and the .ts files add up to 17,584,392 bytes.


The quality of the HLS encode is horrible compared to the original and I can’t figure out where I am going sideways with it. I’m even trying a 2 pass encode. I convert our mp4’s to HLS all the time with no issues (but not to these specs.) We normally use 30FPS, VBR and VFR. You can see the items in the spec I am trying to hit in the mediainfo output at the end of this message.


Below is my ffmpeg command, my entire ffmpeg session output plus a mediainfo report on the HLS encode. In the mediainfo output I’ve added (<——REQUIRED BY SPEC) next to the items that are being required of our video.


I would appreciate any advice on how to maintain better quality on the HLS stream.




==========================ffmpeg command ==========================
/usr/bin/ffmpeg -i "$SOURCE" \
-profile:v main -level 3.1 -s 1280x720 -vf "fps=fps=30*1000/1001:round=zero" \
-c:v libx264 -pass 1 -preset slow -x264-params "nal-hrd=cbr:scenecut=0:ref=2:force-cfr=1" -g 2 \

-g 2 is very strange, it is GOP size and expressed in number of frames,
not seconds. That surely does not help with quality.


-b:v 2M -maxrate 2.0M -minrate 2.0M -bufsize 8M \

Is CBR really a requirement? If not, use CRF mode, alternatively with a
bitrate cap.

Regards,
Marton


-b:a 128k -ar 48000 -f hls logfile && /usr/bin/ffmpeg -i "$SOURCE" \
-profile:v main -level 3.1 -s 1280x720 -vf "fps=fps=30*1000/1001:round=zero" \
-c:v libx264 -pass 2 -preset slow -x264-params "nal-hrd=cbr:scenecut=0:ref=2:force-cfr=1" -g 2 \
-f segment -segment_list_type m3u8 -segment_list_size 0 -segment_time 6.006 -segment_time_delta 0.1 \
-b:v 2M -maxrate 2.0M -minrate 2.0M -bufsize 8M \
-b:a 128k -ar 48000 -start_number 0 \
-hls_time 6 -hls_list_size 0 -f hls \
-hls_base_url "$BASEURL" \
-hls_segment_filename "video%04d.ts


========================== ffmpeg output =============================


ffmpeg version 3.4.8 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --disable-encoder=libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-l
ibvorbis --enable-libv4l2 --enable-libvidstab --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect

libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://fkwi.com/currentweather.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 00:01:00.00, start: 0.000000, bitrate: 2265 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2183 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 81 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x241d860] using SAR=1/1
[libx264 @ 0x241d860] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x241d860] profile Main, level 3.1
[libx264 @ 0x241d860] 264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x1:0 me=dia subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=22 lookahead_threads=5 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=1 b_pyramid=0 b_adapt=1 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=2 keyint_min=1 scenecut=0 intra_refresh=0 rc_lookahead=50 rc=cbr mbtree=1 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=2000 vbv_bufsize=8000 nal_hrd=cbr filler=1 ip_ratio=1.40 aq=1:1.00
[hls @ 0x2383440] Opening 'logfile0.ts' for writing
Output #0, hls, to 'logfile':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Stream #0:0(und): Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 29.97 fps, 90k tbn, 29.97 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 2000000/0/2000000 buffer size: 8000000 vbv_delay: -1
Stream #0:1(eng): Audio: aac (LC), 48000 Hz, mono, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc57.107.100 aac
[hls @ 0x2383440] Opening 'logfile1.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile2.ts' for writing9 bitrate=N/A speed=13.2x
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile3.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile4.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile5.ts' for writing0 bitrate=N/A speed=12.3x
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile6.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile7.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile8.ts' for writing2 bitrate=N/A speed=11.8x
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile9.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile10.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile11.ts' for writing bitrate=N/A speed=11.7x
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile12.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile13.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile14.ts' for writing bitrate=N/A speed=11.6x
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile15.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile16.ts' for writing bitrate=N/A speed=11.3x
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile17.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile18.ts' for writing bitrate=N/A speed=11.1x
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile19.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile20.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile21.ts' for writing bitrate=N/A speed= 11x
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile22.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile23.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile24.ts' for writing bitrate=N/A speed= 11x
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile25.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile26.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile27.ts' for writing bitrate=N/A speed= 11x
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile28.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
[hls @ 0x2383440] Opening 'logfile29.ts' for writing
[hls @ 0x2383440] Opening 'logfile.tmp' for writing
Last message repeated 1 times
frame= 1798 fps=322 q=-1.0 Lsize=N/A time=00:00:59.92 bitrate=N/A speed=10.7x
video:15041kB audio:886kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x241d860] frame I:899 Avg QP:41.41 size: 16733
[libx264 @ 0x241d860] frame P:899 Avg QP:48.09 size: 399
[libx264 @ 0x241d860] mb I I16..4: 84.2% 0.0% 15.8%
[libx264 @ 0x241d860] mb P I16..4: 0.2% 0.0% 0.0% P16..4: 6.8% 0.0% 0.0% 0.0% 0.0% skip:93.0%
[libx264 @ 0x241d860] coded y,uvDC,uvAC intra: 37.6% 30.1% 12.0% inter: 0.1% 0.4% 0.0%
[libx264 @ 0x241d860] i16 v,h,dc,p: 26% 49% 19% 6%
[libx264 @ 0x241d860] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 20% 20% 5% 5% 6% 5% 6% 4%
[libx264 @ 0x241d860] i8c dc,h,v,p: 69% 26% 4% 1%
[libx264 @ 0x241d860] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x241d860] kb/s:2053.70
[aac @ 0x23ea640] Qavg: 5516.975
+ /usr/bin/ffmpeg -i https://fkwi.com/currentweather.mp4 -profile:v main -level 3.1 -s 1280x720 -vf 'fps=fps=30*1000/1001:round=zero' -c:v libx264 -pass 2 -preset slow -x264-params nal-hrd=cbr:scenecut=0:ref=2:force-cfr=1 -g 2 -f segment -segment_list_type m3u8 -segment_list_size 0 -segment_time 6.006 -segment_time_delta 0.1 -b:v 2M -maxrate 2.0M -minrate 2.0M -bufsize 8M -b:a 128k -ar 48000 -start_number 0 -hls_time 6 -hls_list_size 0 -f hls -hls_base_url http://fkwi.com/livestreams/test/test1/ -hls_segment_filename video%04d.ts video.m3u8
ffmpeg version 3.4.8 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --disable-encoder=libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-l
ibvorbis --enable-libv4l2 --enable-libvidstab --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect

libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://fkwi.com/currentweather.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 00:01:00.00, start: 0.000000, bitrate: 2265 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2183 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 81 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x246cee0] using SAR=1/1
[libx264 @ 0x246cee0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x246cee0] profile Main, level 3.1
[libx264 @ 0x246cee0] x264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=22 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=1 b_pyramid=0 b_adapt=1 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=2 keyint_min=1 scenecut=0 intra_refresh=0 rc_lookahead=50 rc=2pass mbtree=1 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 cplxblur=20.0 qblur=0.5 vbv_maxrate=2000 vbv_bufsize=8000 nal_hrd=cbr filler=1 ip_ratio=1.40 aq=1:1.00
[hls @ 0x2444cc0] Opening 'video0000.ts' for writing
Output #0, hls, to 'video.m3u8':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Stream #0:0(und): Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 29.97 fps, 90k tbn, 29.97 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 2000000/0/2000000 buffer size: 8000000 vbv_delay: -1
Stream #0:1(eng): Audio: aac (LC), 48000 Hz, mono, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc57.107.100 aac
[hls @ 0x2444cc0] Opening 'video0001.ts' for writing bitrate=N/A speed=11.4x
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0002.ts' for writing bitrate=N/A speed=11.2x
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0003.ts' for writing bitrate=N/A speed=10.8x
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0004.ts' for writing bitrate=N/A speed=10.5x
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0005.ts' for writing bitrate=N/A speed=10.1x
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0006.ts' for writing bitrate=N/A speed=9.99x
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0007.ts' for writing bitrate=N/A speed=9.95x
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0008.ts' for writing bitrate=N/A speed=9.83x
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video0009.ts' for writing bitrate=N/A speed=9.65x
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writing
[hls @ 0x2444cc0] Opening 'video.m3u8.tmp' for writingitrate=N/A speed=9.49x
frame= 1798 fps=287 q=-1.0 Lsize=N/A time=00:00:59.92 bitrate=N/A speed=9.56x
video:15291kB audio:886kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x246cee0] frame I:899 Avg QP:42.31 size: 16121
[libx264 @ 0x246cee0] frame P:899 Avg QP:45.32 size: 1296
[libx264 @ 0x246cee0] mb I I16..4: 69.9% 0.0% 30.1%
[libx264 @ 0x246cee0] mb P I16..4: 0.4% 0.0% 0.0% P16..4: 8.8% 0.6% 0.7% 0.0% 0.0% skip:89.6%
[libx264 @ 0x246cee0] coded y,uvDC,uvAC intra: 29.7% 31.0% 12.5% inter: 0.0% 0.2% 0.0%
[libx264 @ 0x246cee0] i16 v,h,dc,p: 14% 61% 8% 17%
[libx264 @ 0x246cee0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 7% 20% 7% 9% 6% 8% 8% 16%
[libx264 @ 0x246cee0] i8c dc,h,v,p: 56% 37% 5% 2%
[libx264 @ 0x246cee0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x246cee0] kb/s:2087.90
[aac @ 0x246e8e0] Qavg: 5516.975




======================================== MEDIAINFO===========================


mediainfo video0000.ts
General
ID : 1 (0x1)
Complete name : video0000.ts
Format : MPEG-TS
File size : 1.52 MiB
Duration : 5 s 939 ms
Overall bit rate mode : Variable
Overall bit rate : 2 125 kb/s


Video
ID : 256 (0x100)
Menu ID : 1 (0x1)
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L3.1 <——REQUIRED BY SPEC
Format settings : CABAC / 2 Ref Frames <——REQUIRED BY SPEC
Format settings, CABAC : Yes <——REQUIRED BY SPEC
Format settings, Reference frames : 2 frames <——REQUIRED BY SPEC
Format settings, GOP : M=1, N=2
Codec ID : 27 <——REQUIRED BY SPEC
Duration : 6 s 6 ms
Bit rate mode : Constant <——REQUIRED BY SPEC
Nominal bit rate : 2 000 kb/s <——REQUIRED BY SPEC
Width : 1 280 pixels <——REQUIRED BY SPEC
Height : 720 pixels <——REQUIRED BY SPEC
Display aspect ratio : 16:9
Frame rate : 29.970 (30000/1001) FPS <——REQUIRED BY SPEC
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.072
Writing library : x264 core 148 r2795 aaa9aa8
Encoding settings : cabac=1 / ref=2 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=8 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=22 / lookahead_threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=1 / b_pyramid=0 / b_adapt=1 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=2 / keyint_min=1 / scenecut=0 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=2000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=2000 / vbv_bufsize=8000 / nal_hrd=cbr / filler=1 / ip_ratio=1.40 / aq=1:1.00


Audio
ID : 257 (0x101)
Menu ID : 1 (0x1)
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Format version : Version 4
Muxing mode : ADTS
Codec ID : 15-2
Duration : 5 s 824 ms
Bit rate mode : Variable
Channel(s) : 1 channel
Channel layout : C
Sampling rate : 48.0 kHz <——REQUIRED BY SPEC
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Delay relative to video : -21 ms
Language : English
_______________________________________________
ffmpeg-user mailing list
[hidden email]

https://ffmpeg.org/mailman/listinfo/ffmpeg-user



To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Trying to solve drop in quality

Eduardo Alarcón
El mar., 3 nov. 2020 a las 18:36, John Harlow via ffmpeg-user (<
[hidden email]>) escribió:

> The -g is definitely the quality problem. I tried setting it various to
> 30*1000/1001, 60*1000/1001 120*1000/1001, 180*1000/1001, 360/1000/1001and
> even 15*1000/1001.
>
>
>
> Any of those changes show up in mediainfo as:
>
> Format settings                          : CABAC / 4 Ref Frames
> Format settings, CABAC                   : Yes
> Format settings, Reference frames        : 4 frames
>
>
>
> I would have thought the interval for the ref frames was either 2 seconds
> (60*1000/1001) or 2 per ts segment
>
> which would be (basically) 180*1000/1001.
>
>
> I'm not sure how to get to Reference Frames 2.
>
> -g is the gop size in frames, integer, not time, if you want a key frame
every 2 seconds you should use -g 60,  when using 30fps.
With gop 2, you are getting a keyframe every 2 frames, so basically your
video is a huge collection of jpeg images
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Trying to solve drop in quality

FFmpeg-users mailing list
I figured it out. Pointing out that it was the GOP set me on the right path


I eliminated -g and changed:
-x264-params "nal-hrd=cbr:scenecut=0:ref=2:cabac=1:force-cfr=1"
to
-x264-params "nal-hrd=cbr:scenecut=0:ref=1:b-pyramid=0:force-cfr=1"


thanks everyone!



On November 3, 2020 at 4:45 PM, Eduardo Alarcón <[hidden email]> wrote:


El mar., 3 nov. 2020 a las 18:36, John Harlow via ffmpeg-user (<
[hidden email]>) escribió:


The -g is definitely the quality problem. I tried setting it various to
30*1000/1001, 60*1000/1001 120*1000/1001, 180*1000/1001, 360/1000/1001and
even 15*1000/1001.






Any of those changes show up in mediainfo as:


Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames






I would have thought the interval for the ref frames was either 2 seconds
(60*1000/1001) or 2 per ts segment


which would be (basically) 180*1000/1001.




I'm not sure how to get to Reference Frames 2.


-g is the gop size in frames, integer, not time, if you want a key frame
every 2 seconds you should use -g 60, when using 30fps.
With gop 2, you are getting a keyframe every 2 frames, so basically your
video is a huge collection of jpeg images
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".