'When use gogs as private git server, can I use a video in README.md?
I deployed a gogs application as our company's private git server.
To show an experiment result, I encoded a couple of statistital graphics to a video by H264 fourcc with opencv-python and pyav. The snippet looks like this:
video = av.open('data/benchmark_res.mp4', 'w')
stream = video.add_stream('h264', 12)
stream.bit_rate = 8000000
for i in tqdm(range(1000000, 101000000, 1000000)):
im = plot_each_million(df, i)
if i == 100000000: cv2.imwrite('imgs/poster.png', im)
stream.height = im.shape[0]
stream.width = im.shape[1]
frame = av.VideoFrame.from_ndarray(im, format='bgr24')
packet = stream.encode(frame)
video.mux(packet)
video.close()
Here, the function plot_each_million()
called during each iteration is a self-defined function which returns a numpy.ndarray
as a image.
The video generated was tested by insertion into any other webpage. Since with H264 formatted, it works well all the time.
The way I use to insert the video to Gogs' README.md
is just a pair of H5 <video>
tag:
<video controls autoplay loop poster="imgs/poster.png">
<source src="benchmark_res.mp4" type="video/mp4">
<p><a href="benchmark_res.mp4">download</a></p>
</video>
So is this feature not supported? Or anything goes wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|