Dynamically Record Video

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynamically Record Video

Jump to solution
2,390 Views
itaigolan
Contributor II

Hi, I’m displaying a video from v4l2src in a waylandsink and while I’m doing that I want to dynamically record the video to an mp4. I want to allow a user provided input to determine when to start recording to an mp4 and when to stop the recording. The recording pipeline I’m currently using is:
gst-launch-1.0 v4l2src ! vpuenc_h264 ! h264parse ! mp4mux ! filesink location=sample.mp4 -e

I tried connecting the recording pipeline to a tee and then deleting it when I’m done recording and I was able to get video to record but that approach causes problems after starting and stopping recording multiple times. Does anyone know a way I can approach this, preferably by just pausing the recording section of the pipeline?

 
Labels (1)
0 Kudos
Reply
1 Solution
2,327 Views
malik_cisse
Senior Contributor I

Hi @itaigolan,
I would implement a gstreamer Tee that sinks in an Appsink. After that, every time a new recording event occurs, I will start a recording pipeline using Appsrc. This would be my best bet.

You might alternatively look at Ridgerun Interpipe that can do similar stuff:
https://developer.ridgerun.com/wiki/index.php/GstInterpipe_-_GstInterpipe_Overview 

Using pause or start/stop does not work well with MP4 because MP4 needs a proper file header that contains all key frame positions of the stream. A more robust file format for this is Mpeg-TS. H.264 elementary stream embeds very well in *.ts files and TS muxer are available in stock Gstreamer.

View solution in original post

0 Kudos
Reply
4 Replies
2,328 Views
malik_cisse
Senior Contributor I

Hi @itaigolan,
I would implement a gstreamer Tee that sinks in an Appsink. After that, every time a new recording event occurs, I will start a recording pipeline using Appsrc. This would be my best bet.

You might alternatively look at Ridgerun Interpipe that can do similar stuff:
https://developer.ridgerun.com/wiki/index.php/GstInterpipe_-_GstInterpipe_Overview 

Using pause or start/stop does not work well with MP4 because MP4 needs a proper file header that contains all key frame positions of the stream. A more robust file format for this is Mpeg-TS. H.264 elementary stream embeds very well in *.ts files and TS muxer are available in stock Gstreamer.

0 Kudos
Reply
2,236 Views
itaigolan
Contributor II

Thanks for the response, I got good results using the appsink approach.

2,375 Views
joanxie
NXP TechSupport
NXP TechSupport

what processor and bsp version do you use? and what kind of problem do you have? 

0 Kudos
Reply
2,351 Views
itaigolan
Contributor II

The processor is imx8mp and we are running Mickledore. My question is how do I set up a system where I can dynamically start and stop video recording while constantly displaying the video on a waylandsink.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1844586%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EDynamically%20Record%20Video%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1844586%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CDIV%20class%3D%22%22%3E%3CP%3EHi%2C%20I%E2%80%99m%20displaying%20a%20video%20from%20v4l2src%20in%20a%20waylandsink%20and%20while%20I%E2%80%99m%20doing%20that%20I%20want%20to%20dynamically%20record%20the%20video%20to%20an%20mp4.%20I%20want%20to%20allow%20a%20user%20provided%20input%20to%20determine%20when%20to%20start%20recording%20to%20an%20mp4%20and%20when%20to%20stop%20the%20recording.%20The%20recording%20pipeline%20I%E2%80%99m%20currently%20using%20is%3A%3CBR%20%2F%3Egst-launch-1.0%20v4l2src%20!%20vpuenc_h264%20!%20h264parse%20!%20mp4mux%20!%20filesink%20location%3Dsample.mp4%20-e%3C%2FP%3E%3CP%3EI%20tried%20connecting%20the%20recording%20pipeline%20to%20a%20tee%20and%20then%20deleting%20it%20when%20I%E2%80%99m%20done%20recording%20and%20I%20was%20able%20to%20get%20video%20to%20record%20but%20that%20approach%20causes%20problems%20after%20starting%20and%20stopping%20recording%20multiple%20times.%20Does%20anyone%20know%20a%20way%20I%20can%20approach%20this%2C%20preferably%20by%20just%20pausing%20the%20recording%20section%20of%20the%20pipeline%3F%3C%2FP%3E%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1844586%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MX%208M%20%7C%20i.MX%208M%20Mini%20%7C%20i.MX%208M%20Nano%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1850247%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Dynamically%20Record%20Video%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1850247%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThanks%20for%20the%20response%2C%20I%20got%20good%20results%20using%20the%20appsink%20approach.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1845950%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Dynamically%20Record%20Video%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1845950%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F227072%22%20target%3D%22_blank%22%3E%40itaigolan%3C%2FA%3E%2C%3CBR%20%2F%3EI%20would%20implement%20a%20gstreamer%20%3CSTRONG%3ETee%3C%2FSTRONG%3E%20that%20sinks%20in%20an%20%3CSTRONG%3EAppsink%3C%2FSTRONG%3E.%20After%20that%2C%20every%20time%20a%20new%20recording%20event%20occurs%2C%20I%20will%20start%20a%20recording%20pipeline%20using%20%3CSTRONG%3EAppsrc%3C%2FSTRONG%3E.%20This%20would%20be%20my%20best%20bet.%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20might%20alternatively%20look%20at%20%3CSTRONG%3ERidgerun%20Interpipe%3C%2FSTRONG%3E%20that%20can%20do%20similar%20stuff%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdeveloper.ridgerun.com%2Fwiki%2Findex.php%2FGstInterpipe_-_GstInterpipe_Overview%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdeveloper.ridgerun.com%2Fwiki%2Findex.php%2FGstInterpipe_-_GstInterpipe_Overview%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EUsing%20pause%20or%20start%2Fstop%20does%20not%20work%20well%20with%20MP4%20because%20MP4%20needs%20a%20proper%20file%20header%20that%20contains%20all%20key%20frame%20positions%20of%20the%20stream.%20A%20more%20robust%20file%20format%20for%20this%20is%20%3CSTRONG%3EMpeg-TS%3C%2FSTRONG%3E.%20H.264%20elementary%20stream%20embeds%20very%20well%20in%20*.ts%20files%20and%20TS%20muxer%20are%20available%20in%20stock%20Gstreamer.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1845459%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Dynamically%20Record%20Video%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1845459%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22%22%3EThe%20processor%20is%20imx8mp%20and%20we%20are%20running%20Mickledore.%20My%20question%20is%20how%20do%20I%20set%20up%20a%20system%20where%20I%20can%20dynamically%20start%20and%20stop%20video%20recording%20while%20constantly%20displaying%20the%20video%20on%20a%20waylandsink.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1844747%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Dynamically%20Record%20Video%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1844747%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Ewhat%20processor%20and%20bsp%20version%20do%20you%20use%EF%BC%9F%20and%20what%20kind%20of%20problem%20do%20you%20have%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E