Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am recording the MJPEG video from an IP camera and saving it to a file but the problem is that file's duration is way smaller than the actual recording time. Its around 9 seconds video for 2 minutes recording. I tried following commands in order

ffmpeg -f mjpeg -r 8 -i http://c-cam.uchicago.edu/mjpg/video.mjpg -vcodec mpeg4 -b 1000000 -r 8 video_file.avi 

Then I omitted the most of the flags and tried like this

ffmpeg -f mjpeg -i http://c-cam.uchicago.edu/mjpg/video.mjpg video_file.avi

But the problem is that the duration of recorded file is 9 seconds where as the actual recording time is around 2 minutes. I finally tried setpts filter that is supposed to insert the timestamps. The command is as follows

ffmpeg -f mjpeg -i http://c-cam.uchicago.edu/mjpg/video.mjpg -vf "setpts=1*PTS" video_file.avi

But result was still the same. Recording time was way more than video duration.

share|improve this question
    
are you missing images / frames from the final video (eg, the file is "just to short for my gut feeling")? is it just the "display of the presentational timestamps (pts)" that annoyes you? –  akira Sep 14 '12 at 8:01
    
I don't know exactly if frames are dropped. I think they are because video is recorded from internet source. The actual thing that worries me is that I record video for 2 minutes and final video plays back just for 9 seconds. I think it has to do something with frame rate. Say, ffmpeg sets the frame rate to 10 frames/second and it receives 100 frames over two minutes but, it would just play it for 10 seconds. That's my understanding of the problem! –  Muhammad Adeel Zahid Sep 14 '12 at 9:27

2 Answers 2

I know this is an old question, however, this worked for me as an option to ffmpeg: -use_wallclock_as_timestamps 1

share|improve this answer
    
Answering old questions is totally acceptable. Would you care to elaborate on what the effect of that option is? The relevant parts of the manual page could be included, for example. –  Ярослав Рахматуллин Apr 9 '13 at 17:49
    
This forces FFMPEG (a hack really) to use the recording SYSTEM's timestamp instead of trying to compute the time of the movie depending on the number of fps it detects. FPS detection is notoriously inaccurate, for instance -- as FFMPEG freely admits when it gives this error: Estimating duration from bitrate, this may be inaccurate. This also enables the -t flag (duration) to be realtime as well, instead of also being dependent on the fps calculation. –  Jann Apr 9 '13 at 21:11

I had a similar problem and the -re option resolved it for me. This tells ffmpeg to act as a frame grabber would act.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.