Page 1 of 1

Convert mp4/AAC to mov/PCM under Linux with ffmpeg

PostPosted: Sat Nov 14, 2020 4:13 pm
by Dieter Scheel
Hi
So, you end up with a lot of .mp4 files and Resolve is unable to import because of the AAC audio codec used in Smartphones and Camcorders nowadays? Fear no more, here is a simple bash script to convert everything to the correct media that you can import into Resolve Studio:

Code: Select all
#!/bin/bash
for f in *.mp4; do ffmpeg -i "$f" "${f/%mp4/wav}"; ffmpeg -i "$f" -vcodec copy -an -bsf:v h264_mp4toannexb "${f/%mp4/m4v}"; rm "$f"; ffmpeg -i "${f/%mp4/m4v}" -i "${f/%mp4/wav}" -acodec copy -vcodec copy "${f/%mp4/mov}"; rm "${f/%mp4/m4v}"; rm "${f/%mp4/wav}"; done


Just copy and paste to a new file, make it executable and start it inside the folder with a bunch of mp4 files. The script converts any audo track to a PCM file, extracts the video untouched and multiplexes everything into a mov file. There is no transcoding of the video track so the script is as fast as your HD or SSD can read and write files. After that you can import the mov into Resolve.

Please be aware that you must make a backup copy of your mp4 files before you use the script.

Have fun and good luck

PS:
Feel free to modify the script for your needs.

Re: Convert mp4/AAC to mov/PCM under Linux with ffmpeg

PostPosted: Mon Nov 16, 2020 5:14 pm
by buitani
Thank you for this script. This exactly what I was looking for.

Re: Convert mp4/AAC to mov/PCM under Linux with ffmpeg

PostPosted: Wed Nov 18, 2020 12:39 pm
by Dieter Scheel
You're welcome, Katy :)

Re: Convert mp4/AAC to mov/PCM under Linux with ffmpeg

PostPosted: Wed Jul 07, 2021 3:33 am
by Boris Kovalev
I have something similar in this topic
;)

Re: Convert mp4/AAC to mov/PCM under Linux with ffmpeg

PostPosted: Wed Mar 30, 2022 4:01 pm
by hutber
Worth reading before run it :lol: with the rm's. I working with dummy content but could have hurt me as my files are `H.265` not `H.264`. So my file just had a black screen and no video :D

In fact I still cannot get it to export with audio and video!

Re: Convert mp4/AAC to mov/PCM under Linux with ffmpeg

PostPosted: Mon Aug 14, 2023 9:15 pm
by barnamos
I had AAC audio inside some iphone mov files and needed to make happy with my dr centos 18. This doesn't rm anything but puts originals into a folder for backup. Was a very helpful script someone else did for mp4s. Easy enough to do the mp4s if you want to batch those at the same time.

Code: Select all
set -e
origdir="./original"
shopt -s extglob nullglob

if [ ! -d "$origdir" ];
then
    echo "Creating $origdir directory."
    mkdir "$origdir"
fi

for vid in *.mov; do
 noext="${vid%.mov}"
 ffmpeg -i "$vid" -acodec pcm_s16le -vcodec copy "${noext// /_}.mov"
    mv "$vid" "$origdir"
done
for vid in *.MOV; do
 noext="${vid%.MOV}"
 ffmpeg -i "$vid" -acodec pcm_s16le -vcodec copy "${noext// /_}.mov"
    mv "$vid" "$origdir"

done