New to ffmpeg and playing around that to understand better. I'm trying to use ffmpeg code base to get TS packets from a HLS Streaming server. I don't need any decoding as I just have to store the TS packets to be processed later.
First I built a minimal FFMPEG as outlined in https://ffmpeg.zeranoe.com/forum/viewto ... f=5&t=7426. No decoders and only hls and mpegts demuxers. Then using the following code to receive the frames. While inspecting it doesn't seem to be MPEG-TS packets while looking into buffers thru GDB. Attaching the code here..
Two Questions:
1. Shouldn't the av_recv_frame get me the TS packets? However When I trace all the way to playlists (off HLSContext), the read_buffer there contains TS packets. IS there any example I could look into to get TS packets in this scenario without decoders?
2. If I get answer for (1), How to get the best stream off the HLS server? when looking into ffplay, av_find_best_stream() sounds like the one to look into.. But again without needing to decode, is there a way to get best one according to the network condition?
Thanks..
int main(int argc, char *argv[])
{
AVFormatContext * ifmt_ctx = NULL;
char *in_filename = NULL;
int ret = 0;
AVPacket pkt;
if (argc != 2)
{
return 1;
}
in_filename = argv[1];
av_register_all();
if (!(ifmt_ctx = avformat_alloc_context())) {
goto end;
}
if ((ret = avformat_open_input(&ifmt_ctx, in_filename, 0, 0)) < 0)
{
fprintf(stderr, "Could not open input file '%s'", in_filename);
goto end;
}
if ((ret = avformat_find_stream_info(ifmt_ctx, 0)) < 0)
{
fprintf(stderr, "Failed to retrieve input stream information");
goto end;
}
av_dump_format(ifmt_ctx, 0, in_filename, 0);
while (1)
{
ret = av_read_frame(ifmt_ctx, &pkt);
if (ret < 0)
break;
av_free_packet(&pkt);
}
end:
avformat_close_input(&ifmt_ctx);
return 0;
}
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 2 of 2
Thread
-
-
Got more info. What gets returned from av_recv_frame is either Audio/Video stream from the HLS server. Also its not given as TS packets.
So my question should have been how to get TS packets as is given an input url.
Similar Threads
-
Automatically get VideoID for HLS stream
By vikeyev in forum Video Streaming DownloadingReplies: 0Last Post: 27th Jun 2019, 21:23 -
Error in Download of Stream with ffmpeg HLS
By 4lb3rt0 in forum Video Streaming DownloadingReplies: 0Last Post: 25th Sep 2016, 09:11 -
Download protected stream (hls?)
By maicasajusta in forum Video Streaming DownloadingReplies: 3Last Post: 21st Jun 2016, 11:21 -
How to Capture Subtitles Associated with HLS Stream?
By dak1 in forum Video Streaming DownloadingReplies: 6Last Post: 21st May 2016, 23:35 -
Decoding raw binary with G729.1, any tools available ?
By shasi23 in forum AudioReplies: 2Last Post: 6th May 2015, 07:03