How can I send directshow's graphedit output to FFMPEG? - ffmpeg

I need to take an output from a directshow filter and use it as input to ffmpeg. Basically i will capture a video and compress it (x264 dshow filter, it needs to be hardware accelerated), and then mux it (TS) using ffmpeg. I couldn't find a TS muxer filter for ffmpeg, so i figured this would be the solution.
So, how would I send the output of graphedit to ffmpeg?

DirectShow filter output is a non-deterministic sequence of calls on its output pins. This cannot be sent to FFmpeg. Also, there is no such thing as output of graphedit. You should be starting with input options of FFmpeg, file and non-file, and then trying to find out if you can produce this output from DirectShow filter/graph or hosting application.

Related

Given a MPEG DASH .mpd URL, is that possible to down all media segments through youtube_dl?

I'm looking for a MPEG DASH downloader and youtube_dl just hit on me.
Given a .mpd URL, is that possible to use youtube_dl to download all media segments then?
To download all video and audio segments and mux them into a single file, call youtube-dl thus:
youtube-dl -f bestvideo+bestaudio http://URL/TO/manifest.mpd
The option -f <id1>[,<id2>]... is used to select which stream (or streams) of segments to save. The -f bestvideo+bestaudio in this example makes youtube-dl save only the best video and audio streams. See format selection syntax for details and more advanced format selectors. In order to discover the available streams, use youtube-dl -F http://URL/TO/manifest.mpd.
In order to mux (merge) video and audio streams into a single file, you must have FFmpeg or libav installed in your system. Otherwise, youtube-dl will produce a separate file for each stream (in my example, one for audio and one for video).
Without explicit format selection, the default is -f bestvideo+bestaudio/best. Youtube-dl will automatically select the best video and audio, and if there are no separate video-only or audio-only streams, the best stream that contains both video and audio is selected.
youtube-dl http://URL/TO/manifest.mpd
This default is used since version 2015.04.26. Before that (or if -o - is specified, making youtube-dl write output to stdout), the default was -f best, ignoring the video-only and audio-only streams. You may want to specify -f best explicitly when separate video and audio have worse quality than a stream that has both.

ffmpeg: Decoding specific AVProgram from the hls stream

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 cannot use AV_CODEC_ID_MPEG2TS in ffmpeg

I wanna use ffmpeg to convert yuv raw video file into ts stream video file.So I do this in my code:
avcodec_find_encoder(AV_CODEC_ID_MPEG2TS);
But when I run it ,it occurs that:
[NULL # 0x8832020] No codec provided to avcodec_open2()
I change the "AV_CODEC_ID_MPEG2TS" into "AV_CODEC_ID_MPEG2VIDEO", it works well ,and generate a mpg file running well too.So I wanna ask why I cannot use "AV_CODEC_ID_MPEG2TS"?
I'm also looking for streaming a file with ffmpeg so I'm not sure about that but it is what I understand....
Mpeg TS (Transport Stream) is not a codec, it is an encapsulation method, so you have to encode the stream with some code (I'm not sure if you can chose any codec) and then you can encapsulate it with mpeg ts before transmit over the network.
If you don't need to transmit the stream over the network maybe you don't need mpeg ts.
I hope this will helpful....!
Look here: ffmpeg doxygen

Save Live Video Stream To Local Storage

Problem:
I have to save live video streams data which come as an RTP packets from RTSP Server.
The data come in two formats : MPEG4 and h264.
I do not want to encode/decode input stream.
Just write to a file which is playable with proper codecs.
Any advice?
Best Wishes
History:
My Solutions and their problems:
Firt attempt: FFmpeg
I use FFmpeg libary to get audio and video rtp packets.
But in order to write packets i have to use av_write_frame :
which seems that decode /encode takes place.
Also, when i give output format as mp4 ( av_guess_format("mp4", NULL, NULL)
the output file is unplayable.
[ any way ffmpeg has bad doc. hard to find what is wrong]
Second attempth: DirectShow
Then i decide to use DirectShow. I found a RTSP Source Filter.
Then a Mux and File Writer.
Cretae Single graph:
RTSP Source --> MPEG MUX ---> File Writer
It worked but the problem is that the output file is not playable
if graph is not stoped. If something happens, graph crashed for example
the output file is not playable
Also i can able to write H264 data, but the video is completely unplayable.
The MP4 file format has an index that is required for correct playback, and the index can only be created once you've finished recording. So any solution using MP4 container files (and other indexed files) is going to suffer from the same problem. You need to stop the recording to finalise the file, or it will not be playable.
One solution that might help is to break the graph up into two parts, so that you can keep recording to a new file while stopping the current one. There's an example of this at www.gdcl.co.uk/gmfbridge.
If you try the GDCL MP4 multiplexor, and you are having problems with H264 streams, see the related question GDCL Mpeg-4 Multiplexor Problem

Convert to DV AVI Type-1 video

I'm working on a project that requires converting mpg,avi,wmv formats. A vendor requires the format to be in DV AVI Type 1. This is a format that Windows Movie Maker offers during capture off your camcorder.
I need this format for some vendor tools that assume that the user is capturing the data off the device, or that the import of an existing file is in this format.
I know of these 2 tools that do it, but I'm looking to incorporate a stand-alone library / command line interface so that I can wrap the encoding process in my own application.
http://paul.glagla.free.fr/dvdate_en.htm
http://www.stoik.com/products/video/STOIK-Video-Converter/
Last time I checked FFMPEG does NOT support this conversion... just the reverse from DV AVI1 to DV AVI2.
I've read through this resource, but don't know how this could be incorporated into ffmpeg
http://msdn.microsoft.com/en-us/library/dd388641(v=VS.85).aspx
Has anyone tried to convert from format X to DV AVI Type 1 ?
I'm a little unsure of the exact problem you're trying to solve. It sounds like you want to encode mpg,avi,wmv files into DV AVI type 1 and you want to use ffmpeg as part of the solution.
There are Microsoft DV Video Encoder and DV muxer DirectShow filters that will combine video and audio into the single video+audio DV stream needed for type 1 DV AVI.
http://msdn.microsoft.com/en-us/library/dd388645(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/dd388642(v=vs.85).aspx
I'm not very familiar with ffmpeg but I'm not sure why you need it for your particular problem. DirectShow can handle a wide variety of input formats. It seems from the FAQ that ffmpeg can get input from a DirectShow filter but not write data to a DirectShow filter.
It would be simplest to do the conversion with DirectShow alone without ffmpeg:
Create a DirectShow graph (CoCreateInstance getting IGraphBuilder).
Create a source filter from your input file (IGraphBuilder::AddSourceFilter)
Create a DV encoder filter (CoCreateInstance)
Add the DV encoder filter to the graph (IFilterGraph::AddFilter)
Connect the video source pin to the dv encoder (IGraphBuilder::Connect)
Then similarly:
Connect a new dv muxer to the output
of the dv video encoder and the audio
ouput from the source filter (you may
need an intermediate filter to
compress the audio into the right
format).
Connect the output of the dv
muxer to a new avi mux filter.
Connect the output of the avi mux to
a new file writer filter set up with
your destination file.
Run the graph using IMediaControl and IMediaEvents to convert your input file to your output file.
If I've misunderstood your question then you should be able to construct a different graph that will convert to or from DV AVI type 1 or 2. For writing type 2 you wouldn't need to use the dv muxer.
All of this can be easily tested in advance using GraphEdit or similar tools before writing any code. GraphEdit is available with the Windows SDK. GraphStudio is one open source alternative but there are others too. For development purposes you could also construct a graph in GraphEdit or similar and then load it and run it in your own test application (see http://msdn.microsoft.com/en-us/library/dd390649(v=vs.85).aspx)
For some basic getting started information see:
- The Wikipedia page on DirectShow
- How can I learn a DirectShow programming?
- Where can I find a thorough DirectShow tutorial?

Resources