I’m converting an app from using Quicktime to use AV Foundation. I’m testing 
the code that is in the "make video from images” demo. The demo runs but the 
same code in my app always breaks at “.startWriting.” Here’s the code:

-----------------------------------------------------------------------------------------------
m_AVFoundation = new MyAVFoundationMBS
                                
dim pic as new Picture(m_FrameWidth, m_FrameHeight, 32)
m_AV_buffer_mbs = new CVPixelBufferMBS(pic)
                                
dim e as NSErrorMBS
m_AV_videoWriter_mbs = new AVAssetWriterMBS(m_AV_DestFile, 
m_AVFoundation.AVFileTypeMPEG4, e)
                                
if m_AV_videoWriter_mbs = nil then
                MsgBox "Failed to create video writer!"
                break
                return
end if
                                
dim videosettings as new Dictionary
videosettings.Value(m_AVFoundation.AVVideoCodecKey) = 
m_AVFoundation.AVVideoCodecH264
                                
videosettings.Value(m_AVFoundation.AVVideoWidthKey) = m_FrameWidth
videosettings.Value(m_AVFoundation.AVVideoHeightKey) = m_FrameHeight
                                
'MsgBox "m_FrameSize = " + str(m_FrameWidth) + " x " + str(m_FrameHeight)
                                
m_AV_videoWriterInput_mbs = 
AVAssetWriterInputMBS.assetWriterInputWithMediaType(m_AVFoundation.AVMediaTypeVideo,
 videosettings)
                                
if m_AV_videoWriterInput_mbs = nil then
                MsgBox "Failed to create video writer input!"
                break
                return
end if
                                
dim options as new Dictionary
options.Value(CVPixelBufferMBS.kCVPixelBufferWidthKey) = m_AV_buffer_mbs.Width
options.Value(CVPixelBufferMBS.kCVPixelBufferHeightKey) = m_AV_buffer_mbs.Height
options.Value(CVPixelBufferMBS.kCVPixelBufferPixelFormatTypeKey) = 
m_AV_buffer_mbs.kCVPixelFormatType_32ARGB
                                
m_AV_Adaptor = 
AVAssetWriterInputPixelBufferAdaptorMBS.assetWriterInputPixelBufferAdaptorWithAssetWriterInput(m_AV_videoWriterInput_mbs,
 options)
                                
if m_AV_Adaptor = nil then
        MsgBox "Failed to create adaptor!"
end if
                                
if not m_AV_videoWriter_mbs.canAddInput(m_AV_videoWriterInput_mbs) then
        MsgBox "Can't add input!"
        break
        return
end if
                                
m_AV_videoWriterInput_mbs.expectsMediaDataInRealTime = true
                                
m_AV_videoWriter_mbs.addInput m_AV_videoWriterInput_mbs
                                
/**********************************************************************
/ This is where it breaks. What should I be looking for
/ that would cause it to fail to write. As far as I can see the setup proceeding
/ this check is identical to the demo.
/**********************************************************************

if not m_AV_videoWriter_mbs.startWriting then
        MsgBox "Failed to start writing!"
        break
        return
end if
-------------------------------------------------------------------------------------------

Best Regards,

Ola Olsson
[email protected]

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
[email protected]
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Reply via email to