I have used this command to concate multiple images with transition effects to create video.
"-y -f concat -safe 0 -i <txt file path> -filter_complex [0:0][1:0]concat=n=2:v=0:a=1[out] -map [v] -shortest -vf fps=40 -pix_fmt yuv420p <video path>"
But it is showing error :
Stream specifier ':0' in filtergraph description [0:0][1:0]concat=n=2:v=0:a=1[out] matches no streams.
Here is my txt file
file '/storage/emulated/0/image1.jpg'
duration 5
file '/storage/emulated/0/image2.jpg'
duration 5
file '/storage/emulated/0/image3.jpg'
However if i am not applying any filter effect, it is successfully creating a video.
Following command creates the video at a frame rate of 1 frame for 5 seconds.
ffmpeg -y -r 1/5 -i image1.jpg -i image2.jpg -i image3.jpg -filter_complex 'concat=n=3:v=1:a=0 [out]' -map [out] -c:v libx264 output.mp4
Related
I have two videos and two audios
1:-
video 1 - length:- 60 sec || audio 1 - length:- 15 sec
2:-
video - length:- 86 sec || audio 2 - length:- 18 sec
Play video1 and audio1 together, if audio1 is ended then restart that audio till video1 end. this will final video 1.
same way,
play video2 and audio2 together, if audio2 is ended then restart that audio till video2 end. this will final video 2.
after that concatenate those final video 1 and final video 2 and create single video as output.
Thank you in advance.
Because your inputs are arbitrary you need to make them the same before concatenation.
ffmpeg -i video1 -stream_loop -1 -i audio1 -filter_complex "[0:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1,setsar=1,fps=25,format=yuv420p[v]" -map "[v]" -map 1:a -ac 2 -ar 44100 -shortest temp1.mp4
ffmpeg -i video2 -stream_loop -1 -i audio2 -filter_complex "[0:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1,setsar=1,fps=25,format=yuv420p[v]" -map "[v]" -map 1:a -ac 2 -ar 44100 -shortest temp2.mp4
Concatenate.
Make input.txt:
file 'temp1.mp4'
file 'temp2.mp4'
Run ffmpeg:
ffmpeg -f concat -i input.txt -c copy -movflags +faststart output.mp4
As a "single line command" as requested (but make input.txt first):
ffmpeg -i video1 -stream_loop -1 -i audio1 -filter_complex "[0:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1,setsar=1,fps=25,format=yuv420p[v]" -map "[v]" -map 1:a -ac 2 -ar 44100 -shortest temp1.mp4 && ffmpeg -i video2 -stream_loop -1 -i audio2 -filter_complex "[0:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1,setsar=1,fps=25,format=yuv420p[v]" -map "[v]" -map 1:a -ac 2 -ar 44100 -shortest temp2.mp4 && ffmpeg -f concat -safe 0 -i input.txt -c copy -movflags +faststart output.mp4
I have 2 commands, one for overlay(work alone), one for add text (work alone), i want this 2 commands in one.
ffmpeg -i myvideo.mp4 -i image.png -filter_complex [0:v][1:v]overlay=5:5,drawtext=fontfile=:text=mytext:fontcolor=orange#1.0:fontsize=30:x=30:y=200[v] -map [output] output.mp4
This command generate empty file without error.
Your -map option is using a label that does not reference anything.
You should be getting this error:
Output with label 'output' does not exist in any defined filter graph, or was already used elsewhere.
The -filter_complex output and the -map option should use the same label. It can be almost any arbitrary name as long as they match. Also, your fontfile is missing the font path. You may have to quote your text string, but you're using Android and it is weird with quoting. Lastly, you should stream copy the audio.
Use this: both filter output and -map are using [v]
ffmpeg -i myvideo.mp4 -i image.png -filter_complex [0:v][1:v]overlay=5:5,drawtext=text=mytext:fontcolor=orange#1.0:fontsize=30:x=30:y=200[v] -map [v] -map 0:a -c:a copy output.mp4
or this: both filter output and -map are using [output]
ffmpeg -i myvideo.mp4 -i image.png -filter_complex [0:v][1:v]overlay=5:5,drawtext=text=mytext:fontcolor=orange#1.0:fontsize=30:x=30:y=200[output] -map [output] -map 0:a -c:a copy output.mp4
or this: use the default stream selection
ffmpeg -i myvideo.mp4 -i image.png -filter_complex [0:v][1:v]overlay=5:5,drawtext=text=mytext:fontcolor=orange#1.0:fontsize=30:x=30:y=200 -c:a copy output.mp4
I m using below ffmpeg command to generate video(slideshow) from list of images,but the issue is that its only displaying first image.
ffmpeg -loop 1 -t 3 -i image1.jpg -i image2.jpg -i image3.jpg -filter_complex [v][v1][v2] concat=n=3:v=1,format=yuv422p[a] -map [a] out.mp4
Any help will be appreciate.
Thanks.
Finally after lot of practices got the solution and better ffmpeg command then above command.
ffmpeg -f concat -safe 0 -i img-list.txt -f concat -safe 0 -i audio-list.txt -c:a aac -pix_fmt yuv420p -crf 23 -r 24 -shortest -y -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" video.mp4
in above command input.txt will contains path of image files seperated with new line.
input.txt
file '*/image1.jpg'
file '*/image2.jpg'
file '*/image3.jpg'
Using Ffmpeg on Android to make a video from Single image merged with an Audio file, it works but the output video is not seeking to any time stamps
ex - always starts from 0:00, on seeking the video ahead it just restarts the whole video from start.
The command I used is -
-y -framerate 30 -i "+ImagePath+" -i "+AudioPath+" -vsync vfr -c:v libx264 -codec:a copy -pix_fmt yuv420p -crf 23 "+OutputVideoPath
can this be due to single frame only? (one image in video)
if so what can be used to convert a single image to seekable video.
This command will work to make a seekable MP4 (using input from image file and MP3 audio).
ffmpeg -y -i AUDIO.file -f image2 -loop 1 -r 2 -i IMAGE.file -shortest -c:a copy -c:v libx264 -crf 18 -framerate 30 -preset veryfast -movflags +faststart OUTPUT.mp4
Just replace AUDIO.file and IMAGE.fileand OUTPUT.mp4 with your custom file names.
Try this in your Android code:
-y -i "+AudioPath+" -f image2 -loop 1 -r 2 -i "+ImagePath+" -shortest -c:a copy -c:v libx264 -crf 18 -framerate 30 -preset veryfast -movflags +faststart "+OutputVideoPath+"
Try setting up your code like this:
"-y -i "+AudioPath+" -f image2 -loop 1 -r 2 -i "+ImagePath+" -shortest -c:a copy -c:v libx264 -crf 18 -framerate 30 -preset veryfast -movflags +faststart "+OutputVideoPath
I am cutting out segments from a long mp4 file and then rejoining parts of them. However, since FFMPEG apparently keeps the same MOOV atom for the trimmed files as the original, it looks to FFMPEG that the trimmed videos are all identical since they all have the same MOOV atom, and therefore only uses the first segment when trying to join the videos. Is there a way around this? Unfortunately since FFMPEG is embedded in an Android app, I can only use version 0.11.
Edit:
This is a sample of the processes:
ffmpeg -i /sdcard/path/movie.mp4 -ss 00:00:06.000, -t 00:00:05.270, -c:a aac -c:v libx264 /sdcard/path/file1.mp4
ffmpeg -i /sdcard/path/movie.mp4 -ss 00:00:12.000, -t 00:00:04.370, -c:a aac -c:v libx264 /sdcard/path/file2.mp4
ffmpeg -i /sdcard/path/movie.mp4 -ss 00:00:23.000, -t 00:00:03.133, -c:a aac -c:v libx264 /sdcard/path/file3.mp4
ffmpeg -i "concat:/sdcard/path/file1.mp4|/sdcard/path/file2.mp4|/sdcard/path/file3.mp4" -c:a aac -c:v libx264 /sdcard/path/output.mp4
I've also tried using the copy codec option but that hasn't helped.
Can you try something like:
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
I hope this works with ffmpeg version 0.11. We need to make sure you can concat before applying the cut of file.
Also can you check the intermediary file*.mp4 works well? Can you try to put your video files on the same folder as ffmpeg I am not sure how the concat protocol reacts to /sdcard/path/file1.mp4|/sdcard/path/file2.mp4?