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

2019-09-09 Thread Ben Houghton
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):

HLS output distorted image 
MPEGDASH output distorted image 
It isn't doing this every time, but roughly 50%.

The ffmpeg commands being run are:

ffmpeg -re -y -loglevel error -hide_banner -threads 1 
-use_wallclock_as_timestamps 1 -f rawvideo -pix_fmt yuv420p -s 640x480 
-framerate 30.30517578125 -thread_queue_size 512 -i tcp://127.0.0.1:43713 
-thread_queue_size 512 -i tcp://127.0.0.1:41871 -vsync 1 -r 30.30517578125 
-c:a aac -c:v h264 -profile:v high -b_strategy 0 -bf 1 -f dash -use_template 1 
-use_timeline 1 -window_size 5 -live 1 -min_seg_duration 200 -preset 
veryfast -crf 22 -g 48 -keyint_min 48 -sc_threshold 0 -filter_complex 
[0]format=pix_fmts=yuv420p[temp0];[temp0]scale=-2:240[A0] -map [A0]:v -b:v:0 
400k -maxrate 428k -bufsize 600k -map 1:a -b:a:0 64k -filter_complex 
[0]format=pix_fmts=yuv420p[temp1];[temp1]scale=-2:360[A1] -map [A1]:v -b:v:1 
700k -maxrate 749k -bufsize 1050k -map 1:a -b:a:1 96k 
/usr/src/app/cdn-path/webrtc_test.mpd

ffmpeg -re -y -loglevel error -hide_banner -threads 1 
-use_wallclock_as_timestamps 1 -f rawvideo -pix_fmt yuv420p -s 640x480 
-framerate 30.30517578125 -thread_queue_size 512 -i tcp://127.0.0.1:43713 
-thread_queue_size 512 -i tcp://127.0.0.1:41871 -vsync 1 -r 30.30517578125 
-c:a copy -c:v h264 -profile:v high -b_strategy 0 -bf 1 -f mpegts 
/usr/src/app/cdn-stream-save/webrtc_test_1567437442625.ts -c:a aac -c:v h264 
-profile:v high -b_strategy 0 -bf 1 -f hls -hls_time 2 -hls_list_size 5 
-hls_flags delete_segments -preset veryfast -crf 22 -g 48 -keyint_min 48 
-sc_threshold 0 -filter_complex 
[0]format=pix_fmts=yuv420p[temp0];[temp0]scale=-2:240[A0] -map [A0]:v -b:v:0 
400k -maxrate 428k -bufsize 600k -map 1:a -b:a 64k 
/usr/src/app/cdn-path/webrtc_test_1.m3u8 -hls_time 2 -hls_list_size 5 
-hls_flags delete_segments -preset veryfast -crf 22 -g 48 -keyint_min 48 
-sc_threshold 0 -filter_complex 
[0]format=pix_fmts=yuv420p[temp1];[temp1]scale=-2:360[A1] -map [A1]:v -b:v:1 
700k -maxrate 749k -bufsize 1050k -map 1:a -b:a 96k 
/usr/src/app/cdn-path/webrtc_test_2.m3u8
ffmpeg details:

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 
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

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?

Thank you
___
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".

Re: [FFmpeg-user] yuv420p vs yuv420p(tv)

2019-09-09 Thread George R. Welch

On 9/9/19 9:02 AM, Paul B Mahol wrote:

On 9/9/19, George R. Welch  wrote:

Hi folks,

I have two versions of the same video and I would like to only keep
one.  If one is higher quality, I'd obviously want to keep that one.  I
can't tell tell any difference through casual watching with VLC, so
perhaps it does not matter.

But anyway, when I run ffmpeg -i on the two, the difference is:

< Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x1080, 4011 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
---
  > Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661),
yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 4173 kb/s, 29.97 fps, 29.97
tbr, 90k tbn, 59.94 tbc (default)

I think I understand the difference between yuv420p(pc) and yuv420p(tv),
but here I have yuv420p vs yuv420p(tv).

Can someone offer suggestions as to which of these two videos might be
the better encoding?

You should not trust anyone giving you such answer by comparing only
metadata and not actual data.


Thank you.  I should add that I do know that the only difference between 
the videos is the encoding scheme.  Both were produced from the same 
master.  It's just that I don't know what was done (and can't find out 
easily).


My hope was that ffmpeg's output could offer me a clue about the 
encodings of the two, from which I could make an educated guess about 
which one might be better (if either).


If one can't tell from this, I'm happy to flip a coin.  But does anyone 
know the difference between yuv420p and yuv420p(tv).  As opposed to 
yuv420p(pc) vs yuv420p(tv), I mean.


Best,

--George
___
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".

Re: [FFmpeg-user] ffmpeg to stream an already h.264 encoded stream

2019-09-09 Thread DopeLabs


> On Sep 9, 2019, at 5:59 28AM, Verachten Bruno  wrote:
> 
> Hi there,
> 
> this is my first message on this list, so please bear with me.
> I have access to a h.264 encoder that will supply a few rtmp streams
> corresponding to the various HDMI inputs it has. It is supposed to use
> ffmpeg by the way (TBS2605).
> Anyway... I have a Linux machine, and my goal is to:
> - grab one of these streams, add audio coming from a USB sound card
> (FocusRite 2i4 2nd Gen), and stream that to YouTube while recording on
> the disk too.
> - grab two of these streams, compose them on top of a template, add
> audio (like in https://youtu.be/01nM2Shnyz0?t=1638), stream that to
> YouTube while recording on the disk too.
> 
> For the time being, I have managed to stream to YouTube, but the
> YouTube platform is not happy with my stream quality, saying "The
> stream's current bitrate (1653.00 Kbps) is lower than the recommended
> bitrate. We recommend that you use a stream bitrate of 4500 Kbps.".
> The bitrate that is output by the encoder is supposed to be 4000Kbps.
> The ffmpeg command I have gives me around 2200/2400Kbps.
> So I guess I made a mess and decoded with my command the h.264 stream
> before encoding again... as the speed is around 0.962x, and the CPU is
> quite busy. I thought there was no need to decode/encode to add an
> audio stream (but I have no idea what I'm doing, as you had already
> guessed ;-) ).
> 
> I recompiled the 4.2 ffmpeg release sources on this very machine.
> 
> Here is the kind of output I get:
> ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
>  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
>  configuration: --enable-gpl --enable-version3 --disable-static
> --enable-shared --enable-small --enable-avisynth --enable-chromaprint
> --enable-frei0r --enable-gmp --enable-gnutls --enable-ladspa
> --enable-libaom --enable-libass --enable-libcaca --enable-libcdio
> --enable-libcodec2 --enable-libfontconfig --enable-libfreetype
> --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack
> --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb
> --enable-libopencore-amrwb --enable-libopencore-amrwb
> --enable-libopenjpeg --enable-libopenmpt --enable-libopus
> --enable-libpulse --enable-librsvg --enable-librubberband
> --enable-librtmp --enable-libshine --enable-libsnappy --enable-libsoxr
> --enable-libspeex --enable-libssh --enable-libtesseract
> --enable-libtheora --enable-libtwolame --enable-libv4l2
> --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
> --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
> --enable-libxvid --enable-libxml2 --enable-libzmq --enable-libzvbi
> --enable-lv2 --enable-libmysofa --enable-openal --enable-opencl
> --enable-opengl --enable-libdrm --enable-nonfree --enable-libfdk-aac
> --enable-libbluray --extra-libs='-lnettle -lhogweed -lgmp'
>  libavutil  56. 31.100 / 56. 31.100
>  libavcodec 58. 54.100 / 58. 54.100
>  libavformat58. 29.100 / 58. 29.100
>  libavdevice58.  8.100 / 58.  8.100
>  libavfilter 7. 57.100 /  7. 57.100
>  libswscale  5.  5.100 /  5.  5.100
>  libswresample   3.  5.100 /  3.  5.100
>  libpostproc55.  5.100 / 55.  5.100
> Input #0, flv, from 'rtmp://192.168.1.211:1935/live/stream0':
>  Duration: N/A, start: 15024.271000, bitrate: N/A
>Stream #0:0: Video: h264, yuv420p(progressive), 1920x1080, 30 fps,
> 30 tbr, 1k tbn
>Stream #0:1: Audio: aac, 48000 Hz, stereo, fltp
> Guessed Channel Layout for Input Stream #1.0 : stereo
> Input #1, pulse, from 'default':
>  Duration: N/A, start: 1568033472.683289, bitrate: 1536 kb/s
>Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
> Stream mapping:

as you can see below, you are re-encoding... 

>  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
>  Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
> Press [q] to stop, [?] for help
> [libx264 @ 0x559c4df3e780] using cpu capabilities: MMX2 SSE2Fast SSSE3
> SSE4.2 AVX FMA3 BMI2 AVX2
> [libx264 @ 0x559c4df3e780] profile High, level 4.0
> [libx264 @ 0x559c4df3e780] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4
> AVC codec - Copyleft 2003-2017 - 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=60
> keyint_min=6 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
> mbtree=1 crf=3.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=7000
> vbv_bufsize=512 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40
> aq=1:1.00
> Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/dh5g-r8tf-x5qy-cse8':
>  Metadata:
>encoder : Lavf58.29.100
>Stream 

Re: [FFmpeg-user] yuv420p vs yuv420p(tv)

2019-09-09 Thread Paul B Mahol
On 9/9/19, George R. Welch  wrote:
> Hi folks,
>
> I have two versions of the same video and I would like to only keep
> one.  If one is higher quality, I'd obviously want to keep that one.  I
> can't tell tell any difference through casual watching with VLC, so
> perhaps it does not matter.
>
> But anyway, when I run ffmpeg -i on the two, the difference is:
>
> < Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
> 1920x1080, 4011 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
> ---
>  > Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661),
> yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 4173 kb/s, 29.97 fps, 29.97
> tbr, 90k tbn, 59.94 tbc (default)
>
> I think I understand the difference between yuv420p(pc) and yuv420p(tv),
> but here I have yuv420p vs yuv420p(tv).
>
> Can someone offer suggestions as to which of these two videos might be
> the better encoding?

You should not trust anyone giving you such answer by comparing only
metadata and not actual data.

>
> Thanks,
>
> --George
> ___
> 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".
___
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".

[FFmpeg-user] yuv420p vs yuv420p(tv)

2019-09-09 Thread George R. Welch

Hi folks,

I have two versions of the same video and I would like to only keep 
one.  If one is higher quality, I'd obviously want to keep that one.  I 
can't tell tell any difference through casual watching with VLC, so 
perhaps it does not matter.


But anyway, when I run ffmpeg -i on the two, the difference is:

< Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 
1920x1080, 4011 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)

---
> Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), 
yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 4173 kb/s, 29.97 fps, 29.97 
tbr, 90k tbn, 59.94 tbc (default)


I think I understand the difference between yuv420p(pc) and yuv420p(tv), 
but here I have yuv420p vs yuv420p(tv).


Can someone offer suggestions as to which of these two videos might be 
the better encoding?


Thanks,

--George
___
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".

[FFmpeg-user] ffmpeg to stream an already h.264 encoded stream

2019-09-09 Thread Verachten Bruno
Hi there,

this is my first message on this list, so please bear with me.
I have access to a h.264 encoder that will supply a few rtmp streams
corresponding to the various HDMI inputs it has. It is supposed to use
ffmpeg by the way (TBS2605).
Anyway... I have a Linux machine, and my goal is to:
 - grab one of these streams, add audio coming from a USB sound card
(FocusRite 2i4 2nd Gen), and stream that to YouTube while recording on
the disk too.
 - grab two of these streams, compose them on top of a template, add
audio (like in https://youtu.be/01nM2Shnyz0?t=1638), stream that to
YouTube while recording on the disk too.

For the time being, I have managed to stream to YouTube, but the
YouTube platform is not happy with my stream quality, saying "The
stream's current bitrate (1653.00 Kbps) is lower than the recommended
bitrate. We recommend that you use a stream bitrate of 4500 Kbps.".
The bitrate that is output by the encoder is supposed to be 4000Kbps.
The ffmpeg command I have gives me around 2200/2400Kbps.
So I guess I made a mess and decoded with my command the h.264 stream
before encoding again... as the speed is around 0.962x, and the CPU is
quite busy. I thought there was no need to decode/encode to add an
audio stream (but I have no idea what I'm doing, as you had already
guessed ;-) ).

I recompiled the 4.2 ffmpeg release sources on this very machine.

Here is the kind of output I get:
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
  configuration: --enable-gpl --enable-version3 --disable-static
--enable-shared --enable-small --enable-avisynth --enable-chromaprint
--enable-frei0r --enable-gmp --enable-gnutls --enable-ladspa
--enable-libaom --enable-libass --enable-libcaca --enable-libcdio
--enable-libcodec2 --enable-libfontconfig --enable-libfreetype
--enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack
--enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libopenmpt --enable-libopus
--enable-libpulse --enable-librsvg --enable-librubberband
--enable-librtmp --enable-libshine --enable-libsnappy --enable-libsoxr
--enable-libspeex --enable-libssh --enable-libtesseract
--enable-libtheora --enable-libtwolame --enable-libv4l2
--enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxvid --enable-libxml2 --enable-libzmq --enable-libzvbi
--enable-lv2 --enable-libmysofa --enable-openal --enable-opencl
--enable-opengl --enable-libdrm --enable-nonfree --enable-libfdk-aac
--enable-libbluray --extra-libs='-lnettle -lhogweed -lgmp'
  libavutil  56. 31.100 / 56. 31.100
  libavcodec 58. 54.100 / 58. 54.100
  libavformat58. 29.100 / 58. 29.100
  libavdevice58.  8.100 / 58.  8.100
  libavfilter 7. 57.100 /  7. 57.100
  libswscale  5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc55.  5.100 / 55.  5.100
Input #0, flv, from 'rtmp://192.168.1.211:1935/live/stream0':
  Duration: N/A, start: 15024.271000, bitrate: N/A
Stream #0:0: Video: h264, yuv420p(progressive), 1920x1080, 30 fps,
30 tbr, 1k tbn
Stream #0:1: Audio: aac, 48000 Hz, stereo, fltp
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, pulse, from 'default':
  Duration: N/A, start: 1568033472.683289, bitrate: 1536 kb/s
Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[libx264 @ 0x559c4df3e780] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x559c4df3e780] profile High, level 4.0
[libx264 @ 0x559c4df3e780] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4
AVC codec - Copyleft 2003-2017 - 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=60
keyint_min=6 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=3.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=7000
vbv_bufsize=512 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40
aq=1:1.00
Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/dh5g-r8tf-x5qy-cse8':
  Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007),
yuv420p, 1920x1080, q=-1--1, 5000 kb/s, 30 fps, 1k tbn, 30 tbc
Metadata:
  encoder : Lavc58.54.100 libx264
Side data:
  cpb: bitrate max/min/avg: 700/0/500 buffer size: 512000