The current input stream is hls and output is lowered multi-bitrate hls streams. The incoming hls stream has a secondary stream which is switched when the primary stream is unavailable. Currently, the secondary stream's audio codec is mp2a whilst the primary is aac. When this switch occurs, I'm losing the audio on the output streams. Is there a way to compensate for this switch?
Related
The issue: I need to convert an h.264 stream streamed over RTP into MJPEG, but for very convoluted reasons I am required to use the libjpeg-turbo library, not the mjpeg encoder that comes with ffmpeg. So the only thing FFMPEG needs to do is convert the h.264 RTP stream to rawvideo in RGBA and output to a socket where I then manually do the transcoding.
However, libjpeg-turbo only expects complete frames, meaning I need to collect rawvideo packet fragments and somehow synchronize them. Putting incoming raw video fragments into a buffer as they come results in heavily broken images.
Is there some way of saving the header information of the initial h.264 RTP packets? The command I'm currently using is very straightforward:
-i rtsp://: -vcodec rawvideo -f rawvideo udp://:
Here's how I stream MPEG-TS to a relay using ffmpeg:
ffmpeg -re -i out.ts -f mpegts -vcodec copy -acodec copy http://localhost:8081/secret
My question is in the internals of ffmpeg, I want to understand the core process as to how ffmpeg stream mpegts, what it does to the file to stream it, does it manipulate the byte it streams or it just stream as-is?
In this case, the transport stream is parsed, the audio and video elementary streams are read and depacketized. They are then repacketized, and remuxed into a new transport stream, then sent over http.
If you changed containers, the elementary streams may be converted to slightly different format depending on the codec and container global headers before being remuxed.
And if you transcoded the elementary stream would have been converted to raw pixels, and PCM, the reencoded back to a new elementary stream.
I'm using libffmpeg to decode an RTSP video stream and write it to a file.
The time_base reported by the codec when I open the stream is 1 / 180000. When I create my output AVStream, I'm copying this time_base over to the output. It works, but I get this message when I call avformat_write_header:
"WARNING codec timebase is very high. If duration is too long,file may not be playable by quicktime. Specify a shorter timebase"
I tried specifying a shorter timebase (say, 1/30) but when I do this, the video plays back at the wrong speed.
What's the right way to adjust the time_base on my output stream without modifying the playback time?
Thanks.
I am developing a player based on ffmpeg.
Now I try to decode hls video. The video stream has several programs (AVProgram) separated by quality. I want to select one specific program with desired quality. But ffmpeg reads packets from all programs (all streams).
How can I tell ffmpeg which streams to read?
Solved by using disard field in AVStream structure:
_stream->discard = AVDISCARD_ALL;
I create a simple direct show source filter using FFmpeg.I read rtp packets from RTSP source and give them to decoder. It works for h264 stream.
MyRtspSourceFilter[H264 Stream] ---> h264 Decoder --> Video Renderer
The bad news is that it does not work for MPEG-4. I can able to connect my rtsp source filter with MPEG-Decoder. I got no exception but video renderer does not show anything. Actually just show one frame then nothing [just stop]... Decoders and Renderers are 3rd party so i can not debug them.
MyRtspSourceFilter[MP4 Stream] ---> MPEG-4 Decoder --> Video Renderer
I can able to get rtp packets from MPEG-4 RTSP Source using FFmpeg sucessfully.There is no problem with it.
It seems that i have not set something(?) in my Rtsps Source
Filter which is not necessary for H264 stream but may be important for
MPEG-4 stream
What may cause this h264 stream and MPEG-4 stream difference in a direct show rtsp source filter? Any ideas.
More Info:
-- First i try some other rtsp source filters for MPEG-4 Stream...Although my rtsp source is same i see different subtypes in their pin connections.
-- Secondly i realy get suspicious if the source is really MPEG-4 SO i check with FFmpeg...FFmpeg gives the source codec id as "CODEC_ID_MPEG4".
Update:
[ Hack ]
I just set m_bmpInfo.biCompression = DWORD('xvid') it just worked fine...But it is static. How to dynamically get/determine this value using ffmpeg or other ways...
I am on the RTSP-server side, different use case with required by-frame conversions
MP4 file ---> MPEG-4 Decoder --> H264 Encoder --> RTSP Stream
Will deploy libav, which is kernel of ffmpeg.
EDIT:
With H264 encoded video layer, the video just needs to be remuxed from
length-prefixed file format "AVCC" to byte stream format according to some "Annex B" of the MPEG-4 specification. libav provides required bit-stream filter "h264_mp4toannexb"
MP4 file ---> h264_mp4toannexb_bsf --> RTSP Stream
Now, for decoding RTSP:
Video and Audio come in separate channels. Parsing and decoding the H264 stream is done here: my basic h264 decoder using libav
Audio is a different thing:
RTP Transport suggests, that AAC frames are encapsulated in ADTS, where RTSP players like VLC expect plane AAC and accordingly available RTSP server implementations AACSource::HandleFrame() pinch the ADTS header off.
Another different thing is "time stamps and RTP":
VLC does not support compensation of time offsets between audio and video. Nearly every RTSP producer or consumer has constraints or non-documented assumptions for a time offset; you might consider an additional delay pipe to compensate the offset of an RTSP source.