Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Compression Techniques ffmpeg adding white flash frame at end of .mov output file

  • Len Hugh

    April 1, 2016 at 9:43 pm

    My work around of late has been to create audio using afconvert. which is another commandline tool build into mac(windows has something similar i think) then make the h264 video with ffmpeg and copy the afconvert created audio into the h264.
    its a bit of double handling and I love to know if there is a way to make the afconvert file in some sort of temp folder so it gets removed after I have my h264.
    but it works.

  • Mark Burton

    April 27, 2016 at 8:43 am

    Hi mate, sorry I didn’t come to you on this. If I were you, I’d just do it all in ffmpeg in one hit and use another tool to rewrap the .mov. Its not so much the encode of the aac thats the issue with ffmpeg, but the way it creates the .mov wrapper where the problem occurs I believe.

  • Len Hugh

    April 27, 2016 at 9:25 am

    What I have working thru avconvert seems to work. I have not used pix so I cant be 100% sure if its pix friendly but checking it back thru avid and protools I can see the difference.

  • Mark Burton

    April 27, 2016 at 11:46 am

    OK cool. How are you combining the two together?

  • Len Hugh

    May 27, 2016 at 1:18 pm

    Apologies for the delay.
    busy.
    The script I was using involved taking 3 wavs and a .mov picture and combining.
    I recently went to create a script that would work with only one .mov file as the input.
    I found that afconvert does not like .mov files. All I get out is the sound of static. If anyone can tell me why that would be great.
    WAV files seem ok.
    So it means I have to first get ffmpeg to create a wav file from the original, then give that to afconvert, then ffmpeg can use that afconvert file in its encode. I store the wav and the afconvert audio in the temporary files. If you are using applescript then this code helps….
    set wav_intermediate_audio to quoted form of (POSIX path of (path to temporary items)
    To connect the ffmpeg script to strip the WAV, and the afconvert, and the final encode I use “;” between each section. In a bash script this will daisy chain the scripts so they run one after another.
    Here is my latest script.
    /usr/local/bin/ffmpeg -threads 0 -y -i 'original.mov' -vn '/private/var/folders/wb/sdb3ggw90k52h17chk5pt9qr0000gp/T/TemporaryItems/wav_intermediate_audio.wav';afconvert -v '/private/var/folders/wb/sdb3ggw90k52h17chk5pt9qr0000gp/T/TemporaryItems/wav_intermediate_audio.wav' -o '/private/var/folders/wb/sdb3ggw90k52h17chk5pt9qr0000gp/T/TemporaryItems/primed_acc.wav' -q 127 -b 128000 -f m4af -d aac;/usr/local/bin/ffmpeg -threads 0 -y -i '/private/var/folders/wb/sdb3ggw90k52h17chk5pt9qr0000gp/T/TemporaryItems/primed_acc.wav' -i 'original.mov' -map 0 -c copy -map 1:v -vcodec libx264 -crf 22 -pix_fmt yuv420p -preset faster "output.mov"
    I have only just finished it so I have not tested the speed of it. But audio is pretty quick to encode.

  • Mark Burton

    May 31, 2016 at 7:17 pm

    Thanks mate. Not sure I understand the batch command though, why is the output from afconvert called ‘primed_acc.wav’? Are you not trying to make an AAC file to go back into the .mov at the end or was this just a typo?

    I’m not sure there is a way for afconvert to handle a .mov file, it is called Audio File Convert after all!

  • Len Hugh

    May 31, 2016 at 11:04 pm

    your right, there is probably a more sensible containter to use, .wav works as a container as well. the codec within it is still aac.
    .aac as an output extension doesnt seem to work. I get
    “Error: ExtAudioFileOpenURL failed (‘sync’)”
    from afconvert if I try an output with .aac esxtention.

    I checked the file compatibility of afconvert and it sheds light on it all.
    afconvert -hf
    3gpp’ = 3GP Audio (.3gp)
    data_formats: ‘Qclp’ ‘aac ‘ ‘aace’ ‘aacf’ ‘aach’ ‘aacl’
    ‘aacp’ ‘samr’
    ‘3gp2’ = 3GPP-2 Audio (.3g2)
    data_formats: ‘Qclp’ ‘aac ‘ ‘aace’ ‘aacf’ ‘aach’ ‘aacl’
    ‘aacp’ ‘samr’
    ‘adts’ = AAC ADTS (.aac, .adts)
    data_formats: ‘aac ‘ ‘aach’ ‘aacp’
    ‘ac-3’ = AC3 (.ac3)
    data_formats: ‘ac-3’
    ‘AIFC’ = AIFC (.aifc, .aiff, .aif)
    data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 UI8 ‘ulaw’
    ‘alaw’ ‘MAC3’ ‘MAC6’ ‘ima4’ ‘QDMC’ ‘QDM2’
    ‘Qclp’ ‘agsm’
    ‘AIFF’ = AIFF (.aiff, .aif)
    data_formats: I8 BEI16 BEI24 BEI32
    ‘amrf’ = AMR (.amr)
    data_formats: ‘samr’
    ‘m4af’ = Apple MPEG-4 Audio (.m4a, .m4r)
    data_formats: ‘aac ‘ ‘aace’ ‘aacf’ ‘aach’ ‘aacl’ ‘aacp’
    ‘ac-3’ ‘alac’ ‘paac’
    ‘m4bf’ = Apple MPEG-4 AudioBooks (.m4b)
    data_formats: ‘aac ‘ ‘aace’ ‘aacf’ ‘aach’ ‘aacl’ ‘aacp’
    ‘paac’
    ‘caff’ = CAF (.caf)
    data_formats: ‘.mp1’ ‘.mp2’ ‘.mp3’ ‘AC-3’ ‘QDM2’ ‘QDMC’
    ‘Qclp’ ‘Qclq’ ‘aac ‘ ‘aace’ ‘aacf’ ‘aach’
    ‘aacl’ ‘aacp’ ‘ac-3’ ‘aes3’ ‘alac’ ‘alaw’
    ‘dvi8’ ‘ilbc’ ‘ima4’ I8 BEI16 BEI24 BEI32
    BEF32 BEF64 LEI16 LEI24 LEI32 LEF32 LEF64
    ‘ms\x00\x02’ ‘ms\x00\x11’ ‘ms\x001’ ‘ms \x00’
    ‘paac’ ‘samr’ ‘ulaw’ ‘zaac’ ‘zach’ ‘zacp’
    ‘MPG1’ = MPEG Layer 1 (.mp1, .mpeg, .mpa)
    data_formats: ‘.mp1’
    ‘MPG2’ = MPEG Layer 2 (.mp2, .mpeg, .mpa)
    data_formats: ‘.mp2’
    ‘MPG3’ = MPEG Layer 3 (.mp3, .mpeg, .mpa)
    data_formats: ‘.mp3’
    ‘mp4f’ = MPEG-4 Audio (.mp4)
    data_formats: ‘aac ‘ ‘aace’ ‘aacf’ ‘aach’ ‘aacl’ ‘aacp’
    ‘ac-3’
    ‘NeXT’ = NeXT/Sun (.snd, .au)
    data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 ‘ulaw’
    ‘Sd2f’ = Sound Designer II (.sd2)
    data_formats: I8 BEI16 BEI24 BEI32
    ‘WAVE’ = WAVE (.wav)
    data_formats: UI8 LEI16 LEI24 LEI32 LEF32 LEF64 ‘ulaw’
    ‘alaw’

    I guess I should be using .mp4 as an output really. but WAV is working fine.

  • Mark Burton

    June 1, 2016 at 12:55 pm

    Got it. I gave this method a go and for me the resulting .mov file displays an audio track duration which is too long, its as ffmpeg would do on its own for me. If I take a 00:00:15.00 (15 seconds exactly) 24fps file and process with this method, the resulting file has a duration of 00:00:15.062. Using modmovie, the file is 00:00:15.00.
    Are you getting a resulting file with an audio track which matches exactly the source file?

  • Len Hugh

    June 11, 2016 at 12:14 pm

    No, my audio is longer then my source wav file but after I finally sat down and properly read this
    https://developer.apple.com/library/ios/technotes/tn2258/_index.html

    Reading this it seems that a longer duration for aac audio is correct and that its up to the player to offset 2112 samples so its in sync.

    2112 silent samples at the head and then a number of samples at the tail to round it up to the next 1024 packet would mean that it is always longer then the original audio, and longer then the video

    I have been putting various tests thru afinfo.
    its built into macs.
    (into the terminal type afinfo and then the file you want the info on)

    my test original is a 10 second count down with a pip at 10, another at 2 and one at the very last frame.

    I am still working thru a variety of tests,
    Its worth putting a pip at the first and last frame of your files to check your results. I get some strange results. eg. avid dnx mov put thru Mpegstreamclip and the result mp4 with aac audio has the pip on the last frame missing.

    the only thing to say at this point is a wav output from avid then put that thru afconvert(aac audio) provides an afinfo report of…
    audio 480000 valid frames + 2112 priming + 192 remainder = 482304
    and so far its the only way I have found to hear both the first frame pip and the last frame pip is to go via afconvert.
    yes the audio is longer then the wav but it seems to behave as the apple developer page says.
    If you are getting an aac file the same duration as a wav I would check that its not dropping samples of your audio.

    Ill update you later when I get time to study more methods and tests.

Page 3 of 3

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy