[Libwebsockets] Help wanted: V4L2 / mp4 / h.264

Andy Green andy at warmcat.com
Mon May 3 21:27:34 CEST 2021



On 4/30/21 3:39 PM, Silas Parker wrote:
> Hi Andy,
> 
> I can't offer anything specific, but in the past I've used Shaka 
> Packager (https://github.com/google/shaka-packager 
> <https://github.com/google/shaka-packager>) for generating MPEG DASH 
> streams which is a standard way of delivering streaming video to 
> browsers and other devices.  You might be able to glean what Chrome is 
> after by looking at the MP4 files that it generates.

Thanks for the hint Silas.

I started looking at this earlier today, rather than compare output, 
it's interesting to see what it says when I give it what's produced when 
spooled to a /tmp file as its input.

It complained I had disabled some mp4 boxes that were not needed on ffox 
and errored out on each, so that's a significant clue.

After it was OK at mp4 level, it complains now about finding a type 13 
NAL at the NALU layer, I instrumented shaka to print the NAL type

$ ./out/Release/packager 
'in=/tmp/str.mp4,stream=video,output=/tmp/x.mp4' 
--generate_static_live_mpd --mpd_output h264.mpd
[0503/110045:INFO:demuxer.cc(89)] Demuxer::Run() on file '/tmp/str.mp4'.
[0503/110045:INFO:demuxer.cc(155)] Initialize Demuxer for file 
'/tmp/str.mp4'.
[0503/110045:ERROR:avc_decoder_configuration_record.cc(53)] 13
[0503/110045:ERROR:avc_decoder_configuration_record.cc(54)] Failure 
while processing: nalu.type() == Nalu::H264_SPS
[0503/110045:ERROR:mp4_media_parser.cc(605)] Failed to parse avcc.
[0503/110045:ERROR:packager_main.cc(550)] Packaging Error: 8 
(PARSER_FAILURE): Cannot parse media file /tmp/str.mp4

but I can't see any type 13 NAL ("SPS extension") in the hexdump from a 
quick look.  There's also some problem with slightly truncated h.264 
stream according to mplayer

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe9bb5e6340]stream 0, sample 777, dts 25899974
32768=mp_read(0x55cffa2c4220, 0x55cffa2c9100, 32768), pos: 13043046, eof:0
vd_ffmpeg data: 0000, bd05700f, 0000, 15160500
[h264 @ 0x7fe9bad80040]nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x7fe9bad80040]nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x7fe9bad80040]nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x7fe9bad80040]nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x7fe9bad80040]nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x7fe9bad80040]bytestream overread -17
[h264 @ 0x7fe9bad80040]error while decoding MB 39 22, bytestream -17
[h264 @ 0x7fe9bad80040]concealing 50 DC, 50 AC, 50 MV errors in I frame
V:  25.8   0/  0 15%  0%  0.0% 0 0

...it shows up as a thin area of corrupted decode at the very bottom right.

Even so, I can play the output file now in Chrome itself using a 
file:///tmp/str.mp4 URL, it can't be a million miles away.

So I will continue with this at the weekend, it's certainly better than 
fiddling with things in the dark.

-Andy



More information about the Libwebsockets mailing list