ffplay - how to get only single channel audio from video - audio

For a video file, how can I only get the showwave filter instead of both showwave n spectrum.
ffplay -f lavfi 'amovie=abc.mp4,asplit=3[out1][a][b]; [a]showwaves=s=640x240[waves]; [b]showspectrum=s=640x240[spectrum]; [waves][spectrum] vstack[out0]'
And this shows the video as audio waveform but i get 2 identical waveform (most prob left/right)
ffplay - showmode 1 abc.mp4

Use
ffplay -f lavfi 'amovie=abc.mp4,asplit=2[out1][waves];[waves]pan=1c|c0=c0,showwaves=s=640x240[out0]'
The pan filter here keeps only the first channel, which is, likely, the Left channel. Change c0=c0 to c0=c1 to keep the Right only.

Related

FFMPEG - How to add a default codec for wav using -filter_complex

Is it possible to set the audio codec via -filter_complex in FFMPEG?
My Google-fu is weak and I haven't had good hits so far.
I'm working on a fork of a (possibly abandoned) project, and this is currently the -filter_complex argument:
[0:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=1.0[audout0]
How do I set the audio codec here?
I've tried:
[0:a]aformat=sample_fmts=fltp:sample_rates=44100:acodec=pcm_s16le:channel_layouts=stereo,volume=1.0[audout0]
by adding: acodec=pcm_s16le
But this results in: Option 'acodec' not found
I'm trying to accomplish is adding a default audio codec for a .wav output, because the system complains that there's no default audio codec chosen for a wav output, because I get this error message with my project when I try to output to .wav:
Automatic encoder selection failed for output stream #0:0. Default encoder for format wav (codec none) is probably disabled. Please choose an encoder manually.
Error selecting an encoder for stream 0:0
Thanks!

Stream HTTPS (and password protected) m3u8 to AirPlay

Similar to other questions I've seen I find that I cannot stream my HTTPS (and password protected via JWT/server-side auth) m3u8 TS streams to AirPlay. The files are being served via my own API/web app using HTML.
My HLS stream play fine on my iPhone (iPhone 8 w/ latest iOS at time of writing), but it's AirPlay that seems to fail. Apple's example m3u8 HTTP video stream files for TS and MP4 work as expected from my phone to AirPlay, but my own m3u8 file does not.
I imagine the answer may be within Apple's HTTP Live Streaming (HLS) specification documentation or their WWDC talk on HLS authoring, but I find the reference materials too opaque to follow as a person who is new to HLS streaming in general.
I've tried explicitly opting in to AirPlay using x-webkit-airplay="allow" on the video element as well as switching the server response Content-Type to application/vnd.apple.mpegurl from application/x-mpegURL, but with no success.
I'm using hls.js to play the videos, and the videos were transcoded like so using ffmpeg.
ffmpeg -i "${1}" \
-filter_complex "[0:v]split=1[v1]; [v1]scale=w=1080:h=-1[v1out]" \
-map "[v1out]" -c:v:2 libx264 -x264-params "nal-hrd=cbr:force-cfr=1" -b:v:2 5M -maxrate:v:2 5M -minrate:v:2 5M -bufsize:v:2 10M -preset slow -g 48 -sc_threshold 0 -keyint_min 48 \
-map "a:0" -c:a:0 aac -b:a:0 96k -ac 2 \
-f hls \
-hls_time 2 \
-hls_playlist_type vod \
-hls_flags independent_segments \
-hls_segment_type mpegts \
-hls_segment_filename "${2}/${3}/data%02d.ts" \
-var_stream_map "v:0,a:0" "${2}/${3}/stream.m3u8"
My iPhone seemingly shows that the video is currently playing, but AirPlay shows no signs that anything is being played.
Here is a snippet of my m3u8 file...
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXTINF:2.400000,
data00.ts
#EXTINF:1.600000,
data01.ts
#EXTINF:2.400000,
data02.ts
#EXTINF:1.60
...
...vs Apple's example...
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=2218327,BANDWIDTH=2227464,CODECS="avc1.640020,mp4a.40.2",RESOLUTION=960x540,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v5/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=8144656,BANDWIDTH=8178040,CODECS="avc1.64002a,mp4a.40.2",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v9/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=6307144,BANDWIDTH=6453202,CODECS="avc1.64002a,mp4a.40.2",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v8/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=4775338,BANDWIDTH=5054232,CODECS="avc1.64002a,mp4a.40.2",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v7/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=3240596,BANDWIDTH=3289288,CODECS="avc1.640020,mp4a.40.2",RESOLUTION=1280x720,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v6/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=1292926,BANDWIDTH=1296989,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=768x432,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v4/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=914722,BANDWIDTH=922242,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v3/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=541239,BANDWIDTH=553010,CODECS="avc1.640015,mp4a.40.2",RESOLUTION=480x270,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v2/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=2439704,BANDWIDTH=2448841,CODECS="avc1.640020,ac-3",RESOLUTION=960x540,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud2",SUBTITLES="sub1"
v5/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=8366033,BANDWIDTH=8399417,CODECS="avc1.64002a,ac-3",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud2",SUBTITLES="sub1"
v9/prog_index.m3u8
...
The issue is when the device playing the video tries to play it what it really does in the end is load the master.m3u8 playlist and then play the video. Since your m3u8 is protected the device does not have permission to load it. And the cookies in the main browser are not passed to the tv device so in reality it works as expected: a person you don’t know (the tv) is trying to play the video.
Look for ways to only protect the main playlist with a signature in the url itself and then having a middle ware creating cookies to protect the rest of the segments.
We have that working with AWS cloud front and lambda at edge

ffmpeg HLS Multiple Audio Renditions

How can I convert an mp4 video file having inside 3 audio tracks (english, german and french) to an HLS playlist having :
one videofile.m3u8 and its corresponding segmentsfile.ts
one audiofile-english.m3u8 and its corresponding segmentsfile.aac
one audiofile-german.m3u8 and its corresponding segmentsfile.aac
one audiofile-french.m3u8 and its corresponding segmentsfile.aac
one masterfile.m3u8 like that :
#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="medium",NAME="#1 Fre",DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="fre",URI="medium/planete_interdite_500_h264_240p_audio1_fre.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="medium",NAME="#2 Eng",DEFAULT=NO,AUTOSELECT=YES,LANGUAGE="eng",URI="medium/planete_interdite_500_h264_240p_audio2_eng.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="medium",NAME="#3 Fre",DEFAULT=NO,AUTOSELECT=YES,LANGUAGE="de",URI="medium/planete_interdite_500_h264_240p_audio1_de.m3u8"
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=3274000, CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=854x480,AUDIO="medium"
medium/planete_interdite_2080_q264_480p.m3u8
You can use ffmpeg for firstly convert only hls video with flags -an -sn, than converts hls audio streams with flags -vn -sn, and finally make playlist with some scripts

HandbrakeCLI command lines

I'm trying to convert DVD iso files to mp4 using HandbrakeCLI. I use the following line in a batch file:
D:\HandBrakeCLI.exe -i "D:\input.iso" -o "D:\output.mp4" --no-markers --width "720" --height "480" --preset "HQ 480p30 Surround" --encoder "mpeg2" --audio-lang-list "eng"
When I do this, I must then extract the audio from the file, using the following line:
D:\eac3to\eac3to.exe "D:\output.mp4" "D:\output.wavs" -down16
However, when I attempt to extract the audio, I get the error message
The format of the source file could not be detected.
Is there anything wrong with my former line of code that's causing the mp4 to get screwed up?
Minor side question: I'm also trying to get handbrake to remove subtitles and also only keep English audio, do you know what code could be used for that? I started a bit there with the --audio-lang-list "eng" but I'm now sure what to do from there.
Thanks a lot in advance!
You need to use a valid audio format. .wavs is not valid. You have to use an available audio codec to output to the below for --aencoder. The default output audio for MP4 is .aac
av_aac
copy:aac
ac3
copy:ac3
eac3
copy:eac3
copy:truehd
copy:dts
copy:dtshd
mp3
copy:mp3
vorbis
flac16
flac24
copy:flac
opus
copy
Defaults for audio
av_mp4 = av_aac
av_mkv = mp3
You need to pass none for no subtitles
-s none
And define only eng track like you were doing
--audio-lang-list eng
Check out the Handbrake CLI Documentation for the command line code:
https://handbrake.fr/docs/en/latest/cli/cli-guide.html
You can also try using a different program once you extract the audio. A program like XMediaRecode. It can also remux audio and video and convert other audio formats to wav
https://www.videohelp.com/software/XMedia-Recode

Is it possible to stream during a conversion? - FFMPEG

I'm wondering if it is possible to stream video while the video is being generated through conversion.
Any ideas?
Assuming that your copy of FFmpeg includes something like rtmp amongst the protocols listed with ffmpeg -protocols you should be able to do this using the split video filter. The whole command will look something like:
ffmpeg -i input.mp4 <video options> -filter split rtmp://server[:port][/app] out.mp4
well use the url you want to stream to (be it udp or rtmp) as output instead to output to a file.
To do both , you ll need to use pipe

Resources