pion / mediadevices

Go implementation of the MediaDevices API.
https://pion.ly/
MIT License
540 stars 123 forks source link

Archive example not totaty working #401

Closed EmrysMyrddin closed 2 years ago

EmrysMyrddin commented 2 years ago

Your environment.

What did you do?

Tried do run the archive example.

➜  archive git:(master) ✗ go run . out.h264
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High, level 3.0, 4:2:0, 8-bit
Recording... Press Ctrl+c to stop
^Cx264 [info]: frame I:5     Avg QP:21.50  size: 23186
x264 [info]: frame P:250   Avg QP:23.16  size:  5029
x264 [info]: mb I  I16..4:  8.4% 67.2% 24.4%
x264 [info]: mb P  I16..4:  0.2%  0.5%  0.1%  P16..4: 52.7% 14.6%  8.3%  0.0%  0.0%    skip:23.6%
x264 [info]: 8x8 transform intra:67.2% inter:71.7%
x264 [info]: coded y,uvDC,uvAC intra: 76.0% 71.2% 20.0% inter: 28.0% 31.2% 0.4%
x264 [info]: i16 v,h,dc,p: 16%  5%  7% 72%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 10% 21%  6%  7%  9%  5%  9%  8%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 14% 13%  7%  7%  8%  6%  7%  6%
x264 [info]: i8c dc,h,v,p: 61% 14% 19%  6%
x264 [info]: Weighted P-Frames: Y:30.0% UV:0.4%
x264 [info]: ref P L0: 62.7% 20.9% 11.6%  4.1%  0.7%
x264 [info]: kb/s:1077.01
Your video has been recorded to out.h264

What did you expect?

I expect a readable video file.

What happened?

The video partially readable but some metadata are probably wrong since it is played at a lower speed than expected and is fastforwarded at each keyframes.

EmrysMyrddin commented 2 years ago

GStreamer seems to also complain about metadata not being valid :

➜  archive git:(master) ✗ /Library/Frameworks/GStreamer.framework/Commands/gst-launch-1.0 playbin uri=file://${PWD}/out.h264     
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Got context from element 'sink': gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayCocoa\)\ gldisplaycocoa0";

(gst-launch-1.0:24779): GStreamer-Video-CRITICAL **: 17:46:10.750: gst_video_center_rect: assertion 'src->h != 0' failed

(gst-launch-1.0:24779): GStreamer-Video-CRITICAL **: 17:46:10.750: gst_video_center_rect: assertion 'src->h != 0' failed
EmrysMyrddin commented 2 years ago

It is clearly a metadata problem since it works well when transcoded with ffmpeg (H264 -> H264)

EmrysMyrddin commented 2 years ago

In fact it seems normal, raw H264 doesn't seems to have metadata at all on frames. It needs a container to be read properly by a video reader, such as mp4 for example.