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

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline

Dieter Scheel

  • Posts: 259
  • Joined: Tue Feb 14, 2017 11:15 am
  • Location: Germany

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

PostSat Nov 14, 2020 4:13 pm

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.
Resolve Studio 19.1.4 | Linux Mint 22.1 'Xia' | 32 GB | i7 | Nvidia RTX2080 8 GB (570.124.04) | 2.5 TB SSD | 48 TB NAS
Offline

buitani

  • Posts: 7
  • Joined: Sun Nov 15, 2020 9:52 pm
  • Real Name: Katy Maier

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

PostMon Nov 16, 2020 5:14 pm

Thank you for this script. This exactly what I was looking for.
Offline

Dieter Scheel

  • Posts: 259
  • Joined: Tue Feb 14, 2017 11:15 am
  • Location: Germany

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

PostWed Nov 18, 2020 12:39 pm

You're welcome, Katy :)
Resolve Studio 19.1.4 | Linux Mint 22.1 'Xia' | 32 GB | i7 | Nvidia RTX2080 8 GB (570.124.04) | 2.5 TB SSD | 48 TB NAS
Offline

Boris Kovalev

  • Posts: 151
  • Joined: Fri Sep 08, 2017 6:20 pm

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

PostWed Jul 07, 2021 3:33 am

I have something similar in this topic
;)
Offline

hutber

  • Posts: 39
  • Joined: Tue Dec 03, 2019 10:15 pm
  • Real Name: Mr Jamie Hutber

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

PostWed Mar 30, 2022 4:01 pm

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!
Offline

barnamos

  • Posts: 6
  • Joined: Thu Dec 22, 2022 6:24 pm
  • Real Name: Barney Treadway

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

PostMon Aug 14, 2023 9:15 pm

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

Return to DaVinci Resolve

Who is online

Users browsing this forum: Bruce Phung, Google [Bot], michaelh99, panos_mts, Zimmppy and 334 guests