Closed ldenoue closed 3 years ago
Afraid not, what sample command were you using?
I'm using the sample command from the README.md:
GST_PLUGIN_PATH=Release:$GST_PLUGIN_PATH gst-launch-1.0 \
cefsrc url="https://soundcloud.com/platform/sama" ! \
video/x-raw, width=1920, height=1080, framerate=60/1 ! \
cefdemux name=demux ! videoconvert ! \
queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! x264enc ! \
mp4mux name=muxer fragment-duration=1000 ! filesink location='test.mp4' \
audiotestsrc do-timestamp=true is-live=true volume=0.00 ! audiomixer name=mix ! \
queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! audioconvert ! \
audiorate ! audioresample ! voaacenc bitrate=128000 ! muxer. \
demux. ! mix.
I also tried this one:
GST_PLUGIN_PATH=Release:$GST_PLUGIN_PATH gst-launch-1.0 cefsrc url="https://google.com" ! video/x-raw, width=1920, height=1080, framerate=60/1 ! cefdemux name=demux ! videoconvert ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! x264enc ! mp4mux name=muxer fragment-duration=1000 ! filesink location='test.mp4' demux. ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! audioconvert ! audiorate ! audioresample ! voaacenc bitrate=128000 ! muxer.
but both simply display: "Setting pipeline to PAUSED ..."
Is it maybe the CEF version that somehow doesn't fire "page loaded" or something?
Notice I had to use vocaacenc instead of faac because I couldn't find a way to install faac plugin on my Ubuntu: if it could be the reason why the pipeline is stuck to "PAUSED", would you have a simpler pipeline sample that saves to .webm maybe with an opusenc?
The encoder shouldn't really make a difference afaik, however I notice the example pipeline could use some queues.
For webm output, perhas try with:
GST_PLUGIN_PATH=Release:$GST_PLUGIN_PATH gst-launch-1.0 cefsrc url="https://soundcloud.com/platform/sama" ! video/x-raw, width=1920, height=1080, framerate=60/1 ! cefdemux name=demux ! videoconvert ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! vp8enc deadline=1 threads=12 cpu-used=-16 target-bitrate=2560000 ! queue ! webmmux name=muxer ! filesink location=test.mkv audiotestsrc do-timestamp=true is-live=true volume=0.00 ! audiomixer name=mix ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! audioconvert ! audioresample ! opusenc ! queue ! muxer. demux. ! audioconvert ! audioresample ! queue ! mix.
Same here, maybe "CEF depends on X11 library even in windowless mode." https://magpcss.org/ceforum/viewtopic.php?f=6&t=16993&sid=5e46cc6bfb909badf63e0aafcfe9413f&p=42879#p42879
Oh, that could explain I suppose yes, I'm running on X11, please let me know if using xvfb does make a difference @ldenoue :)
@camenduru and @MathieuDuponchelle yes, running Xvfb first works! Thanks a lot for your suggestion.
Xvfb :99 &
export DISPLAY=:99
GST_PLUGIN_PATH=Release:$GST_PLUGIN_PATH gst-launch-1.0 cefsrc url="https://google.com" ! video/x-raw, width=1920, height=1080, framerate=60/1 ! cefdemux name=demux ! videoconvert ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! x264enc ! mp4mux name=muxer fragment-duration=1000 ! filesink location='test.mp4' demux. ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! audioconvert ! audiorate ! audioresample ! voaacenc bitrate=128000 ! muxer.
yields:
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:10.106308239
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
ls Setting pipeline to NULL ...
Freeing pipeline ...
The Xvfb requirement seems removed in when people run Chromium headless, e.g. puppeteer or playwright: I wonder if it would be possible to remove this dependency on CEF, but probably not a question for here.
@ldenoue nice, can you not use xvfb-run
as a shortcut btw?
Also well spotted @camenduru , don't hesitate to contribute an update to the README :)
Yes, it also works with xvfb-run as follows:
GST_PLUGIN_PATH=Release:$GST_PLUGIN_PATH xvfb-run gst-launch-1.0 cefsrc url="https://soundcloud.com/platform/sama" ! video/x-raw, width=1280, height=720, framerate=60/1 ! cefdemux name=demux ! videoconvert ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! x264enc ! mp4mux name=muxer fragment-duration=1000 ! filesink location='test.mp4' audiotestsrc do-timestamp=true is-live=true volume=0.00 ! audiomixer name=mix ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! audioconvert ! audiorate ! audioresample ! voaacenc bitrate=128000 ! muxer. demux. ! mix.
@MathieuDuponchelle The problem is that although I let it run for over one minute before Ctrl-C, the generated mp4 only contains about 7 seconds worth of video and audio.
I only Ctrl-C once, not twice, and the output shows:
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:01:21.793154976
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
Do you also see the videos truncated?
It does work when streaming to RTMP, so perhaps it has to do with the filesink
element?
For posterity, here's a pipeline that works for me to send to RTMP.
Notice that I start xvfb-run
with the same dimensions as the ones used by cefsrc
but I haven't tested whether it's important or not.
GST_PLUGIN_PATH=Release:$GST_PLUGIN_PATH xvfb-run --server-args="-screen 0 1280x720x24" gst-launch-1.0 -v flvmux name=mux ! rtmpsink location=rtmp://YOUR_RTMP_SERVER/live/YOUR_RTMP_KEY cefsrc url="YOUR_WEB_PAGE_URL" ! video/x-raw, width=1280, height=720, framerate=60/1 ! cefdemux name=demux ! videoconvert ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! x264enc ! video/x-h264,profile=baseline,width=1280,height=720 ! h264parse ! mux. demux. ! audioconvert ! audioresample ! queue ! avenc_aac ! aacparse ! mux.
If you want to record an mp4 to a file with gst-launch-1.0
, make sure you use the -e argument to finalise the file correctly when you hit ctrl-C
@ldenoue @thaytan is correct
@MathieuDuponchelle perhaps you can add this -e
arg in the README.md
example that has the filesink location=test.mp4
?
Actually even with the -e option, my file stops increasing in size. Weird that it's working with streaming but not with filesink...
Hey @ldenoue I must have missed this notification :) What pipeline are you running exactly where the file stops growing? -e
is only relevant at ctrl + C / SIGINT time, if the file stops growing prior to that there must be another issue.
Hi @MathieuDuponchelle here's the command I'm using: notice I've added -e
after gst-launch-1.0
but my test2.mp4 file still doesn't grow past a few seconds worth of video/audio.
Notice I use voaacenc
because on my Ubuntu VM there's no faac
found using gst-inspect-1.0 | grep faac
GST_PLUGIN_PATH=Release:$GST_PLUGIN_PATH xvfb-run --server-args="-screen 0 1280
x720x24" gst-launch-1.0 -e cefsrc url="https://webrtc.in.live/anim-simple.html"
! video/x-raw, width=1280, height=720, framerate=60/1 ! cefdemux name=demux ! vi
deoconvert ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000
! x264enc ! mp4mux name=muxer fragment-duration=1000 ! filesink location='test2.
mp4' audiotestsrc do-timestamp=true is-live=true volume=0.00 ! audiomixer name=
mix ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! audio
convert ! audiorate ! audioresample ! voaacenc bitrate=128000 ! muxer. demux. !
mix.
Which outputs on the terminal:
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
After about 15 seconds, I stopped it using Ctrl-C and get this:
^Chandling interrupt.
Interrupt: Stopping pipeline ...
EOS on shutdown enabled -- Forcing EOS on the pipeline
I waited for about one minute, thinking that perhaps the h264 encoding was slow... But I lost patience and hit Ctrl-C another time, which brought me back to my terminal.
The test2.mp4
file is 984954 bytes long, and I made it available here: https://webrtc.in.live/test2.mp4
ffprobe on this URL shows indeed a short duration of 3.92 seconds. Notice also that the audio channel claims mono (I was expecting stereo): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 127 kb/s (default)
Thanks, I just pushed an update to the README (fragment-duration made no sense in that situation, there should always be queues before muxers and after demuxers), and a fix in cefdemux, please try again @ldenoue
Re audio, if you need stereo just pop a capsfilter after the mixer, eg audiomixer name=mix ! audio/x-raw, channels=2 ! ..
It's still not working for me. I noticed that when I don't add audio in the pipeline, Ctrl-C transitions the pipeline to show Waiting for EOS...
followed by a correct sequence of events (see below) that yield to a good mp4 file. Here's the command line that works (notice no audio):
GST_PLUGIN_PATH=Release:$GST_PLUGIN_PATH xvfb-run --server-args="-screen 0 1920x1080x24" gst-launch-1.0 -e cefsrc url="https://soundcloud.com/platform/sama" ! video/x-raw, width=1920, height=1080, framerate=60/1 ! cefdemux name=demux ! queue ! videoconvert ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! x264enc ! queue ! mp4mux name=muxer ! filesink location='test.mp4'
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
^Chandling interrupt.
Interrupt: Stopping pipeline ...
EOS on shutdown enabled -- Forcing EOS on the pipeline
Waiting for EOS...
Got EOS from element "pipeline0".
EOS received - stopping pipeline...
Execution ended after 0:01:22.934784457
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
However, when I add sound I need to hit Ctrl-C twice, which exists prematurely and has the test.mp4 file not written correctly: ffprobe test.mp4
complains about moov atom not found
Here's the command with sound that still fails for me and where I need to hit Ctrl-C twice:
GST_PLUGIN_PATH=Release:$GST_PLUGIN_PATH xvfb-run --server-args="-screen 0 1920x1080x24" gst-launch-1.0 -e cefsrc url="https://soundcloud.com/platform/sama" ! video/x-raw, width=1920, height=1080, framerate=60/1 ! cefdemux name=demux ! queue ! videoconvert ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! x264enc ! queue ! mp4mux name=muxer ! filesink location='test.mp4' audiotestsrc do-timestamp=true is-live=true volume=0.0 ! audiomixer name=mix ! queue max-size-bytes=0 max-size-buffers=0 max-size-time=3000000000 ! audioconvert ! audiorate ! audioresample ! voaacenc ! queue ! muxer. demux. ! queue ! mix.
Is it possible for audio and video need to have their EOS signals handled differently?
Well, it is surprising, this command line now works just fine for me. The only thing I changed is voaacenc -> faac, even though I don't reckon the encoder should make difference can you try with lamemp3enc
? This one also works on my end.
Also, perhaps triple check that you've indeed checked out and rebuilt the latest master, don't know :)
I've tried with lamemp3enc, and also avenc_aac but not to avail. It might be the fact that I'm running with a proper x11 and audio system? I've installed pulseaudio but how would we specify gstcefsrc to use that audio? Still, it works for a few seconds, and it works great when streaming to RTMP, so it seems to only be failing when I write to a file.
gstcefsrc has no need for pulseaudio, it uses CEF's audio capture API. Considering this pipeline now works well on my end, I have no other advice besides making absolutely sure you're running the latest version, or letting you look at logs / stacktraces and figuring out where things get stuck :)
Running on Ubuntu any sample command gets me "Setting pipeline to PAUSED ...". Any idea why? Thank you!