[FFmpeg-user] encode to RAW video
Michael Koch
astroelectronic at t-online.de
Tue Oct 25 21:48:26 EEST 2022
Am 25.10.2022 um 09:29 schrieb Naveen.B:
>>
>> What do you want to do with the RAW video? You know that you can't play
>> it with most players?
>>
>> Yes, I know it cannot be played with most of th players, I need to see the
>> size of the RAW video and make some compression on it for our further
>> analysis.
> Could you please help me on the missing parameters to generate the RAW
> video?
I did some tests and came to the conclusion that it's impossible to
import a group of numbered raw images.
It's possible to import a single raw image.
It's possible to import a group of numbered images (JPG, PNG, TIF...)
But it's not possible to import a numbered group of raw images.
(To the experts: Please correct me if I'm wrong).
Anyway it's a bad idea to save the images in raw format. You should use
PNG images, which have a lossless compression, and 16-bit depth is possible.
I recommend that you convert your images to PNG, and then things become
much easier.
Here is a (Windows) batch file with a few examples:
rem Make 30 PNG images (48-bit per pixel):
ffmpeg -f lavfi -i testsrc2=s=320x200,format=rgb48 -frames 30 -f image2
-y image-%%03d.png
rem Convert these 30 images to a raw video (this conversion is lossless):
ffmpeg -i image-%%03d.png -s 320x200 -pixel_format rgb48 -f rawvideo
-c:v rawvideo -y video.raw
rem The size of the raw video is exactly 320 * 200 * 2 * 3 * 30 =
11520000 Bytes
rem Convert the first frame from the raw video to a PNG image (48-bit
per pixel):
ffmpeg -video_size 320x200 -pixel_format rgb48 -f rawvideo -i video.raw
-frames 1 -y image.png
rem Convert the raw video to a (almost lossless) MP4 video:
ffmpeg -video_size 320x200 -pixel_format rgb48 -f rawvideo -framerate 30
-i video.raw -crf 0 -y video.mp4
pause
I have a question to the experts. The above example works fine with
pixel format rgb48, but with pixel formats gray16 or gray10le the MP4
output looks wrong. I don't yet understand why.
Michael
More information about the ffmpeg-user
mailing list