0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

tsファイルをmp4ファイルにエンコード

0
Posted at

以前撮りためた生TSファイルをエンコード。

環境

Ubuntu 22.04 LTS

調査

docker-mirakurun-epgstation ではどうなっているかな? と調べたら、エンコード設定は epgstation/config/config.yml

の中にある。

            mp4:
                - name: 720p
                  cmd:
                      '%FFMPEG% -re -dual_mono_mode main -i pipe:0 -sn -threads 0 -c:a aac -ar 48000 -b:a 192k -ac 2
                      -c:v libx264 -vf yadif,scale=-2:720 -b:v 3000k -profile:v baseline -preset veryfast -tune
                      fastdecode,zerolatency -movflags frag_keyframe+empty_moov+faststart+default_base_moof -y -f mp4
                      pipe:1'
                - name: 480p
                  cmd:
                      '%FFMPEG% -re -dual_mono_mode main -i pipe:0 -sn -threads 0 -c:a aac -ar 48000 -b:a 128k -ac 2
                      -c:v libx264 -vf yadif,scale=-2:480 -b:v 1500k -profile:v baseline -preset veryfast -tune
                      fastdecode,zerolatency -movflags frag_keyframe+empty_moov+faststart+default_base_moof -y -f mp4
                      pipe:1'

ffmpeg でエンコード

さきほどの内容を参考に以下のようなスクリプトを作成

#!/bin/bash

for FILE in "$@"
do
  ffmpeg -re -dual_mono_mode main -i $FILE -sn -threads 0 -c:a aac -ar 48000 -b:a 192k  -ac 2 -c:v libx264 -vf yadif,scale=-2:720 -b:v 3000k  -profile:v baseline -preset veryfast -tune fastdecode,zerolatency -movflags frag_keyframe+empty_moov+faststart+default_base_moof -y -f mp4 $FILE.mp4
  mv $FILE.mp4 transcoded 
  rm $FILE
done

なお、入力ファイルの指定の位置を後ろにすると以下のようなエラー。

Option b:a (video bitrate (please use -b:v)) cannot be applied to input url 2
Option b:a (video bitrate (please use -b:v)) cannot be applied to input url 201605051530010102-10min.ボックス テイクテック「力を伝える」[字].ts.mp4 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for input file 201605051530010102-10min.ボックス テイクテック「力を伝える」[字].ts.mp

結果

ファイルサイズは約1/5程度になりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?