AVAssetExportSession missing audio track when exporting on device - iphone

I run the export on the simulator and everything works great. I run it on the device and the video gets exported but there's no audio. This leads me to believe that I must be using an audio format that the device doesn't support but OS X does, as the simulator uses what OS X uses. I've tried m4a, aiff, and aifc and have had no luck! Any ideas??

I have a very similar problem. It does not seem to do with codecs, as I made a separate test case that runs fine with the same video. There’s a related question that says the problem might be in playing the same assets using MPMoviePlayerController. That got me on the right track (sort of).
In my case the trouble stem from using the assets in an AVPlayer during the export. I was not able to find the exact combination that causes the export to drop the audio track – in the separate test project the export runs fine even though the asset plays in AVPlayer at the same time. After several hours of trying to find the exact cause I gave up and simply popped the asset out of the player using replaceCurrentItemWithPlayerItem:nil during export. It’s a hack, but it works.
AVFoundation is a very powerful framework, but God I wish it wasn’t so finicky or at least logged more errors instead of silently producing garbage.

Related

Swift playing sound doesn't seem to work on my app

Iv'e tried using the SwiftySound lib
but from some reason it didn't work, Iv'e also tried to play a sound using the AVFoundation but it doesn't seems to work neither (it's wether I get a nil on the url or it's simply doesn't work). the device is not muted and the speakers works fine, does anyone know what it might be?
Make sure you are adding your sound files to your project and also to your application target. It may be the case that, AVfoundation or SwiftySound not able to find your sound file. Also check out example project of SwiftySound.
pod try SwiftySound
Also check out other similar questions:- iOS Sound not playing in Swift

How to Play High Quality Video in Unity

I'm using MovieTexture now, but when a video file is added to unity Project, it will automatically be imported and converted to Ogg Theora format. and the quality is really bad.
I have tried changing the quality setting and even on the highest setting the video is still pretty bad quality, I have tried it in multiple file formats like .mov, .avi. .mpeg4 etc. I have even tried converting it to .ogv to try and get around unity converting it itself, and still the quality is poor. The platform is PC, and in the build the quality is the same as in the editor.
so the question is ,how to play high quality video in unity no matter using MovieTexture or anything else like some plugins?
Unity player on Windows only supports OGG, which is why Unity is transcoding your videos.
I have use the Renderheads AVPRo Quicktime plugin on Windows to play very high quality videos in kiosk setups. (They also have one for Windows Media format, but I used Quicktime).
Link: Renderheads AVPro (Quicktime)
I am not affiliated with them in any way, just a very happy customer, and here is the review I posted on the Unity Asset store:
Great work on your plugin! I've used so many plugins that don't work well over multiple platforms, or require switching between platforms, or manual steps, or manual licensing, or DLL hell, etc. I have to say you nailed it.
I develop on a Mac (and your plugin runs in the Unity Editor), then deploying on Windows. It all worked well straight forward and as documented. Even the events to detect when a video has loaded and is ready to play just what I needed (as we are loading a large video file).
Additionally, the error messages are very precise and pin-point a problem (missing file, bad format, etc) which means less time debugging.

HLS H264/AAC stream functions perfectly except on OS X and iOS?

We are developing an open-source streaming server and are running into some trouble with our implementation of HLS.
We've been able to successfully convert to TS and segment into HLS segments any stream we want to, and it plays back beautifully on most every player... except for the Apple players (iPad, iPhone, Safari, Quicktime). On those, the H264 encoding settings need to be picked very carefully, and even when sticking to Baseline/3.0 some visible glitching can be seen.
The AAC audio, no matter how we encode it (both ffmpeg's aac and the libfkd_aac encoders were tried in nearly all possible configurations) sounds choppy as well. (Again, all these versions play back just fine on non-Apple players.) Changing the encoding settings does yield better results sometimes, but we've not been able to find any combination that will work for every video we've been testing with.
This leads us to conclude that perhaps the Apple-based players require something in the TS stream itself that we're not doing correctly. Is there anything that could cause this kind of behavior? For reference, an HLS teststream outputted by our packager/segmenter can be found here: link
We appreciate any feedback!

Beat Detektion: Detecting audio from app and produce a wave or bar for that audio... Just like Winamp or Windows Media Player

I am trying to understand the concept of Beat Detektion and I found that it works on the basis of detecting sound through Microphone. So, my first question is will it not be a disadvantage if i am detecting sound from Microphone? Because when we are using the device it happens that other sound from environment is also there so the actual beat will not produce for sound.
My second question (actually where i got stuck) I found that this Beat Detektion is not able to access iPod Library. Will i be able to play beats if i fetch the song from ipod Library in my app and then i use with beat detektion.
http://www.cubicproductions.com/index.php?option=com_content&view=article&id=67&Itemid=82
http://www.gearslutz.com/board/product-alerts-older-than-2-months/457617-beatdetektor-iphone-app-open-source-algorithm-bpm-detection.html
I will be very thankful if any reference/link other then above provided to understand Beat Detektion more...
Edit 1
I have got the code for the above from this link But this code is in C++ and there it is written that we have to convert the code to XCODE project using CMAKE software. I am somehow able to convert the code to xcode project but then i am only having cpp files then how should i run the program in iphone???
ok I am somehow able to solve my problem with the Apple's sample code : AurioTouch
I have implemented song in that example and produced the beats of the song on the basis of the beats.. In Iphone we can access sound beat using mic only. So aurioTouch uses same for beat detection

Sound Not Playing In iOS - Not A Source Code Problem

I want to play a sound in my application. Nothing special, just a little WAV file. The file exists in the device in my main bundle, and I've got both the AVFoundation and AudioToolbox frameworks added. I have alternately tried using both of them, testing out every bit of sample code on the net for playing this sound. It won't work. So what else could be wrong, given that the file exists and the code snippet probably isn't the problem?
Is it to do with imports? I import the necessary .h files for the frameworks at the top of the file.
I've noticed that one of the methods requires there to be a delegate that implements a particular protocol. Is this necessary? Some examples require it, others don't. What do I need to implement for this?
This fails to play the sound both on the device and the simulator. HAve I overlooked antyhing else?
Is it to do with imports?
No. Problems with imports will be apparent at build time.
I've noticed that one of the methods
requires there to be a delegate that
implements a particular protocol. Is
this necessary?
No. The AVAudioPlayer delegate is optional.
This fails to play the sound both on
the device and the simulator. HAve I
overlooked antyhing else?
The most likely explanation is that the file is not being properly referenced. Alternatively, the file may be in a non-standard format for and the player chokes on it silently. Try testing with another file type.
In my case today, an mp3 worked fine on the Simulator (and in iTunes and everywhere else I tested it), but not on a device. I converted the mp3 to an aif and IT worked fine on the device.
I know this is more worthy of a comment than an answer, but I lack the rep to comment.