During building record graph to file from video and audio sources using Microsoft MPEG-2 Encoder at Windows 8 ICaptureGraphBuilder2::SetOutputFileName return failed 80040154 result - class not registred.
//Adding MPEG2 Encoder Muxer filter to the graph
hr = m_pCapGraphBuilder->SetOutputFileName(&CLSID_CMPEG2EncoderDS, szOutFileName, &pMPEG2EncoderMuxer, &pFileSinkFilter);
Also at graphedit any attempt to insert at graph MPEG-2 Encoder & MPEG-2 Video Encoder filter failed with description:
"The filter could not be created. Resourses used by this filter may alreadey be in use. (Return code: 0xc004f011) "
Why this happen and how to avoid this problem?
Will be happy for any suggestions
Are you sure your windows 8 has a MPEG-2 encoder? As I heard from MS, they removed MPEG-2 from Windows 8 and you must buy an encoder by yourself.
Related
I'm implementing an RTMP server right now, and everything's been working except for video streaming. I can stream audio with no problems (using OBS to stream), and play it back via VLC. The problem is VLC plays the audio, but no video. What I'm doing right now is forwarding every audio and video message I receive from OBS, I grab the original payload (audio/video data) and put in a Type 0 Chunk, since I've seen pretty much every implementation do this. I don't know if I'm missing some sort of processing that should be done on the video data.
If I try to playback with ffmpeg (saving the RTMP stream to an flv file), then I get this output:
[NULL # 000001eb053ed440] missing picture in access unit with size 5209
[AVBSFContext # 000001eb053ecbc0] No start code is found.
rtmp://192.168.1.2/app/publish: could not find codec parameters
Input #0, flv, from 'rtmp://192.168.1.2/app/publish':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Data: none
Stream #0:1: Video: h264, none, 1k tbn
Output #0, flv, to 'av.flv':
Output file #0 does not contain any stream
It says missing picture in access unit with size 5209, No start code is found, and could not find codec parameters. What am I missing here? I know I'm forwarding the payload exactly as I've received it in my server, I even did a hash check on the video payload I'm receiving and the one I'm sending and it's exactly the same. Any help would be greatly appreciated.
Fixed by following #szatmary's suggestion: resending the sequence headers to every playback client before sending any audio/video messages.
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?
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 am using libav to decode aac audio and then transcode it into mp3 using libmp3lame.
I know when I decode aac stream I get AV_SAMPLE_FMT_FLTP output and mp3 encoder needs the input in AV_SAMPLE_FMT_S16P.So I am doing a sample format conversion using swr_convert of libswresample. I know the no. of samples in the decode output is different (i.e. 1024) from the one required by libmp3lame (i.e. 1152) ? for that I am doing buffering as well.
But it is not crashing because of the buffering, it doesn't even come to that part, it crashes in swr_convert.
and if I see the stacktrace using gdb I see the crash happening somewhere in
ff_float_to_int16.next()
What could be the possible problem?
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.