Skip to content

Instantly share code, notes, and snippets.

@HyunAh-iia
Last active November 8, 2023 18:08
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HyunAh-iia/31eb7485637f129f0a5e40a020a1de15 to your computer and use it in GitHub Desktop.
Save HyunAh-iia/31eb7485637f129f0a5e40a020a1de15 to your computer and use it in GitHub Desktop.
Record firefox from xvfb via ffmepg on Ubuntu 18.04 Docker Image

Record Firefox Browser on Ubuntu Docker Image

Recording Firefox Browser Using xvfb, ffmpeg on Ubuntu 20.04 Docker Image

How to

Download files and run the commands below

$ docker build --tag browser-record .
$ docker run -d --name browser-record browser-record #(Don't remove `-d` option)

Get file to your local

After run the container, command on your local terminal

$ docker cp browser-record:/recording/output/. /yourLocalPath

TO DO

  • Optimize Frame Size
FROM ubuntu:20.04 # Also working on 18.04
RUN /usr/bin/apt-get update && \
/usr/bin/apt-get install -y curl && \
/usr/bin/apt-get update && \
/usr/bin/apt-get upgrade -y && \
/usr/bin/apt-get install -y firefox xvfb ffmpeg
WORKDIR /recording
COPY record.sh /recording/record.sh
RUN chmod +x /recording/record.sh
RUN mkdir /recording/output
ENV DISPLAY :99
ENTRYPOINT ["record.sh"]
#!/bin/bash
echo "run browser(firefox) on virtual frame"
/usr/bin/xvfb-run --listen-tcp --server-num ${DISPLAY} --auth-file /tmp/xvfb.auth -s "-ac -screen 0 1028x720x24" firefox https://en.wikipedia.org/wiki/GIF &
# wait for the browser to be ready
sleep 3
echo "record 30 seconds using ffmpeg (if you want no time limit, remove `-t 30` option)"
/usr/bin/ffmpeg -video_size 1028x720 -framerate 30 -f x11grab -i ${DISPLAY} -t 30 -codec:v libx264 /recording/output/output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment