[FFmpeg-user] Problem converting MPEGTS file to QuickTime compatible MP4

Lou lou at fakeoutdoorsman.com
Sat Apr 16 21:22:01 CEST 2011


On Fri, 15 Apr 2011 20:39:47 -0500
Bryan Murphy <bmurphy1976 at gmail.com> wrote:

> I'm having difficulty converting an h.264+aac MPEGTS file into a
> QuickTime compatible MP4.  If I use ffmpeg to convert a source file
> direct to MP4, everything works.  If I convert to an intermediate
> MPEGTS file (I have multiple reasons for wanting to do this), the
> second conversion from MPEGTS to MP4 produces a file that QuickTime
> refuses to play.
> 
> I've tried multiple versions of ffmpeg and they all seem to exhibit
> the same (or very similar) behavior.
> 
> Here is a shell script that reproduces this behavior.  It creates two
> files, output-good.mp4 which plays in QuickTime, and output-bad.mp4
> which does not.
> 
> #!/bin/bash -e
> 
> wget http://www.2atoms.com/video/haha/smelly_monkey4.wmv
> 
> # create file that works
> ffmpeg -y -i smelly_monkey4.wmv \
> 	-vcodec libx264 -vpre baseline -vpre medium -vpre ipod320 -s

My comments probably won't help your issue, but your commands can be
improved.

Constraining presets, such as baseline, go after your encoding preset.
Also, you don't need to include baseline when using ipod320 as the last
preset because ipod320 is baseline with a few additional options and
will overwrite whatever baseline sets:

-vpre medium -vpre ipod320

> 320x240 -r 29.97 -b 256k -bt 256k \
> 	-acodec libfaac -ab 64k -ar 22050 -ac 1 output-good.mp4

-bt 256k is being ignored so you can remove it. Why are you not using
'-threads 0'? Use CRF if you're doing one pass. See:

FFmpeg x264 encoding guide
<http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/>

> # transcode audio seperately
> ffmpeg -y -i smelly_monkey4.wmv -f wav -acodec pcm_s16le
> -sameq .temp.audio1.wav sox .temp.audio1.wav .temp.audio2.wav
> channels 1 rate 22050 pad 0 30 faac .temp.audio2.wav -b 64 -c 22050
> -o .temp.audio.aac

You don't need -sameq here.

> # transcode video seperately
> ffmpeg -y -i smelly_monkey4.wmv -vcodec libx264 -vpre baseline -vpre
> medium -vpre ipod320 -s 320x240 -r 29.97 -b 256k -bt 256k -an
> .temp.video.h264
> 
> # store output as a .ts file
> ffmpeg -y -shortest -async 1 -i .temp.audio.aac -i .temp.video.h264
> -acodec copy -vcodec copy .temp.transcoded.ts
> 
> # repackage output into various di.temp.transcoded.tsfferent
> containers as needed,including QuickTime compatible MP4
> ffmpeg -y -i .temp.transcoded.ts -acodec copy -vcodec copy
> output-bad.mp4

Does it work with Quicktime if you use .temp.video.h264 and
temp.audio.aac as your sources instead of .temp.transcoded.ts?


More information about the ffmpeg-user mailing list