Log in

View Full Version : ffmpeg settings against broken avi?


FirstBorg
14th April 2013, 17:53
Hi,

I had some parts lying around so I build my self a dashcam for my car, out of a webcam and an old laptop. I use a minimal debian system and ffmpeg to do the capturing. When the car starts, the laptop boots and starts capturing. Now, wenn I turn off the car, since the laptop has no battery left, it immediately shuts down.

The problem now is, that the created avi file seems to be corrupted. For example, I was driving around for an hour yesterday, and the laptop was capturing the entire time. But when I open the file in VLC, it says that it only captured about 30 minutes. BUT, if I reach the end, VLC just keeps playing. So the video is there! In addition, I can only jump to a specific time at the end of the video as VLC thinks it ends.

So, my question is, is there an option to give ffmpeg so that it saves some kind of special frames (I really have no real clue on the theory of this) so that the video is not corrupted when the laptop suddenly turns of without a proper shutdown?

In addition, one more question. I had the idea to also add a gps reciever to the laptop. I could then read the coordinates every second and calculate speed and drive distances. Is there a way to put this text directly into the video? Or would I need to save it to a text file and then somehow load it as a subtitle?
Thx.

smok3
14th April 2013, 18:52
what format do you capture to?
what does mplayer think?
what does mediainfo says?

FirstBorg
14th April 2013, 21:06
Hi,

it captures to avi.

This is the command line I use
ffmpeg -f video4linux2 -input_format mjpeg -s 800x600 -r 25 -t 90000 -i /dev/video0 -vcodec mpeg4 -vb 4000k -r 25 test.avi

Just as VLC, mediainfo says the file just runs for 38 minutes. But I definetly can play more then that if I just let VLC run when it arrives at the 38 minutes. It actually runs alsmost an hour longer.

Maybe it would be better to save into mkv? Would better (faster) to use libx264 instead of mpeg4? The laptop is 10 years old and I would really like realtime encoding, which works with this settings. Although I cannot use the full resolution of the webcam, because then it does not encode with 25 fps anymore.

smok3
15th April 2013, 06:34
can you recopy the file with another pass in ffmpeg? (v:c copy a:c copy) to get timestamps and everything fixed. Or just capture to mjpeg and do a 2nd pass to compress (plus find a way to burn-in gps data)

hanfrunz
16th April 2013, 16:13
You should capture smaller videos and put them together later. Let's say one minute pieces. So only one minute can get lost. But adding a new battery and shutdown safely should be your main goal :)