How can I create a 30 second GIF from a long random video?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I have hundreds of videos in a folder that I want to make a gif for. Each videos length is different but all videos are longer than 30 seconds. I want to take 10 3 second gif images from a video over the course of the video. For example if the video is 25 minutes long a 3 second recorded gif should be taken every 2.5 minutes (150 seconds).
The finished gifs must also have the same name as the video but ending in .gif all videos are .mp4
The gifs should be 560x340
It would be nice to do this with one command to.
ffmpeg mp4 gif
add a comment |
I have hundreds of videos in a folder that I want to make a gif for. Each videos length is different but all videos are longer than 30 seconds. I want to take 10 3 second gif images from a video over the course of the video. For example if the video is 25 minutes long a 3 second recorded gif should be taken every 2.5 minutes (150 seconds).
The finished gifs must also have the same name as the video but ending in .gif all videos are .mp4
The gifs should be 560x340
It would be nice to do this with one command to.
ffmpeg mp4 gif
add a comment |
I have hundreds of videos in a folder that I want to make a gif for. Each videos length is different but all videos are longer than 30 seconds. I want to take 10 3 second gif images from a video over the course of the video. For example if the video is 25 minutes long a 3 second recorded gif should be taken every 2.5 minutes (150 seconds).
The finished gifs must also have the same name as the video but ending in .gif all videos are .mp4
The gifs should be 560x340
It would be nice to do this with one command to.
ffmpeg mp4 gif
I have hundreds of videos in a folder that I want to make a gif for. Each videos length is different but all videos are longer than 30 seconds. I want to take 10 3 second gif images from a video over the course of the video. For example if the video is 25 minutes long a 3 second recorded gif should be taken every 2.5 minutes (150 seconds).
The finished gifs must also have the same name as the video but ending in .gif all videos are .mp4
The gifs should be 560x340
It would be nice to do this with one command to.
ffmpeg mp4 gif
ffmpeg mp4 gif
asked Mar 21 at 17:42
ToodardayToodarday
1056
1056
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Steps:
Get duration withffprobe
.- Use duration as a value in the select filter.
Create gif.- Script everything.
Example script:
#!/bin/bash
mkdir 30gif
for f in *.mp4; do
duration=$(ffprobe -loglevel error -show_entries format=duration -of default=nk=1:nw=1 "$f")
ffmpeg -i "$f" -filter_complex "[0:v]select='lt(mod(t,${duration}/10),3)',setpts=N/(FRAME_RATE*TB),scale=560:340:force_original_aspect_ratio=decrease,pad=560:340:(ow-iw)/2:(oh-ih)/2,setsar=1,split[v0][v1];[v0]palettegen[p];[v1][p]paletteuse[v]" -map "[v]" "30gif/${f%.mp4}.gif"
done
This fulfills your many requirements:
- Output 30 second GIF comprising of 3 second segments equally spanning input duration
- 560x340 output size
- One (
ffmpeg
) command - Using a bash for loop so you can automatically convert hundreds of videos
- Output name is same as input name but with .mp4 replaced with .gif
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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%2faskubuntu.com%2fquestions%2f1127603%2fhow-can-i-create-a-30-second-gif-from-a-long-random-video%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
Steps:
Get duration withffprobe
.- Use duration as a value in the select filter.
Create gif.- Script everything.
Example script:
#!/bin/bash
mkdir 30gif
for f in *.mp4; do
duration=$(ffprobe -loglevel error -show_entries format=duration -of default=nk=1:nw=1 "$f")
ffmpeg -i "$f" -filter_complex "[0:v]select='lt(mod(t,${duration}/10),3)',setpts=N/(FRAME_RATE*TB),scale=560:340:force_original_aspect_ratio=decrease,pad=560:340:(ow-iw)/2:(oh-ih)/2,setsar=1,split[v0][v1];[v0]palettegen[p];[v1][p]paletteuse[v]" -map "[v]" "30gif/${f%.mp4}.gif"
done
This fulfills your many requirements:
- Output 30 second GIF comprising of 3 second segments equally spanning input duration
- 560x340 output size
- One (
ffmpeg
) command - Using a bash for loop so you can automatically convert hundreds of videos
- Output name is same as input name but with .mp4 replaced with .gif
add a comment |
Steps:
Get duration withffprobe
.- Use duration as a value in the select filter.
Create gif.- Script everything.
Example script:
#!/bin/bash
mkdir 30gif
for f in *.mp4; do
duration=$(ffprobe -loglevel error -show_entries format=duration -of default=nk=1:nw=1 "$f")
ffmpeg -i "$f" -filter_complex "[0:v]select='lt(mod(t,${duration}/10),3)',setpts=N/(FRAME_RATE*TB),scale=560:340:force_original_aspect_ratio=decrease,pad=560:340:(ow-iw)/2:(oh-ih)/2,setsar=1,split[v0][v1];[v0]palettegen[p];[v1][p]paletteuse[v]" -map "[v]" "30gif/${f%.mp4}.gif"
done
This fulfills your many requirements:
- Output 30 second GIF comprising of 3 second segments equally spanning input duration
- 560x340 output size
- One (
ffmpeg
) command - Using a bash for loop so you can automatically convert hundreds of videos
- Output name is same as input name but with .mp4 replaced with .gif
add a comment |
Steps:
Get duration withffprobe
.- Use duration as a value in the select filter.
Create gif.- Script everything.
Example script:
#!/bin/bash
mkdir 30gif
for f in *.mp4; do
duration=$(ffprobe -loglevel error -show_entries format=duration -of default=nk=1:nw=1 "$f")
ffmpeg -i "$f" -filter_complex "[0:v]select='lt(mod(t,${duration}/10),3)',setpts=N/(FRAME_RATE*TB),scale=560:340:force_original_aspect_ratio=decrease,pad=560:340:(ow-iw)/2:(oh-ih)/2,setsar=1,split[v0][v1];[v0]palettegen[p];[v1][p]paletteuse[v]" -map "[v]" "30gif/${f%.mp4}.gif"
done
This fulfills your many requirements:
- Output 30 second GIF comprising of 3 second segments equally spanning input duration
- 560x340 output size
- One (
ffmpeg
) command - Using a bash for loop so you can automatically convert hundreds of videos
- Output name is same as input name but with .mp4 replaced with .gif
Steps:
Get duration withffprobe
.- Use duration as a value in the select filter.
Create gif.- Script everything.
Example script:
#!/bin/bash
mkdir 30gif
for f in *.mp4; do
duration=$(ffprobe -loglevel error -show_entries format=duration -of default=nk=1:nw=1 "$f")
ffmpeg -i "$f" -filter_complex "[0:v]select='lt(mod(t,${duration}/10),3)',setpts=N/(FRAME_RATE*TB),scale=560:340:force_original_aspect_ratio=decrease,pad=560:340:(ow-iw)/2:(oh-ih)/2,setsar=1,split[v0][v1];[v0]palettegen[p];[v1][p]paletteuse[v]" -map "[v]" "30gif/${f%.mp4}.gif"
done
This fulfills your many requirements:
- Output 30 second GIF comprising of 3 second segments equally spanning input duration
- 560x340 output size
- One (
ffmpeg
) command - Using a bash for loop so you can automatically convert hundreds of videos
- Output name is same as input name but with .mp4 replaced with .gif
edited Mar 26 at 19:14
answered Mar 21 at 18:06
lloganllogan
5,4151737
5,4151737
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1127603%2fhow-can-i-create-a-30-second-gif-from-a-long-random-video%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