How do I add a delay to a live stream sourced from webcam (v4l2) with FFMPEG?
How can I use FFMPEG to add a delay to a stream being sent from a (v4l2) webcam to a media server?
The use case here is something like a security camera where I want to be able to stream video to a server when something is detected in the video. The easiest way to ensure the event of interest is captured on the video is to use FFMPEG to stream from the camera to a virtual loopback device with an added delay. That loopback device can then be used to initiate live streaming when an even of interest occurs.
In GStreamer, I would accomplish a delay of this sort with the queue
element's min-threshold-time
parameter. For example the following (much-simplified) example pipeline adds a 2 second delay to the output coming from a v4l2 webcam before displaying it:
gst-launch-1.0 v4l2src device=/dev/video1 ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 min-threshold-time=2000000000 ! xvimagesink
How do I accomplish the same thing with FFMPEG? There are some technical challenges that prevent us from using GStreamer for this.
I have investigated the itsoffset
option for this, but as far as I can tell it is only usable for already-recorded files, and it is not clear what a good alternative would be.
ffmpeg video-streaming gstreamer v4l2loopback
add a comment |
How can I use FFMPEG to add a delay to a stream being sent from a (v4l2) webcam to a media server?
The use case here is something like a security camera where I want to be able to stream video to a server when something is detected in the video. The easiest way to ensure the event of interest is captured on the video is to use FFMPEG to stream from the camera to a virtual loopback device with an added delay. That loopback device can then be used to initiate live streaming when an even of interest occurs.
In GStreamer, I would accomplish a delay of this sort with the queue
element's min-threshold-time
parameter. For example the following (much-simplified) example pipeline adds a 2 second delay to the output coming from a v4l2 webcam before displaying it:
gst-launch-1.0 v4l2src device=/dev/video1 ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 min-threshold-time=2000000000 ! xvimagesink
How do I accomplish the same thing with FFMPEG? There are some technical challenges that prevent us from using GStreamer for this.
I have investigated the itsoffset
option for this, but as far as I can tell it is only usable for already-recorded files, and it is not clear what a good alternative would be.
ffmpeg video-streaming gstreamer v4l2loopback
add a comment |
How can I use FFMPEG to add a delay to a stream being sent from a (v4l2) webcam to a media server?
The use case here is something like a security camera where I want to be able to stream video to a server when something is detected in the video. The easiest way to ensure the event of interest is captured on the video is to use FFMPEG to stream from the camera to a virtual loopback device with an added delay. That loopback device can then be used to initiate live streaming when an even of interest occurs.
In GStreamer, I would accomplish a delay of this sort with the queue
element's min-threshold-time
parameter. For example the following (much-simplified) example pipeline adds a 2 second delay to the output coming from a v4l2 webcam before displaying it:
gst-launch-1.0 v4l2src device=/dev/video1 ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 min-threshold-time=2000000000 ! xvimagesink
How do I accomplish the same thing with FFMPEG? There are some technical challenges that prevent us from using GStreamer for this.
I have investigated the itsoffset
option for this, but as far as I can tell it is only usable for already-recorded files, and it is not clear what a good alternative would be.
ffmpeg video-streaming gstreamer v4l2loopback
How can I use FFMPEG to add a delay to a stream being sent from a (v4l2) webcam to a media server?
The use case here is something like a security camera where I want to be able to stream video to a server when something is detected in the video. The easiest way to ensure the event of interest is captured on the video is to use FFMPEG to stream from the camera to a virtual loopback device with an added delay. That loopback device can then be used to initiate live streaming when an even of interest occurs.
In GStreamer, I would accomplish a delay of this sort with the queue
element's min-threshold-time
parameter. For example the following (much-simplified) example pipeline adds a 2 second delay to the output coming from a v4l2 webcam before displaying it:
gst-launch-1.0 v4l2src device=/dev/video1 ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 min-threshold-time=2000000000 ! xvimagesink
How do I accomplish the same thing with FFMPEG? There are some technical challenges that prevent us from using GStreamer for this.
I have investigated the itsoffset
option for this, but as far as I can tell it is only usable for already-recorded files, and it is not clear what a good alternative would be.
ffmpeg video-streaming gstreamer v4l2loopback
ffmpeg video-streaming gstreamer v4l2loopback
asked Nov 19 '18 at 22:09
DavidDavid
32
32
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
With a recent git build of ffmpeg, basic template is
ffmpeg -i input -vf tpad=start_duration=5 -af adelay=5000|5000 stream-out
The tpad
filter will add 5 seconds of black at the start of the video stream, and the apad filter will add 5000 milliseconds of silence to the first two channels of the audio.
Thanks, this worked perfectly! How serendipitous that this filter just made it into master a few weeks ago (by my reading of the FFMPEG listservs). Are there any sources to which one can subscribe to see these kinds of new features without being exposed to the full torrent of development-related conversation?
– David
Nov 21 '18 at 17:59
lists.ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
– Gyan
Nov 21 '18 at 18:14
Thanks for everything here, you've been extremely helpful.
– David
Nov 21 '18 at 20:35
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53383354%2fhow-do-i-add-a-delay-to-a-live-stream-sourced-from-webcam-v4l2-with-ffmpeg%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
With a recent git build of ffmpeg, basic template is
ffmpeg -i input -vf tpad=start_duration=5 -af adelay=5000|5000 stream-out
The tpad
filter will add 5 seconds of black at the start of the video stream, and the apad filter will add 5000 milliseconds of silence to the first two channels of the audio.
Thanks, this worked perfectly! How serendipitous that this filter just made it into master a few weeks ago (by my reading of the FFMPEG listservs). Are there any sources to which one can subscribe to see these kinds of new features without being exposed to the full torrent of development-related conversation?
– David
Nov 21 '18 at 17:59
lists.ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
– Gyan
Nov 21 '18 at 18:14
Thanks for everything here, you've been extremely helpful.
– David
Nov 21 '18 at 20:35
add a comment |
With a recent git build of ffmpeg, basic template is
ffmpeg -i input -vf tpad=start_duration=5 -af adelay=5000|5000 stream-out
The tpad
filter will add 5 seconds of black at the start of the video stream, and the apad filter will add 5000 milliseconds of silence to the first two channels of the audio.
Thanks, this worked perfectly! How serendipitous that this filter just made it into master a few weeks ago (by my reading of the FFMPEG listservs). Are there any sources to which one can subscribe to see these kinds of new features without being exposed to the full torrent of development-related conversation?
– David
Nov 21 '18 at 17:59
lists.ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
– Gyan
Nov 21 '18 at 18:14
Thanks for everything here, you've been extremely helpful.
– David
Nov 21 '18 at 20:35
add a comment |
With a recent git build of ffmpeg, basic template is
ffmpeg -i input -vf tpad=start_duration=5 -af adelay=5000|5000 stream-out
The tpad
filter will add 5 seconds of black at the start of the video stream, and the apad filter will add 5000 milliseconds of silence to the first two channels of the audio.
With a recent git build of ffmpeg, basic template is
ffmpeg -i input -vf tpad=start_duration=5 -af adelay=5000|5000 stream-out
The tpad
filter will add 5 seconds of black at the start of the video stream, and the apad filter will add 5000 milliseconds of silence to the first two channels of the audio.
answered Nov 20 '18 at 5:39
GyanGyan
32.4k22869
32.4k22869
Thanks, this worked perfectly! How serendipitous that this filter just made it into master a few weeks ago (by my reading of the FFMPEG listservs). Are there any sources to which one can subscribe to see these kinds of new features without being exposed to the full torrent of development-related conversation?
– David
Nov 21 '18 at 17:59
lists.ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
– Gyan
Nov 21 '18 at 18:14
Thanks for everything here, you've been extremely helpful.
– David
Nov 21 '18 at 20:35
add a comment |
Thanks, this worked perfectly! How serendipitous that this filter just made it into master a few weeks ago (by my reading of the FFMPEG listservs). Are there any sources to which one can subscribe to see these kinds of new features without being exposed to the full torrent of development-related conversation?
– David
Nov 21 '18 at 17:59
lists.ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
– Gyan
Nov 21 '18 at 18:14
Thanks for everything here, you've been extremely helpful.
– David
Nov 21 '18 at 20:35
Thanks, this worked perfectly! How serendipitous that this filter just made it into master a few weeks ago (by my reading of the FFMPEG listservs). Are there any sources to which one can subscribe to see these kinds of new features without being exposed to the full torrent of development-related conversation?
– David
Nov 21 '18 at 17:59
Thanks, this worked perfectly! How serendipitous that this filter just made it into master a few weeks ago (by my reading of the FFMPEG listservs). Are there any sources to which one can subscribe to see these kinds of new features without being exposed to the full torrent of development-related conversation?
– David
Nov 21 '18 at 17:59
lists.ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
– Gyan
Nov 21 '18 at 18:14
lists.ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
– Gyan
Nov 21 '18 at 18:14
Thanks for everything here, you've been extremely helpful.
– David
Nov 21 '18 at 20:35
Thanks for everything here, you've been extremely helpful.
– David
Nov 21 '18 at 20:35
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53383354%2fhow-do-i-add-a-delay-to-a-live-stream-sourced-from-webcam-v4l2-with-ffmpeg%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown