0

How can I split the audio file .aac into small parts of exactly 4.0 seconds, ie. with ignoring keyframes?

The original video file was in .mp4 format. From this video file I got an .aac audio file. But the new parts of the split audio file always have 3.4 seconds and I need 4.0 seconds of audio. The problem is probably in key frames.

Thanks.

cd $DIR_IN
for file in *.mp4
do
    echo "Extracting the whole audio-track from $file to $DIR_TMP/${file%.mp4}.aac"
    ffmpeg -i "$file" -vn -acodec copy $DIR_TMP/"${file%.mp4}.aac"

    echo "Splitting the large video-file $file to a smaller audio-files '${file%.mp4}'XXX.aac"
    ffmpeg -i $DIR_TMP/"${file%.mp4}.aac" -c copy -f segment -segment_time 4 $DIR_TMP/"${file%.mp4}%03d.aac"

    rm -f $DIR_TMP/"${file%.mp4}.aac"
done
0

Problem solved:

#!/bin/bash
avfile=/tmp/video.mp4
ffmpeg -i "$avfile" -c:v libx264 -crf 23 -map 0 -segment_time 4 -g 4 -sc_threshold 0 -force_key_frames "expr:gte(t,n_forced*4)" -f segment /tmp/output/"${avfile%.mp4}%03d.mp4"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.