I'm trying to add subtitles for a video. Both video file and subtitles files are downloaded on iphone (*in both vtt and srt format)
Example paths:
subtitle: file:///private/var/mobile/Containers/Data/Application/384B1E38-7536-4F52-A9E1-B7D8E5A1490B/Documents/1_665ba05feee690141b7_english.vtt*).
video file: file:///private/var/mobile/Containers/Data/Application/384B1E38-7536-4F52-A9E1-B7D8E5A1490B/Library/com.apple.UserManagedAssets.q1zdd9/1_665ba05f2b5aa225440dc840690141b7_4CD8B29737842BA5.movpkg
I have absolutely no idea how i should create or prepare those files to have a AVMediaSelectionGroup and be able to select a proper AVMediaCharacteristic on
Unfortunately most of tutorials contains only examples for hls streaming, but im not sure if it is valid for offline player.
How should i use AVAssetResourceLoaderDelegate or AVAssetResourceLoader and how should i create a single AVURLAsset with all subtitles?
Could you help me somehow and describe what should i do? I am aware that the question is imprecise, but in fact i do not know where should i start (describing a path - what i should do in steps would be appreciated).
Kind regards.
I'm trying to make an audio upload to S3 and I'm a little confused what I should declare my mime type as. My audio file is an m4a recorded on an iphone as kAudioFormatMPEG4AAC. Would this be considered audio/m4a or audio/mp4? I'm seeing conflicting answers online.
The m4 in m4a is short-hand for MPEG-4, just like mp4 is short-hand for MPEG-4.
In fact, m4a, m4v and mp4 files all have the same internal MPEG-4 atom structure. The difference between the files is their content (video files have video atoms as well as audio atoms.)
The codec of the audio can also be different despite using the same file extension, for example both alac and AAC formats use the MPEG-4 container format with the m4a file extension.
So to answer your question, it really doesn't make much difference. My personal preference would be audio/mp4 since that is effectively saying
Audio data in MPEG-4 container
Whereas, audio/m4a is like saying
Audio data in MPEG-4 container containing audio
Use audio/mp4. audio/m4a may work, but it's invalid.
MP4 MIME type registration:
2. Selection of MIME Types for MP4 Files
The MIME types to be assigned to MP4 files are selected according to
the contents. Basic guidelines for selecting MIME types are as
follows:
a) if the file contains neither visual nor audio presentations, but
only, for example, MPEG-J or MPEG-7, use application/mp4;
b) for all other files, including those that have MPEG-J, etc., in
addition to video or audio streams, video/mp4 should be used;
however:
c) for files with audio but no visual aspect, including those that
have MPEG-J, etc., in addition to audio streams, audio/mp4 may be
used.
In any case, these indicate files conforming to the "MP4"
specification, ISO/IEC 14496-1:2000, systems file format.
Further, the list of standard MIME types includes audio/mp4, not audio/m4a, and non-standard MIME types should include “x-”, like audio/x-m4a.
In 2021 for me audio/mp4 for an .m4a file worked on Firefox + Chrome (Linux), Opera (Android) but not on iPhone Safari. For some formats the OS plays a role due to codecs.
I used a source tag with type attribute set and I also set the same type in the Content-Type header of the streamed / downloaded file.
https://en.wikipedia.org/wiki/HTML5_audio#Supported_audio_coding_formats
https://developer.mozilla.org/en-US/docs/Web/Guide/Audio_and_video_delivery/Cross-browser_audio_basics
https://developer.mozilla.org/en-US/docs/Web/HTTP/Configuring_servers_for_Ogg_media
Also see: How to play .m4a with HTML5 audio in IE(9+) and Safari (Pad)?
I would like to ask you for help with HLS stream.
I would like to stream video in swift but problem is the format of downloaded file. I download m3u file from resource and there are links like:
http://192.168.2.100:8003/1:0:1:13F1:C87:3:EB0000:0:0:0:
Is it possible to play link like that or do I have to create an m3u8 file with link and then play it?
The stream is from enigma2 box.
Thank you and have a nice day.
The file name doesn't matter as long as the server returns the correct Content-Type http header.
Is there any way to set metadata like artist, title, genre etc. for an AAC file recorded with AVAudioRecorder?
For MP3 files there is the ID3 tag. However, I haven't been able to find an equivalent for AAC files. I have searched through the Apple Developer Docs without success but there must be some way to set those attributes because when playing an AAC file downloaded from iTunes in an audio player like VLC or foobar2000 it does recognize the metadata and even the album art.
(For recording the AAC files I use the code from Apple's Multimedia Programming Guide.)
I don't think you can add metadata to your audio file when using AVAudioRecorder. I think you will have to use an extra AVAssetExportSession pass to do that, like is done in this question
Now i am implementing a video playback on my site and for mobile devices i use HTML 5 video player:
<video src="/get_video.php/myfile.mov" controls width="400" height="250"></video>
In src attribute stored url to php file which output a contents of video file. MIME-type of file i don't know(it's dynamic) so i send content type header - application/octet-stream.
And my iPhone cant play this video: screenshot
So Question: How to force the player to play videos?
Thanks.
First of all, I recommend reading these resources on Video tags:
http://www.w3schools.com/tags/tag_video.asp
http://www.w3schools.com/tags/att_video_src.asp
https://developer.mozilla.org/en-US/docs/HTML/Element/video
As I understand, you have to specify in your MIME type a real video type (vs application/octet-stream). You mentioned that it's dynamic, however on the server side you know which file are you reading (so, you can figure out file format).
Supported types are:
video/mp4
video/webm
video/ogg