How to convert .mp4 file to .webm using avconv tool - avconv

I have .mp4 file and I want to convert it to .webm with the same quality by avconv tool,
and vice from .webm to . mp4 with the same quality
document fuzzy to me.

That's not possible. WebM cannot contain MPEG media (video or audio.) So you can't repack ("remux") the media from mp4 to webm. You would need to re-encode them ("transcode" them), with VP8 or VP9 as the video format and Vorbis as the audio format. Thus you can't have the same quality, since transcoding from one lossy format to another always loses some quality.
So your only option is to transcode.

Related

Speech Recongnition Using OpenVINO

I want to implement a python project in which the input will be a .mp4 file and the output will be the transcript or subtitle of the video. The constraint is to use OpenVINO. How can I do that?
mp4 is a container. I believe the current OpenVINO speech demo/samples use wav files as that is what the model is trained for.
If you can convert your mp3 or audio from the mp4 container using a tool to convert it to the wav format, that may work.
speech rec demo

.m4a is considered audio/m4a or audio/mp4

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)?

Encode iOS compatible h264 audio stream with FFMPEG

I am using FFMPEG with Python to encode a low bit rate version of videos that I import. I would like the output to be playable on several devices, including Roku and iOS. This link states that Apple supports H264 High profile, level 4.1 and MP3 audio.
ffmpeg -preset veryslow -y -profile:v high -level 4.0 -movflags +faststart -codec:a libmp3lame -qscale:a 2 -s 1280x720 out.mp4
The resulting videos play fine in an HTML5 browser on a computer. However, on the iPhone the video appears but the audio stream does not play. Is there an issue with the mp3 settings?
From ffprobe:
[STREAM]
index=1
codec_name=mp3
codec_long_name=MP3 (MPEG audio layer 3)
profile=unknown
codec_type=audio
codec_time_base=1/44100
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=s16p
sample_rate=44100
channels=1
channel_layout=mono
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/44100
start_pts=-1105
start_time=-0.025057
duration_ts=2321489
duration=52.641474
bit_rate=94949
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=2016
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=und
TAG:handler_name=SoundHandler
[/STREAM]
I tried using AAC, but did not get good results with the native FFMPEG encoder
The document you reference is for HTTP Live Streaming, which uses a transport stream format, not an ISO mp4 format. Either way I have found many issues with mp3+video in ios. My recommendation is to use AAC (-acodec fdk-aac) instead of mp3. It is just as universally supported, and will provide you with better audio at lower bitrates. If that is not an option, try to specify all audio settings on the command line (-channles -samplerate, etc)

Do I need to convert audio files to .wav first before converting to .caf?

I have several audio files which all of them are in .mp3 format. But playing .mp3 won't maximize the efficiency of audio playing on iOS. From one of research, .wav or .caf is a go for short loop or sound effect audio file used in game. Thus I need to convert this .mp3 file into those two formats.
Currently I use the following command to convert .mp3 to .caf.
afconvert -f caff -d LEI16 kick_sfx.mp3
However, I see that .caf is a container format thus I have a bad feeling that it's still not so efficient. According to that, I think I need to convert those .mp3 files to .wav first in order to maximize efficiency in playing audio file.
Do I need to really convert those (.mp3) files to .wav first before convert them again to .caf? Or using that command alone will do the work for me ?
Any additional info is welcome.

Writing QuickTime files manually

In the app I'm working on, there's an AVIRecord class that manually write AVI headers and JPEG frames into a video files. They are .avi files with MJPEG codec, according to my media player (using KLite codec pack).
My question is: is this AVI compressed or uncompressed? Because the file size is basically sum of all the jpeg frames.
Can I write a similar code to produce a .mov file (Quicktime format)? By similar i mean: writing headers to the file, putting each frames manually into the files.
The app I am working on is supposed to save the jpeg stream from a IP Cam and save it under quicktime format.
Most file formats like AVI, MOV do not compress the video and audio bitstreams present in them. File formats are used to store video and audio decodeable units with associated metadata like timestamps. So when you add JPEGs to AVI file, it does not get compressed any further.
You can create MOV file with MJPEG video, similar to way you have been able to create AVI file with MJPEG video. However you would need creator for MOV (similar to the one you have for AVI).
MOV file format has been specified by Apple. A version of the format is available at http://developer.apple.com/standards/qtff-2001.pdf

Resources