簡體   English   中英

ffmpeg 將 m4s 轉換為 mp4

[英]ffmpeg converting m4s to mp4

我正在研究 DASH,試圖為最終用戶優化 QoE。

我有一個視頻並使用 ffmpeg 將其編碼為不同的比特率,一切都很好,並且可以使用破折號播放視頻。

我想要的是將從用戶接收到的片段組合成一個 m4 並將該 m4 轉換為 mp4。

我在ffmpeg中嘗試了很多方法,但它總是給我這個錯誤:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x9a9e500] could not find corresponding track id 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x9a9e500] could not find corresponding trex
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x9a9e500] error reading header
test2.m4s: Invalid data found when processing input

segment_1.m4s 在那里。

我該如何解決這個問題?

這有效

將 m4s 段合並為一個文件,確保文件順序正確。 例如

cat video-0.m4s >> all.m4s
cat video-1.m4s >> all.m4s
cat video-2.m4s >> all.m4s
cat video-3.m4s >> all.m4s
cat video-4.m4s >> all.m4s
cat video-5.m4s >> all.m4s
cat video-6.m4s >> all.m4s
cat video-7.m4s >> all.m4s
cat video-8.m4s >> all.m4s
cat video-9.m4s >> all.m4s
cat video-10.m4s >> all.m4s

然后一次完成所有轉換。

ffmpeg -i all.m4s -c copy video.mp4

這不

我在嘗試流式傳輸方法時遇到了同樣的問題( could not find corresponding trex )。

我在all.txt文件中有我想要的所有文件,其中包含

file 'video-0.m4s'
file 'video-1.m4s'
file 'video-2.m4s'
file 'video-3.m4s'
file 'video-4.m4s'
file 'video-5.m4s'
file 'video-6.m4s'
file 'video-7.m4s'
file 'video-8.m4s'
file 'video-9.m4s'
file 'video-10.m4s'

我試過ffmpeg -f concat -safe 0 -i all.txt -c copy video.mp4 ,導致同樣的問題。

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55fde2d0c520] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 1280x720): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55fde2d0c520] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55fde2d0c520] could not find corresponding track id 1
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55fde2d0c520] could not find corresponding trex
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55fde2d0c520] error reading header
[concat @ 0x55fde2cff900] Impossible to open 'rifle-1.m4s'
[concat @ 0x55fde2cff900] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 1280x720): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, concat, from 'all.txt':
[... omitted ...]
all.txt: Input/output error

連接初始化段的第一個文件,然后是其他段文件。

windows powershell:

排序和列出視頻文件

 Get-ChildItem -name v1*.m4s| Sort-Object { [regex]::Replace($_, '\d+', { $args[0].Value.PadLeft(20) }) } > list.txt

音頻文件

 Get-ChildItem -name a1*.m4s| Sort-Object { [regex]::Replace($_, '\d+', { $args[0].Value.PadLeft(20) }) } > list.txt

(參考: 如何像 Windows Explorer 一樣按文件名排序?

 type *init*.mp4 list.txt > Filename.mp4

Linux:

 ls -1v v1*.m4s > list.txt
 cat *init*.mp4 list.txt > Filename.mp4

我同意其他答案,但我發現一個略有不同的案例。 連接我得到的相同的m4s文件could not find corresponding trex錯誤。

我得到了這個 m3u8 播放列表:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-TARGETDURATION:5
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MAP:URI="/mypath/something.mp4"
#EXTINF:3.000,
something001.m4s
#EXTINF:3.000,
something002.m4s
#EXTINF:3.000,
something003.m4s
#EXTINF:3.000,
something004.m4s
#EXT-X-ENDLIST

而且我必須從 mp4 文件開始連接所有這些文件。 mp4 文件只有 1.1kB,沒有視頻,只有標題,我猜。

連接文件后,它可能會被某些軟件播放,但它不是很兼容,所以你必須讓 ffmpeg 為你修復它。

這對我有用:

ffmpeg -i allgluedtogetherinorder.mp4 -vcodec copy -strict -2 video_out.mp4

更新:如果您的 ffmpeg 在編譯時激活了 m3u 支持,那么您可以將播放列表轉換為 mp4,它將解決所有問題並為您提供完美的視頻。 您可能需要編輯 m3u 文件中文件的路徑,以便它可以找到它們。 然后:

ffmpeg -i playlist.m3u -vcodec copy -strict -2 video_out.mp4

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM