Ffmpeg decoding of BlackVue videos (ffmpeg is called by the tools)

#1

Would someone please check my findings

Latest git version

I had assumed that the “higher quality” index frames from a BlackVue mp4 (1fps) were always present in the mapillary_tools image output. This does not appear to be the case. Using the fps filter (standard tools processing) and comparing against the first and last index frames in the stream (at 2fps) I found no commom images.

I then ran it in standard rate mode, eg;
ffmpeg -i video.mp4 -r 2 -vsync vfr -qscale:v 1 RFile_%3d.jpg
and every 2nd frame matched an index.

To generate index only frames for testing;
ffmpeg -i video.mp4 -vf “select=eq(pict_type,I)” -vsync vfr -qscale:v 1 IFile_%3d.jpg

The standard tools command
ffmpeg -i video.mp4 -vf fps=1/0.5 -qscale:v 1 MFile_%3d.jpg

I realize this is deprecated, but it may be worth looking into the server side processing of uploaded videos. The small increase in quality may be worth it.

Also note that -qscale:v 1 will in fact default to -qscale:v 2 unless the -qmin 1 switch is added. I think this roughly equates to a jpg quality of 84% vs 95% or higher

1 Like
YI 360 VR camera REVIEW
[BUGREPORT] video upload
#2

planing on testing with mp4’s here. But haven’t spent time investigating the “how to”.

Forgive me, but I don’t understand what the best way to go about it is, reading your post. Could you explain it a bit further? (and maybe explain each setting in short?)

#3

ffmpeg is very complex. It is a video stream processor toolbox. Good for format, size, rate, codec and standards conversions. It will even take images (jpg, png etc) as input and create as output. I suggest you spend some web searching time on its overall usage. The use in mapillary_tools is to convert the mp4 movie into individual jpg frames at whatever rate (frames per second) is needed. For our use that seems to commonly be 2 or 5 fps.

The input mp4 is named after -i

The output images (eg RFile_%3d.jpg) name is some fixed prefix followed by 3 increasing digits. This example would name/number frames from RFile_001.jpg to a maximum RFile_999.jpg

-r 2 means sample the input file at 2fps. So does -vf fps=1/0.5, but it uses a different method and (per my tests) actually selects a different set of frames

-qscale:v 1 sets the output quality. The lower the number the better quality, but results in a larger filesize. This applies to movie outputs as well, but other options can be defined for that. (eg bit rate)

  • mpeg based movies are created with a “new and complete frame” every so often. This is called an index frame. In between each index frame only the changes from one frame to the next are saved as data. Some like a fast moving aerial dogfight will have a lot of intermediate frame data, but talking heads at a news desk have very little. This is a lossy process so if converting to jpg the visual quality degrades after each index from one frame to the next. The BlackVue format creates an index frame once per second, then 29 intermediate frames.

Basically if you run the commands above on one mp4 you would visually (at 1:1 or higher scaling) compare the image output. The index frame example will be the best quality.

I hope this helps.

1 Like
#4

You wrote about a qmin 1 setting, can you tell a bit mire about that?

#5

When a jpg is created with ffmpeg it forces -qscale:v 2 even if -qscale:v 1 is defined. It’s kind of illogical to create a jpg at 1 as there is very little degradation at 2. qmin overrides this and allows 1 to be used. It’s kind of like trying to see a difference between a 98% and 85% quality jpg image. Its probably a better logical choice to use png if one really wants zero loss, but I doubt Mapillary is set up to allow it.

#6

Thanks for the info (I bookmarked the info).

When I can buy the YI 360 VR I can seriously start testing (just my luck, the day I decide to buy it they go out of stock :cry:)

#7

My post was more about BlackVue’s. The Vi spec says it has a photo mode that may be better than decoding movies. Only one frame every 2 secs minimum though. The time lapse movie mode looks even better though as it will do 2fps. Might need some fancy decoding with ffmpeg.

No GPS though?

#8

Exactly! I like the 2fps and maybee even the 30fps option… but as you say, I need to get fancy with ffmpeg (that’s why I bookmarked this thread :wink: )

And indeed, I just need to get smart matching GPX data to the images, working on that :wink:

(I’m a man with a plan :P)