英文:
FFMPEG how to combine -filter_complex with h264 and output to stdout
问题
我需要流式传输由ffmpeg生成的某些输出(音频转视频);为此,我正在使用*-filter_complex avectorscope*。
我正在使用ffplay测试管道,类似这样的命令可以工作:
ffmpeg -i video.mp4 -f h264 - | ffplay -
而且类似这样的命令也可以正常工作(写入文件):
ffmpeg -i input.mp3 -filter_complex "[0:a]avectorscope=s=1920x1080,format=yuv420p[v]" \
-map "[v]" -map 0:a -vcodec libx264 avectorscope.mp4
但是我真正需要的是这样的命令:
ffmpeg -i input.mp3 -filter_complex "[0:a]avectorscope=s=1920x1080,format=yuv420p[v]" \
-map "[v]" -map 0:a -vcodec libx264 -f h264 | ffplay -
但是当我尝试这样做时,我得到了这个错误:
输出流#0:1的自动编码器选择失败。格式h264的默认编码器(无编解码器)可能已禁用。请手动选择编码器。
选择流0:1的编码器时出错
pipe::在处理输入时找到无效数据
所以我可以将它编码到文件,但不能使用相同的标志将它编码到管道。
我还尝试过其他格式(-f flv和-f mpegts)它们也可以工作(对于ffplay),但对于需要h264流作为输入的其他工具来说则不行。
希望有人能帮忙!
英文:
I need to stream some ffmpeg output that is generated with ffmpeg (audio to video); for this I'm using -filter_complex avectorscope.
I am testing the pipe with ffplay, something like this works:
ffmpeg -i video.mp4 -f h264 - | ffplay -
and something like this also works fine (writing to a file):
ffmpeg -i input.mp3 -filter_complex "[0:a]avectorscope=s=1920x1080,format=yuv420p[v]" \
-map "[v]" -map 0:a -vcodec libx264 avectorscope.mp4
But what I really need is something like this:
ffmpeg -i input.mp3 -filter_complex "[0:a]avectorscope=s=1920x1080,format=yuv420p[v]" \
-map "[v]" -map 0:a -vcodec libx264 -f h264 | ffplay -
but when I try that I get this error:
Automatic encoder selection failed for output stream #0:1. Default encoder for format h264 (codec none) is probably disabled. Please choose an encoder manually.
Error selecting an encoder for stream 0:1
pipe:: Invalid data found when processing input
So I can encode it to a file but not encode it to a pipe with the same flags.
I also tried with other format (-f flv and -f mpegts) and they also work (for ffplay), but it doesn't work with other tools that require h264 stream as input.
I hope someone can help!
答案1
得分: 1
-f h264
表示一个原始的 H.264 比特流,所以无法包含音频。
使用一个支持多路复用的容器,比如 nut
。
ffmpeg -i input.mp3 -filter_complex "[0:a]avectorscope=s=1920x1080,format=yuv420p[v]" \ -map "[v]" -map 0:a -vcodec libx264 -f nut | ffplay -f nut -
英文:
-f h264
represents a raw H.264 bitstream so audio can't be included.
Use a container with multiplexing e.g. nut
ffmpeg -i input.mp3 -filter_complex "[0:a]avectorscope=s=1920x1080,format=yuv420p[v]" \
-map "[v]" -map 0:a -vcodec libx264 -f nut | ffplay -f nut -
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论