This question already has answers here:
How to split a video using FFMPEG so that each chunk starts with a key frame?
(6 answers)
record desktop save every 30 minutes
(2 answers)
Export each minute of MP3 into separate WAV
(1 answer)
How to get equally spaced audio chunks from .wav file using ffmpeg?
(1 answer)
How to segment a video and then concatenate back into original one with ffmpeg
(1 answer)
Closed 4 years ago.
I am new in ffmpeg! i want to split videos which duration like 3 mins. or more into 10 sec.using ffmpeg?
please help me how to resolve it.
Use these commands in sequence for splitting videos.
ffmpeg -ss 00:00:00 -t 10 -i input.mov -vcodec copy -acodec copy output_part1.mov
ffmpeg -ss 00:00:10 -t 10 -i input.mov -vcodec copy -acodec copy output_part2.mov
ffmpeg -ss 00:00:20 -t 10 -i input.mov -vcodec copy -acodec copy output_part3.mov
ffmpeg -ss 00:00:30 -t 10 -i input.mov -vcodec copy -acodec copy output_part4.mov
-ss stands for start time,
-t is the length of final clip,
-i is the input file, in this case it's a file called 'input.mov'
-vcodec is the video codec used to encode the output file. 'copy' means we're using the
same codec as the input file.
-acodec is the audio codec. Like the video codec, we'll be using the same audio codec as the input file.
output.mov is the output file, you can rename this to any file name you choose.
Related
I want to create .mp4 video by joining short animation(.mp4) + audio(wav, mp3) using ffmpeg shell command.
I have tried few commands to join mp4 + audio here is my example command which will generate output video.
./ffmpeg -y -i ./output/preview-2.mp4 -i ./output/audio-file.mp3 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -r 25 -vcodec libx264 -pix_fmt yuv420p ./output/converted-video.mp4
But I want to play my animation till audio playing. The above FFMPEG command only join my animation(short video .mp4) file with audio and stopped animation playing after duration of short video reached to end (let's say animation file duration is 10seconds and stopped playing after 10 seconds). But my audio is about 3 minutes and I want to re-play the animation video again and again till the audio file duration (3 minutes). Just like a looping effect.
Add -stream_loop -1 and -shortest:
./ffmpeg -y -stream_loop -1 -i ./output/preview-2.mp4 -i ./output/audio-file.mp3 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -r 25 -vcodec libx264 -pix_fmt yuv420p -shortest ./output/converted-video.mp4
This question already has answers here:
How to add a new audio (not mixing) into a video using ffmpeg?
(10 answers)
Closed 4 years ago.
I need to concatenate some MP4 files. Only one of them has audio. The other ones hasn't.
MyList.txt contains:
file1.mp4 without audio and 5s length
File2.mp4 without audio and 5s length
File3.mp4 without audio and 5s length
File4.mp4 with audio and Ns length
I need an output that cotains the 4 mp4 files and when file4.mp4 starts I want to hear its audio.
If I set the file4.mp4 as the first video to concat, the output video has audio, but If I set the file4.mp4 in another position, the output video hasn't audio.
What I'm doing wrong? What I have to modify in my code?
ffmpeg -f concat -safe 0 -i myList.txt -c:v copy -c:a copy output.mp4
Have you tried generating a silent track for your mp4 files without any sound and then concatenating them?
ffmpeg -i "clip.mp4" -f lavfi -i aevalsrc=0 -shortest -y "new_clip.mp4"
This does the following:
Take clip.mp4 (which is the video clip without audio) (-i "clip.mp4")
Generate the minimum silence required (-f lavfi -i aevalsrc=0
-shortest)
Output the result (-y "new_clip.mp4")
Same problem but asked on stack exchange:
Link
Broader explanation can be found here:
second link
To remove the first 10 seconds of a video without any transcoding I can use the following command:
ffmpeg -i input.webm -vcodec copy -acodec copy -ss 10 output.webm
The problem is that if the key frames are located at 8 seconds then at 12 seconds, the video will start from the 8th second. If I do the following I will get the correct timing, but the whole stream will be transcoded:
ffmpeg -i input.webm -ss 10 output.webm
Is there any way (using avcodec of ffmpeg) to transcode only the part from the 10th to the 12th second then copy the rest of the stream?
I've been trying to find out solutions but could not, on how to extract a video segment (say an mp4) from a given m3u8 file, where the video starts from some offset and has a particular duration. Wish someone could help.
I tried this:
ffmpeg -i http://foo.herokuapp.com/input_test.m3u8 -acodec copy -vcodec copy -y -loglevel info -f mp4 myNewVideo.mp4
It generates the video, but now I need it to start from a particular offset and it needs to last a particular duration. I know that the offset might need the -ss flag, but it doesn't seem to be working.
Examples for a capture starting at 30s (-ss) with a duration of 10s (-t).
If the input HLS playlist is of type VOD you can do:
ffmpeg -ss 00:00:30 -i http://foo.herokuapp.com/input_test.m3u8 -t 10 -c copy -bsf:a aac_adtstoasc -flags +global_header -y output.mp4
If the input is a Live stream then:
ffmpeg -i http://foo.herokuapp.com/input_test.m3u8 -ss 00:00:30 -t 10 -c copy -bsf:a aac_adtstoasc -flags +global_header -y output.mp4
The seek is done on the output in the second case (-ss after -i).
You can also add a -re before -i for the live stream if you want to avoid fetching the latest 3 segments at once when you execute the command.
Here's what I have to do,
I want to convert two different images in different video file (ex: convert a.jpg into a.avi and b.jpg into b.avi).
I am trying to generate video (.avi) from image file. Video file is generated successfully but I can't see the audio properties when I right click on video and see details tab in property.
Then I have one video file (.avi), using ffmpeg concat function, I am concating these three video files (a.avi, middle.avi which I already have, b.avi).
After this, I am getting file output.avi but audio is not there in outout.avi file. I have middle.avi which already contains audio.
Here's my concat command,
ffmpeg -i "concat:a.avi|middle.avi|b.avi" -vcodec copy 103_n4_2.avi
I am trying to generate video (.avi) from only one image file. Video file is generated successfully but I can't see the audio properties when I right click on video and see details tab in property.
Here's my command to convert image to video:
ffmpeg -loop 1 -i bCopy.jpg -t 30 -q:v 0 -r 24 output_a.avi
PS: a.avi and b.avi (which I have generated from images does not contain audio) but only middle.avi contains the audio.
I think the audio track is completly ommitted. I was not able to test it but it seams you need to map the audio stream manually to the output and delay it by the the length of your first image.
ffmpeg -i middle.avi -itsoffset 1 -map 1:1 -i "concat:a.avi|middle.avi|b.avi" -map 0:0 -vcodec copy -acodec copy 103_n4_2.avi
Thanks for the help but I have found the solution of this perticular issue,
Here are the steps:
1. Generate blank mp3 of the first slide duration.
- ffmpeg -f lavfi -i aevalsrc=0 -t 31 -q:a 9 -acodec libmp3lame out.mp3
2. Trim audio from middle slide
- ffmpeg -i middle.avi -acodec copy middle.mp3
3. Concat this two audio
- ffmpeg -i "concat:out.mp3|middle.mp3" -acodec copy 103_n4_2.mp3
4. Now concat audio and video(that we've cgenerated by concatenation)
- ffmpeg -i 103_n4_3.avi -i 103_n4_2.mp3 -c:v copy -c:a aac -strict experimental 103_n4_5.avi