Last active
February 10, 2023 09:25
-
-
Save orumin/785dd5da8c29c5b24754 to your computer and use it in GitHub Desktop.
MPEG2-TS to H.264 within gstreamer on RaspberryPi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# | |
# Usage: mpegts2h264.sh <src.ts> <dst.mp4> | |
# | |
program_no=$(ffmpeg -i $1 2>&1 | grep Program | head -n 1 | awk '{ print $2 }') | |
video_sid=$(ffmpeg -i $1 2>&1 | grep Stream | grep Video | sed -e "s/^.*Stream #0:0\[0x\([0-9a-f][0-9a-f][0-9a-f]\)\].*$/\1/g") | |
audio_sid=$(ffmpeg -i $1 2>&1 | grep Stream | grep Audio | sed -e "s/^.*Stream #0:1\[0x\([0-9a-f][0-9a-f][0-9a-f]\)\].*$/\1/g") | |
gst-launch-1.0 filesrc location=./$1 ! progressreport ! \ | |
tsdemux program-number=$program_no name=demuxer \ | |
demuxer.video_0$video_sid ! video/mpeg ! queue max-size-time=0 max-size-buffers=0 ! \ | |
mpegvideoparse ! omxmpeg2videodec ! \ | |
videoconvert ! omxh264enc target-bitrate=4500000 control-rate=variable periodicty-idr=240 ! \ | |
video/x-h264,stream-format=byte-stream,profile=high ! h264parse ! mux. \ | |
demuxer.audio_0$audio_sid ! audio/mpeg ! queue max-size-time=0 max-size-buffers=0 ! \ | |
aacparse ! avdec_aac ! audioresample ! audioconvert dithering=0 ! faac bitrate=128000 ! \ | |
mp4mux streamable=true name=mux ! filesink location=$2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
これやったの大分前なのでMenu IDがあったか覚えてないです.
たぶん録画データに1SEG用のも入ってたりして辛いしなんとかしようとおもってSID指定した気がするのできっとわざとです.
覚えてないですが