Score:0

ffmpeg convert list of NV12 files to video

ca flag

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?

andrew.46 avatar
in flag
May not help but could you include in your question the full command and complete terminal output?
Score:0
br flag

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"

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.