I want to create a video from different png images. My code is:
ffmpeg -r 20 -f image2 -i slideshow/%d.png -y -s 320x240 -aspect 4:3 out.mp4
and i receive output:
FFmpeg version SVN-r26400, Copyright (c) 2000-2011 the FFmpeg developers
built on Sep 27 2011 00:47:07 with gcc 4.1.2 20080704 (Red Hat 4.1.2-50)
configuration: --enable-avfilter --enable-filter=fade
libavutil 50.36. 0 / 50.36. 0
libavcore 0.16. 1 / 0.16. 1
libavcodec 52.108. 0 / 52.108. 0
libavformat 52.93. 0 / 52.93. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1.74. 0 / 1.74. 0
libswscale 0.12. 0 / 0.12. 0
Input #0, image2, from 'slideshow/%d.png':
Duration: 00:00:00.25, start: 0.000000, bitrate: N/A
Stream #0.0: Video: png, rgb24, 720x471, 20 fps, 20 tbr, 20 tbn, 20 tbc
[buffer # 0x9687230] w:720 h:471 pixfmt:rgb24
[scale # 0x9687600] w:720 h:471 fmt:rgb24 -> w:320 h:240 fmt:yuv420p flags:0xa0000004
Output #0, mp4, to 'out.mp4':
Metadata:
encoder : Lavf52.93.0
Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 20 tbn, 20 tbc
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
Segmentation fault
What might be the problem? Please help...
Currently i am using centos 5 server.
At last i found a fix for the problem. I don't know why but in case of png images of multiple size, ffmpeg was not creating the video but when i used png images of same size video was created without error. So, i cut similar size thumnails from images and create video using those thumbnails and i was able to generate the slideshow...
Related
thanks for taking a moment to look at this FFMPEG error i'm having. I'm trying to transcode any video file, recorded in portrait mode and crop it to a square using the top portion and then size it down to 600x600 square. Here is the command i'm using:
ffmpeg -y -i input-video.mov -filter_complex '[0] crop=1080:1080:0:0, scale=600:600, split=2[out1][out2]' -map '[out1]' video/transcoded-video.mp4 -map '[out2]' -qscale:v 6 thumbnails/thumb_%03d.png
Here are the errors:
[swscaler # 0x2502260] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler # 0x250a2b0] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler # 0x2512300] No accelerated colorspace conversion found from yuv420p to rgb24.
[NULL # 0x24e9dd0] [Eval # 0x7fff769243e0] Undefined constant or missing '(' in 'baseline'
[NULL # 0x24e9dd0] Unable to parse option value "baseline"
[NULL # 0x24e9dd0] Error setting option profile to value baseline.
Here is the output:
ffmpeg version git-2013-06-02-5711e4f Copyright (c) 2000-2013 the FFmpeg developers
built on Jun 2 2013 07:38:40 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
configuration: --enable-shared --disable-asm --prefix=/app/vendor/ffmpeg
libavutil 52. 34.100 / 52. 34.100
libavcodec 55. 13.100 / 55. 13.100
libavformat 55. 8.102 / 55. 8.102
libavdevice 55. 2.100 / 55. 2.100
libavfilter 3. 74.101 / 3. 74.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/app/downloads/bf951fbc8322d9010d679e656ccda330b6f19f36.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2016-07-01 19:27:37
Duration: 00:00:04.77, start: 0.000000, bitrate: 17881 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17874 kb/s, 29.98 fps, 30 tbr, 600 tbn, 1200 tbc
Metadata:
rotate : 90
creation_time : 2016-07-01 19:27:37
handler_name : Core Media Data Handler
[swscaler # 0x2502260] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler # 0x250a2b0] No accelerated colorspace conversion found from yuv420p to rgb24.
[swscaler # 0x2512300] No accelerated colorspace conversion found from yuv420p to rgb24.
[NULL # 0x24e9dd0] [Eval # 0x7fff769243e0] Undefined constant or missing '(' in 'baseline'
[NULL # 0x24e9dd0] Unable to parse option value "baseline"
[NULL # 0x24e9dd0] Error setting option profile to value baseline.
Output #0, mp4, to '/app/outputs/2091/bf951fbc8322d9010d679e656ccda330b6f19f36.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
Stream #0:0: Video: mpeg4, yuv420p, 600x600, q=2-31, 200 kb/s, 90k tbn, 30 tbc
Output #1, image2, to '/app/outputs/2091/thumbs/thumb_%03d.png':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
Stream #1:0: Video: png, rgb24, 600x600, q=2-31, 200 kb/s, 90k tbn, 30 tbc
Stream mapping:
Stream #0:0 (h264) -> crop
split:output0 -> Stream #0:0 (mpeg4)
split:output1 -> Stream #1:0 (png)
Thanks again for looking at this and anything will help.
You're using a very old version, and one which doesn't have libx264 included. Try with a recent build. – #Mulvya
I've been searching everywhere to work out how to extract N images from a video using FFmpeg. All the answers involve playing with the rate setting (-r). However, I'm having some fundamental problems with the rate. According to the docs, the following should produce one frame per second.
ffmpeg -i input.mov -f image2 -r 1 preview-%d.jpeg
If input.mov is 7 seconds long, I would expect to get 7 images. However, I get 10. I also tried on a video 119 seconds long, but I got 122 images. I'm getting 3 more images than expected. What am I missing?
For example, with this ~3 second video I get six frames https://www.dropbox.com/s/8eke6q2gz1kgk1f/example.mov?dl=0
benblack$ ffmpeg -i example.mov -f image2 -r 1 preview-%d.jpeg
ffmpeg version 2.1.4 Copyright (c) 2000-2014 the FFmpeg developers
built on Mar 2 2014 13:38:24 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'example.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2015-02-11 16:52:01
Duration: 00:00:02.83, start: 0.000000, bitrate: 736 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 638x468 [SAR 1:1 DAR 319:234], 726 kb/s, 59.29 fps, 60 tbr, 6k tbn, 12k tbc (default)
Metadata:
creation_time : 2015-02-11 16:52:01
handler_name : Core Media Data Handler
[swscaler # 0x7fdb13008c00] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'preview-%d.jpeg':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
encoder : Lavf55.19.104
Stream #0:0(und): Video: mjpeg, yuvj420p, 638x468 [SAR 1:1 DAR 319:234], q=2-31, 200 kb/s, 90k tbn, 1 tbc (default)
Metadata:
creation_time : 2015-02-11 16:52:01
handler_name : Core Media Data Handler
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mjpeg)
Press [q] to stop, [?] for help
frame= 6 fps=0.0 q=0.0 Lsize=N/A time=00:00:06.00 bitrate=N/A dup=0 drop=162
video:283kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.007598%
I don't know why -r doesn't produce what I expect. However, I managed to extract N frames by using -vf and -vsync:
ffmpeg -i example.mov -f image2 -vsync vfr -vf "select='not(mod(n,17)')" -vframes 10 preview-%d.jpeg
round(number of frames in video/number of frames wanted) = 168/10 = 17. The number of frames in the video can be found using ffprobe:
ffprobe -v error -select_streams v:0 -show_entries stream=nb_frames -i example.mov
The vframes setting is to limit the number of frames, because due to rounding we might sometimes generate one more frame.
Another popular way to extract images from videos is a frame per second.
If you want to extract a portion of images from a video use the -ss option to specify the starting timestamp, and the -t option to specify the encoding duration, eg from 52 seconds in for 1 minute and 5 seconds:
ffmpeg.exe -i simpsonsRockBottom.mp4 -ss 00:00:52 -t 00:01:05 -r 1/1 $filename%03d.jpg
The timestamps need to be in HH:MM:SS.xxx format or in seconds.
If you don't specify the -t option it will go to the end.
I have rtmp stream created by flash player in h264 but when i convert it to video or tumbnail using ffmpeg it some times works after very very long time and some time not work but if I create a stream with Flash Media live encoder on same FMS server the command below works fine. At the same time if I try the stream in player it works well and fine.
I am using IP so DNS resolving issue is not possible either I think.
ffmpeg -i rtmp://xxx.xxx.xx.xx/live/bdeef2c065509361e78fa8cac90aac741cc5ee29 -r 1 -an -updatefirst 1 -y thumbnail.jpg
Following is when it worked aftre 15 - 20 minutes
ffmpeg -i "rtmp://xxx.xxx.xx.xx/live/bdeef2c065509361e78fa8cac90aac741cc5ee29 live=1" -r 1 -an -updatefirst 1 -y thumb.jpg
[root#test ~]# ffmpeg -i rtmp://38.125.41.20/live/bdeef2c065509361e78fa8cac90aac741cc5ee29 -r 1 -an -updatefirst 1 -y thumbnail.jpg
ffmpeg version N-49953-g7d0e3b1-syslint Copyright (c) 2000-2013 the FFmpeg developers
built on Feb 14 2013 15:29:40 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-decoder=liba52 --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include/ --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslint
libavutil 52. 17.101 / 52. 17.101
libavcodec 54. 91.103 / 54. 91.103
libavformat 54. 63.100 / 54. 63.100
libavdevice 54. 3.103 / 54. 3.103
libavfilter 3. 37.101 / 3. 37.101
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[flv # 0x14c0100] Stream #1: not enough frames to estimate rate; consider increasing probesize
[flv # 0x14c0100] Could not find codec parameters for stream 1 (Audio: none, 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[flv # 0x14c0100] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'rtmp://xxx.xxx.xx.xx/bdeef2c065509361e78fa8cac90aac741cc5ee29':
Metadata:
keyFrameInterval: 15
quality : 90
level : 3.1
bandwith : 0
codec : H264Avc
fps : 15
profile : baseline
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 15 tbr, 1k tbn, 30 tbc
Stream #0:1: Audio: none, 0 channels
Output #0, image2, to 'thumbnail.jpg':
Metadata:
keyFrameInterval: 15
quality : 90
level : 3.1
bandwith : 0
codec : H264Avc
fps : 15
profile : baseline
encoder : Lavf54.63.100
Stream #0:0: Video: mjpeg, yuvj420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 1 tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mjpeg)
Press [q] to stop, [?] for help
frame= 2723 fps=1.3 q=1.6 size=N/A time=00:45:23.00 bitrate=N/A dup=8 drop=12044
and on stopping the stream by closing the browser running the flash player which is publishing the video I get the following
[flv # 0x23684e0] Could not find codec parameters for stream 1 (Audio: none, 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[flv # 0x23684e0] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'rtmp://xxx.xxx.xx.xx/live/bdeef2c065509361e78fa8cac90aac741cc5ee29':
Metadata:
keyFrameInterval: 15
quality : 90
bandwith : 0
level : 3.1
codec : H264Avc
fps : 15
profile : baseline
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 15 tbr, 1k tbn, 30 tbc
Stream #0:1: Audio: none, 0 channels
when if i stop the stream it quickly creates a thumbnail file where as running stream is an issue.
I found the reason and cause of this, if a stream created by flash not no microphone selected the audio channel is 0 in rtmp published stream so for that reason the audio codec part of rtmp goes into some kind of loop and not returns and goes further . I have found the cause . but looking for a way to get rid if this loop incase there is no audio channel . may be might have to modify the source code of rtmp and compile again .
The mp3 has an image in it, maybe some album images. When I use ffmpeg to convert it to mp4, it goes wrong. But if I convert an mp3 without an image, it succeeds.
My command is like this:
ffmpeg -i input.mp3 output.mp4
Here's the error:
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg -> mpeg4)
Stream #0:0 -> #0:1 (mp3 -> aac)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Here is all the console output:
ellodeiMac:mine ello$ ffmpeg -frames 0 -i 4.mp3 -y test.mp4
ffmpeg version 0.11.2 Copyright (c) 2000-2012 the FFmpeg developers
built on Oct 24 2012 12:21:13 with llvm_gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
configuration: --disable-yasm
libavutil 51. 54.100 / 51. 54.100
libavcodec 54. 23.100 / 54. 23.100
libavformat 54. 6.100 / 54. 6.100
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 77.100 / 2. 77.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
[mp3 # 0x7fa12301ae00] max_analyze_duration 5000000 reached at 5015510
Input #0, mp3, from '4.mp3':
Metadata:
artist : 贵族乐团
album : 美声天籁
title : 肖邦离别曲
Tagging time : 2012-09-18T08:12:10
Duration: 00:04:01.44, start: 0.000000, bitrate: 129 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s
Stream #0:1: Video: mjpeg, yuvj420p, 240x240 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
Metadata:
title : e
comment : Cover (front)
[buffer # 0x109115780] w:240 h:240 pixfmt:yuvj420p tb:1/90000 sar:1/1 sws_param:flags=2
[buffersink # 0x109133720] No opaque field provided
[format # 0x1091338e0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'format'
[scale # 0x109133bc0] w:240 h:240 fmt:yuvj420p sar:1/1 -> w:240 h:240 fmt:yuv420p sar:1/1 flags:0x4
[mp4 # 0x7fa123035c00] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
[aformat # 0x109136ec0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'src' and the filter 'aformat'
[aresample # 0x1091370c0] chl:stereo fmt:s16 r:44100Hz -> chl:stereo fmt:flt r:44100Hz
[mpeg4 # 0x7fa12303be00] timebase 1/90000 not supported by MPEG 4 standard, the maximum
admitted value for the timebase denominator is 65535
Output #0, mp4, to 'test.mp4':
Metadata:
artist : 贵族乐团
album : 美声天籁
title : 肖邦离别曲
Tagging time : 2012-09-18T08:12:10
Stream #0:0: Video: mpeg4, yuv420p, 240x240 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 90k tbn, 90k tbc
Metadata:
title : e
comment : Cover (front)
Stream #0:1: Audio: none, 44100 Hz, stereo, flt, 128 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (mjpeg -> mpeg4)
Stream #0:0 -> #0:1 (mp3 -> aac)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Use -vn to remove the video stream.
ffmpeg -i input.mp3 -vn output.mp4
I convert AVI to FLV with ffmpeg using -sameq parameter (same quality):
ffmpeg -i test.avi -sameq -f flv sameq.flv
The resulting file has the same video and audio quality as the original, but it's more than twice the original file size:
84M sameq.flv
41M test.avi
Why does it happen?
Transcoder output:
ffmpeg version N-34750-g070d2d7, Copyright (c) 2000-2011 the FFmpeg developers
built on Nov 12 2011 11:23:07 with gcc 4.6.1
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab
libavutil 51. 24. 1 / 51. 24. 1
libavcodec 53. 33. 0 / 53. 33. 0
libavformat 53. 20. 0 / 53. 20. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 48. 0 / 2. 48. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, avi, from 'test.avi':
Duration: 00:06:30.00, start: 0.000000, bitrate: 866 kb/s
Stream #0:0: Video: mpeg4 (Advanced Real Time Simple Profile) (DIVX / 0x58564944), yuv420p, 400x300 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, mono, s16, 64 kb/s
[buffer # 0xa247ae0] w:400 h:300 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
Output #0, flv, to 'sameq.flv':
Metadata:
encoder : Lavf53.20.0
Stream #0:0: Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 400x300 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 25 tbc
Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, mono, s16, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 -> flv)
Stream #0:1 -> #0:1 (mp3 -> libmp3lame)
Press [q] to stop, [?] for help
frame= 9742 fps=255 q=0.0 Lsize= 85074kB time=00:06:30.00 bitrate=1787.0kbits/s
video:79163kB audio:5525kB global headers:0kB muxing overhead 0.455568%
Two thing comes to mind:
Compress a video without audio stream to eliminate the audio portion of this issue. BTW, the audio source is HALF the bitrate of the output, that increases the size a little. Use -ar and -ab switches to control the output.
Check out this article on qscale vs quality using -qscale option. Add in the -b (bitrate) and -s (size) and tweak it to your needs.
When all fails, there are a few switches you can try from the ffmpeg website or try using the new H.264 compression, the two pass option is recommended. Have fun compressing
its because of -sameq. It gives you a good quality but pay the price with a bigger file size.
Can you try adding:
-qcomp 1.0
video quantizer scale compression ( VBR ) (default 0.5). Constant of ratecontrol equation. Recommended range for default rc_eq: 0.0-1.0