MP4Box MP4 concatenation not working - mp4

I download lectures in mp4 format from Udacity, but they're often broken down into 2-5 minute chunks. I'd like to combine the videos for each lecture into one continuous stream, which I've had success with on Windows using AnyVideo Converter. I'm trying to do the same thing on Ubuntu 15, and most of my web search results suggest MP4Box, whose documentation and all the online examples I can find offer the following syntax:
MP4Box -cat vid1.mp4 -cat vid2.mp4 -cat vid3.mp4 -new combinedfile.mp4
This creates a new file with working audio, but the video doesn't work. When I open with Ubuntu's native video player, I get the error "No valid frames decoded before end of stream." When I open with VLC, I get the error "Codec not supported: VLC could not decode the format 'avc3' (No description for this codec." I've tried using the -keepsys switch, as well, but I get the same results.
All the documentation and online discussion makes it sound as though what I'm trying to do is and should be really simple, but I can't seem to find info relevant to the specific errors I'm getting. What am I missing?

Use the -force-cat option.
For example,
MP4Box -force-cat -add in1.mp4 -cat in2.mp4 -cat in3.mp4 ... -new out.mp4
From the MP4Box documentation:
-force-cat
skips media configuration check when concatenating file.

It looks, by the presence of 'avc3', that these videos are encoded with h.264|avc. There are several modes for the concatenation of such streams. Either the video streams have compatible encoder configurations (frame size, ...) in which case only one configuration description is used in the file (signaled by 'avc1'). If the configurations are not fully compatible, MP4Box uses the 'inband' storage of those configurations (signaled by 'avc3'). The other way would be to use multiple sample description entries (stream configurations) but that is not well supported by players and not yet possible with MP4Box. There is no other way unless you want to reencode your videos. On Ubuntu, you should be able to play 'avc3' streams with the player that goes with MP4Box: MP4Client.

Related

Flutter FFmpeg moov atom not found whilst running ffmpeg command during recording

Hi am currently trying to retrieve 3 second clips of an audio file whilst it is recording in flutter. I am using the recording module flutter sound and flutter ffmpeg.
I record the audio file with default codec (.aac). The file is saved to the cache getTemporaryDirectory()
I then copy the file using this flutter ffmpeg code
List<String> arguments = ["-ss", start.toString(), "-i", inPath, "-to", end.toString(), "-c", "copy", outPath];
await flutterFFmpeg.executeWithArguments(arguments);
Start: start time (e.g. 0) and End: end time (e.g. 3)
It then returns this error
FFmpeg exited with rc: 1 [mov,mp4,m4a,3gp,3g2,mj2 # 0x748964ea00] moov
atom not found
Helpful information:
A moov atom is data about the file (e.g timescale,duration)
I know the inPath exists because I check that before executing ffmpeg command
The outPath is also format .aac
This ffmpeg function is being ran whilst the recording is still occurring
Example inPath uri looks like this /data/user/0/com.my.app/cache/output.aac
I have no problems when running on iOS, only on android
I would be grateful for help, I have spent many days trying to fix this problem. If you need anymore info please leave a comment. Thanks
Default Codec is not guaranteed to be AAC/ADTS.
It will depend of the Android version of your device.
You can do several things to understand better :
ffprobe on your file to see what has been recorded by Flutter Sound.
Use a specific Codec instead of default : aac/adts is a good choice because it can be streamed (you want to process the audio data during the recording and not after closing the file)
Verify that your file contains something and that the data are not still in internal buffers
Record to a dart PCM stream instead of a file. Working with a file and use FFmpeg to seek into it is complicated and perhaps does not fill your needs.

Does exiftool require the complete file for extracting metadata

This question is about extraction of metadata only.
Is it required for exiftool to get a complete file for propperly working?
Scenario:
I want to extract the metadata of a 20 GB video file. Do I need to provide exiftool with the complete file (via stdin), or is it enough to provide it with a certain amount of bytes.
Motivation:
I am programatically (golang) calling exiftool in a streaming context and want to have the extraction as fast as possible. Magic numbers for filetypes work with the first 33 bytes and I am wondering if that is possible with the exiftool metadata as well.
The answer depends upon the file and the location of the metadata within that file.
There are a couple of threads on the subject on the ExifTool forums (link 1, link 2) and Phil Harvey, the author, says that about half the time the in the case of MP4/MOV videos, the metadata is at the end of the file.
Using the -fast option might help. I've done some quick tests using cURL and a large image file (see the second to the last example under Piping Examples) and in that case cURL didn't download the whole image file, just enough to extra the metadata. It might be different with a video file though, as I haven't tested that situation.

How do I join AAC/.m4a files via CLI (Mac OS X)

I need to quickly join a number of separate m4a files in to one large one. Is there any way to do so via CLI on in Mac OS X?
I think I found a way myself without any transcoding nessesary, with some inspiration from Coxys answer. MP4Box lets me do it: MP4Box -cat file1.m4a -cat file2.m4a output.m4a. It doesn´t retain any metadata but for my purpose its just fine.
Now, given Coxys answer, are there any pitfalls with the file I just haven´t discovered yet?
Unfortunately AAC files cannot be joined by simple concatenation, which is what I assume you mean when you mention doing it via the command line?
If you installed something like ffmpeg then you could certainly build up a process to take in AAC audio files, convert them to the uncompressed wave data, join them all up, then export the resulting file back to AAC again.
Alternately, if using the CLI is not a hard requirement then you could do this with iTunes and Audacity.

MP3 conversion on Amazon's EC2

I run a small record label and we have a bunch of audio files stored on Amazon's S3. We want them converted to MP3's with a standard bitrate. I read about the NYTimes converting all their PDF's using EC2 and since I'm a nerdy web programmer, I'm intrigued. Instead of downloading all the files and converting them by hand, I'm wondering what it takes to set up an EC2 instance and get it set up to convert files? I want to be able to control it from my web server with PHP, so is the approach to create a virtual LAMP stack and install the LAME encoder?
If you want to convert your audio files (I'm assuming .wav since it's a pretty common format pre-format conversion) to mp3 LAME is a solid encoder.
A full blown LAMP stack is highly unnecessary for using LAME, a simple shell script will suffice.
This will convert all *.wav files in the current directory to .mp3 files if they do not have a converted copy already in-place (LAME doesn't care about clobbering output files).
#!/bin/bash
for file in *.wav; do
dest="${file%wav}mp3"
if [[ -e "$file" ]] && [[ ! -e "$dest" ]]; then
lame "$file" "$dest"
fi
done
You will want to look through man lame for the conversion options specific to your VBR/CBR/ABR (variable, constant and average bitrate) needs.
While the above answer would work if you already had the files in the local EC2, you'll have to fetch each song from S3 into EC2, either into a pipe for conversion or into a temporary file, then either pipe it back up to S3 or store it in a temp file and then send it back to EC2.
Haven't actually used EC2, so not sure what kind of storage you're working with, but you should have plenty of space to store the one temporary mp3.
You would probably also want to create some way of tracking status, probably by doing a listing on your bucket before you start.
Probably a perl script using the S3 module would be more suited, but I'm too lazy to type that all in here :).
You could use Elastic MapReduce for this. Although you'd have to play around a bit to get it to spit out separate files as output.

Best he-aac encoder on linux?

I need an encoder that can convert mp3 files to he-aac (aka aac+).
So far the best one I have found is nero aac encoder .
I have two problemes with it :
- Only one input format : wav . It is a little bit slow to transform mp3 files to wav and then to he-aac.
- a free license for non commercial use.
Too bad ffmpeg does not support he-aac ...
There is a commercial solution, on2 flix, but it seems to be a golden hammer for the simple task I need to do.
Nero AAC is the only one as far as I know. Even if FAAC supported HE-AAC it would be useless, since as an encoder its pretty awfully designed and its quality is not even competitive with LAME, let alone a good AAC encoder.
Kostya on the FFMPEG team is currently working on an AAC encoder but it has a long way to go--its not ready for primetime with LC-AAC, let alone HE-AAC (its not even committed to the repository yet). The first step before anything will be to get the ffmpeg decoder to support HE-AAC; currently it can only be decoded through FAAD.
I don't believe there is any HE-AAC encoder on any platform with a more permissive license than Nero's at this point in time.
I've been using neroAacEnc for quite a while now, and I'm largely satisfied with the results. If you're on Linux, making an .AAC file out of an .MP3 or whatever else, is quite easy, all you need is a small wrapper script, that takes care of decoding into .WAV and after encoding, removes the .WAV file.
Be advised: Converting from one lossy encoding to another further reduces quality. So when you can live with .MP3 and you don't have lossless sources, you better stick to them.
Here's a small script, that converts from .FLACto .AAC, it accepts only .FLAC files as arguments:
#!/bin/zsh
for file in ${argv[*]}; do
flac -d ${file}
neroAacEnc -q 0.6 -if ${file%%.flac}.wav -of ${file%%.flac}.aac
rm ${file%%.flac}.wav
done
This script is sequential, but it can be easily made into a multithreaded script.
There is an encoder called accplus which is under the GNU license available here.
Another encoder: mp4tools
I don't have an idea about the quality, but I just found
enhAacPlusEnc