[FFmpeg-user] When capturing rawvideo from camera (avfoundation), ffmpeg adds extra 32 bytes for each frame.

Peter Gusev gpeetonn at gmail.com
Wed Sep 19 16:33:43 EEST 2018


Hi!

As a part of figuring out the problem I have with ffplay
<https://stackoverflow.com/questions/52390694/video-moves-sideways-when-captured-raw-from-camera-and-piped-into-ffplay/52399554#52399554>,
I noticed, that ffmpeg adds 32 bytes to raw 0rgb frames when capturing from
a camera (macOS 10.12):

$ ffmpeg -f avfoundation -pixel_format 0rgb -framerate 25 -video_size
640x480 -i "0" -map 0:v -c copy -f rawvideo -vframes 1 /tmp/frame.0rgb
$ wc -c /tmp/frame.0rgb
 1228832 /tmp/frame.0rgb

which is exactly 32 bytes larger than expected (1228800 = 640x480x4). This
also holds for larger frame resolutions:

$ ffmpeg -f avfoundation -pixel_format 0rgb -framerate 25 -video_size
1280x720 -i "0" -map 0:v -c copy -f rawvideo -vframes 1 /tmp/frame.0rgb
$ wc -c /tmp/frame.0rgb
 3686432 /tmp/frame.0rgb

Moreover, it's not an "initial header", but rather a per-frame header,
because when I save 2 frames, the resulting size is 64 bytes larger:

$ ffmpeg -f avfoundation -pixel_format 0rgb -framerate 25 -video_size
1280x720 -i "0" -map 0:v -c copy -f rawvideo -vframes 2 /tmp/frame.0rgb
$ wc -c /tmp/frame.0rgb
 7372864 /tmp/frame.0rgb

I believe this affects ffplay's preview, which results in "video scrolling"
effect (see the link for my stackoverflow question above).

Why does ffmpeg add 32 bytes for each frame and how can I work around it to
drop it on the receiving end (ffplay)?

Thanks

-- 
Peter Gusev <https://www.linkedin.com/in/peter-gusev-8135441a/>
*gpeetonn at gmail.com <gpeetonn at gmail.com>*


*+1 213 587-27-48*


*Research Scholar @ REMAP UCLA <http://www.remap.ucla.edu/home/about>Video
streaming/ICN networks/Creative Coding/Interactive Media*
*dj peetonn <https://soundcloud.com/peter-gusev>*


More information about the ffmpeg-user mailing list