New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording headless selenium tests to mp4 with Xvfb and ffmpeg #4

Open
afterdesign opened this Issue Feb 7, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@afterdesign
Owner

afterdesign commented Feb 7, 2016

If you found error in my post or have new interesting insights on this topic please leave your comment here.

Thanks !

@afterdesign afterdesign added the comments label Feb 7, 2016

@kjagiello

This comment has been minimized.

Show comment
Hide comment
@kjagiello

kjagiello Apr 18, 2017

I just wonder if you know if it would be possible to achieve 60 fps using this method? I'm looking for a way to convert a page with a bit of CSS animations to a video file and I came across your post and it seemed promising!

kjagiello commented Apr 18, 2017

I just wonder if you know if it would be possible to achieve 60 fps using this method? I'm looking for a way to convert a page with a bit of CSS animations to a video file and I came across your post and it seemed promising!

@afterdesign

This comment has been minimized.

Show comment
Hide comment
@afterdesign

afterdesign Apr 19, 2017

Owner

@kjagiello I think you can try to set -r parameter to 60 and check the end result.
From documentation:

-r[:stream_specifier] fps (input/output,per-stream)
Set frame rate (Hz value, fraction or abbreviation).

As an input option, ignore any timestamps stored in the file and instead generate timestamps assuming constant frame rate fps. This is not the same as the -framerate option used for some input formats like image2 or v4l2 (it used to be the same in older versions of FFmpeg). If in doubt use -framerate instead of the input option -r.

As an output option, duplicate or drop input frames to achieve constant output frame rate fps.
Owner

afterdesign commented Apr 19, 2017

@kjagiello I think you can try to set -r parameter to 60 and check the end result.
From documentation:

-r[:stream_specifier] fps (input/output,per-stream)
Set frame rate (Hz value, fraction or abbreviation).

As an input option, ignore any timestamps stored in the file and instead generate timestamps assuming constant frame rate fps. This is not the same as the -framerate option used for some input formats like image2 or v4l2 (it used to be the same in older versions of FFmpeg). If in doubt use -framerate instead of the input option -r.

As an output option, duplicate or drop input frames to achieve constant output frame rate fps.
@flaz14

This comment has been minimized.

Show comment
Hide comment
@flaz14

flaz14 May 14, 2017

Hi Rafał! Thank you very much for the nice post!

I've used your post while writing an article about converting SWF into MP4 (I'm not very good at English so it's in Russian, sorry). In few details: I've played SWF video on virtual screen and captured it with aid of FFmpeg.


Let me put my two cents in. It's possible to stop FFmpeg politely without tmux but with aid of Bash co-process. All you need is just to run ffmpeg via coproc. The following script:

#!/usr/bin/env bash

coproc ffmpeg -f x11grab -video_size 1680x1050 -i :0 -codec:v libx264 -r 5 ./test.mp4 &
sleep 10
echo 'q' >&"${COPROC[1]}"

captures screen for about 10 seconds. I tried to play the resultant test.mp4 file in VLC - everything is OK. And FFmpeg reports that the file has correct duration, e.g.:

$ ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 test.mp4
10.200000

flaz14 commented May 14, 2017

Hi Rafał! Thank you very much for the nice post!

I've used your post while writing an article about converting SWF into MP4 (I'm not very good at English so it's in Russian, sorry). In few details: I've played SWF video on virtual screen and captured it with aid of FFmpeg.


Let me put my two cents in. It's possible to stop FFmpeg politely without tmux but with aid of Bash co-process. All you need is just to run ffmpeg via coproc. The following script:

#!/usr/bin/env bash

coproc ffmpeg -f x11grab -video_size 1680x1050 -i :0 -codec:v libx264 -r 5 ./test.mp4 &
sleep 10
echo 'q' >&"${COPROC[1]}"

captures screen for about 10 seconds. I tried to play the resultant test.mp4 file in VLC - everything is OK. And FFmpeg reports that the file has correct duration, e.g.:

$ ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 test.mp4
10.200000
@afterdesign

This comment has been minimized.

Show comment
Hide comment
@afterdesign

afterdesign May 15, 2017

Owner

@flaz14 This is really cool ! Thanks for the info :)

Owner

afterdesign commented May 15, 2017

@flaz14 This is really cool ! Thanks for the info :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment