Hi.
Have a MTS file size 231 MB and length 02:32 minutes.
I want to extract all frames from this file and save those as PNG files to a folder.
The command I use is (runs from a bat file):
Instead of extracting any images, I just get this console text:Code:D:\Multimedia\ffmpeg\bin\ffmpeg.exe -i 00025.MTS -r 1/1 $filename%03d.jpg
Code:H:\Q>REM D:\Multimedia\ffmpeg\bin\ffmpeg.exe -i 00025.MTS -r 1/1 $filename"H:\Q\ pextract.bat"3d.jpg H:\Q>D:\Multimedia\ffmpeg\bin\ffmpeg.exe -i 00025.MTS -r 1/1 $filename"H:\Q\pext ract.bat"3d.jpg ffmpeg version N-58401-gffe31c6 Copyright (c) 2000-2013 the FFmpeg developers built on Nov 22 2013 20:01:03 with gcc 4.8.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 54.100 / 52. 54.100 libavcodec 55. 44.100 / 55. 44.100 libavformat 55. 21.101 / 55. 21.101 libavdevice 55. 5.100 / 55. 5.100 libavfilter 3. 91.100 / 3. 91.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Input #0, mpegts, from '00025.MTS': Duration: 00:02:32.13, start: 2.306356, bitrate: 12744 kb/s Program 1 Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1 080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fl tp, 384 kb/s Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080 [swscaler @ 02c665c0] deprecated pixel format used, make sure you did set range correctly Output #0, image2, to '$filenameH:\Q\pextract.bat3d.jpg': Metadata: encoder : Lavf55.21.101 Stream #0:0: Video: mjpeg, yuvj420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 2 00 kb/s, 90k tbn, 1 tbc Stream mapping: Stream #0:0 -> #0:0 (h264 -> mjpeg) Press [q] to stop, [?] for help [image2 @ 03482020] Could not open file : $filenameH:\Q\pextract.bat3d.jpg
+ Reply to Thread
Results 1 to 30 of 31
-
-
assuming this is film, change the -r l/l to -r 23.976
this works for me:
Code:ffmpeg.hevc.exe -i video.hm10 -r 23.976 image.jpg
-
Thanks, but I still doesn't get it to work
I changed the command toCode:D:\Multimedia\ffmpeg\bin\ffmpeg.exe -i 00025.MTS -r 25.000 image.jpg
I still got this console output:
Code:H:\Q>D:\Multimedia\ffmpeg\bin\ffmpeg.exe -i 00025.MTS -r 25.000 image.jpg ffmpeg version N-58401-gffe31c6 Copyright (c) 2000-2013 the FFmpeg developers built on Nov 22 2013 20:01:03 with gcc 4.8.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 54.100 / 52. 54.100 libavcodec 55. 44.100 / 55. 44.100 libavformat 55. 21.101 / 55. 21.101 libavdevice 55. 5.100 / 55. 5.100 libavfilter 3. 91.100 / 3. 91.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Input #0, mpegts, from '00025.MTS': Duration: 00:02:32.13, start: 2.306356, bitrate: 12744 kb/s Program 1 Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1 080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fl tp, 384 kb/s Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080 [swscaler @ 02c66640] deprecated pixel format used, make sure you did set range correctly Output #0, image2, to 'image.jpg': Metadata: encoder : Lavf55.21.101 Stream #0:0: Video: mjpeg, yuvj420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 2 00 kb/s, 90k tbn, 25 tbc Stream mapping: Stream #0:0 -> #0:0 (h264 -> mjpeg) Press [q] to stop, [?] for help [image2 @ 033a1020] Could not get frame filename number 2 from pattern 'image.jp g' (either set updatefirst or use a pattern like %03d within the filename patter n) av_interleaved_write_frame(): Invalid argument
-
there different ways of doing it.
Code:ffmpeg -i g:\1440x1080p.H264.m2ts -ss 00:00:00 -ss 00:00:04 -frames:v 24 -r 23.976 -y im_%4d.png
the %4d is the length of the padding for zeros sequentually, or else the sorting won't work correctly when opening/viewing the images in a folder or video timeline.
the -frames:v n (n) is the how many frames you want to extract from that -ss position and onward, up to the end of the video. in the above example, i am extracting 24 frames, im_0001 im_0002 im_0003, ... im_0024.png
if you add the .png at the end of the filename, ffmpeg will understand you want the .png format and convert to it automatically. -
Hi. It still won't work. Now, ffmpeg ask to overwrite the input file
Here is the command:
Code:D:\Multimedia\ffmpeg\bin\ffmpeg.exe 00025.MTS -ss 00:00:00 -ss 00:00:10 -frames:v 50 -r 25.000 -y image_%4d.jpg
Code:H:\Q>D:\Multimedia\ffmpeg\bin\ffmpeg.exe 00025.MTS -ss 00:00:00 -ss 00:00:10 -fr ames:v 50 -r 25.000 -y image_d.jpg ffmpeg version N-58401-gffe31c6 Copyright (c) 2000-2013 the FFmpeg developers built on Nov 22 2013 20:01:03 with gcc 4.8.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 54.100 / 52. 54.100 libavcodec 55. 44.100 / 55. 44.100 libavformat 55. 21.101 / 55. 21.101 libavdevice 55. 5.100 / 55. 5.100 libavfilter 3. 91.100 / 3. 91.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Output #0, mpegts, to '00025.MTS': Output file #0 does not contain any stream
-
when working through "batch" mode, you need to add the -y command. that overrides that issue.
also, make sure that your seconds -ss command is the exact time or less, or else it won't work. i had that problem.
i.e., 00:01:50:04 is 1h, 50min, and 4sec
don't enter 00:01:51
tip: don't test ffmpeg inside batch scripts/files. run the ffmpeg params from inside a dos console window. then, once you have everything working, you can add them into a script file. sometimes, for reasons i can't explain, if it doesn't work in a script, you have to add an CMD.EXE in front of the ffmpeg.
i.e, cmd.exe /C ffmpeg params.
also, make sure there are no spaces, or else you should always enclose "drive_path_filename" inside quotes.
you should put all exe files and videos in the same folder. it looks like you are not including the drive/path parts.
and last, the problem could also be the version of ffmpeg. there is a link somewhere for the ffmpeg builds. -
I've taken into account your tip. However it just seems to not work whatever I do.
I now have this command, adjusting the time format, adding CMD.EXE /C in front, AND I'm positive there is no spaces nor non-english characters in any file names. Unsuccessful command goes like this:
Code:CMD.EXE /C D:\Multimedia\ffmpeg\bin\ffmpeg.exe 00025.MTS -map 0 -ss 00:00:00:00 -ss 00:00:00:10 -frames:v 50 -r 25.000 -y image_%%4d.jpg
Code:H:\Q>CMD.EXE /C D:\Multimedia\ffmpeg\bin\ffmpeg.exe 00025.MTS -map 0 -ss 00:00:0 0:00 -ss 00:00:00:10 -frames:v 50 -r 25.000 -y image_%4d.jpg ffmpeg version N-58401-gffe31c6 Copyright (c) 2000-2013 the FFmpeg developers built on Nov 22 2013 20:01:03 with gcc 4.8.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 54.100 / 52. 54.100 libavcodec 55. 44.100 / 55. 44.100 libavformat 55. 21.101 / 55. 21.101 libavdevice 55. 5.100 / 55. 5.100 libavfilter 3. 91.100 / 3. 91.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 00025.MTS: Permission denied
-
It's not working because you're not following instructions
If you want to extract ALL frames as you said you wanted to do in the 1st post, use the command line given in my post above
You're commandline doesn't make any sense. Why do you have 2 -ss entries ? If you want 50 frames, then you only need to specify the start time with -frames:v 50 . If your file is 25 fps, then that will be 2 seconds. If you want a duration , then you need to specify a start time -ss , and a duration -t . not 2 start times. not -frames:v
The -y command is causing you to overwrite because you haven't specified an input file (-i isn't in your commandline) . It's very dangerous to use -y unless you know what you are doing (it will automatically say "yes" to whatever) -
(-i isn't in your commandline)
the op should double-check the filesize of his "00025.MTS" file, just in case it was overwritten to zero due to not having the -i when using -y command, or else it still won't work. -
You are correct. You must change that to %%04d actually.
%% in bat file converts to % in console command
Next you must use 0 before the 4. Zero means pad unused digits with 0. 4d means 4 decimal number and it specifies the number of digits to pad to. You must remember to use d or I think it defaults to hexadecimal (or might not even know what to do, and crash).
With that set up. the smallest number is 0 and will be padded out to 0000. And then 1 becomes 0001 and 2 becomes 0002, etc. Then the largest number with that command will be 9999. This means you can extract a maximum of 10000 frames this way. -
Thanks guys, I finaly put together a command that actually works:
Code:CMD.EXE /C D:\Multimedia\ffmpeg\bin\ffmpeg.exe -i 00025.MTS -ss 00:00:00 -t 00:00:10 -frames:v 50 -r 25.000 -y image_%%04d.jpg
Yes, I omitted the zeero character - I had no idea it was that important.
Just two more questions - Is it possible to make ffmpeg extract only keyframes? And is there possible to make ffmpeg to extract all frames without knowing the video file frame rate.
I plan to make a script in sendto of right click menu in windows for this, and therefore I need to be able to extract all frames, regardless of their framerates.
Any way, thanks a lot for getting me this far -
-vf select="eq(pict_type\,PICT_TYPE_I)"
Note, ffmpeg does not distinguish between non keyframe "i" frames, and keyframe or "IDR" frames. ( ie. You will get all "I" frames, some of which might not be true keyframes)
And is there possible to make ffmpeg to extract all frames without knowing the video file frame rate.
Your commandline still doesn't make sense . You specified a start time (-ss) and a duration (-t) for 10 seconds, but then you specify 50 frames ? 10 seconds at 25 fps is 250 frames
For example if you only wanted from 0 to 10 seconds, you don't need -frames:v 50 . Or if you only wanted 50 frames, you don't need -t -
Thanks for pointing out a bug in the command, poisondeathray. It's just a little too much in my head at once so I didn't noticed
When it comes to IDR frames I guess I can live with that, thought I haven't read up on IDR frames
Just have to say you guys made my day, thanks for helping me solve this.
-
Note, ffmpeg does not distinguish between non keyframe "i" frames, and keyframe or "IDR" frames. ( ie. You will get all "I" frames, some of which might not be true keyframes)
-
-
What numbering are you referring to, because the stream numbering starts at zero.
Code:Duration: 00:00:17.16, start: 0.000000, bitrate: 860 kb/s Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 25 tbr, 25 tbn, 25 tbc Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 123 kb/s
-
I meant if you export a still image sequence like PNG, JPEG (you know, the topic of this thread ...
)
-
Ah, okay. (doesn't really matter to me if the numbering starts at zero or one
)
Only way to change the image numbering is probably to patch the source before building.
btw. "image_%%04d.jpg" should be "image_%04d.jpg" -
-
Hi, me again. Starting getting the hang of it thanks to you guys.
I ran into two problems.
Problem 1
I did try to add -vf select="eq(pict_type\,PICT_TYPE_I)" to only get I-frames, however it did not turned out as expected.
I have a short video that contains 600 frames totally, and when changing the command so that ffmpeg extract only I-frames, it outputs something like 580 picture files. When I browse through the pictures, then a lot of the pictures is identical. When I browsing through the pictures, I'll find that typically 6 to 10 following pictures is completely identical.
Is this a bug or is there a command that resolve the issue.
Problem 2
I have a video clip, MP4 container, AVC format, 1440x1080 pixels. When playing this file in e.g. VLC, it automatically resize to 16:9, but ffmpeg does not resize, resulting in wrong aspect ratio for output pictures.
I can always have a program doing the resizing, but I wonder how I can make ffmpeg do that.
Thanks in advance -
regarding 1: without a sample, hard to say if this is a bug or you making some mistake
regarding 2: you have to tell ffmpeg to resize according to the aspect ratio, otherwise ffmpeg handles the aspect ratio as it what it is a flag which gets ignored unless you tell it to do something with it -
Code:
SWScaler AVOptions: -sws_flags <flags> E..V.. scaler flags (default 4) fast_bilinear E..V.. fast bilinear bilinear E..V.. bilinear bicubic E..V.. bicubic experimental E..V.. experimental neighbor E..V.. nearest neighbor area E..V.. averaging area bicublin E..V.. luma bicubic, chroma bilinear gauss E..V.. gaussian sinc E..V.. sinc lanczos E..V.. lanczos spline E..V.. natural bicubic spline print_info E..V.. print info accurate_rnd E..V.. accurate rounding full_chroma_int E..V.. full chroma interpolation full_chroma_inp E..V.. full chroma input bitexact E..V.. error_diffusion E..V.. error diffusion dither -srcw <int> E..V.. source width (from 1 to INT_MAX) (default 16) -srch <int> E..V.. source height (from 1 to INT_MAX) (default 16) -dstw <int> E..V.. destination width (from 1 to INT_MAX) (default 16) -dsth <int> E..V.. destination height (from 1 to INT_MAX) (default 16) -src_format <int> E..V.. source format (from 0 to 332) (default 0) -dst_format <int> E..V.. destination format (from 0 to 332) (default 0) -src_range <int> E..V.. source range (from 0 to 1) (default 0) -dst_range <int> E..V.. destination range (from 0 to 1) (default 0) -param0 <double> E..V.. scaler param 0 (from INT_MIN to INT_MAX) (default 123456) -param1 <double> E..V.. scaler param 1 (from INT_MIN to INT_MAX) (default 123456) -src_v_chr_pos <int> E..V.. source vertical chroma position in luma grid/256 (from -1 to 512) (default -1) -src_h_chr_pos <int> E..V.. source horizontal chroma position in luma grid/256 (from -1 to 512) (default -1) -dst_v_chr_pos <int> E..V.. destination vertical chroma position in luma grid/256 (from -1 to 512) (default -1) -dst_h_chr_pos <int> E..V.. destination horizontal chroma position in luma grid/256 (from -1 to 512) (default -1) -sws_dither <int> E..V.. set dithering algorithm (from 0 to 4) (default 1) auto E..V.. leave choice to sws bayer E..V.. bayer dither ed E..V.. error diffusion
Similar Threads
-
How to merge multiple .mts files (canon HF) into one single .mts file
By frmsuv2van in forum Video ConversionReplies: 15Last Post: 5th Sep 2014, 21:21 -
ffmpeg audio parallel extract possible?
By Selur in forum Newbie / General discussionsReplies: 3Last Post: 19th Aug 2013, 09:41 -
Ffmpeg meta data fails to write UTF-8 and screws up files?
By burzum793 in forum AudioReplies: 0Last Post: 22nd Nov 2012, 05:36 -
FFMPEG: extract frames
By mogadanez in forum Video ConversionReplies: 6Last Post: 4th May 2012, 11:06 -
Strange mp4, ffmpeg fails...
By elmuz in forum Video ConversionReplies: 0Last Post: 17th Jun 2011, 10:26