linux - 从 Linux 管道读取图像路径时,ffmpeg 说“在图像中找不到 JPEG 数据”
问题描述
我正在尝试将一组图片转换为视频,并且我想从管道中读取图片的文件路径。我想运行的命令如下所示:
find dir/*.JPG | sort | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -s 6000x4000 -pix_fmt yuvj422p -i - -vcodec libx264 -s 1080x720 -r 20 -pix_fmt yuv420p out.mkv
但我不断收到No JPEG data found in image
错误。这是完整的日志:
Input #0, image2pipe, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj422p(bt470bg/unknown/unknown), 6000x4000, 1 fps, 1 tbr, 1 tbn, 1 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
[mjpeg @ 0x558e98cd7300] No JPEG data found in image
Error while decoding stream #0:0: Invalid data found when processing input
[swscaler @ 0x558e98ce9440] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x558e98cdaac0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x558e98cdaac0] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x558e98cdaac0] 264 - core 161 r3039 544c61f - H.264/MPEG-4 AVC codec - Copyleft
2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=20 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'out.mkv':
Metadata:
encoder : Lavf58.76.100
Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 1080x720, q=2-31, 20 fps, 1k tbn
Metadata:
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 0 fps=0.0 q=0.0 Lsize= 1kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
图片采用以下格式(带mediainfo
),文件名采用以下格式DSC_1234.JPG
:
Format : JPEG
Video
Format : JPEG
Width : 6 000 pixels
Height : 4 000 pixels
Display aspect ratio : 3:2
Color space : YUV
Chroma subsampling : 4:2:2
Bit depth : 8 bits
Compression mode : Lossy
另外,我想避免使用没有管道路径的解决方案(-f image2 -i DSC_%04d.JPG
例如)。你知道发生了什么吗?
解决方案
您的命令正在将文件名传递给管道,但需要文件的内容,请像这样调整您的命令:
find dir/ -iname '*.jpg' | xargs cat | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -s 6000x4000 -pix_fmt yuvj422p -i - -vcodec libx264 -s 1080x720 -r 20 -pix_fmt yuv420p out.mkv
推荐阅读
- php - 如何在php中获取调用者文件名?
- reactjs - 如何在 AntD 表格单元格中渲染两个元素?
- java - 使用 spring boot、tcpdump 和 docker 捕获所有主机网络
- r - 有没有办法从带有协变量的混合效应模型中绘制交互作用?
- python - 如果使用“For循环”制作的二维列表与python中的元素乘法制作,则替换单个元素
- r - (R) 我试图从我的数据集中删除所有有雨的日子,以及之后的一天
- javascript - 无法让 Bootstrap-5 脚本和 Rails6 工作(尽管这里有很多问答:(
- omnet++ - 在 OMNeT IDE 中导入外部对象文件
- python - cv2 网络摄像头流仅显示前几行图像
- pdf - NetSuite 高级 PDF 拣货工单