locked
PrepareStreamTranscodeAsync Argument Exception RRS feed

  • Question

  • I am trying to transcode a a video file using PrepareStream and play it simultaneously but I am getting Argument Exception, the value does not fall within expected range for the line

    var preparedTranscodeResult = await mt.PrepareStreamTranscodeAsync(srcv,dstv,vmedia);

                MediaEncodingProfile vmedia=MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga);
                IReadOnlyList<Windows.Storage.StorageFile> resultsLibrary = await Windows.Storage.KnownFolders.VideosLibrary.GetFilesAsync();
                MediaElement m = new MediaElement();
                MediaTranscoder mt = new MediaTranscoder();
                m.Height = 300;
                m.Width = 300;
                dgrid.Children.Add(m);
                var srcv = await resultsLibrary[0].OpenAsync(Windows.Storage.FileAccessMode.Read);
                Windows.Storage.Streams.IRandomAccessStream dstv=null;
                var preparedTranscodeResult = await mt.PrepareStreamTranscodeAsync(srcv,dstv,vmedia);
                await preparedTranscodeResult.TranscodeAsync();
                m.SetSource(dstv, resultsLibrary[0].FileType);
                m.Play();
    Monday, October 7, 2013 1:40 AM

Answers

  • Hello,

    "dstv" needs to be a real instance. In the code above you set it to "null". You need to create an instance before passing it to the API. The API does not take an "out" parameter.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, October 8, 2013 12:11 AM
    Moderator

All replies

  • Hello,

    "dstv" needs to be a real instance. In the code above you set it to "null". You need to create an instance before passing it to the API. The API does not take an "out" parameter.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, October 8, 2013 12:11 AM
    Moderator
  • How can I create a instance of IRandomAccessStream? 

    Wednesday, October 9, 2013 12:45 PM
  • Try this pseudo code:

    file = createFileAsync

    IRandomAccessStream = file.OpenAsync

    -James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/



    Monday, October 21, 2013 11:53 PM
    Moderator