[FFmpeg-devel] [PATCH 3/5] lavd/avfoundation: Using the actual stream index instead of hardcoded value.

Thilo Borgmann thilo.borgmann at mail.de
Sun Apr 20 13:00:21 CEST 2014


-------------- next part --------------
>From fbb762a14e6bde4cf2a9fa59e5ec28c546007e32 Mon Sep 17 00:00:00 2001
From: Thilo Borgmann <thilo.borgmann at mail.de>
Date: Sun, 20 Apr 2014 11:42:05 +0200
Subject: [PATCH 3/5] lavd/avfoundation: Using the actual stream index instead
 of hardcoded value.

---
 libavdevice/avfoundation.m | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index cc3a07c..7f2f5b7 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -55,6 +55,7 @@ typedef struct
 
     int             list_devices;
     int             video_device_index;
+    int             video_stream_index;
 
     AVCaptureSession         *capture_session;
     AVCaptureVideoDataOutput *video_output;
@@ -205,6 +206,8 @@ static int get_video_config(AVFormatContext *s)
         return 1;
     }
 
+    ctx->video_stream_index = stream->index;
+
     avpriv_set_pts_info(stream, 64, 1, avf_time_base);
 
     CVImageBufferRef image_buffer = CMSampleBufferGetImageBuffer(ctx->current_frame);
@@ -333,7 +336,7 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt)
             pkt->pts = pkt->dts = av_rescale_q(av_gettime() - ctx->first_pts,
                                                AV_TIME_BASE_Q,
                                                avf_time_base_q);
-            pkt->stream_index  = 0;
+            pkt->stream_index  = ctx->video_stream_index;
             pkt->flags        |= AV_PKT_FLAG_KEY;
 
             CVPixelBufferLockBaseAddress(image_buffer, 0);
-- 
1.8.3.2



More information about the ffmpeg-devel mailing list