com.mydetv.swarm ffmpeg

USING -threads 4 messed me up, don’t do it!

# this works to transcode to a webm vp8 file
ffmpeg -i fireworks.mp4 \
-c:v libvpx -crf 10 -b:v 512K \
-c:a libopus -b:a 128k -vbr on -compression_level 10 \
-pass 1 -y fireworks.webm; \
ffmpeg -i fireworks.mp4 \
-c:v libvpx -crf 10 -b:v 512K \
-c:a libopus -b:a 128k -vbr on -compression_level 10 \
-pass 2 -y fireworks.webm

# just stream
ffmpeg -i fireworks.mp4 \
-vcodec copy -an -f rtp rtp://10.11.1.96:5122 \
-vn -f rtp rtp://10.11.1.96:5124

# let’s try to stream and transcode
# worked but choppy
ffmpeg -i people.mp4 \
-c:v libvpx -crf 10 -b:v 256K \
-an -f rtp rtp://10.11.1.96:5124 \
-c:a libopus -b:a 64k \
-vn -f rtp rtp://10.11.1.96:5122

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update

(2017/12/20 had trouble streaming to janus, rolled my own https://gist.github.com/faleev/3435377)

Supporting Chrome and Firefox
Mozilla compatibility page
Chrome blog about vp9
WebM vp9 is cool. Send the full stream to one guy and he can decide to send a lower bitrate version to the next guy with no transcoding!

ffmpeg converting to webm
mozillas bitrate discussion

We’ll do constrained quality, which should provide 3 bitrates in one file.

Let’s target these two bitrates for our old/new (when we upgrade to HD) videos
640x480p @ 24,25,30 512 (LQ), 750 (MQ) 256 (LQ) 375 (MQ) 742 (LQ) 1088 (MQ)
1920x1080p @ 50,60 3000 1500 4350

only a7 worked, a8 gave “Unrecognized option ’tile-columns'”

converting to webm

fight to get ffmpeg installed
mac
brew install libvpx
brew install ffmpeg –with-libvorbis -with-vorbis –with-theora \
–with-libass \
–with-openssl \
–with-libvpx –with-libvpx –with-opus

ffmpeg -i 34-01-05_She_Wronged_Him_Right_512kb.mp4 -vf scale=640×480 -b:v 512k \
-minrate 256k -maxrate 742k -tile-columns 1 -g 240 -threads 4 \
-quality good -crf 34 -c:v libvpx-vp9 -c:a libopus \
-pass 1 -speed 4 34-01-05_She_Wronged_Him_Right_512kb.webm && \
ffmpeg -i 34-01-05_She_Wronged_Him_Right_512kb.mp4 -vf scale=640×480 -b:v 512k \
-minrate 256k -maxrate 742k -tile-columns 1 -g 240 -threads 4 \
-quality good -crf 34 -c:v libvpx-vp9 -c:a libopus \
-pass 2 -speed 4 -y 34-01-05_She_Wronged_Him_Right_512kb.webm

try to constrain opus to 128bit audio
ffmpeg -i in.mp4 -c:a libopus -vn -vbr on out.opus
ffmpeg -i input -acodec libopus -b:a bitrate -vbr on -compression_level 10 output

ffmpeg -i Betty_Boop_Baby_Be_Good_1935_512kb.mp4 -vf scale=640×480 -b:v 512k \
-minrate 256k -maxrate 742k -tile-columns 1 -g 240 -threads 4 -passlogfile xxx \
-quality good -crf 34 -c:v libvpx-vp9 \
-c:a libopus -b:a 128k -vbr on -compression_level 10 \
-pass 1 -speed 4 Betty_Boop_Baby_Be_Good_1935_512kb.webm && \
ffmpeg -i Betty_Boop_Baby_Be_Good_1935_512kb.mp4 -vf scale=640×480 -b:v 512k \
-minrate 256k -maxrate 742k -tile-columns 1 -g 240 -threads 4 -passlogfile xxx \
-quality good -crf 34 -c:v libvpx-vp9 \
-c:a libopus -b:a 128k -vbr on -compression_level 10 \
-pass 2 -speed 4 -y Betty_Boop_Baby_Be_Good_1935_512kb.webm

ffmpeg -i people.mp4 -vf scale=640×480 -b:v 512k \
-minrate 256k -maxrate 742k -tile-columns 1 -g 240 -threads 4 \
-quality good -crf 34 -c:v libvpx-vp9 -c:a libopus \
-pass 1 -speed 4 people.webm && \
ffmpeg -i people.mp4 -vf scale=640×480 -b:v 512k \
-minrate 256k -maxrate 742k -tile-columns 1 -g 240 -threads 4 \
-quality good -crf 34 -c:v libvpx-vp9 -c:a libopus \
-pass 2 -speed 4 -y people.webm

# WHOPSIE janus doesn’t do vp9 yet
ffmpeg -i fireworks.mp4 \
-c:v libvpx -crf 10 -b:v 512K \
-c:a libopus -b:a 128k -vbr on -compression_level 10 \
-pass 1 -y fireworks.webm; \
ffmpeg -i fireworks.mp4 \
-c:v libvpx -crf 10 -b:v 512K \
-c:a libopus -b:a 128k -vbr on -compression_level 10 \
-pass 2 -y fireworks.webm

ffmpeg -i input.mp4 -c:v libvpx -qmin 0 -qmax 50 -crf 5 -b:v 1M -c:a libvorbis output.webm
ffmpeg -i input.mp4 -c:v libvpx-vp9 -minrate 5M -maxrate 5M -b:v 5M output.webm

2017/12/21 this worked!
ffmpeg -i fireworks.mp4 \
-c:v libvpx -crf 10 -b:v 512K \
-c:a libopus -b:a 128k -vbr on -compression_level 10 \
-y fc.vp8.webm

ffmpeg -i people.mp4 -vf scale=640×480 -b:v 512k \
-minrate 256k -maxrate 742k -tile-columns 1 -g 240 -threads 4 \
-quality good -crf 34 -c:v libvpx -c:a libopus \
-pass 1 -speed 4 people.vp8.webm && \
ffmpeg -i people.mp4 -vf scale=640×480 -b:v 512k \
-minrate 256k -maxrate 742k -tile-columns 1 -g 240 -threads 4 \
-quality good -crf 34 -c:v libvpx -c:a libopus \
-pass 2 -speed 4 -y people.vp8.webm

ffmpeg -i /usr5/videos/archive.org/GhostsontheLoose/GhostsontheLoose.ogv -vf scale=640×480 -b:v 512k \
-minrate 256k -maxrate 742k -tile-columns 1 -g 240 -threads 4 \
-quality good -crf 34 -c:v libvpx-vp9 -c:a libopus \
-pass 1 -speed 4 /usr3/webm/archive.org/GhostsontheLoose//GhostsontheLoose.webm && \
ffmpeg -i /usr5/videos/archive.org/GhostsontheLoose/GhostsontheLoose.ogv -vf scale=640×480 -b:v 512k \
-minrate 256k -maxrate 742k -tile-columns 1 -g 240 -threads 4 \
-quality good -crf 34 -c:v libvpx-vp9 -c:a libopus \
-pass 2 -speed 4 -y /usr3/webm/archive.org/GhostsontheLoose//GhostsontheLoose.webm

debian 8 Jessie, had to roll compile ffmpeg myself
apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev \
libsdl2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev \
libvpx4 libopus-dev libx264-dev libx265-dev libfdk-aac1 x265 x264
grab some sox stuff too, we’ll need it later
apt-get install libsox-dev sox
./configure \
–prefix=”/usr/local/bin” \
–pkg-config-flags=”–static” \
–enable-gpl \
–enable-libass \
–enable-libfreetype \
–enable-libmp3lame \
–enable-libopus \
–enable-libtheora \
–enable-libvorbis \
–enable-libvpx \
–enable-libx264 \
–enable-libopus \
–enable-nonfree
and it still don’t work for some conversions:
/tmp/buildd/libvpx-1.3.0/vp9/encoder/vp9_encodeframe.c:1747: rd_pick_partition: Assertion `tp_orig < *tp’ failed.
and then these on some archive.org files:
[aac @ 0x3856d60] SSR is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.

and on a7, tried to compile from git

converting to webm with watermark

ffmpeg -codecs
Codecs:
D….. = Decoding supported
.E…. = Encoding supported
..V… = Video codec
..A… = Audio codec
..S… = Subtitle codec
…I.. = Intra frame-only codec
….L. = Lossy compression
…..S = Lossless compression
——-

ffmpeg -formats
File formats:
D. = Demuxing supported
.E = Muxing supported

a8 shows
formats:
D matroska,webm Matroska / WebM
E webm WebM
E webm_chunk WebM Chunk Muxer
DE webm_dash_manifest WebM DASH Manifest
codecs:
D.A.L. opus Opus (Opus Interactive Audio Codec)
D.V.L. vp9 Google VP9

a7 shows
formats:
D matroska,webm Matroska / WebM
E webm WebM
E webm_chunk WebM Chunk Muxer
DE webm_dash_manifest WebM DASH Manifest

codecs:
DEV.L. vp9 Google VP9 (decoders: vp9 libvpx-vp9 vp9_cuvid ) (encoders: libvpx-vp9 )
DEA.L. opus Opus (Opus Interactive Audio Codec) (decoders: opus libopus ) (encoders: opus libopus )

ffmpeg -i input -f rtsp -rtsp_transport tcp rtsp://localhost:8888/live.sdp
-c:v libvpx

ffmpeg -i sample.mp4 -strict -2 -f rtsp rtsp://192.168.0.3:1935/live/myStream

ffmpeg -stream_loop -1 -thread_queue_size 4 -i NTSCTVTestPattern.mp4 -strict -2 -vcodec copy -an -f rtp rtp://10.10.1.97:6005 -acodec copy -vn -sdp_file saved_sdp_file -f rtp rtp://10.11.1.97:7005

ffmpeg -stream_loop -1 -thread_queue_size 4 -i NTSCTVTestPattern.mp4 -strict -2 -f rtsp rtsp://10.10.1.97:6005/live/stream

ffmpeg -re -stream_loop -1 -thread_queue_size 4 -i NTSCTVTestPattern.mp4 -strict -2 \
-sdp_file saved_sdp_file \
-f rtsp rtsp://10.10.1.97:6005 \

ffmpeg -protocol_whitelist “file,rtp,udp” -i saved_sdp_file -strict -2 saved_video_file.mp4

Broken file, keyframe not correctly marked
trying to resolve with latest ffmpeg
didn’t help:
ffmpeg version N-89073-gff8f40a Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.5) 20160609

Leave a Reply

Your email address will not be published. Required fields are marked *