Reputation: 137
To encode a video using FFMPEG the following command is used:
/usr/bin/ffmpeg -i INPUT.MP4
-preset veryfast -r 25 -g 75 -threads 4 -sc_threshold 0
-map 0:v:0 -map 0:a:0
-filter:v:0 scale=h=240:w=-2
-minrate:v:0 75k
-maxrate:v:0 218k
-bufsize:v:0 300k
-b:v:0 150k -c:a aac -b:a 128k -ac 2
-var_stream_map "v:0,a:0"
-master_pl_name master.m3u8
-f hls -hls_time 3 -segment_time 6
-hls_list_size 0 -segment_format mpegts
-hls_segment_filename /res-%v/segment-%d.ts OUTPUT.M3U8 1> log.txt 2>&1
In general, despite such a huge command, it copes with the task with a bang
But there is one little BUT:
If you run this command on a video WITHOUT audio, there will be an error:
Stream map '0:a:0' matches no streams. To ignore this, add a trailing '?' to the map.
Yes, I understand that the command tells me that the audio stream was not found. And to ignore this, you need to add a trailing question mark to the map
But only I can’t understand where? to which place?
I will be glad to any advice or suggestion
Thanks in advance
Upvotes: 10
Views: 19414
Reputation: 134093
Use -map 0:a:0?
, as in:
/usr/bin/ffmpeg -i INPUT.MP4
-preset veryfast -r 25 -g 75 -threads 4 -sc_threshold 0
-map 0:v:0 -map 0:a:0?
-filter:v:0 scale=h=240:w=-2
-minrate:v:0 75k
-maxrate:v:0 218k
-bufsize:v:0 300k
-b:v:0 150k -c:a aac -b:a 128k -ac 2
-var_stream_map "v:0,a:0"
-master_pl_name master.m3u8
-f hls -hls_time 3 -segment_time 6
-hls_list_size 0 -segment_format mpegts
-hls_segment_filename /res-%v/segment-%d.ts OUTPUT.M3U8 1> log.txt 2>&1
Upvotes: 11