我想从静止图像创建 ts 流。
我试过:
ffmpeg -f image2 -i image.png test.mp4
ffmpeg -i test.mp4 -c copy output.ts
测试.m3u:
#EXTM3U
#EXTINF:-1 tvg-id="none" tvg-name="failo" tvg-logo="" group-title="title",test
http://192.168.1.54/test.m3u8
测试.m3u8
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:5, no desc
http://192.168.1.54/output.ts
我做错了什么?文件无法播放,我试过在 VLC 中播放。
main debug: using access module "access"
main debug: looking for stream_filter module matching "prefetch,cache_block": 26 candidates
prefetch debug: using 103 bytes buffer, 103 bytes read
main debug: using stream_filter module "prefetch"
main debug: looking for stream_filter module matching "any": 26 candidates
prefetch debug: end of stream
main debug: no stream_filter modules matched
main debug: looking for stream_directory module matching "any": 1 candidates
main debug: no stream_directory modules matched
main debug: attachment of directory-extractor failed for http://192.168.1.54/test.m3u
main debug: looking for stream_filter module matching "record": 26 candidates
main debug: using stream_filter module "record"
main debug: creating demux: access='http' demux='any' location='192.168.1.54/test.m3u' file='(null)'
main debug: looking for demux module matching "any": 55 candidates
adaptive debug: Updated playlist ID http://192.168.1.54/test.m3u, after 0s
adaptive debug: Representation http://192.168.1.54/test.m3u
adaptive debug: Segment #1 url=http://192.168.1.54/output.ts duration 300
adaptive debug: Period
adaptive debug: BaseAdaptationSet default_id#0
adaptive debug: Representation http://192.168.1.54/test.m3u
adaptive debug: Segment #1 url=http://192.168.1.54/output.ts duration 300
adaptive debug: opening playlist file (192.168.1.54/test.m3u)
main debug: using demux module "adaptive"
main debug: looking for meta reader module matching "any": 2 candidates
main debug: no meta reader modules matched
main debug: `http://192.168.1.54/test.m3u' successfully opened
macosx debug: Continue to use IOKit assertion NoIdleSleepAssertion (41968)
macosx debug: Continue to use IOKit assertion NoIdleSleepAssertion (41968)
adaptive debug: Retrieving http://192.168.1.54:80/test.m3u @0
main debug: creating access: http://192.168.1.54:80/test.m3u
main debug: looking for access module matching "http": 24 candidates
http debug: resolving 192.168.1.54 ...
http debug: outgoing request:
GET /test.m3u HTTP/1.1
Host: 192.168.1.54:80
Accept: */*
Accept-Language: en_US
User-Agent: VLC/3.0.16 LibVLC/3.0.16
Range: bytes=0-
答案1
这看起来像是 VLC 的一个错误 - VLC 无法播放单帧视频文件。
其他播放器(例如 FFplay 和 MPC-HC)可以播放单帧。
您可以使用选项创建一个 2 帧视频文件-stream_loop 1
。
您不必先创建 MP4 文件 - 您可以选择 TS 文件:
ffmpeg -y -stream_loop 1 -r 1 -i image.png -vcodec libx264 -crf 17 -pix_fmt yuv420p output.ts
-y
- 如果文件已经存在则覆盖该文件。-stream_loop 1
- 循环输入图像两次(再循环一次)。-r 1
- 选择 1fps 帧率。-vcodec libx264
- 选择 H.264 视频编码器。-crf 17
- 选择恒定(质量)率因子(值越低,质量越高)。-pix_fmt yuv420p
选择编码像素格式。
我不知道如何播放m3u
和m3u8
文件。
我播放过output.ts
文件。