[FFmpeg-user] Non-mandatory audio

Greg Oliver oliver.greg at gmail.com
Wed Oct 14 18:18:33 EEST 2020


sorry just realized I had to redirect stderr to get the results

On Wed, Oct 14, 2020 at 10:17 AM Greg Oliver <oliver.greg at gmail.com> wrote:

> On Tue, Oct 13, 2020 at 8:50 AM Mar Andrés López <mar.andres.l at gmv.com>
> wrote:
>
>> Dear all,
>>
>>
>> I am using the following command to generate dash content from a file:
>>
>>
>> ffmpeg -i video.mp4 –r 25 -c:v libx264 -c:a aac -b:a 128k -ac 1 -ar 44100
>> -map v:0 -b:v:0 2M -map v:0 -b:v:1 145k -map v:0 -b:v:2 365k -map 0:a -f
>> dash dash.mpd
>>
>>
>> But sometimes I have streams with audio and sometimes not. Is there
>> anyway to make this command to not break if the video file does not
>> contains audio?
>>
>>
>> A lot of thanks
>>
>
> Assuming you are scripting this, probe the file first and check for
> audio.  Use a separate ffmpeg command line for eac result.
>
> ffprobe <infile> | grep "Stream.*Audio"
> if [ $? -eq 0 ]; then
>     ffmpeg command with audio
> else
>     ffmpeg command without audio
> fi
>


ffprobe <infile> 2>&1 | grep "Stream.*Audio"
if [ $? -eq 0 ]; then
    ffmpeg command with audio
else
    ffmpeg command without audio
fi


More information about the ffmpeg-user mailing list