I have a list of images, containing incremental integer values saved in png format starting from number 1, which need to be converted to a video with GOP 1 using ffmpeg. I have used the following command to convert the images to video and subsequently used ffplay to seek to a particular frame. The displayed frame doesn't match the frame being seek. Any help?
ffmpeg -i image%03d.png -c:v libx264 -g 1 -pix_fmt yuv420p out.mp4
Related
I use this command to crop a few seconds of mkv/mp4 videos. Sometimes it works perfectly fine.
But other times the output file which is in mp4 format only contains the audio. How can I fix it?
ffmpeg -i input.mp4 -ss 01:10:15 -to 01:10:20 -c:v copy -c:a copy output.mp4
Don't use -c:v copy -c:a copy Re-encode it.
Direct stream copy copies the GOP (Group of pictures) chunks of the structure of file (from the first I-frame to the last P or B-frame).
Presumably your time is too short, less than one chunk of GOP.
I am creating a video with ffmpeg by stringing together a bunch of PNG files. The resulting video has horizontal lines running across it and the colors are not accurate. Here's the command I used:
ffmpeg -framerate 1 -i img%04d.png -pix_fmt yuv420p timer.mp4
I am attaching an example of one of the input PNG files and a frame from the video. Can anyone tell what's wrong?
input file
video frame
I am using ffmpeg to convert mp4 to .ts format. In the meta file generated I can see chunk size are random which is acceptable to me, but i need to specify minimum duration of chunk size. Like 15sec or 30sec. Currently I am using following command to convert the videos.
ffmpeg -i ad1.mp4 -strict -2 -profile:v baseline -level 3.0 -start_number 0 -hls_list_size 0 -hls_segment_filename 'sample-%06d.ts' -f hls sample.m3u8
Pastebin link for sample m3u8 file
I know how to combine a single image with an mp3 to create a video like this
"ffmpeg.exe" -loglevel 0 -loop 1 -i c:\path\foo.jpg -i c:\path\foo.mp3 -c:v libx264 -pix_fmt yuv420p -crf 0 -c:a copy -shortest c:\path\foo.mkv
How can I make ffmpeg create a video using multiple images that it cycles through at regular intervals, or even randomly? Basically I want to use more than one image in a video rather than just 1.
You can use the examples from the wiki to create a slideshow from images.
For example:
ffmpeg -framerate 1/3 -pattern_type glob -i '*.jpg' -c:v libx264 out.mp4
Keep in mind that all images must have the same size!
In my test the resulting mp4 file was approximately the same size as the sum of the input files;
> du out.mp4
768 out.mp4
> du -c *.jpg|grep total
648 total
Note that photos from a digital camera are generally a lot bigger than even a HD movie, so you might want to scale the images.
This can be done using the scale filter, or with an external program like ImageMagick. In my example I scaled the images before making a movie out of them.
trying to get my head around ffmpeg to create a slideshow where each image is displayed for ~5 seconds with some audio. created a bat file to run the following so far:
ffmpeg -f image2 -i image-%%03d.jpg -i music.mp3 output.mpg
It gets the images and displayes them all very fast in the first second of the video, it then plays out the rest of the audio while showing the last image.
I want to make the images stay up longer (about 5 seconds), and stop the video after the last frame (not playing the rest of the song), are either of these things possible? i could hack the frame rate thing i guess by having hundreds of the same image in order to keep it up longer, but this is far from ideal!
Thanks
The default encoder for mpg output, mpeg1video, is strict about the allowed frame rates, so an input and an output -r are required:
ffmpeg -r 1/5 -i image-%03d.jpg -i music.mp3 -r 25 -qscale:v 2 -shortest -codec:a copy output.mpg
The input images will have a frame rate of 1 frame every 5 seconds and the output will duplicate frames to reach 25 frames per second.
-f image2 is generally not required.
-qscale:v can control output quality. A sane range is 2-5.
-shortest will make the output duration the same as the shortest input duration.
-codec:a copy copy your MP3 audio instead of re-encoding.
MPEG-1 video has more modern alternatives. See the FFmpeg and x264 Encoding Guide for more info.
Also see:
* FFmpeg FAQ: How do I encode single pictures into movies?
* FFmpeg Wiki: Create a video slideshow from images
You could use the filter fps instead of output framerate
ffmpeg -r 1/5 -i img%03d.png -i musicfile -c:v libx264 -vf fps=25 -pix_fmt yuv420p out.mp4
This however skips the last image for me strangely.