In terminal :
ffmpeg -f v4l2 -i /dev/video0 -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -s 1280x720 -r 30 -b:v 1500k -bufsize 1500k -maxrate 7000k -f flv rtmp://192.168.1.6:1935/live/test
I get:
Output #0, flv, to 'rtmp://192.168.1.6:1935/live/test':
Metadata:
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 1280x720, q=-1--1, 1500 kb/s, 30 fps, 1k tbn, 30 tbc
Metadata:
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 7000000/0/1500000 buffer size: 1500000 vbv_delay: -1
frame= 115 fps=0.1 q=21.0 size= 3088kB time=00:00:17.96 bitrate=1407.9kbits/s speed=0.0141x
When I open VLC player and open network stream in network rtmp://192.168.1.6/live/test, but it does not play it shows no error it just keeps on loading.
Thanks in advance
try this way:
rtmpdump -v -r "rtmp://192.168.1.6:1935/live/test" -o - | "vlc" -
https://rtmpdump.mplayerhq.hu/
https://en.wikipedia.org/wiki/RTMPDump
Related
I have one video file .mkv.
Inside this file, there is a video track, 3 audio tracks, 2 subtitles, a poster file, and a backdrop file.
Does ffmpeg know how to split .mkv into separate parts, video / 3 audio / 2 subtitles?
~# ffmpeg -hide_banner -i input.mkv
Input #0, matroska,webm, from 'input.mkv':
Duration: 01:37:03.90, start: 0.000000, bitrate: 3605 kb/s
Metadata:
title : 01:33:51.582
Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, progressive), 1024x576 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
title : Video
Stream #0:1(rus): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
Metadata:
title : MVO «West Video»
Stream #0:2(spa): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
title : MVO Spain-1
Stream #0:3(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
title : MVO TRK
Stream #0:4(eng): Subtitle: subrip (default)
Metadata:
title : RUS
Stream #0:5(eng): Subtitle: subrip
Metadata:
title : Eng
Stream #0:6(und): Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 780x1170 [SAR 1:1 DAR 2:3], 90k tbr, 90k tbn, 90k tbc (attached pic)
Metadata:
filename : poster.jpg
mimetype : image/jpeg
title : poster
LANGUAGE : und
Stream #0:7(und): Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 1280x719 [SAR 1:1 DAR 1280:719], 90k tbr, 90k tbn, 90k tbc (attached pic)
Metadata:
filename : backdrop.jpg
mimetype : image/jpeg
title : backdrop
LANGUAGE : und
I need:
Video
input0.mp4
Audio
input0.m4a
input1.m4a
input2.m4a
Subtitle
input0.vtt
input1.vtt
These commands do the splitting, but I need to know exactly how many audio files and how many subtitle files are in the mkv.
ffmpeg -y -i input.mkv \
-map 0:v:0 -c:v libx264 output0.mp4
ffmpeg -y -i input.mkv \
-map 0:a:0 -c:a aac output0.m4a \
-map 0:a:1 -c:a aac output1.m4a \
-map 0:a:2 -c:a aac output2.m4a
ffmpeg -y -i input.mkv \
-map 0:s:0 output0.vtt \
-map 0:s:1 output1.vtt
Is it possible to make such divisions without knowing the file number 0:a:2, 0:s:1?
i try to change the order of the output of 3 inputs (2 audio + 1 video)
this is my command:
/usr/bin/ffmpeg -async 1 \
-f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor \
-f pulse -i alsa_input.pci-0000_00_1b.0.analog-stereo \
-f x11grab -video_size 1920x1080 -framerate 8 -i :0.0 \
-filter_complex amix=inputs=2 \
-c:a aac -b:a 128k \
-c:v h264_nvenc -b:v 1500k -maxrate 1500k -minrate 1500k \
-override_ffserver -g 16 http://10.100.102.109:8090/feed1.ffm
this command works but, the first output is audio , therefore my third app cant view this output
this is my output:
Stream mapping:
Stream #0:0 (pcm_s16le) -> amix:input0 (graph 0)
Stream #1:0 (pcm_s16le) -> amix:input1 (graph 0)
amix (graph 0) -> Stream #0:0 (aac)
Stream #2:0 -> #0:1 (rawvideo (native) -> h264 (h264_nvenc))
Press [q] to stop, [?] for help
-async is forwarded to lavfi similarly to -af aresample=async=1:min_hard_comp=0.100000:first_pts=0.
Last message repeated 1 times
Output #0, ffm, to 'http://10.100.102.109:8090/feed1.ffm':
Metadata:
creation_time : now
encoder : Lavf57.83.100
Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc57.107.100 aac
Stream #0:1: Video: h264 (h264_nvenc) (Main), bgr0, 1920x1080, q=-1--1, 1500 kb/s, 8 fps, 1000k tbn, 8 tbc
Metadata:
encoder : Lavc57.107.100 h264_nvenc
Side data:
cpb: bitrate max/min/avg: 1500000/0/1500000 buffer size: 3000000 vbv_delay: -1
****how can i replace the output that the video will be first?****
(when i do this command with 1 audio and 1 video inputs, the output is fine, the video is first , and the third part App can view it)
i spent a lot of hours on it please help me.
tnx a lot ...
In the absence of mapping, output streams from complex filtergraphs will be ordered before other streams. So, add a label to the filter_complex output and map in the order required.
Use
/usr/bin/ffmpeg -async 1 \
-f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor \
-f pulse -i alsa_input.pci-0000_00_1b.0.analog-stereo \
-f x11grab -video_size 1920x1080 -framerate 8 -i :0.0 \
-filter_complex "amix=inputs=2[a]" \
-map 2:v -map '[a]' \
-c:a aac -b:a 128k \
-c:v h264_nvenc -b:v 1500k -maxrate 1500k -minrate 1500k \
-override_ffserver -g 16 http://10.100.102.109:8090/feed1.ffm
I am trying to concatenate multiple files together using ffmpeg concatenate demuxer. However final video is out of sync.
First parts are coming from static image which are converted to 5-seconds video in the following way:
ffmpeg -r 30 -i 1.png -vf loop=loop=150:size=1:start=0 -pix_fmt yuv420p -c:v libx264 -preset superfast -tune stillimage loop.mp4
Then I add silent audio stream:
ffmpeg -i loop.mp4 -f lavfi -i anullsrc -map 0:v -map 1:a -ar 44100 -ac 2 -c:v copy -c:a aac -shortest silent.mp4
ffrobe for the silent.mp4:
ffprobe -v quiet -show_entries stream=start_time,duration silent.mp4
[STREAM]
start_time=0.000000
duration=5.733333
[/STREAM]
[STREAM]
start_time=0.000000
duration=5.665011
[/STREAM]
Which already shows that audio and video streams have different duration.
Then I prepare concat input file, last line is the video with same dimension and framerate, also it has existing audio stream (44.1kHz, stereo)
file silent.mp4
file silent.mp4
... (multiple lines, say 10)
file silent.mp4
file video.mp4
To make sure that inputs have same parameters:
ffmpeg -i silent.mp4 -i video.mp4
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'silent.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:05.03, start: 0.000000, bitrate: 32 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 19 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:43.03, start: 0.000000, bitrate: 1622 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 1484 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Now, after concatenation final video is out of sync with audio (audio stream of the last part starts before static part is finished)
ffmpeg -f concat -i concat.txt -c copy result.mp4 (no warnings)
I have tried to pad audio stream with silence in both loop.mp4 and video.mp4, but it did not help - it randomly modifies duration and start time of both video and audio streams and audio is again out of sync after concat.
Also, I am not able to increase the duration of static part (so that number of entries in concat.txt can be decreased) because each static part can be different - this is just an example.
I have an mp4 file like this(same format but longer):
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'N1.2.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2018-10-31T13:44:21.000000Z
Duration: 00:28:54.21, start: 0.000000, bitrate: 10295 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 9972 kb/s, 50 fps, 50 tbr, 50k tbn, 100 tbc (default)
Metadata:
creation_time : 2018-10-31T13:44:21.000000Z
handler_name : ?Mainconcept Video Media Handler
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
Metadata:
creation_time : 2018-10-31T13:44:21.000000Z
handler_name : #Mainconcept MP4 Sound Media Handler
I also have another video file that is 3 minutes long. and has no audio. What is the fastest way to encode the other video in a way that it is encoded like my main video and then replace the last three minutes of the video track of my original video with this?
In other words.
I have video A that is 1 hour long. With the encoding shown above.
I have video B that is 3 minutes long with no audio. with a random encoding.
I want to have video C with the same encoding and same audio as A. But it's video track would be the first 57 minutes of A + B(which is 3 minutes).
I want to do this as fast as possible so I would like to not re encode A.
I know how to concatenate two videos, I use this command:
ffmpeg -f concat -i files.txt -c copy res.mp4
Make end video using parameters of main video:
ffmpeg -i videob.mp4 -f lavfi -i anullsrc=sample_rate=48000:channel_layout=stereo -filter_complex "[0:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,format=yuv420p,fps=50[v]" -map "[v]" -map 1:a -c:v libx264 -profile:v main -c:a aac -video_track_timescale 50000 -shortest videob2.mp4
Get duration of main video:
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 main.mp4
Make files.txt which is needed for concat demuxer:
file 'main.mp4'
outpoint 3420
file 'videob2.mp4'
In this example outpoint is main video duration minus end video duration.
Concatenate:
ffmpeg -f concat -i files.txt -i main.mp4 -map 0:v -map 1:a -c copy -shortest output.mp4
When using FFmpeg's split filter for video tracks, I want to filter audio track as well. I tested asplit but not sure where to use it in the filter chain.
When running this command:ffmpeg -y -probesize 100M -analyzeduration 5000000 -hide_banner -i $input -i $logo \
-filter_complex "[0:a]aformat=channel_layouts=stereo,aresample=async=1000[a1];[0:v]overlay=20:20,drawtext=fontfile=$font:text='some text':fontcolor=c1ff30:fontsize=50:x=250:y=100,split=3[v1][v2][v3];[v1]setpts=PTS-STARTPTS,yadif=0:-1:0,scale=w=640:h=360:force_original_aspect_ratio=decrease:sws_dither=ed:flags=lanczos,setdar=16/9[v1];[v2]setpts=PTS-STARTPTS,yadif=0:-1:0,scale=w=1024:h=576:force_original_aspect_ratio=decrease:sws_dither=ed:flags=lanczos,setdar=16/9[v2];[v3]setpts=PTS-STARTPTS,yadif=0:-1:0,scale=w=1600:h=900:force_original_aspect_ratio=decrease:sws_dither=ed:flags=lanczos,setdar=16/9[v3]" \
-map "[v1]" -map "[a1]" -c:a libfdk_aac -ac 2 -b:a 128k -ar 48000 -c:v libx264 -crf 23 -maxrate 550k -bufsize 1100k -bsf:v h264_mp4toannexb -forced-idr 1 -sc_threshold 0 -r 25 -g 50 -keyint_min 50 -preset medium -profile:v main -level 3.1 -coder 1 -pix_fmt yuv420p -flags +loop+mv4+cgop -flags2 +local_header -movflags faststart -cmp chroma -hls_time 6 -hls_playlist_type vod /dir/1.m3u8 \
-map "[v2]" -map "[a1]" -c:a libfdk_aac -ac 2 -b:a 128k -ar 48000 -c:v libx264 -crf 23 -maxrate 1400k -bufsize 2800k -bsf:v h264_mp4toannexb -forced-idr 1 -sc_threshold 0 -r 25 -g 50 -preset medium -profile:v main -level 4 -coder 1 -pix_fmt yuv420p -flags +loop+mv4+cgop -flags2 +local_header -movflags faststart -cmp chroma -keyint_min 50 -hls_time 6 -hls_playlist_type vod /dir/2.m3u8 \
-map "[v3]" -map "[a1]" -c:a libfdk_aac -ac 2 -b:a 128k -ar 48000 -c:v libx264 -crf 23 -maxrate 3100k -bufsize 6200k -bsf:v h264_mp4toannexb -forced-idr 1 -sc_threshold 0 -r 25 -g 50 -preset medium -profile:v high -level 3.1 -coder 1 -pix_fmt yuv420p -flags +loop+mv4+cgop -flags2 +local_header -movflags faststart -cmp chroma -keyint_min 50 -hls_time 6 -hls_playlist_type vod /dir/3.m3u8
FFmpeg throws this error:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Volumes/aaa/bbb/file.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.20.100
Duration: 00:00:10.00, start: 0.000000, bitrate: 117945 kb/s
Stream #0:0(eng): Video: prores (apcn / 0x6E637061), yuv422p10le(tv, bt709, top coded first (swapped)), 1920x1080, 115636 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 10k tbn, 10k tbc (default)
Metadata:
handler_name : Telestream, LLC Telestream Media Framework - Local 99.99.999999
encoder : Apple ProRes 422
timecode : 01:25:44:05
Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s (default)
Metadata:
handler_name : Telestream, LLC Telestream Media Framework - Local 99.99.999999
Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
Metadata:
handler_name : Telestream, LLC Telestream Media Framework - Local 99.99.999999
timecode : 01:25:44:05
Input #1, png_pipe, from '/Volumes/aaa/bbb/logo.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 1920x1080 [SAR 2835:2835 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Output with label 'a1' does not exist in any defined filter graph, or was already used elsewhere.
When removing the audio filtering ([0:a]aformat=channel_layouts=stereo,aresample=async=1000[a1]) and mapping 0:a as audio, the command runs fine.
What am I missing?
Filtergraph outputs can be used only once. You'll have to clone the audio output for multiple use.
First,
[0:a]aformat=channel_layouts=stereo,aresample=async=1000,asplit=3[a1][a2][a3]
and then map a1, a2, a3 as required.