linux下传输ts流,在Linux中使用FFMPEG覆蓋TS流文件

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”命令部分,它現在只寫一個文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值