Safe H264 video saving to file

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Safe H264 video saving to file

Myzhar
Hi all,

I'm trying to find the best way to save to file a H264 stream in the safest way.

What I want is to have a playable file even if for some reason (e.g. power loss) the stream is interrupted without EOS.

Any suggestion?

Thank you
Walter
Walter Lucetti
www.myzhar.com
Reply | Threaded
Open this post in threaded view
|

Re: Safe H264 video saving to file

Stephenwei
This post was updated on .
Hi,
I think most of muxer(matroskamux, mp4mux) would satisfy your requirement.

Regards,
Stephen
Reply | Threaded
Open this post in threaded view
|

Re: Safe H264 video saving to file

Arjen Veenhuizen
Be aware that MP4 by default requires to be properly closed (e.g. the MOOV atom has to be written). Safest bet would probably  be mpeg2ts or matroska.
Reply | Threaded
Open this post in threaded view
|

Re: Safe H264 video saving to file

Myzhar
My problem is that I have a stream with audio and video and I need to save them to multiple files using "multifilesink" (I cannot use splitmuxsink because I must use a GStreamer version that does not support it).

Using "multifilesink" with "mpegtsmux" and H264 codec generates files that are not playable.

I can use any kind of codec for the output files, so I must find the "safest" one with an eye on quality ;-)

Can you suggest me the better way to achieve this result?

Thank you

Walter
Walter Lucetti
www.myzhar.com
Reply | Threaded
Open this post in threaded view
|

Re: Safe H264 video saving to file

Arjen Veenhuizen
Perhaps you can write the output to a named pipe and let ffmpeg do the chunking? Or does it have to be a GStreamer only solution?
Reply | Threaded
Open this post in threaded view
|

Re: Safe H264 video saving to file

Myzhar
A "GStreamer only" solution is better

2017-05-25 10:07 GMT+02:00 Arjen Veenhuizen [via GStreamer-devel] <[hidden email]>:
Perhaps you can write the output to a named pipe and let ffmpeg do the chunking? Or does it have to be a GStreamer only solution?


If you reply to this email, your message will be added to the discussion below:
http://gstreamer-devel.966125.n4.nabble.com/Safe-H264-video-saving-to-file-tp4683065p4683099.html
To unsubscribe from Safe H264 video saving to file, click here.
NAML



--
Walter Lucetti
www.myzhar.com
Reply | Threaded
Open this post in threaded view
|

Re: Safe H264 video saving to file

Arjen Veenhuizen
What is the output of mpegtsmux + multifilesink right now? individual files of which only the first one is playable? Or?

Some general remarks (assuming h264):
* Use a fixed gop size (1 second)
* Set config-interval on h264parse at 1 (second) to make sure it inserts SPS/PPS at each GOP [1]
* Disable scene change detection on x264enc (e.g. option-string="no-scenecut")

[1] Note that in 1.8+, you can set config-interval to -1 to make sure it inserts SPS/PPS at each I-frame
Reply | Threaded
Open this post in threaded view
|

Re: Safe H264 video saving to file

Myzhar

* Set config-interval on h264parse at 1 (second) to make sure it inserts SPS/PPS at each GOP [1] 

This made the trick! Using mpegtsmux now I have playable files!

Thank you very much for help

PS

FYI this is my pipeline:

gst-launch-1.0 udpsrc do-timestamp=true multicast-iface=eth0 multicast-group=239.0.0.11 auto-multicast=true port=16001 ! "application/x-rtp, encoding-name=H264, payload=96" ! rtph264depay ! h264parse config-interval=1 ! queue ! mux. \
udpsrc do-timestamp=true multicast-iface="LAN_Console" multicast-group=239.0.0.11 auto-multicast=true port=16002 ! "application/x-rtp, media=audio, clock-rate=44100, encoding-name=MP4A-LATM, cpresent=(string)0, config=(string)40002420, payload=97" ! rtpmp4adepay ! aacparse ! avdec_aac ! audioconvert ! queue ! mix. \ 
audiotestsrc wave=4 is-live=true do-timestamp=true ! queue ! mix. \
liveadder name=mix ! queue ! audioconvert ! voaacenc ! aacparse ! queue ! mux. \ 
mpegtsmux name=mux ! multifilesink next-file=max-size max-file-size=10485760 location=test_%06d.mp4 -e

I mix my audio UDP source with a "silent" stream (audiotestsrc wave=4) to be sure that video recording does not stop even if the audio stream is stopped/changed

--
Walter Lucetti
www.myzhar.com
Reply | Threaded
Open this post in threaded view
|

Re: Safe H264 video saving to file

Myzhar

2017-05-25 15:50 GMT+02:00 Yurii Monakov <[hidden email]>:
IIRC, multifilesink with max-size policy does not preserve key frame boundaries.

What do you mean?


--

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Walter Lucetti
www.myzhar.com
Reply | Threaded
Open this post in threaded view
|

Re: Safe H264 video saving to file

Arjen Veenhuizen
Make sure that your individual segments all start with an I-frame. You could use
ffprobe -show_frames -i <segment_x.ts>|grep pict_type 
for that
Reply | Threaded
Open this post in threaded view
|

Re: Safe H264 video saving to file

Myzhar

2017-05-25 16:09 GMT+02:00 Arjen Veenhuizen [via GStreamer-devel] <[hidden email]>:
ffprobe -show_frames -i <segment_x.ts>|grep pict_type

Ok, thank you again


--
Walter Lucetti
www.myzhar.com
Reply | Threaded
Open this post in threaded view
|

Re: Safe H264 video saving to file

Michael MacIntosh
In reply to this post by Myzhar

You need to use the "h264parse" element before your splitmuxsink split on I frames.  If you don't split on I frames, then you will get messed up video at the beginning of each video segment that it records.


On 5/25/2017 7:11 AM, Walter Lucetti wrote:

2017-05-25 15:50 GMT+02:00 Yurii Monakov <[hidden email]>:
IIRC, multifilesink with max-size policy does not preserve key frame boundaries.

What do you mean?


--
Walter Lucetti

email: [hidden email]
web: www.robot-home.it



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel