w3c / webcodecs

WebCodecs is a flexible web API for encoding and decoding audio and video.
https://w3c.github.io/webcodecs/
Other
978 stars 136 forks source link

missing three frames when decoding h264 video #519

Closed badcode06 closed 2 years ago

badcode06 commented 2 years ago

hi all, I have a basic pipeline. 1- Create an mp4 video from RGB images with FFmpeg 2- Decode this mp4 video in (chrome)web browser with webcodec (using your sample code)

I realized that, when I decode the frames, there are missing three frames every time. These are the last three frames.

here is my encoding script for step 1:

#!/bin/bash 
ffmpeg -hide_banner \                                                              
    -loglevel verbose  \                                                        
    -sws_flags print_info+accurate_rnd+bitexact+full_chroma_int \               
    -color_range pc  \                                                          
    -color_trc arib-std-b67  \                                                  
    -color_primaries bt2020  \                                                  
    -colorspace bt2020nc  \                                                     
    -pix_fmt yuvj444p  \                                                        
    -framerate 20 -i 'frames/%d.jpg' \                                          
    -c:v libx264 -r 20 \                                                        
    -color_range pc  \                                                          
    -color_trc arib-std-b67  \                                                  
    -color_primaries bt2020  \                                                  
    -vf "scale=1024:1024" \                                                     
    -colorspace bt2020nc  \                                                     
    -pix_fmt rgb24   \                                                          
    -sws_flags print_info+accurate_rnd+bitexact+full_chroma_int  \              
    output.mp4 -y                                                               

so you can decode with FFmpeg to check the frames (everything is ok, there are no missing frames)

to decode

ffmpeg -i output.mp4 thumb%04d.jpg

and for step 2 as I said, I use this sample ( https://github.com/w3c/webcodecs/tree/main/samples/mp4-decode ) but it's not possible to extract the last three frames.

Is there any way to solve this problem? maybe a config file or something like that?

dalecurtis commented 2 years ago

This sounds like a Chrome bug - while this tracker is for the specification. If you're calling flush() and still not seeing those frames, feel free to open a bug a https://crbug.com/new