0

I have folder of YUV files in NV12 format and I want to make them into a video. I cannot glob them as they are not numbered in a good way with leading zeros. Practically I cannot change it. But I have a list of the files in the correct order for the video.

ffmpeg -y -pix_fmt nv12 -s 1920x1080 -r 30 -f concat -safe 0 -i yuvlist.txt -c:v libx264 -pix_fmt yuv420p output.mp4

yuvlist.txt

file 'yuvfile_01.yuv'
file 'yuvfile_02.yuv'

and so on (and yes the files exist)

This always ends in this error

[IMGUTILS] Picture size 0x0 is invalid
[concat] Impossible to open 'yuvfile_01.yuv'
yuvlist.txt Invalid argument

and I have tried to put the information for the NV12 -pix_fmt nv12 -s 1920x1080 at various places on the command line but to still get the same error.

I can achieve this by first converting all YUV with ffmpeg to e.g. BMP and then using ffmpeg -y -r 30 -f concat -safe 0 -i bmplist.txt -c:v libx264 -pix_fmt yuv420p output.mp4 and here of course the Picture size is metadata inside the BMP and it can succeed. It takes both time and disk space to do this via BMP so where shall I place my picture size and format to directly use YUV in the first ffmpeg command line example?

1
  • May not help but could you include in your question the full command and complete terminal output?
    – andrew.46
    Nov 23, 2022 at 7:52

1 Answer 1

0

Input must come first, nearly always. There's YUV chroma issues with mpeg4 input. Use video filter -vf to correct it. If file resolutions match, you don't have to set scale, usually. Using -r is input rate. It's only needed if full encoding (not stream copy) for handling variable bitrate source. Use -framerate for output rate.

5.6 Advanced Video options "If pix_fmt is a single +, ffmpeg selects the same pixel format as the input (or graph output) and automatic conversions are disabled"

Give this a try:
ffmpeg -f concat -safe 0 -i yuvlist.txt -pix_fmt "+" -vf "format=yuv420p,scale=1920:1080" -framerate 30 -c:v libx264 "output.mp4"

Also, you can concatenate without a list, if needed. That saved my day once.
ffmpeg -i concat:"file1.ext|file2.ext|file3.ext"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .