I am converting my.flv to my.gp3 with this command
ffmpeg -i my.flv -acodec libamr_nb -s 176x144 -ar 8000 -b 120000 -vcodec h263 -ab 10.2k -ac 1 my.3gp
but size of my flv is 320x240 and I am trying change 176x144 to 320x240 but getting 3gp file with 0kb , how can I do that and get my.3gp file with same size like my.flv
And one more thing , the my.flv is product of converting from my.swf(vide) , if you know some command which will do swf->3gp with same size it would be better .
Thanks a lot.
I used your command line with my copy of ffmpeg (bundled with Xuggler) and it produced perfect output. There were some warnings but it didn't affect the output.
E:\media\New>ffmpeg -i red5.flv -acodec libamr_nb -s 176x144 -ar 8000 -b 120000 -vcodec h263 -ab 10.
2k -ac 1 my.3gp
FFmpeg version SVN-r24930-xuggle-4.0.896, Copyright (c) 2000-2010 the FFmpeg developers
built on Aug 25 2010 23:41:31 with gcc 4.2.4 (TDM-1 for MinGW)
configuration: --prefix=/usr/xuggle --extra-version=xuggle-4.0.896 --extra-cflags=-I/usr/home/Paul
/code/trunk/java/xuggle-xuggler/build/native/i686-pc-mingw32/captive/usr/xuggle/include --extra-ldfl
ags=-L/usr/home/Paul/code/trunk/java/xuggle-xuggler/build/native/i686-pc-mingw32/captive/usr/xuggle/
lib --enable-shared --enable-gpl --enable-nonfree --enable-version3 --enable-libx264 --enable-libmp3
lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libopencore-amrnb --enable-lib
opencore-amrwb --extra-cflags=-mno-cygwin --extra-cflags=-fno-common --extra-ldflags=-mno-cygwin --e
xtra-ldflags=--out-implib --enable-w32threads --enable-memalign-hack
libavutil 50.24. 0 / 50.24. 0
libavcore 0. 6. 0 / 0. 6. 0
libavcodec 52.86. 1 / 52.86. 1
libavformat 52.78. 3 / 52.78. 3
libavdevice 52. 2. 1 / 52. 2. 1
libavfilter 1.38. 1 / 1.38. 1
libswscale 0.11. 0 / 0.11. 0
[flv # 007d9f20] Estimating duration from bitrate, this may be inaccurate
Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 11.99 (12000/
1001)
Input #0, flv, from 'red5.flv':
Metadata:
duration : 1
width : 480
height : 360
videodatarate : 0
framerate : 12
videocodecid : 4
filesize : 27733
Duration: 00:00:01.33, start: 0.167000, bitrate: N/A
Stream #0.0: Video: vp6f, yuv420p, 480x368, 11.99 tbr, 1k tbn, 1k tbc
[buffer # 007de2f0] w:480 h:368 pixfmt:yuv420p
[scale # 007dee70] w:480 h:368 fmt:yuv420p -> w:176 h:144 fmt:yuv420p flags:0xa0000004
Output #0, 3gp, to 'my.3gp':
Metadata:
encoder : Lavf52.78.3
Stream #0.0: Video: h263, yuv420p, 176x144, q=2-31, 120 kb/s, 12k tbn, 11.99 tbc
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
[h263 # 006cc200] warning, clipping 1 dct coefficients to -127..127
Last message repeated 10 times
[h263 # 006cc200] warning, clipping 2 dct coefficients to -127..127
Last message repeated 1 times
[h263 # 006cc200] warning, clipping 1 dct coefficients to -127..127
Last message repeated 3 times
[h263 # 006cc200] warning, clipping 2 dct coefficients to -127..127
[h263 # 006cc200] warning, clipping 1 dct coefficients to -127..127
[h263 # 006cc200] warning, clipping 2 dct coefficients to -127..127
[h263 # 006cc200] warning, clipping 1 dct coefficients to -127..127
frame= 13 fps= 0 q=1.6 Lsize= 24kB time=1.08 bitrate= 182.3kbits/s
video:23kB audio:0kB global headers:0kB muxing overhead 3.130478%
Related
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 .
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...
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
Apologies if this question has been asked. I couldn't find it, but if it has, please let me know and I'll close this out.
I'm attempting a simple scale of a video whose original dimensions are 480x360 and whose target dimensions are 400x300. The video starts as an FLV and eventually needs to end up as an MPEG. I'm using the following command line to do this:
ffmpeg -i user.flv -vf "scale=400:300" user_scaled.mpg
When I play the scaled video in MPEG Streamclip, the scale is correct and the video info shows that the dimensions are 400x300. However, when I play the scaled video in Quicktime, the video is scaled to 478x359. More importantly, FFMPEG, itself, treats the video as being 478x359, so any future commands (trimming, conversion, overlaying, etc) executed on it result in a video of 478x359.
The initial workflow required an FLV to MPEG conversion, but I've tried this with several different in and out formats (FLV -> FLV, FLV -> MPEG, MPEG -> MPEG, etc) all with the same results. As long as I can end up with an MPEG, though, I can deal with however many steps and conversions it would take to get this scaling working.
I'll paste the command-line output below, and a sample input video is also linked below, if you'd like it. Thank you very much for any help.
http://www.monkeydriver.com/dpassera/stack_flv.zip
Command-line output:
ffmpeg -i user.flv -vf "scale=400:300" user_scaled.mpg
ffmpeg version 0.7-rc1, Copyright (c) 2000-2011 the FFmpeg developers
built on May 21 2011 22:13:19 with gcc 4.1.2 20080704 (Red Hat 4.1.2-50)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64
--mandir=/usr/share/man --incdir=/usr/include --disable-avisynth
--extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC'
--enable-avfilter --enable-libdirac --enable-libgsm --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264
--enable-gpl --enable-postproc --enable-pthreads --enable-shared
--enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
--disable-yasm --enable-filters --enable-filter=movie
libavutil 50. 40. 1 / 50. 40. 1
libavcodec 52.120. 0 / 52.120. 0
libavformat 52.108. 0 / 52.108. 0
libavdevice 52. 4. 0 / 52. 4. 0
libavfilter 1. 77. 0 / 1. 77. 0
libswscale 0. 13. 0 / 0. 13. 0
libpostproc 51. 2. 0 / 51. 2. 0
[flv # 0x11dd3b30] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'user.flv':
Metadata:
duration : 5
videocodecid : 2
audiocodecid : 6
canSeekToEnd : true
createdby : FMS 4.0
creationdate : Mon Oct 31 11:43:44 2011
Duration: 00:00:04.62, start: 0.000000, bitrate: N/A
Stream #0.0: Video: flv, yuv420p, 640x480, 1k tbr, 1k tbn, 1k tbc
Stream #0.1: Audio: nellymoser, 44100 Hz, mono, s16
[buffer # 0x11ddc950] w:640 h:480 pixfmt:yuv420p
[scale # 0x11dda610] w:640 h:480 fmt:yuv420p -> w:400 h:300 fmt:yuv420p flags:0xa0000004
[mpeg # 0x11dd6bd0] VBV buffer size not set, muxing may fail
Output #0, mpeg, to 'user_scaled.mpg':
Metadata:
duration : 5
videocodecid : 2
audiocodecid : 6
canSeekToEnd : true
createdby : FMS 4.0
creationdate : Mon Oct 31 11:43:44 2011
encoder : Lavf52.108.0
Stream #0.0: Video: mpeg1video, yuv420p, 400x300, q=2-31, 200 kb/s, 90k tbn, 60 tbc
Stream #0.1: Audio: mp2, 44100 Hz, mono, s16, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 230 fps= 0 q=10.2 size= 366kB time=3.82 bitrate= 785.6kbits/s dup=175 drop=0
frame= 267 fps= 0 q=10.7 Lsize= 412kB time=4.43 bitrate= 761.3kbits/s dup=203 drop=0
video:370kB audio:36kB global headers:0kB muxing overhead 1.568959%
After much gnashing of teeth, I think the problem has nothing to do with ffmpeg, and everything to do with Quicktime.
Quicktime Player (10.1 (501.5)) scales videos to match the size of the window, and has a minimum window size. So regardless of the actual video size, Quicktime will scale it to at least 480 by 360. This is why the info display has size information in the "Format" section (the true size), but also has a "Current Size" section. Changing the window size changes that latter number.
So, scale videos using ffmpeg either with -vf scale or just -s, but don't trust Quicktime Player to show them to you at the correct size. I recommend VLC as a very capable alternative.