Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware Codec questions - trying to use h264_v4l2m2m instad of libx264 #62

Open
bengeek2 opened this issue Feb 7, 2024 · 3 comments
Open

Comments

@bengeek2
Copy link

bengeek2 commented Feb 7, 2024

My index.ts file is generating this ffmpeg command:

-i /dev/video0 -f alsa -hwaccel auto -i hw:C4K,0 -an -r 30 -vcodec h264_v4l2m2m -b:v 5000k -filter:v scale=w=1280:h=720 -loglevel info -fflags nobuffer -analyzeduration 0 -f h264 -pix_fmt yuv420p -preset ultrafast -g 30 -bsf:v h264_metadata=aud=insert unix:./1.sock -ac 2 -ar 48000 -vn -f s16le unix:./2.sock

When the program is run with this ffmpeg command: the bot joins, creates the stream, I can hear audio, but video has an infinite load symbol.

if i generate this ffmpeg command:

-i /dev/video0 -f alsa -hwaccel auto -i hw:C4K,0 -an -r 30 -vcodec libx264 -b:v 5000k -filter:v scale=w=1280:h=720 -loglevel info -fflags nobuffer -analyzeduration 0 -f h264 -pix_fmt yuv420p -preset ultrafast -g 30 -bsf:v h264_metadata=aud=insert unix:./1.sock -ac 2 -ar 48000 -vn -f s16le unix:./2.sock

everything works perfectly.

Both console outputs look the same, any ideas on what could be going wrong?

The only change between the 2 is changing -vcodec libx264 to -vcodec h264_v4l2m2m

@dank074
Copy link
Owner

dank074 commented Feb 8, 2024

That's weird.

If you enable logging for the ffmpeg process do you see anything?

@bengeek2
Copy link
Author

bengeek2 commented Feb 8, 2024

Yes, when I had ffmpeg set to info, i had no errors and the ffmpeg output seemed to be encoding like normal. i was also able to modify the commands to output to a video file and it recorded as expected for both codecs

@longnguyen2004
Copy link
Collaborator

longnguyen2004 commented Feb 9, 2024

Try adding -bf 0 to the first command. WebRTC doesn't support B frames, and even if the stream works, it'll be very glitchy.

If that doesn't work either, can you provide a video file after running it through the encoder?

Another thing to try would be to record into a file (with -bf 0), then replaying that file through the copy codec path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants