FFMPEG Consumer "Invalid argument"

#1
Hi all,
I have a problem with FFMPEG Consumer and new release of CasparCG 2.2.0.
I have this config (working with v2.1.0)

Code: Select all

  <channels>
    <channel>
      <video-mode>720p2500</video-mode>
      <channel-layout>stereo</channel-layout>
      <consumers>
	<ffmpeg>
            <path>rtmp://host.tld:1935/app/stream</path>
            <args>-c:v libx264 -preset veryfast -g 50 -vf format=yuv420p -video_size 1280x720 -maxrate 1500k -bufsize 3000k -c:a aac -b:a 128k -ar 48000 -ac 2 -strict experimental -f flv</args>
        </ffmpeg>
      </consumers>
    </channel>
  </channels>
Now this not work.
I read that FFMPEG Consumer is almost rewritten from scratch, could somebody help me to try to fix it with the new CasparCG?
The error I got in the log file is:

Code: Select all

[2018-03-08 02:28:50.307] [info]    Initializing OpenGL Device.
[2018-03-08 02:28:50.322] [info]    Successfully initialized OpenGL 
[2018-03-08 02:28:51.370] [info]    Initialized OpenGL Accelerated GPU Image Mixer for channel 1
[2018-03-08 02:28:51.371] [info]    video_channel[1|720p2500] Successfully Initialized.
[2018-03-08 02:28:51.373] [info]    ffmpeg[rtmp://host.tld:1935/app/stream] Initialized.
[2018-03-08 02:28:51.373] [info]    Initialized channels.
[2018-03-08 02:28:51.374] [info]    Initialized controllers.
[2018-03-08 02:28:51.374] [info]    Initialized osc.
[2018-03-08 02:28:51.375] [error]   [ffmpeg] [NULL @ 00000246A94223C0] Unable to find a suitable output format for 'rtmp://live3.ivoplay.it:1935/ivotv?doPublish=playout_2017/ivotv1'
[2018-03-08 02:28:51.375] [error]   
[2018-03-08 02:28:51.376] [error]   [ffmpeg] [NULL @ 00000246A94223C0] Unable to find a suitable output format for 'rtmp://live3.ivoplay.it:1935/ivotv?doPublish=playout_2017/ivotv1'
[2018-03-08 02:28:51.376] [error]   
[2018-03-08 02:28:51.422] [error]   C:\Program Files (x86)\Jenkins\workspace\casparcg-server\master\src\modules\ffmpeg\consumer\ffmpeg_consumer.cpp(468): Throw in function auto __cdecl caspar::ffmpeg::ffmpeg_consumer::initialize::<lambda_28279d2b049c1510d5b87c89898ce938>::operator ()(void) const
[2018-03-08 02:28:51.422] [error]   Dynamic exception type: class boost::exception_detail::clone_impl<struct caspar::ffmpeg::ffmpeg_error_t>
[2018-03-08 02:28:51.422] [error]   [struct boost::errinfo_api_function_ * __ptr64] = avformat_alloc_output_context2( &oc, nullptr, !format.empty() ? format.c_str() : nullptr, path_.c_str())
[2018-03-08 02:28:51.422] [error]   [struct boost::errinfo_errno_ * __ptr64] = 22, "Invalid argument"
[2018-03-08 02:28:51.422] [error]   [struct caspar::tag_stacktrace_info * __ptr64] =  0# 0x00007FF760CE8A8E in casparcg
[2018-03-08 02:28:51.422] [error]    1# 0x00007FF760D16F50 in casparcg
[2018-03-08 02:28:51.422] [error]    2# 0x00007FF760EB0EB7 in casparcg
[2018-03-08 02:28:51.422] [error]    3# 0x00007FF760EB3390 in casparcg
[2018-03-08 02:28:51.422] [error]    4# 0x00007FF760CE3949 in casparcg
[2018-03-08 02:28:51.422] [error]    5# iswascii in ucrtbase
[2018-03-08 02:28:51.422] [error]    6# BaseThreadInitThunk in KERNEL32
[2018-03-08 02:28:51.422] [error]    7# RtlUserThreadStart in ntdll
[2018-03-08 02:28:51.422] [error]   
[2018-03-08 02:28:51.422] [error]   
Note that I edited the rtmp url with a fake one.

Thank you very much.

Lapo

Re: FFMPEG Consumer "Invalid argument"

#3
Hi balte,
it works really fine! Thank you.

Anyway, now I need to figure out why these options (correct using v2.1.0 of CasparCG server) are ignored:

Code: Select all

Unused option ac=2
Unused option ar=48000
Unused option bufsize=3000k
Unused option c=aac:a
Unused option g=50
Unused option maxrate=1500k
Unused option preset=veryfast
Unused option vf=format=yuv420p
Unused option video_size=1280x720
EDIT:
After some investigations I changed all option aliases with corresponding option name, so I changed

Code: Select all

-c:v libx264 -preset veryfast -g 50 -vf format=yuv420p -video_size 1280x720 -maxrate 1500k -bufsize 3000k -c:a aac -b:a 128k -ar 48000 -ac 2 -strict experimental -f flv
to

Code: Select all

-codec:v libx264 -preset veryfast -g 50 -filter:v format=yuv420p,scale=1280:720 -maxrate 1500k -bufsize 3000k -codec:a aac -ar 48000 -b:a 128k -ac 2 -strict experimental -format flv
Unfortunately some ignored options still there:

Code: Select all

Unused option ac=2
Unused option ar=48000
Unused option bufsize=3000k
Unused option g=50
Unused option maxrate=1500k
Unused option preset=veryfast
I tried also to change the profile to "baseline" or "main", but I receive an error.

Thanks again.

Lapo

Re: FFMPEG Consumer "Invalid argument"

#5
Thank you balte.

Hoping to be a help for others with similar problems, I write here the final args row:

Code: Select all

-codec:v libx264 -profile:v baseline -preset:v veryfast -g:v 50 -filter:v format=yuv420p -video_size:v 1280x720 -maxrate:v 1500k -bufsize:v 3000k -codec:a aac -ar:a 48000 -b:a 128k -filter:a pan=stereo -ac:a 2 -strict experimental -format flv
It seems to work fine.
I need to double check if audio is good, because in caspar.config I have channel-layout to stereo, but ffmpeg consumer assume it as 7.1, so I need to -ac:a 2 and -filter:a pan=stereo but I never used the pan filter.

Thank you for all your help.

Lapo

Re: FFMPEG Consumer "Invalid argument"

#6
lapoguidi wrote:
08 Mar 2018, 14:48
I need to double check if audio is good, because in caspar.config I have channel-layout to stereo, but ffmpeg consumer assume it as 7.1, so I need to -ac:a 2 and -filter:a pan=stereo but I never used the pan filter.
Version 2.2.0 uses a fixed 8 channel audio pipeline internally, so it is correct that you have to use an audio filter.
CasparCG enthusiast and broadcast geek

Re: FFMPEG Consumer "Invalid argument"

#8
Here again,
now all it seems correct with FFMPEG consumer, but a new problem appeared now.
If I use path to an mp4 file all works fine, but if I use path to an rtmp stream the server receive the stream, video is totally black and audio is totally mute.
Working:

Code: Select all

<consumers>
  <ffmpeg>
    <path>e:\output.mp4</path>
    <args>-codec:v libx264 -profile:v baseline -preset:v veryfast -g:v 50 -filter:v format=yuv420p -video_size:v 1280x720 -maxrate:v 1500k -bufsize:v 3000k -codec:a aac -ar:a 48000 -b:a 128k -filter:a pan=stereo -ac:a 2 -strict experimental -format flv</args>
  </ffmpeg>
</consumers>
Not Working:

Code: Select all

<consumers>
  <ffmpeg>
    <path>rtmp://hostname.tld:1935/appname/streamname</path>
    <args>-codec:v libx264 -profile:v baseline -preset:v veryfast -g:v 50 -filter:v format=yuv420p -video_size:v 1280x720 -maxrate:v 1500k -bufsize:v 3000k -codec:a aac -ar:a 48000 -b:a 128k -filter:a pan=stereo -ac:a 2 -strict experimental -format flv</args>
  </ffmpeg>
</consumers>
Any suggestion?

Thank you.

Lapo