Ffmpeg consumer stream to rtmp doesn't work with Wowza

When I try to stream CasparCG output to Wowza using ffmpeg consumer, audio is ok but video is absent.
This is stopped working from CasperCG v2.2 or CasperCG v2.3

ADD 1-1 STREAM rtmp://<rtmpIp:port>/live/test-rtmp -filter:v format=pix_fmts=yuv420p,scale=1280:720,fps=30 -codec:v h264_nvenc -preset:v llhq -profile:v high -b:v 6M -bufsize:v 12M -g:v 15 -strict -2 -codec:a aac -b:a 256k -ar:a 48000 -fflags nobuffer -probesize 32 -analyzeduration 0 -format flv

Wowza receives below error :

2022-07-18 04:34:24 UTC comment server INFO 200 - LiveStreamPacketizerCupertino.handlePacket[live/definst/test-rtmp][null]: H264 Video info: {MediaCodecInfoVideo: codec:H264, profile:unknown:0, level:0.0, frameSize:0x0, displaySize:0x0, frameRate:0.000000} - - - 303376.625 - - - -

CasperCG works with RTSP over TCP with same wowza and also works with ffmpeg command with RTMP url (ffmpeg -re -i inputfile.mp4 -codec copy -f flv “rtmp://[wowza-address]:1935/myApplication/myStream” ).

Wowza is not receiving the stream only if it gets stream from casperCG consumer.Need help to solve this issue from casperCG ffmpeg consumer side?

Server version: v2.3.0
GPU : NVIDIA GeForce GTX 1050
channel Configuration is 720p3000.

1 Like

This issue is similar to ffmpeg customer stream to rtmp doesn't work with Twitch · Issue #1294 · CasparCG/server · GitHub where streaming with ffmpeg consumer doesnt work with TWITCH as well.
Any help will be appreciated.

Captured RTMP tcpdump today and where i see First H264 keyframe is getting send however next consecutive H264 I-Frames are size of 4044 which doesn’t seems to be correct for h264 video frames. Hence streaming server is not able to identify and decode the packets.
Kindly help if you see anything obvious to solve.

Attaching the snapshot of capturedump where casparcg ffmpeg consumer sends 4044 bytes of packet to RTMP server.
Do we know why casparcg ffmpeg consumer packetise packet this way? Any way to fix this?

If anyone facing this issue i’ve found a fix.
add +global_header arg when adding RTMP stream this will enable individual stream headers required for FLV.

Technically this should be added based on the Muxer we use but there is code bug in CarparCG where we open the encoder before setting AV_CODEC_FLAG_GLOBAL_HEADER flag.

FF(avcodec_open2(enc.get(), codec, &dict)); … … if (oc->oformat->flags & AVFMT_GLOBALHEADER) { enc->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; }

Which should be like

if (oc->oformat->flags & AVFMT_GLOBALHEADER) { enc->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; } FF(avcodec_open2(enc.get(), codec, &dict));

Older casparcg has this sequence so it’s working
@ronag @Julusian can you guys patch this up in 2.3.x lts? it might help other people who are facing this RTMP bug

1 Like
Privacy Policy   Terms of Service