ffmpeg: Could not find codec parameters for stream 0 (Video: h264) unspecified size
Your input is simply not an h264 stream, yet you are telling ffmpeg it is one.
You need to tell ffmpeg what it actually is: a v4l2 stream in mjpeg or yuyv format (depending on what format your camera was set to at the time of capture, of the two listed by v4l2-ctl --list-formats
). If you want ffmpeg to transcode it to an h264, you need to tell it that, too.
If the input is raw YUYV frames, you want:
ffmpeg -f rawvideo -pix_fmt yuyv422 -s:v 640x480 -r 25 -i output.raw -c:v libx264 output.mp4
Replace 640x480 and 25 with the dimensions and framerate of your video.
If the input is MJPEG, you should be able to just leave out the -f
and ffmpeg should figure it out:
ffmpeg -i output.raw -c:v libx264 output.mp4
Incidentally, you do not need another capture tool; ffmpeg can capture from v4l2 devices just fine:
ffmpeg -f v4l2 -r 25 -s:v 640x480 -i /dev/video0 -c:v libx264 output.mp4
dempap
Updated on September 18, 2022Comments
-
dempap over 1 year
I try to convert a video from .raw to .mp4. For this reason I did download, build and install both x264 and ffmpeg. However, command:
ffmpeg -f h264 -i output.raw -vcodec copy output.mp4
fails with error (shown in picture below). Is there any way to fix this?
Commands I also run:
1
root@beagleboard:/# v4l2-ctl --list-formats ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Pixel Format: 'YUYV' Name : YUV 4:2:2 (YUYV) Index : 1 Type : Video Capture Pixel Format: 'MJPG' (compressed) Name : MJPEG
2
root@beagleboard:/dev# v4l2-ctl --set-fmt-video=pixelformat=0
-
Rajib over 10 yearscould you just post the output of this:
ffmpeg -i output.raw
, assuming you are trying to convertoutput.raw
. Also if you tryffmpeg -i output.raw -vcodec libx264 -pix_fmt yuv420p output.mp4
what is the console output? -
dempap over 10 yearsThank's for your reply. Both outputs are exactly the same, as edited above. Do you think there is a problem in encoding, or in the file while capturing video?
-
slhck over 10 yearsWhere did you get
output.raw
from and how did you create it? -
dempap over 10 yearsBy executing
./capture -f -c 100 -o > output.raw
. capture.c downloaded from: linuxtv.org/downloads/v4l-dvb-apis/capture-example.html.
-