Re: [FFmpeg-user] frame extract is not accurate enough
I stumbled over some similar issue when using the "-r 1" option. See ticket http://trac.ffmpeg.org/ticket/3990 for details and some possible work-around using the "fps" filter. Regards, Tobias ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Re: [FFmpeg-user] frame extract is not accurate enough
Hi Gergely, On Mon, Jul 27, 2015 at 15:46:48 +, Lukácsy Gergely wrote: > I think ffmpeg never outputs the header information regarding duration and > such. I think it does. It doesn't by default output the individual streams' duration, though. $ ffmpeg -i out_ffmpeg.mp4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out_ffmpeg.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf56.11.100 Duration: 00:00:00.57, start: 0.046440, bitrate: 304 kb/s Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 320x240 [SAR 1:1 DAR 4:3], 80 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name: VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 98 kb/s (default) Metadata: handler_name: SoundHandler Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 98 kb/s (default) Metadata: handler_name: SoundHandler Compare with ffrobe, which shows that MP4/MOV presents separate lengths for container and streams, so at least the former must be from a global header: $ FILE=out_ffmpeg.mp4; for detail in format streams; do ffprobe -show_$detail "$FILE" 2>/dev/null | grep -E '(format_name|start_time|duration|codec_type)=' ; done format_name=mov,mp4,m4a,3gp,3g2,mj2 start_time=-0.046440 duration=0.57 codec_type=video start_time=0.00 duration=0.52 codec_type=audio start_time=-0.046440 duration=0.569048 codec_type=audio start_time=-0.046440 duration=0.569048 Three streams, and none of those lengths matches the "format's" duration. > Running an empty run with ffmpeg shows me that the video is composed > of 7423 frames which translates to exactly 296.92 seconds if we > calulate with 25 fps ( 7423 / 25 = 296.92 ). Yeah. I was just thinking out load, and wondering whether something else could be wrong. I suggest you check the stream's length using "ffprobe -show_streams", perhaps it will show your expected 300 seconds. Again, I'm guessing. :-) Actually, I think I want to see the exact timestamps for each and everyone of those 7423 frames, to see if something is fishy. Your mentioned 5 second drift does make me wonder! Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Re: [FFmpeg-user] frame extract is not accurate enough
> Smaller, you meant to say? Actually, you mistyped 496? Damn... yes, I mistyped it, the correct duration is 296 (as you noticed in the console log). > Perhaps that's according to the header, and the actual video stream is > longer, resulting in about 300 seconds. I think ffmpeg never outputs the header information regarding duration and such. Running an empty run with ffmpeg shows me that the video is composed of 7423 frames which translates to exactly 296.92 seconds if we calulate with 25 fps ( 7423 / 25 = 296.92 ). > Are you sure the video is truly CFR? Is it captured from some device which delivers slightly varying frame rate? You can never be 100% sure about that, but I think this video has constant frame rate (see the results above). :) We captured a notebook screen with an Epiphan Pearl, which may alter the frame rate in certain conditions, but in this case the CPU was far away from overload. Cheers, Gergely. ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Re: [FFmpeg-user] frame extract is not accurate enough
On Fri, Jul 24, 2015 at 09:15:16 +, Gergely Lukácsy wrote: Apart from everything else: > The strange thing that the total number of frames (300) produced is bigger > than what the video duration (496 s) and the 1 sec framerate would indicate. Smaller, you meant to say? Actually, you mistyped 496? [...] > Duration: 00:04:56.92, start: 0.00, bitrate: 1480 kb/s The file you're showing us is 296.92 seconds long, not 496. Perhaps that's according to the header, and the actual video stream is longer, resulting in about 300 seconds. You would know better by letting ffmpeg parse the complete stream: $ ffmpeg -i /tmp/presentation.mp4 -f null - or using ffprobe to count the frames. Are you sure the video is truly CFR? Is it captured from some device which delivers slightly varying frame rate? Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
[FFmpeg-user] frame extract is not accurate enough
Greetings, FFmpeg users! I'm trying to OCR some presentation videos, using ffmpeg to extract frames. I need to figure out the exact locations of each transitions, and there's no other method to do that than inspecting the number of the output frame. The command is the following: /home/gergo/ffmpeg/ffmpeg-customvsq-git20150116-static/ffmpeg -i /tmp/presentation.mp4 -filter_complex 'scale=w=320:h=180:force_original_aspect_ratio=decrease' -r 1 -q:v 1 -f image2 /tmp/thumbnail/%06d.png -r 1 -q:v 1 -f image2 /tmp/full/%06d.jpg As you can see, there's a 1 second framerate set for each output thread. (I'm splitting the output to get a full- and a thumbnail sized version.) The strange thing that the total number of frames (300) produced is bigger than what the video duration (496 s) and the 1 sec framerate would indicate. For example, there's a transition at 97 sec which occurs only at the 102nd frame. That's 4-5s latency in the first two minutes! So, is there a method to increase the accuracy? What causes this varying framerate? Thanks in advance: Gergely Lukácsy Here's the complete, uncut console output: ffmpeg version N-69054-gc4f1abe-static Copyright (c) 2000-2015 the FFmpeg developers built on Jan 16 2015 14:03:28 with gcc 4.7 (Debian 4.7.2-5) configuration: --prefix=/home/gergo/buildscript/ffmpeg-static-master-customVSQ/target --extra-cflags='-I/home/gergo/buildscript/ffmpeg-static-master-customVSQ/target/include -static' --extra-cflags=--static --extra-ldflags='-L/home/gergo/buildscript/ffmpeg-static-master-customVSQ/target/lib -lm -static' --extra-libs=-ldl --extra-version=static --disable-debug --disable-shared --enable-static --extra-cflags=--static --disable-ffplay --disable-ffserver --disable-doc --enable-gpl --enable-pthreads --enable-postproc --enable-gray --enable-runtime-cpudetect --enable-libfaac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-bzlib --enable-zlib --enable-nonfree --enable-version3 --enable-libvpx --enable-libvo-aacenc --enable-librtmp libavutil 54. 16.100 / 54. 16.100 libavcodec 56. 20.100 / 56. 20.100 libavformat56. 18.101 / 56. 18.101 libavdevice56. 4.100 / 56. 4.100 libavfilter 5. 7.101 / 5. 7.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc53. 3.100 / 53. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/presentation.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf55.0.100 Duration: 00:04:56.92, start: 0.00, bitrate: 1480 kb/s Stream #0:0(und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p, 1366x768, 1479 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name: VideoHandler [swscaler @ 0x38885e0] deprecated pixel format used, make sure you did set range correctly Output #0, image2, to '/tmp/thumbnail/%06d.png': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf56.18.101 Stream #0:0: Video: png, rgb24, 320x180, q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc (default) Metadata: encoder : Lavc56.20.100 png Output #1, image2, to '/tmp/full/%06d.jpg': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf56.18.101 Stream #1:0(und): Video: mjpeg, yuvj422p(pc), 1366x768, q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc (default) Metadata: handler_name: VideoHandler encoder : Lavc56.20.100 mjpeg Stream mapping: Stream #0:0 (h264) -> scale (graph 0) scale (graph 0) -> Stream #0:0 (png) Stream #0:0 -> #1:0 (h264 (native) -> mjpeg (native)) Press [q] to stop, [?] for help frame= 300 fps=3.0 q=0.0 Lq=0.0 size=N/A time=00:05:00.00 bitrate=N/A dup=0 drop=14246 video:72350kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user