ffmpeg to stream an already h.264 encoded stream

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

ffmpeg to stream an already h.264 encoded stream

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
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  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
  libpostproc    55.  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: 7000000/0/5000000 buffer size: 512000
vbv_delay: -1
    Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002),
48000 Hz, stereo, fltp, 712 kb/s
    Metadata:
      encoder         : Lavc58.54.100 libmp3lame
frame=  621 fps= 27 q=40.0 size=    5451kB time=00:00:20.73
bitrate=2153.8kbits/s speed=0.904x

And here is my command to stream from the h.264 encoded stream while
adding audio coming from the USB Sound card. It is based on this gist
https://gist.github.com/olasd/9841772 :
VBR="5000k"
FPS="30"
ffmpeg -i "$SOURCE" -thread_queue_size 2048 -f pulse -i default
-vcodec h264 -r 30 -g $(($FPS * 2)) -b:v $VBR  -maxrate 7000k -threads
6 -crf 3 -b:a 712000 -bufsize 512k -f flv "$YOUTUBE_URL/$KEY"

If you have any pointer to help me, please let me know. I've been
reading quite a lot for a while regarding ffmpeg, but I can't seem to
understand the basics.

Best regards,
--
Bruno Verachten
_______________________________________________
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: ffmpeg to stream an already h.264 encoded stream

DopeLabs


> On Sep 9, 2019, at 5:59 28AM, Verachten Bruno <[hidden email]> 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
>  libavformat    58. 29.100 / 58. 29.100
>  libavdevice    58.  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
>  libpostproc    55.  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 #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: 7000000/0/5000000 buffer size: 512000
> vbv_delay: -1
>    Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002),
> 48000 Hz, stereo, fltp, 712 kb/s
>    Metadata:
>      encoder         : Lavc58.54.100 libmp3lame
> frame=  621 fps= 27 q=40.0 size=    5451kB time=00:00:20.73
> bitrate=2153.8kbits/s speed=0.904x
>
> And here is my command to stream from the h.264 encoded stream while
> adding audio coming from the USB Sound card. It is based on this gist
> https://gist.github.com/olasd/9841772 :
> VBR="5000k"
> FPS="30"
> ffmpeg -i "$SOURCE" -thread_queue_size 2048 -f pulse -i default
> -vcodec h264 -r 30 -g $(($FPS * 2)) -b:v $VBR  -maxrate 7000k -threads
> 6 -crf 3 -b:a 712000 -bufsize 512k -f flv "$YOUTUBE_URL/$KEY"

you can do a 'stream copy' which will bea much lighter process...

so instead of specifying any type of encoding values you would simply

ffmpeg -i videoin -i audioin -c:v copy -c:a aac -b:a 64k -f flv rtmp://out

you would basically replace this

> -vcodec h264 -r 30 -g $(($FPS * 2)) -b:v $VBR  -maxrate 7000k -threads
> 6 -crf 3  -bufsize 512k

with

-c:v copy

>
> If you have any pointer to help me, please let me know. I've been
> reading quite a lot for a while regarding ffmpeg, but I can't seem to
> understand the basics.
>
> Best regards,
> --
> Bruno Verachten
> _______________________________________________
> 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: ffmpeg to stream an already h.264 encoded stream

Verachten Bruno
Thanks a lot, I am now able to stream two videos at the same time with
the computer doing almost nothing.
Now, I have to replace the audio of the streams with what is coming
from the FocusRite Scarlett 2i4 2nd generation, and lots of other
things.

Best regards,

Bruno Verachten
_______________________________________________
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: ffmpeg to stream an already h.264 encoded stream

Verachten Bruno
First of all, I don't know if I should continue within this thread or
create a new one. It's all about the same subject, streaming and
recording locally RTMP streams. Please let me know.

So, for the time being, I am able to stream the h.264 encoded stream
with the audio changed thanks to:
ffmpeg -i "$SOURCE" -thread_queue_size 2048 -f pulse -i
"alsa_input.usb-Focusrite_Scarlett_2i4_USB-00.analog-stereo" -c:v copy
 -map 0:v:0 -map 1:a:0 -f flv "$YOUTUBE_URL/$KEY"
That's fine, I'm really happy with that.
Now, I have to save the video on the disk too.
So I had a look at the tee format, and issued that command:
ffmpeg -i rtmp://192.168.1.212:1935/live/stream1 -thread_queue_size
2048 -f pulse -i
alsa_input.usb-Focusrite_Scarlett_2i4_USB-00.analog-stereo -c:v copy
-map 0:v:0 -map 1:a:0 -f tee "[f=flv:onfail=ignore]$YOUTUBE_URL/$KEY"
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
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  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
  libpostproc    55.  5.100 / 55.  5.100
Input #0, flv, from 'rtmp://192.168.1.212:1935/live/stream1':
  Duration: N/A, start: 12094.717000, bitrate: N/A
    Stream #0:0: Video: h264, yuv420p(progressive), 1920x1080, 29.97
fps, 29.97 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
'alsa_input.usb-Focusrite_Scarlett_2i4_USB-00.analog-stereo':
  Duration: N/A, start: 1568128912.858773, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Automatic encoder selection failed for output stream #0:1. Default
encoder for format tee (codec none) is probably disabled. Please
choose an encoder manually.
Error selecting an encoder for stream 0:1

I had other outputs for the tee, but as it was not working, I removed
them. There must be something important that I missed in that tee
format...
Please let me know.

Best wishes,

Bruno Verachten

On Tue, Sep 10, 2019 at 11:23 AM Verachten Bruno <[hidden email]> wrote:

>
> Thanks a lot, I am now able to stream two videos at the same time with
> the computer doing almost nothing.
> Now, I have to replace the audio of the streams with what is coming
> from the FocusRite Scarlett 2i4 2nd generation, and lots of other
> things.
>
> Best regards,
>
> Bruno Verachten



--
Bruno Verachten
_______________________________________________
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: ffmpeg to stream an already h.264 encoded stream

Moritz Barsnick
On Tue, Sep 10, 2019 at 17:25:43 +0200, Verachten Bruno wrote:
> ffmpeg -i rtmp://192.168.1.212:1935/live/stream1 -thread_queue_size
> 2048 -f pulse -i
> alsa_input.usb-Focusrite_Scarlett_2i4_USB-00.analog-stereo -c:v copy
> -map 0:v:0 -map 1:a:0 -f tee "[f=flv:onfail=ignore]$YOUTUBE_URL/$KEY"
[...]
> Automatic encoder selection failed for output stream #0:1. Default
> encoder for format tee (codec none) is probably disabled. Please
> choose an encoder manually.
> Error selecting an encoder for stream 0:1
>
> I had other outputs for the tee, but as it was not working, I removed
> them. There must be something important that I missed in that tee
> format...
> Please let me know.

Yes, you missed the actual error message. ;-)

The tee muxer, unlike the flv muxer, doesn't have useful defaults for
codecs. You are only specifying the video codec ("-c:v copy"), you also
need to specify an audio codec. AFAICT, flv defaults to mp3, so if you
want that, you should add "-c:a libmp3lame" to your command line.

Hope this helps,
Moritz
_______________________________________________
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: ffmpeg to stream an already h.264 encoded stream

Verachten Bruno
Thanks a lot Moritz, that did the trick.
So I now have:
ffmpeg -i "$SOURCE" -thread_queue_size 2048 -f pulse -i "$AUDIO_SOURCE"
-c:v copy -map 0:v:0 -map 1:a:0 -c:a libmp3lame -f tee
"[f=flv:onfail=ignore]$YOUTUBE_URL/$KEY|[f=flv:onfail=ignore]local_file.mkv"
which gives
Output #0, tee, to '[f=flv:onfail=ignore]rtmp://
a.rtmp.youtube.com/live2/my-key|[f=flv:onfail=ignore]local_file.mkv':

The output file is created, and the stream on YouTube is working too. I
don't know if MKV is the best format to use in this case.

I still have to figure out how to create a filename with a timestamp in it.
I had a look at the strftime option, but I don't know how to insert it into
the tee parameters.

I have another problem now, which is that the bitrate and the size have
disappeared:
frame= 4491 fps= 29 q=-1.0 size=N/A time=00:02:34.16 bitrate=N/A
speed=0.999x
I guess it's because of the tee. Is there any way to put them back on? It
was useful to check the streaming was going ok.

On Tue, Sep 10, 2019 at 10:03 PM Moritz Barsnick <[hidden email]> wrote:

> On Tue, Sep 10, 2019 at 17:25:43 +0200, Verachten Bruno wrote:
> > ffmpeg -i rtmp://192.168.1.212:1935/live/stream1 -thread_queue_size
> > 2048 -f pulse -i
> > alsa_input.usb-Focusrite_Scarlett_2i4_USB-00.analog-stereo -c:v copy
> > -map 0:v:0 -map 1:a:0 -f tee "[f=flv:onfail=ignore]$YOUTUBE_URL/$KEY"
> [...]
> > Automatic encoder selection failed for output stream #0:1. Default
> > encoder for format tee (codec none) is probably disabled. Please
> > choose an encoder manually.
> > Error selecting an encoder for stream 0:1
> >
> > I had other outputs for the tee, but as it was not working, I removed
> > them. There must be something important that I missed in that tee
> > format...
> > Please let me know.
>
> Yes, you missed the actual error message. ;-)
>
> The tee muxer, unlike the flv muxer, doesn't have useful defaults for
> codecs. You are only specifying the video codec ("-c:v copy"), you also
> need to specify an audio codec. AFAICT, flv defaults to mp3, so if you
> want that, you should add "-c:a libmp3lame" to your command line.
>
> Hope this helps,
> Moritz
> _______________________________________________
> 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".



--
Bruno Verachten
_______________________________________________
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: ffmpeg to stream an already h.264 encoded stream

Verachten Bruno
As for the filename, I used a bash variable, and it worked. I should have
thought about it earlier.
I haven't found yet how to keep the bitrate and size, and still have to add
delay for the sound.

I tried to play back the file on another machine (Windows this time), and
it doesn't work.
It stays on the first part of the video, ignoring the rest, and giving
errors when trying to fast forward:
 ./ffmpeg-20181106-d96ae9d-win64-static/bin/ffplay.exe
third-HDMI-input-20190912.182417486.mkv
ffplay version N-94455-g01994c93db Copyright (c) 2003-2019 the FFmpeg
developers
  built with gcc 9.1.1 (GCC) 20190716
  configuration: --enable-gpl --enable-version3 --enable-sdl2
--enable-fontconfig --enable-gnutls --enable-iconv --enable-libass
--enable-libdav1d --enable-libbluray --enable-libfreetype
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp
--enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc
--enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom
--enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid
--enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2
--enable-avisynth --enable-libopenmpt
  libavutil      56. 33.100 / 56. 33.100
  libavcodec     58. 55.100 / 58. 55.100
  libavformat    58. 30.100 / 58. 30.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.100 /  7. 58.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, flv, from 'third-HDMI-input-20190912.182417486.mkv':
  Metadata:
    encoder         : Lavf58.29.100
  Duration: 00:00:00.00, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 100
tbr, 1k tbn
    Stream #0:1: Audio: mp3, 48000 Hz, stereo, fltp, 128 kb/s
SDL_OpenAudio (2 channels, 48000 Hz): WASAPI can't initialize audio client:
CoInitialize n’a pas été appelé.

SDL_OpenAudio (1 channels, 48000 Hz): WASAPI can't initialize audio client:
CoInitialize n’a pas été appelé.

SDL_OpenAudio (2 channels, 44100 Hz): WASAPI can't initialize audio client:
CoInitialize n’a pas été appelé.

SDL_OpenAudio (1 channels, 44100 Hz): WASAPI can't initialize audio client:
CoInitialize n’a pas été appelé.

No more combinations to try, audio open failed
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0   B f=0/0
   f=0/0
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0
third-HDMI-input-20190912.182417486.mkv: error while seekingf=0/0
 673.85 M-V:  0.000 fd= 225 aq=    0KB vq=    0KB sq=    0B f=0/0

Bruno

On Thu, Sep 12, 2019 at 10:31 AM Verachten Bruno <[hidden email]> wrote:

> Thanks a lot Moritz, that did the trick.
> So I now have:
> ffmpeg -i "$SOURCE" -thread_queue_size 2048 -f pulse -i "$AUDIO_SOURCE"
> -c:v copy -map 0:v:0 -map 1:a:0 -c:a libmp3lame -f tee
> "[f=flv:onfail=ignore]$YOUTUBE_URL/$KEY|[f=flv:onfail=ignore]local_file.mkv"
> which gives
> Output #0, tee, to '[f=flv:onfail=ignore]rtmp://
> a.rtmp.youtube.com/live2/my-key|[f=flv:onfail=ignore]local_file.mkv
> <http://a.rtmp.youtube.com/live2/my-key%7C%5Bf=flv:onfail=ignore%5Dlocal_file.mkv>
> ':
>
> The output file is created, and the stream on YouTube is working too. I
> don't know if MKV is the best format to use in this case.
>
> I still have to figure out how to create a filename with a timestamp in
> it. I had a look at the strftime option, but I don't know how to insert
> it into the tee parameters.
>
> I have another problem now, which is that the bitrate and the size have
> disappeared:
> frame= 4491 fps= 29 q=-1.0 size=N/A time=00:02:34.16 bitrate=N/A
> speed=0.999x
> I guess it's because of the tee. Is there any way to put them back on? It
> was useful to check the streaming was going ok.
>
> On Tue, Sep 10, 2019 at 10:03 PM Moritz Barsnick <[hidden email]> wrote:
>
>> On Tue, Sep 10, 2019 at 17:25:43 +0200, Verachten Bruno wrote:
>> > ffmpeg -i rtmp://192.168.1.212:1935/live/stream1 -thread_queue_size
>> > 2048 -f pulse -i
>> > alsa_input.usb-Focusrite_Scarlett_2i4_USB-00.analog-stereo -c:v copy
>> > -map 0:v:0 -map 1:a:0 -f tee "[f=flv:onfail=ignore]$YOUTUBE_URL/$KEY"
>> [...]
>> > Automatic encoder selection failed for output stream #0:1. Default
>> > encoder for format tee (codec none) is probably disabled. Please
>> > choose an encoder manually.
>> > Error selecting an encoder for stream 0:1
>> >
>> > I had other outputs for the tee, but as it was not working, I removed
>> > them. There must be something important that I missed in that tee
>> > format...
>> > Please let me know.
>>
>> Yes, you missed the actual error message. ;-)
>>
>> The tee muxer, unlike the flv muxer, doesn't have useful defaults for
>> codecs. You are only specifying the video codec ("-c:v copy"), you also
>> need to specify an audio codec. AFAICT, flv defaults to mp3, so if you
>> want that, you should add "-c:a libmp3lame" to your command line.
>>
>> Hope this helps,
>> Moritz
>> _______________________________________________
>> 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".
>
>
>
> --
> Bruno Verachten
>


--
Bruno Verachten
_______________________________________________
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".