<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 3 mai 2023, 21 h 15, Guru Govindan <<a href="mailto:gurunathan.govindan@gmail.com">gurunathan.govindan@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Nicolas,<div>Thanks for your response, I figured out a way to extract the h264 header by making another connection to the camera and extracting data from the first stream. I used help from here <a href="https://stackoverflow.com/questions/24884827/possible-locations-for-sequence-picture-parameter-sets-for-h-264-stream/24890903#24890903" target="_blank" rel="noreferrer">https://stackoverflow.com/questions/24884827/possible-locations-for-sequence-picture-parameter-sets-for-h-264-stream/24890903#24890903</a></div><div><br></div><div>I also verified that the extracted header is valid by running `ffmpeg -i header1.h264 -an -c:v copy -bsf:v trace_headers -f null` and verified that it is a valid h264 file and contains SPS and PPS values.</div><div><br></div><div>However when I cat the recovered header and copy the truncated file, it says it is not a valid file.</div><div><br></div><div>Any ideas? Should it be inserted before every keyframe and not just in front of the file?</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">You only need it once, unless you had dynamic resolution change (which never happen with security cam). My guess would be the stream format (avec vs byte-stream), you want byte stream for mpeg ts.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 3, 2023 at 12:47 PM Nicolas Dufresne <<a href="mailto:nicolas@ndufresne.ca" target="_blank" rel="noreferrer">nicolas@ndufresne.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div>Le mercredi 03 mai 2023 à 10:22 -0700, Guru Govindan via gstreamer-devel a écrit :</div><blockquote type="cite" style="margin:0px 0px 0px 0.8ex;border-left:2px solid rgb(114,159,207);padding-left:1ex"><div dir="ltr">Hi There,<br><div>I am having an issue where a lot of video footage from a security camera was recorded without the sprop-parameters-set (SPS/PPS).</div><div><br></div><div>I am unable to play or transcode these ts files as it does not have SPS/PPS values. </div><div><br></div><div>I tried the following by sending the h264parse the stream format but that failed</div></div></blockquote><div><br></div><div>The only way to recover is to find the origin SPS/PPS, note, this is static on most cameras. The sprop-parameters contains it, just it may need to be transformed. Then something like this may work, but never tried`<br><br>gst-launch-1.0 \<br>  filesrc location=truncated.ts ! tsdemux ! filesink location=truncated.h264<br>cat recovered-header.h264 > fixed.h264<br>cat truncated.h264 >> fixed.h264</div><div><div>gst-launch-1.0 \</div></div><div>  filesrc location=fixed.h264 ! h264parse ! mpegtsmux ! filesink location=fixed.ts</div><div><br></div><div>This is video only though, totally untested.<br></div><div><br></div><div>Nicolas</div><div><br></div><blockquote type="cite" style="margin:0px 0px 0px 0.8ex;border-left:2px solid rgb(114,159,207);padding-left:1ex"><div dir="ltr"><div><br></div><div>```</div><div>gst-launch-1.0 -v filesrc location=2.ts ! tsparse ! tsdemux name=demux demux. ! queue ! h264parse ! video/x-h264,stream-format=avc,alignment=au ! decodebin ! videoconvert ! vaapih264enc ! h264parse ! mpegtsmux alignment=-1 ! filesink location=output.ts<br></div><div>```</div><div>failed with /</div><div>GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:sink: caps = video/x-h264, stream-format=(string)byte-stream</div>ERROR: from element /GstPipeline:pipeline0/GstH264Parse:h264parse0: No valid frames found before end of stream<div><br></div><div>I then tried to split it as per keyframes and then mux it.. like below but that failed as well</div><div><br></div><div>```</div><div>gst-launch-1.0 -v filesrc location=2.ts ! tsdemux name=demux ! h264parse ! splitmuxsink max-size-time=1000000000 location=segment%02d.ts mpegtsmux name=mux ! filesink location=output.ts demux.video_0 ! queue ! mux.<br></div><div>```</div><div>failed with h264parse0: No valid frames found before end of stream</div><div><br></div><div>Since it could not find EOS.. I thoiught of sending the entire manifest.. but that didnt work as well</div><div><br></div><div>```</div><div>gst-launch-1.0 -v filesrc location="<manifest uri>" ! hlsdemux ! h264parse ! video/x-h264,stream-format='(string)avc,alignment=(string)au' ! mpegtsmux ! h264parse config-interval=-1 ! mpegtsmux ! filesink location=output.ts<br></div><div>```</div><div><br></div><div>Just like how we can add config-interval to a rtp stream, is there a way to add it to a ts segment?</div><div><br></div><div>Best Regards,</div><div>Guru</div><div><br></div></div></blockquote><div><br></div><div><span></span></div></div>
</div></blockquote></div>
</blockquote></div></div></div>