Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Compression Techniques How to Record mjpeg video in a file with synchronized time Information

  • How to Record mjpeg video in a file with synchronized time Information

    Posted by Adeel Zahid on September 13, 2012 at 11:24 am

    Hi,
    I am new to ffmpeg and I was trying to record the MJPEG video from an IP camera and store it in a file. Recording worked ok and file was created on the disk. When I played the video It played only for 2 minutes but it was recorded in around 10 minutes. Are there any flags in ffmpeg that I can use to save the timing information along with video data?

    Regards
    Adeel

    Reuben Martin replied 13 years, 8 months ago 2 Members · 2 Replies
  • 2 Replies
  • Adeel Zahid

    September 14, 2012 at 7:46 am

    Hi again,

    I have used following commands to record the video in order

    ffmpeg -f mjpeg -r 8 -i https://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 https://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 https://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.

  • Reuben Martin

    September 16, 2012 at 1:10 am

    It’s an IP cam. It lies about it’s frame rate. (It says it’s frame rate is 25fps but that’s crap)

    When it can’t send the frame in time it just drops it. Playback at a fixed framerate will no ever be quite right, although using the framerate of 8 should be somewhat in the ballpark.

    ffmpeg -re -r 8 -i https://c-cam.uchicago.edu/mjpg/video.mjpg -r 8 -vcodec libx264 -preset slower -vprofile high -trellis 2 -crf 22 -pix_fmt yuv420p -an -f mp4 IpCamCapture.mp4

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy