• 将愚人从他们所敬拜的锁链下解放出来是非常困难@伏尔泰 (启蒙思想家)

ffmpeg mkv to mp4 with specified channel

programming BobMaster 2066次浏览 1793字 0个评论
文章目录[显示]
这篇文章在 2020年11月13日13:04:30 更新了哦~
()

Description

Recently i deployed jellyfin on my openwrt router using docker. My jellyfin version is 10.4.3 . After i mapped its media directory to the resources disk , i found when i opened the mkv format video , it came out with following error : PlaybackErrorNoCompatibleStream

Then i tried some mp4 format video , everything works on well. So i decided to transform it into mp4 format. Here comes our hero - - - FFmpeg

Instruction

As you know mkv format video can contain several audios and subtitles . So when we transform it to mp4 , we should choose which audio channel we would like to maintain , so as the subtitle.

First get video information

Use this command to find out information about the video

# replace your info
ffmpeg -i 1.mkv -hide_banner

Second do the transform

Accroding to its result , remember the audio you would like to choose. Such as #0:4(jpn) , that means audio in Japanese version is the fifth stream.

Then we can use ffmpeg -map parameter to specify our choice.

# replace your info
ffmpeg -i 1.mkv -map 0:0 -map 0:a:3 -c:v copy 1.mp4
# or in this way
ffmpeg -i 1.mkv -map 0:0 -map 0:4 -c:v copy -c:a copy 2.mp4

0:a:3 means the fourth audio. Though the Japanese version is #0:4 , there is a video channel #0:0 before it. So you can simply use-map 0:4 or -map 0:a:3

Complement

  • If you want directly to get the specific language audio
ffmpeg -i 1.mkv -map 0:m:language:jpn 1.aac/1.mp3 
  • if you want to include the subtitle #0:6(eng):Subtitle:ass (the first subtitle)
# replace your info | (:n) can be omitted when there is only one video stream,  it's used to choose video channel  
ffmpeg -i 1.mkv -map 0:v:0 -map 0:a:3 -vf subtitles=1.mkv 3.mp4
# other subtitle such as #0:12(chi):subtitle:ass (the sixth subtitle)
ffmpeg -i 1.mkv -map 0:v -map 0:a:3 -vf subtitles=1.mkv:si=5 3.mp4

Tip:When you use vf subtitle parameter , do not use -c copy , or it will come out with

Filtergraph 'subtitles=1.mkv:si=2' was defined for video output stream 0:0 but codec copy was selected.
Filtering and streamcopy cannot be used together.

Reference

  1. https://ffmpeg.org/ffmpeg.html#Advanced-options
  2. https://ffmpeg.org/ffmpeg-filters.html#subtitles

总共人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

很抱歉,这篇文章对您没有用!

让我们改善这篇文章!

告诉我们我们如何改善这篇文章?


文章版权归原作者所有 | 本站默认采用 CC-BY-NC-SA 4.0协议进行授权|
转载请务必注明原作者及本文原始地址:
https://blog.hibobmaster.com/ffmpeg-mkv-to-mp4-with-specified-channel/
喜欢 (0)
分享:-)
关于作者:
人生如音乐,欢乐且自由
发表我的评论(代码和日志请使用Pastebin或Gist)
取消评论

                       

去你妹的实名制!

  • 昵称 (必填)
  • 邮箱 (必填,不要邮件提醒可以随便写)
  • 网址 (选填)