PDA

View Full Version : Axis-camera, mjpeg format problem


Johan.
23rd September 2009, 14:28
Hi, don't know where to put these questions but I hope that this will do.

I have filmed some with an axis camera and the output file is in mjpeg format. The only program I have found that can open it is VLC. So far so good... But than the problems begins. I can't jump in the file just go forward and pause but not go back, than I have to start over again. The time in VLC is only in seconds I need at least tenth of seconds. So what I need help with is to find a program that manage the files good or re-encode it so I can use whatever program.

I have tried both virtualdub and avidemux but no one of them can open it. ffdshow is installed but still I can't open it in MPC.

I put a link to a sample, I don't know how to re-encode it... And a program that shows centesimal seems hard... so please give me a hand.

http://dl.getdropbox.com/u/669332/File.mjpg

sneaker_ger
23rd September 2009, 14:47
Use ffmpeg (http://www.videohelp.com/download/ffmpeg-0.5.7z) to mux the file into an avi container. You may use the following command line:
ffmpeg -i file.mjpg -vcodec copy mjpeg.avi

Activate mjpg in ffdshow and you will be able to edit the file in VirtualDub.

mariush
23rd September 2009, 15:04
Why not just use the Convert option from VLC to convert it to a .ts container where the video is encoded in MPEG2 and audio in MPEG. This works for sure (tested it right now)... maybe other containers and codecs work also

Johan.
23rd September 2009, 15:36
Thank you it worked very nice with ffmpeg. The VLC option woked too.

Virtualdub doesn't work so good, I need to be able to play the film in slow motion and that doesn't seem to work so good in virtualdub. Now the file plays nice in wmp, mpc, vlc etc. I can go back and forth without getting error, but these programs doesn't gives only time in seconds I need less.

I found another problem though. The program that saves the file to hard disk is supposed to cut it in 30 min parts but now when I checked the time on them they are 34 min 25 sec, that will give me big errors... So from a small problem to a bigger...

Boolsheet
23rd September 2009, 16:41
you can adjust the source frame rate in VirtualDub in the Video -> Frame Rate menu (CTRL + R) to slow it down.
There's even a "Interpolate" filter if you want it smoother. It's only linear blending, but it does a good job if you don't scale too high.

Hm, your new problem sounds like variable framerate, but I don't know how to confirm that. Your sample looks like a raw mjpeg stream to me.
If it's not variable then maybe FFmpeg gets the frame rate wrong, you can force it with the -r switch on the command line or in VirtualDub like I described.

Johan.
23rd September 2009, 16:50
If it's variable framerate is there anything I can do about it? I fast forwarded the raw format in vlc and checked what time I got and it ends at the same time as ffmpeg output file is, so it encodes it correct from the source.

One thing I've noticed is that the picture sometimes jump about a car length.

poisondeathray
23rd September 2009, 17:35
Does your camera come with any software?

Johan.
24th September 2009, 08:23
I don't have any software for it. I just access the camera via my browser. The system consists of a camera with a harddrive attached on top of it which is controlled by a linux system (bubba server I think).

Anyway I need to talk with those who built it to figure out the time problem.

Boolsheet
24th September 2009, 13:16
If it's variable framerate is there anything I can do about it?
Not without timestamps in the video file.
But I think it's just FFmpeg assuming its default 25 fps. try a frame rate of 29.97 or 30 and look if it's closer to your 30 minutes. ;)
Does the web interface say something about the frame rate?

Johan.
24th September 2009, 15:37
Thanks will try that.

But isn't it strange that when I play the raw file in VLC it is the same length?

Boolsheet
24th September 2009, 17:08
Almost all open source projects with multimedia encoding and decoding use FFmpeg, this includes VLC. The implementations vary a little, but the most part behaves like the cli version.

"ffmpeg -i file.mjpg -vcodec copy mjpeg.avi" means: Take the input file, copy the video stream into a avi file. It's still the same MJPEG stream, just wrapped with the avi container.

Johan.
24th September 2009, 18:17
Thanks a lot, I think the problem is solved now.

I just took the frames and divided them with 30*60, as I assume that the recording is 30 minutes long, and got a framerate at 28.62. When I used that framerate I got 29.59 long movie. That is close enough.


Edit: Are there any other media player except virtualdub that shows at least a tenth of a second, virtualdub is not working as smooth as I want. vlc and mpc works perfectly but only shows time in seconds...

Johan.
26th September 2009, 10:23
Ok, I thought the problem was solved but it shows that the result can be even better.

The camera sends 30 fps but the system that is supposed to record the film is not able to record all because it is too slow. The result is that it loses 1.2 fps. The good part though is that all the frames have timestamps.

I have tried to look through ffmpeg documentation but can't find out how to get it to use timestamps. So help with that would be very appreciated.