tee muxer failing with error: Output file #0 does not contain any stream - ffmpeg

I am able to stream with ffmpeg an mp4 file with h264 encoded video and aac encoded audio to flash flv output. The command I used is:
ffmpeg -re -i bigbuckbunny_HD_60fps.mp4 -c copy -f flv rtmp://192.168.3.64:1935/main/stream0
When I am trying to use the tee option to duplicate the output I am failing with an error. This is the command I use:
ffmpeg -re -i bigbuckbunny_HD_60fps.mp4 -c copy -f tee "[f=flv]rtmp://192.168.3.64:1935/main/stream0|[f=flv]rtmp://192.168.3.64:1935/main/stream1"
However, it fails. What I am missing? The output I have from ffmpeg is:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bigbuckbunny_HD_60fps.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.29.104
Duration: 00:10:34.58, start: 0.000000, bitrate: 4279 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4141 kb/s, 60 fps, 60 tbr, 90k tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
handler_name : SoundHandler
Output #0, tee, to '[f=flv]rtmp://192.168.3.64:1935/mainconcept/obs_stream|[f=flv]rtmp://192.168.3.64:1935/mainconcept/obs_stream1':
Output file #0 does not contain any stream

You have to add the -map option when using the tee muxer. From the tee muxer documentation:
Since the tee muxer does not represent any particular output format,
ffmpeg cannot auto-select output streams. So all streams intended for
output must be specified using -map.
Example to include all streams from the input (-map 0):
ffmpeg -re -i bigbuckbunny_HD_60fps.mp4 -map 0 -c copy -f tee "[f=flv]rtmp://192.168.3.64:1935/main/stream0|[f=flv]rtmp://192.168.3.64:1935/main/stream1"
See FFmpeg Wiki: Map for more info and examples.

Related

ffmpeg tee muxer failing with error: Tag avc1 incompatible with output codec id '28'

I am able to stream with ffmpeg an mp4 file with h264 encoded video and aac encoded audio to flash flv output. The command I used is:
ffmpeg -re -i bigbuckbunny_HD_60fps.mp4 -c copy -f flv rtmp://192.168.3.64:1935/main/stream0
When I am trying to use the tee option to duplicate the output I am failing with an error. This is the command I use:
ffmpeg -re -i bigbuckbunny_HD_60fps.mp4 -map 0 -c copy -f tee "[f=flv]rtmp://192.168.3.64:1935/main/stream0|[f=flv]rtmp://192.168.3.64:1935/main/stream1"
However, it fails. What I am missing? The output I have from ffmpeg is:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bigbuckbunny_HD_60fps.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.29.104
Duration: 00:10:34.58, start: 0.000000, bitrate: 4279 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4141 kb/s, 60 fps, 60 tbr, 90k tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
handler_name : SoundHandler
[flv # 0x24607a0] Tag avc1 incompatible with output codec id '28' ([7][0][0][0])
[tee # 0x2365260] Slave '[f=flv]rtmp://192.168.3.64:1935/mainconcept/stream0': error writing header: Invalid data found when processing input
[tee # 0x2365260] Slave muxer #0 failed, aborting.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Last message repeated 1 times
According to ffmpeg -f tee refuses to do anything useful add -tag:v 7 (or -vtag 7, same thing):
ffmpeg -re -i bigbuckbunny_HD_60fps.mp4 -map 0 -c copy -tag:v 7 -f tee "[f=flv]rtmp://192.168.3.64:1935/main/stream0|[f=flv]rtmp://192.168.3.64:1935/main/stream1"
If you get error Tag mp4a incompatible with output codec id '86018' add -tag:a 10 / -atag 10:
ffmpeg -re -i bigbuckbunny_HD_60fps.mp4 -map 0 -c copy -tag:v 7 -tag:a 10 -f tee "[f=flv]rtmp://192.168.3.64:1935/main/stream0|[f=flv]rtmp://192.168.3.64:1935/main/stream1"
Related bug report is #6258: tee muxer fails on stream copy.

Create image with audio and concate to another video

Please help me understand! I spent a lot of time...:( Thank you!
I'm stuck with a problem. I have a stream with damaged video and normal audio. And 2nd video, continued, with normal video and audio. I want to attach a picture to the beginning of an undamaged video with normal audio from damaged video without re-encoding the normal video.
I try this one:
ffmpeg -hide_banner -loop 1 -framerate 50 -t 3478 -i image.jpg -t 3478 -i audio.mp3 -i video.mp4 -filter_complex "[0:0] [1:0] [2:0] [2:1] concat=n=2:v=1:a=1" output.mp4
But it converts normal video.
Mediainfo from normal video:
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.12.100
Duration: 00:56:31.61, start: 0.000000, bitrate: 3726 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 3594 kb/s, 27.46 fps, 50 tbr, 50k tbn, 100 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler

ffmpeg cannot concatenate m4a files with -c copy parameter

While using ffmpeg to concatenate similar m4a files:
ffmpeg -f concat -safe 0 -i <(for f in ./*.m4a; do echo "file '$PWD/$f'"; done) -c copy output.m4a
ffmpeg reports an error:
[ipod # 0x7f8db8014a00] Could not find tag for codec mjpeg in stream #0, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
The files used are: chapter1.m4a, chapter2.m4a. Their ffprobe have no differences other than the duration. Possible related output is:
Duration: 00:13:16.72, start: 0.000000, bitrate: 48 kb/s
Stream #0:0(eng): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 46 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 640x360 [SAR 100:100 DAR 16:9], 90k tbr, 90k tbn, 90k tbc
I just found out the error was due to the Stream #0, which is the cover art, and covers the actual audio track.
After removing the cover artworks in all files, I was able to concatenate them. And the speed is quite fast : speed=1.92e+03x.

ffmpeg http slower than downloading first

When trying to get a clip of a video from a remote source
Input source:
ffprobe version 3.3.2-static http://johnvansickle.com/ffmpeg/ Copyright (c) 2007-2017 the FFmpeg developers
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://website.com/video.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2017-07-13T15:44:58.000000Z
Duration: 00:57:32.42, start: 0.000000, bitrate: 1939 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 720x480 [SAR 10:11 DAR 15:11], 1745 kb/s, 29.97 fps, 29.97 tbr, 29970 tbn, 59.94 tbc (default)
Metadata:
creation_time : 2017-07-13T15:44:58.000000Z
handler_name : Mainconcept MP4 Video Media Handler
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2017-07-13T15:44:58.000000Z
handler_name : Mainconcept MP4 Sound Media Handler
Current command:
ffmpeg version 3.3.2-static
ffmpeg.linux -threads 2 -y -ss 3273 -i "http://website.com/video.mp4" -an -movflags +faststart -preset veryfast -codec copy /outputfolder/trimmed_video.mp4
This 5m35.102s to create a 45mb 2min file.
If I download the file using wget it takes 28s and using ffmpeg only takes 0.243s
If I add -vn OR -an to the output portion of the command it completes the trim in about 2.101s. Meaning it's faster to download the two stream and merge them myself.
Can anyone explain this behaviour and why my first command takes so long when on a lot of other video files it's very fast?
Videos where the command completed fast were optimized for streaming by youtube.
User uploaded media was not optimized.
Running ffmpeg with -movflags +faststart on the files fixed the issues server side.

Demux audio (AMR_WB) and video(H264) from mp4 file using ffmpeg

I want to demux audio (AMR_WB) and video(H264) from an mp4 file. I need to write a program which does this using ffmpeg libraries.
In demuxing.c file which is there in FFMPEG examples i was able to get only the raw formats as the output.
Can i somehow modify that code to get H264 and AMR_WB in encoded format from the mp4 file?
Run ffmpeg twice , each time specify that just 1 track be copy to output.
Example on diff mp4 will provide most of the idea which u will need to adapt to your specific track types for the respective video/audio in your container...
MP4 example : demux h264 and aac tracks to separate outputs (tout1, tout2 )
Whats in input?
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'phoneCam_20120902_112701.mp4':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: isom3gp4
creation_time : 2012-09-02 18:27:14
Duration: 00:00:12.65, start: 0.000000, bitrate: 8011 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1280x720, 7707 kb/s, SAR 65536:65536 DAR 16:9, 28.64 fps, 29.83 tbr, 90k tbn, 180k tbc
Metadata:
creation_time : 2012-09-02 18:27:14
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, s16, 96 kb/s
Pass 1, just get the Vid
ffmpeg -i phoneCam_20120902_112701.mp4 -map 0:0 -c copy tout1.mp4
Pass2 just get the aud
ffmpeg -i phoneCam_20120902_112701.mp4 -map 0:1 -c aac -ar 48000 -ab
48000 -strict -2 tout2.3gp
In your program, just run ffmpeg from the CLI or call main() in ffmpeg.c

Resources