I'm trying to convert rtmp streams to m3u8 stream. To reach that aim I use FFMPEG. Now, there is no problem with converting and downloading. However, it writes lots of .ts file such as channel0000.ts,channel0001.ts,channel0002.ts. Per every 10 seconds, 1 ts file is created. In this point, I want a single ts file. In other words, I need overwriting because I don't want to store all the stream I need just last 10 seconds. When I try to write on the same file I get this error:
我正在嘗試將rtmp流轉換為m3u8流。為了達到這個目標,我使用了FFMPEG。現在,轉換和下載沒有問題。但是,它寫了很多.ts文件,比如channel0000.ts,channel0001.ts,channel0002.ts。每10秒創建一個ts文件。在這一點上,我想要一個單獨的ts文件。換句話說,我需要重寫,因為我不想存儲所有我只需要10秒鍾的流。當我試圖在同一個文件上寫時,我得到了這個錯誤:
Invalid segment filename template 'channel.ts'
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argumentStream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Last message repeated 1 times
Here is my FFMPEG command.
這是我的FFMPEG命令。
ffmpeg -loglevel quiet -i rtmp://example -c:v libx264 -profile:v baseline -level 3.1 -c:a aac -strict experimental -f mpegts - | ffmpeg -i - -c copy -map 0 -f segment -segment_list channel.m3u8 -segment_format mpegts -segment_time 10 channel%04d.ts
Any suggestion?
任何建議嗎?
1 个解决方案
#1
2
In FFMPEG documentation, I found "segment_wrap" options. When you add this option, files are written in a loop. In my problem I added "-segment_wrap 1" command part and it writes just a single file now.
在FFMPEG文檔中,我找到了“segment_wrap”選項。當您添加此選項時,文件被寫入一個循環中。在我的問題中,我添加了“-segment_wrap 1”命令部分,它現在只寫一個文件。