iPhone App Dev - Edited mp3 files are not working in App - audio

In my application there are mp3 files located in the bundle (nothing from the web). Some of the mp3 files are original files and some I had edited using simple sound editing software (the ones where you insert a file, cut a slice of it and save it as a new and shorter mp3 file).
I'm using the AVAudioPlayer [initWithData] method.
All the original files (the ones that I hadn't edited and inserted to the bundle as is) are working perfectly and all the ones that were edited are not working at all.
I used 2 different editing software and the outcome is the same.
Anyone had ever encountered that or have any idea what may I done wrong?
Thanks,
Ohad

Converting the mp3 to caf worked for me
as specified here.
see the following:
How do I convert an audio file to the preferred format for iPhone OS?
The preferred full-quality audio format for iPhone OS is 16-bit, little-endian, linear PCM packaged as a CAF file. To convert an audio file to this format, use the afconvert tool at the command line in Mac OS X, as shown in Listing 5.
Listing 5 Converting an audio file to the preferred format for iPhone OS
/usr/bin/afconvert -f caff -d LEI16 {INPUT} {OUTPUT}
To see all the options available for the afconvert tool, enter afconvert -h at the command line.

Related

How to embed an MP4 inside a PDF?

I am a happy user of img2pdf. This tool does the minimal amount of work to put a series of JPEG 2000/JPEG/PNG images into a PDF "enveloppe". However I am now faced with a new challenge: embed a MP4 file into a PDF "enveloppe".
I see that commercial tool can do it, as seen at:
Add audio, video, and interactive objects to PDFs
Here is one such sample PDF file (no Flash required on windows in this sample):
https://gitlab.com/agrahn/media9/-/issues/9#note_345903962
https://gitlab.com/agrahn/media9/uploads/90fddd777e0ec514c39c924cd8d3b688/video_test.pdf
It seems to have been introduced in ISO 32000-1 (PDF 1.7 Extension Level 5)
I am looking for a solution which will use the Rich Media annotation inside the PDF stream.
There are dozen of duplicated questions on superuser/stackoverflow, which all pretty much refer to imagemagick/convert command line tool. But in my case, convert expand the images into a multi-page PDF (which is not my desired behavior):
$ convert input.mp4 output.pdf
$ pdfinfo output.pdf
Title: out
Producer: https://imagemagick.org
CreationDate: Wed Aug 19 15:38:01 2020 CEST
ModDate: Wed Aug 19 15:38:01 2020 CEST
Tagged: no
UserProperties: no
Suspects: no
Form: none
JavaScript: no
Pages: 1601
Encrypted: no
Page size: 352 x 288 pts
Page rot: 0
File size: 534407296 bytes
Optimized: no
PDF version: 1.3
with:
$ convert --version
Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib
and
$ file input.mp4
input.mp4: ISO Media, MP4 Base Media v1 [IS0 14496-12:2003]
$ ffprobe -v quiet -print_format json -show_streams input.mp4 | grep codec_long_name
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
How would you embed an MP4 inside a PDF now that Flash support is being removed from Acrobat (Dec 2020) ? The solution should be on the command line (linux based system).
It was common and still possible to use Rich Media Annotation to include 3D animations or Media files within a PDF. Generally you need top end editors such as Acrobat PRO but there are a few LaTeX editor modules that some times work, thus can be PDFLaTeX compiled from Linux command line. for outdated example app see http://www.acrotex.net/blog/?cat=22 for an overflow example see https://www.overleaf.com/project/5ff76fa5686edd3e034cfedb and for prior adobe reply (but did not work for a while) see
> Embedded media, as well as referenced media outside a PDF file, may be played with a variety of player software. (In some situations, the player software may be the conforming reader itself.)
[Later comments] Adobe shot selves in foot with the poor closure of their buggy insecure SWFlash and only improved some rich media handling in more recent Windows Reader versions Acrobat DC - 21.001.20135 plus ! having turned their back on maintaining Portable Document Format Readers for Linux/Mac. What is needed is a push to use HTMLZ as ideal Rich Media Format but that would need Google Chrome to run with the bouton (pun).
Its NOT recommended except for 3D PDF as most methods require manual over-ridding security measures to STOP runtime applications within a PDF.
SWF/Flash is no longer acceptable for that reason. MicroSoft Edge (pre-chrome) made an attempt at imbedding pdf links to You Tube videos but AFAIK that was abandoned. Thus RMA pdfs can not run in more common browsers they need specialist viewers and the best viewer for Linux is possibly Okular but I cannot run that file in my version.
When opening a 3D file you need to jump through multiple hoops to allow and for floating video it may not even run. your links lead to this media example which can run inline (seen above) or better pop out with system application controls.
However in some viewers it needs to be manually exported from the pdf archive as an attachment to be run in a system media player. and for browser presentations it can be a local hyperlink like this.
Using Okular on windows it does not ask prior to running content but that could be because it found no suitable player, however it allows me to link to a local file and run that in system viewer.
For everyday presentations its easier to include the media file in a zip with the pdf or PowerPoint presentation for running locally from the pdf.
[Updated PoC for building using alternative raw mp4's]
It is possible to write a complex PDF in text on the console (Here is a 203 line example in Windows CMD), Typical output I would not normally suggest that as an answer to a highly complex structure such as Rich Media, but a simpler all platforms approach is possible with a small nip and tuck of header & trailer, plus variable mp4 body.
Source modified example spliced as 3 parts https://transfer.sh/8kQIbB/all.pdf
Different body with a small amount of command line math https://transfer.sh/Uqmv6t/all2.pdf
Method
Store the text header as a pre-set template then append the mp4 without changes finally add the PDF trailer with modified values from file lengths. too long to describe its now 216 lines (with comments and notes) and working well for PDFs in xChange as a drag and drop any 1-9 MB.mp4 (need to up that math value to 1999 MB) or send file to or CLI command for single files, but the programming can be done simply as I did using CMD or OS script and the result generated in windows with roughly scripting around
copy /b head2.bin + pixels.mp4 + tail2.bin all2.pdf /b
the secondary part is how to use text to overlay a cover image in as few lines as possible
So that is now scripted to add variable length of any video.mp4 so I simply run or drag and drop per consol and a dialog can show progress and show feedback and get inputs such as names or dimensions via mp4toPDF video.mp4 [output.pdf] so next step is user to add the caption (perhaps other scalars) as variable argument(s).
The number of PDF viewers supporting Rich Media is dwindling, I can't use Acrobat nor Edge either, so it seems I need to use Tracker (below) which is much more versatile and has many other advantages, but is Windows only.
or Cross platform Foxit. However, on Windows Foxit is way inferior with no resize or search bar or other floating controls.
So currently I can add via script and run in either edit viewer a mp4 or wmv or other video under 2GB but the field (locked aspect in Foxit) has no cover (plain white) however if I move an image over the top it seems to block out action but under white its unseen so need to resolve that transparency issue, have settled on stamp bigger white area to keep the run button visible. but having some issues with auto stamping its affecting run button even when the two are not overlapping
Breaking news, OMG, no idea which way this will help any one, other than the "Revenue Men"
Microsoft Edge’s new PDF viewer is powered by Adobe, and it won’t let you forget that. In an announcement on its website, Microsoft says it’s replacing Edge’s existing PDF viewer with one from Adobe Acrobat, which includes some “advanced” features that are available if you’re willing to pay for them.
Video controls support are disabled in Adobe Acrobat, and is not supported by web browsers. Although you want ta add video with video controls, you can use Adobe Actrobat DC Pro, and you can automatize it using Action wizard.
Check this out https://helpx.adobe.com/acrobat/using/action-wizard-acrobat-pro.html
You can make a python script to embed your video.
Thanks to pyPdf2 api, you can use the addAttachment method to embed your video.
https://github.com/mstamy2/PyPDF2

Is there an ActionScript library for MP3 encoding than Shine-MP3-Encoder?

Is there an ActionScript library for MP3 encoding than Shine-MP3-Encoder? (https://github.com/kikko/Shine-MP3-Encoder-on-AS3-Alchemy)
This library works fine, but I wanted to find a similar solution (on ActionScript, not C) to optimize it for specific needs.
Thanks.
Dont wait for it. A pure AS3 library is impossible as the speed of AS3 is too slow to do MP3 encoding. You will need C++ via AIR Native Extensions (ANE) or Alchemy for this. ANEs work with Adobe AIR so you can publish your content as an app for desktop and mobile. I dont see any issue with it.
See these for ANE-based Mic recording:
ANE-RecordAudio
AirMicrophone
AirMicrophone-ANE
I recorded the mic into a WAV and then use ffmpeg -i d:/path/input.wav d:/path/output.mp3 to convert it instantly into an MP3. I delete the WAV when FFMPEG completes. FFMPEG is a cool little EXE you can just add to your project in any dir. I used Thibault's class to record into WAV.

Stripping Audio From Vob Files through command prompt

What we need to do is either, extract the audio from a group or singular Vob video file and convert it to a .Wav format. Now the process of actually extracting the audio and converting it can be done from a third party application however this application has to be activated from a batch or c# script. The media we are retrieving the vob files from always comes from the CD drive and will always be placed in the same folder location once the conversion is complete.
In shot I need a program or script that can be activated remotely to extract and convert vob files to .WAV.
Any help will be greatly appreciated.
I only install ffmpeg on Windows and put in cmd this command:
ffmpeg -i [VOB_file_route].VOB [WAV_file_output_route].wav
And that's all, just works.
To do somthing like this you will need to use VLC and cmd they work togeather well and will allow you to strip video and audio from a file easily

Render swf to png or other image format

How can I, on linux, render a swf to a image file?
I need to be able to load other swfs into that swf and run actionscript code.
Is it even possible on linux? I need to do it from PHP, it's fine if I have to use command-line tools.
swfrender from swftools works for basic SWF files.
swfdec-thumbnailer from swfdec-gnome works though it only gets the first frame of the swf.
To get any frame from swf using swfdec see the C code snippet in the following mailing list post.
gnash from gnash also works gnash -s<scale-image-factor> --screenshot last --screenshot-file output.png -1 -r1 input.swf, last image of the swf.
ffmpeg from ffmpeg also works for some swf formats ffmpeg -i movie.swf -f image2 -vcodec png movie%d.png
Also see the following guide for a commandline pipeline.
In order to call external programs from php you use the exec command documented here.
Note that for security reasons it is important to escape arguments passed to exec with another command like escapeshellcmd or escapeshellarg for security reasons.
Once you have converted to an image format whether for single frame or all frame, you can't run action script. Other non GNU / Linux tools support the export of the action script from from SWF.
If the SWF that you are exporting to PNG is too complicated for the other tools than you can use the Flash Plugin or Gnash and Xvfb along with screen capture software to capture either image frames of the SWF or a video format like avi. Then you can extract the images from the video format.
This virtual framebuffer method will support complicated SWF files, though it requires a lot of work as you need to use either Gnash and Xvfb and Screen Capture, or a browser , Xvfb and Selenium, if you want to capture a certain set of mouse / keyboard interactions with the SWF.
Gnash with and without the Virtual FrameBuffer should load the ActionScript before exporting, but may have issues with complicated ActionScript. Flash Plugin with Virtual Framebuffer will load the ActionScript before exporting.
Also see the following StackOverFlow questions, which you question is a duplicate of
Convert SWF to PNG
Render Flash (SWF) frame as image (PDF,PNG,JPG)
SWF to image (jpg, png, …) with PHP
This is the solution I ended up using.
You can use a tool like Xvfb (X11 server) and run the standalone flash player projector inside it (you may need to install a bunch of 32-bit libraries), then use a screen capture utility like import to capture the screen and crop it to size.
I found this page on rendering swf screenshots in linux helpful. It also says that you can use gnash to do this, however gnash won't work for flash player 9+.
Try this air application http://swfrenderer.kurst.co.uk
It render swf frame by frame

Creating customized .dmg files upon download

I want to distribute a cross-platform application for which the executable file is slightly different, depending on the user who downloaded it. This is done by having a placeholder string somewhere in the executable that is replaced with something user-specific upon download.
The webserver that has to do these string replacements is a Linux machine. For Windows, the executable is not compressed in the installer .exe, so the string replacement is easy.
For uncompressed Mac OS X .dmg files, this is also easy. However, .dmg files that are compressed with either gzip or bzip2 are not so easy. For example, in the latter case, the compressed .dmg is not one big bzip2-compressed disk image, but instead consists of a few different bzip2-compressed parts (with different block sizes) and a plist suffix. Also, decompressing and recompressing the different parts with bzip2 does not result in the original data, so I'm guessing Apple uses some different parameters to bzip2 than the command-line tool.
Is there a way to generate a compressed .dmg from an uncompressed one on Linux (which does not have hdiutil)? Or maybe another suggestion for creating customized applications without pregenerating them? It should work without any input by the user.
I realize that I'm a bit too late here, but we wanted to do exactly the same thing and got it to work using libdmg. https://github.com/planetbeing/libdmg-hfsplus
Basically, you can use libdmg to unpack a dmg file to an uncompressed file containing a hfs+ file system, play around with the files inside the hfs+ file system, and them put it back together again as a dmg file with the correct checksums.
If you use any fancy dmg features, like showing an EULA before the image is mounted, then these will not survive the process. Background images and so on work, though.
If your web server and client support the gzip encoding, then you can deal with uncompressed files on the server, but have them compressed / decompressed on the fly by the web server / web client respectively.
e.g. apache's mod_gzip.
Otherwise maybe you can split your dmg into 3 parts:
the stuff before what you want to replace
the string you want to replace
the stuff after what you want to replace
If the gzip stream is splittable at those points, you could just concatenate the front and back onto the gzipped string you want to replace. That would let you generate it on the fly.
Release a normal, read-only, compressed dmg. Then bundle your app in a package installer with a pre-flight script that sets the variables you need.

Resources