Re: [FFmpeg-user] Video output distortion on ffpmeg live stream

2019-09-10 Thread Ben Houghton
Hi Moritz,
Many thanks for the detailed response. 

>> I am helping build a node server that runs ffmpeg to stream a live
>> WebRTC input to HLS and MPEGDASH. Often when the encoding starts it
>> produces a corrupted video output that looks something like this
>> (viewed using VLC):
> 
> Are you saying that after a few frames the video becomes correct?

No, once it starts “bad", it stays “bad".

>> Does anyone have any ideas on what might cause this type of
>> distortion on the output stream or how I can test further to track it
>> down?
> 
> To see what ffmpeg is doing with your input, it would have been helpful
> to look at ffmpeg's complete log output. But:
> 
>> ffmpeg -re -y -loglevel error -hide_banner
> 
> Without "-loglevel error" and without "-hide_banner" please.

I’ve attached the stout produced from ffmpeg when the issue is occurring with 
just those options removed.  I don’t see any issues there so I am thinking you 
may be right about it being an issue with the Web RTC input.

ffmpeg version 3.4.6 Copyright (c) 2000-2019 the FFmpeg developers
   built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 20160609
   configuration: --disable-debug --disable-doc --disable-ffplay 
--enable-shared --enable-avresample --enable-libopencore-amrnb 
--enable-libopencore-amrwb --enable-gpl --enable-libass --enable-libfreetype 
--enable-libvidstab --enable-libmp3lame --enable-libopenjpeg --enable-libopus 
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp 
--enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree 
--enable-openssl --enable-libfdk_aac --enable-libkvazaar --enable-postproc 
--enable-small --enable-version3 --extra-cflags=-I/opt/ffmpeg/include 
--extra-ldflags=-L/opt/ffmpeg/lib --extra-libs=-ldl --prefix=/opt/ffmpeg
   libavutil  55. 78.100 / 55. 78.100
   libavcodec 57.107.100 / 57.107.100
   libavformat57. 83.100 / 57. 83.100
   libavdevice57. 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
   libpostproc54.  7.100 / 54.  7.100

 info: Received: ice
 info: Received: ice
 info: Ice candidate added
 info: Ice candidate added
Input #0, rawvideo, from 'tcp://127.0.0.1:43455':
   Duration: N/A, start: 1568117517.228372, bitrate: 110592 kb/s
 Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 110592 
kb/s, 30 tbr, 30 tbn, 30 tbc

Input #1, mp3, from 'tcp://127.0.0.1:35403':
   Duration: N/A, start: 0.00, bitrate: 192 kb/s
 Stream #1:0
: Audio: mp3, 48000 Hz, mono, s16p, 192 kb/s

Stream mapping:
   Stream #0:0 (rawvideo) -> format (graph 0)
   Stream #0:0 (rawvideo) -> format (graph 1)
   scale (graph 0) -> Stream #0:0 (libx264)
   Stream #1:0 -> #0:1 (mp3 (native) -> aac (native))
   scale (graph 1) -> Stream #0:2 (libx264)
   Stream #1:0 -> #0:3 (mp3 (native) -> aac (native))
 Press [q] to stop, [?] for help

[libx264 @ 0xad76e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX 
FMA3 AVX2 LZCNT BMI2

[libx264 @ 0xad76e0] profile High, level 1.3

[libx264 @ 0xad76e0] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 
2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 
deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 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=7 lookahead_threads=1 sliced_threads=0 
nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=1 
b_pyramid=0 b_adapt=0 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 
keyint=48 keyint_min=25 scenecut=0 intra_refresh=0 rc_lookahead=10 rc=crf 
mbtree=1 crf=22.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=749 
vbv_bufsize=1050 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00

[libx264 @ 0xadc1a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX 
FMA3 AVX2 LZCNT BMI2

[libx264 @ 0xadc1a0] profile High, level 3.0
 [libx264 @ 0xadc1a0] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 
2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 
deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 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=9 lookahead_threads=2 sliced_threads=0 
nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=1 
b_pyramid=0 b_adapt=0 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 
keyint=48 keyint_min=25 scenecut=0 intra_refresh=0 rc_lookahead=10 rc=crf 
mbtree=1 crf=22.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=749 
vbv_bufsize=1050 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00

[dash @ 0xad6260] Opening '/usr/src/app/cdn-path/mpd/init-stream0.m4s' for 
writing

[dash @ 0xad6260] Opening '/usr/src/app/cdn-path/mpd/init-stream1.m4s' for 
writing

[dash @ 0xad6260] Opening 

Re: [FFmpeg-user] Video output distortion on ffpmeg live stream

2019-09-10 Thread Moritz Barsnick
Hi Ben,

On Tue, Sep 10, 2019 at 06:09:30 +0100, Ben Houghton wrote:
> I am helping build a node server that runs ffmpeg to stream a live
> WebRTC input to HLS and MPEGDASH. Often when the encoding starts it
> produces a corrupted video output that looks something like this
> (viewed using VLC):

Are you saying that after a few frames the video becomes correct?

> HLS output distorted image 
> MPEGDASH output distorted image 

This doesn't look like an encoding error by ffmpeg, but it could be a
decoding artifact. In particular if the first frame is not a keyframe
or just partially received. There's possibly nothing you can do,
because that's the way the stream is initially picked up. (Just
guessing so far.)

> Does anyone have any ideas on what might cause this type of
> distortion on the output stream or how I can test further to track it
> down?

To see what ffmpeg is doing with your input, it would have been helpful
to look at ffmpeg's complete log output. But:

> ffmpeg -re -y -loglevel error -hide_banner

Without "-loglevel error" and without "-hide_banner" please.

To see whether the input is at fault, you would strip all the output
magic and just dump a few seconds to file, by keeping all the input
options, but just writing a simple file, for example:

$ ffmpeg { input options } -map 0:v -map 1:a -t 5 testout.mp4

to check whether the same effects are to be seen in that file.

> ffmpeg version 3.4.6 Copyright (c) 2000-2019 the FFmpeg developers

Though it probably isn't part of your issue, we always recommend to
test (or even use) a very recent version of ffmpeg. This rules out
debugging fixed bugs. If you can't find a newer ffmpeg in some other
repository, and you don't want to build yourself, you can grab a static
binary from here and test with that:

https://johnvansickle.com/ffmpeg/

(Left column, "git master", please.)

Regards,
Moritz
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".