Answers.Body: <p>I've got same problem yesterday. Solution is first convert them separately to mp4 files and merge audio.mp4 and video.mp4 into one file afterwards.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-14T21:13:39.560Z
Answers.Text: Thanks, I'll give that a try next time I run into this. Given that it's been two and a half years, these particular files are long gone from memory, but I'll keep your advice in mind for the future.
Answers.UserDisplayName: InteXX
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-13T18:18:00.960Z
Answers.LastActivityDate: 2024-01-13T18:18:00.960Z
Answers.UserDisplayName: Firat Yılmaz
Body: <p>I have two streams, one audio and the other video. I'm trying to combine them using this command:</p>
  <pre><code>ffmpeg -y -i audio.m3u8 -i video.m3u8 -c copy Video.mp4
  </code></pre>
  <p>I found this syntax here:</p>
  <ul>
  <li><a href="https://video.stackexchange.com/a/18216">https://video.stackexchange.com/a/18216</a></li>
  <li><a href="https://stackoverflow.com/a/60663842">https://stackoverflow.com/a/60663842</a></li>
  <li><a href="https://superuser.com/a/885958">https://superuser.com/a/885958</a></li>
  </ul>
  <p>The <code>m3u8</code> playlists are below.</p>
  <p>The problem is that, while the audio in the resulting video is smooth and uninterrupted, the video  is not. <code>ffmpeg</code> seems to have plucked only certain frames from each 5-second video segment and merged them with the corresponding audio segment. In the resulting video, each of these frames displays for exactly two seconds before moving on to the next one. There is no motion in the video.</p>
  <p>I can play a given video segment and it works fine (just no audio). I've randomly tested a dozen or so of these.</p>
  <p>How can I successfully merge all of these audio and video segments into an <code>mp4</code> video?</p>
  <hr />
  <p><strong>Audio.m3u8</strong></p>
  <pre><code>#EXTM3U
  #EXT-X-ALLOW-CACHE:NO
  #EXT-X-VERSION:4
  #EXT-X-TARGETDURATION:7
  #EXT-X-MEDIA-SEQUENCE:1
  #EXT-X-PLAYLIST-TYPE:VOD
  #EXTINF:6.059,
  nova4806_r-hls-16x9-1080pAudio_2_00001.aac
  #EXTINF:5.995,
  nova4806_r-hls-16x9-1080pAudio_2_00002.aac
  #EXTINF:6.016,
  nova4806_r-hls-16x9-1080pAudio_2_00003.aac
  #EXTINF:5.995,
  nova4806_r-hls-16x9-1080pAudio_2_00004.aac
  #EXTINF:6.016,
  nova4806_r-hls-16x9-1080pAudio_2_00005.aac
  
  ...
  
  #EXTINF:4.117,
  nova4806_r-hls-16x9-1080pAudio_2_00532.aac
  #EXT-X-ENDLIST
  </code></pre>
  <p><strong>Video.m3u8</strong></p>
  <pre><code>#EXTM3U
  #EXT-X-VERSION:4
  #EXT-X-TARGETDURATION:6
  #EXT-X-MEDIA-SEQUENCE:1
  #EXT-X-I-FRAMES-ONLY
  #EXT-X-PLAYLIST-TYPE:VOD
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:752@376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00001.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:71816@1983400
  nova4806_r-hls-16x9-1080p-1080p-6500k_00001.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:44932@3277404
  nova4806_r-hls-16x9-1080p-1080p-6500k_00001.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:111296@376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00002.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:89300@1748964
  nova4806_r-hls-16x9-1080p-1080p-6500k_00002.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:124644@3753796
  nova4806_r-hls-16x9-1080p-1080p-6500k_00002.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:107912@376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00003.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:83284@1639736
  nova4806_r-hls-16x9-1080p-1080p-6500k_00003.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:198528@3142044
  nova4806_r-hls-16x9-1080p-1080p-6500k_00003.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:95692@376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00004.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:119944@1713808
  nova4806_r-hls-16x9-1080p-1080p-6500k_00004.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:167320@3345460
  nova4806_r-hls-16x9-1080p-1080p-6500k_00004.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:146452@376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00005.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:172020@1739000
  nova4806_r-hls-16x9-1080p-1080p-6500k_00005.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:135548@3396032
  nova4806_r-hls-16x9-1080p-1080p-6500k_00005.ts
  
  ...
  
  #EXTINF:0.100100,
  #EXT-X-BYTERANGE:564@3384376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00532.ts
  #EXT-X-ENDLIST
  </code></pre>
  <p><strong>Master.m3u8</strong></p>
  <pre><code>#EXTM3U
  #EXT-X-INDEPENDENT-SEGMENTS
  #EXT-X-VERSION:4
  #EXT-X-MEDIA:URI=&quot;nova4806_r-hls-16x9-1080pAudio%20Selector%201.m3u8&quot;,TYPE=AUDIO,GROUP-ID=&quot;multiple_audio_tracks&quot;,LANGUAGE=&quot;eng&quot;,NAME=&quot;English&quot;,DEFAULT=YES,AUTOSELECT=YES
  #EXT-X-MEDIA:URI=&quot;nova4806_r-captions.m3u8&quot;,TYPE=SUBTITLES,GROUP-ID=&quot;subs&quot;,LANGUAGE=&quot;en&quot;,NAME=&quot;English&quot;,DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,CHARACTERISTICS=&quot;public.accessibility.describes-music-and-sound,public.accessibility.transcribes-spoken-dialog&quot;
  #EXT-X-MEDIA:URI=&quot;nova4806_r-hls-16x9-1080pAudio%20Selector%202.m3u8&quot;,TYPE=AUDIO,GROUP-ID=&quot;multiple_audio_tracks&quot;,LANGUAGE=&quot;eng&quot;,NAME=&quot;English AD&quot;,DEFAULT=NO,AUTOSELECT=YES,CHARACTERISTICS=&quot;public.accessibility.describes-video&quot;
  #EXT-X-STREAM-INF:BANDWIDTH=2629077,AVERAGE-BANDWIDTH=2265370,RESOLUTION=960x540,CODECS=&quot;avc1.64001f,mp4a.40.2&quot;,AUDIO=&quot;multiple_audio_tracks&quot;,SUBTITLES=&quot;subs&quot;
  nova4806_r-hls-16x9-1080p-540p-2000k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=7966199,AVERAGE-BANDWIDTH=6905882,RESOLUTION=1920x1080,CODECS=&quot;avc1.640028,mp4a.40.2&quot;,AUDIO=&quot;multiple_audio_tracks&quot;,SUBTITLES=&quot;subs&quot;
  nova4806_r-hls-16x9-1080p-1080p-6500k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=5471302,AVERAGE-BANDWIDTH=4841216,RESOLUTION=1280x720,CODECS=&quot;avc1.64001f,mp4a.40.2&quot;,AUDIO=&quot;multiple_audio_tracks&quot;,SUBTITLES=&quot;subs&quot;
  nova4806_r-hls-16x9-1080p-720p-4500k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=3909956,AVERAGE-BANDWIDTH=3298061,RESOLUTION=1280x720,CODECS=&quot;avc1.64001f,mp4a.40.2&quot;,AUDIO=&quot;multiple_audio_tracks&quot;,SUBTITLES=&quot;subs&quot;
  nova4806_r-hls-16x9-1080p-720p-3000k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=1583840,AVERAGE-BANDWIDTH=1338316,RESOLUTION=768x432,CODECS=&quot;avc1.64001e,mp4a.40.2&quot;,AUDIO=&quot;multiple_audio_tracks&quot;,SUBTITLES=&quot;subs&quot;
  nova4806_r-hls-16x9-1080p-432p-1100k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=1108550,AVERAGE-BANDWIDTH=957278,RESOLUTION=640x360,CODECS=&quot;avc1.64001e,mp4a.40.2&quot;,AUDIO=&quot;multiple_audio_tracks&quot;,SUBTITLES=&quot;subs&quot;
  nova4806_r-hls-16x9-1080p-360p-730k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=624245,AVERAGE-BANDWIDTH=565523,RESOLUTION=480x270,CODECS=&quot;avc1.4d4015,mp4a.40.2&quot;,AUDIO=&quot;multiple_audio_tracks&quot;,SUBTITLES=&quot;subs&quot;
  nova4806_r-hls-16x9-1080p-270p-365k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=360807,AVERAGE-BANDWIDTH=334708,RESOLUTION=416x234,CODECS=&quot;avc1.4d400c,mp4a.40.2&quot;,AUDIO=&quot;multiple_audio_tracks&quot;,SUBTITLES=&quot;subs&quot;
  nova4806_r-hls-16x9-1080p-234p-145k.m3u8
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=1030462,RESOLUTION=960x540,CODECS=&quot;avc1.64001f&quot;,URI=&quot;nova4806_r-hls-16x9-1080p-540p-2000k_I-Frame.m3u8&quot;
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=3127072,RESOLUTION=1920x1080,CODECS=&quot;avc1.640028&quot;,URI=&quot;nova4806_r-hls-16x9-1080p-1080p-6500k_I-Frame.m3u8&quot;
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=1349242,RESOLUTION=1280x720,CODECS=&quot;avc1.64001f&quot;,URI=&quot;nova4806_r-hls-16x9-1080p-720p-4500k_I-Frame.m3u8&quot;
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=1343232,RESOLUTION=1280x720,CODECS=&quot;avc1.64001f&quot;,URI=&quot;nova4806_r-hls-16x9-1080p-720p-3000k_I-Frame.m3u8&quot;
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=630297,RESOLUTION=768x432,CODECS=&quot;avc1.64001e&quot;,URI=&quot;nova4806_r-hls-16x9-1080p-432p-1100k_I-Frame.m3u8&quot;
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=436976,RESOLUTION=640x360,CODECS=&quot;avc1.64001e&quot;,URI=&quot;nova4806_r-hls-16x9-1080p-360p-730k_I-Frame.m3u8&quot;
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=215984,RESOLUTION=480x270,CODECS=&quot;avc1.4d4015&quot;,URI=&quot;nova4806_r-hls-16x9-1080p-270p-365k_I-Frame.m3u8&quot;
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=96159,RESOLUTION=416x234,CODECS=&quot;avc1.4d400c&quot;,URI=&quot;nova4806_r-hls-16x9-1080p-234p-145k_I-Frame.m3u8&quot;
  </code></pre>
  
Tags: <ffmpeg><video><audio><streaming>
Title: Trouble combining audio and video streams
UserDisplayName: InteXX
ThreadText: # Trouble combining audio and video streams
  
  (Asked by: username_0 on 2021-07-08)
  
  I have two streams, one audio and the other video. I'm trying to combine them using this command:
  
  ```
  ffmpeg -y -i audio.m3u8 -i video.m3u8 -c copy Video.mp4
  
  ```
  
  I found this syntax here:
  
  * <https://video.stackexchange.com/a/18216>
  * <https://stackoverflow.com/a/60663842>
  * <https://superuser.com/a/885958>
  
  The `m3u8` playlists are below.
  
  The problem is that, while the audio in the resulting video is smooth and uninterrupted, the video is not. `ffmpeg` seems to have plucked only certain frames from each 5-second video segment and merged them with the corresponding audio segment. In the resulting video, each of these frames displays for exactly two seconds before moving on to the next one. There is no motion in the video.
  
  I can play a given video segment and it works fine (just no audio). I've randomly tested a dozen or so of these.
  
  How can I successfully merge all of these audio and video segments into an `mp4` video?
  
  ---
  
  **Audio.m3u8**
  
  ```
  #EXTM3U
  #EXT-X-ALLOW-CACHE:NO
  #EXT-X-VERSION:4
  #EXT-X-TARGETDURATION:7
  #EXT-X-MEDIA-SEQUENCE:1
  #EXT-X-PLAYLIST-TYPE:VOD
  #EXTINF:6.059,
  nova4806_r-hls-16x9-1080pAudio_2_00001.aac
  #EXTINF:5.995,
  nova4806_r-hls-16x9-1080pAudio_2_00002.aac
  #EXTINF:6.016,
  nova4806_r-hls-16x9-1080pAudio_2_00003.aac
  #EXTINF:5.995,
  nova4806_r-hls-16x9-1080pAudio_2_00004.aac
  #EXTINF:6.016,
  nova4806_r-hls-16x9-1080pAudio_2_00005.aac
  
  ...
  
  #EXTINF:4.117,
  nova4806_r-hls-16x9-1080pAudio_2_00532.aac
  #EXT-X-ENDLIST
  
  ```
  
  **Video.m3u8**
  
  ```
  #EXTM3U
  #EXT-X-VERSION:4
  #EXT-X-TARGETDURATION:6
  #EXT-X-MEDIA-SEQUENCE:1
  #EXT-X-I-FRAMES-ONLY
  #EXT-X-PLAYLIST-TYPE:VOD
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:752@376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00001.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:71816@1983400
  nova4806_r-hls-16x9-1080p-1080p-6500k_00001.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:44932@3277404
  nova4806_r-hls-16x9-1080p-1080p-6500k_00001.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:111296@376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00002.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:89300@1748964
  nova4806_r-hls-16x9-1080p-1080p-6500k_00002.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:124644@3753796
  nova4806_r-hls-16x9-1080p-1080p-6500k_00002.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:107912@376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00003.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:83284@1639736
  nova4806_r-hls-16x9-1080p-1080p-6500k_00003.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:198528@3142044
  nova4806_r-hls-16x9-1080p-1080p-6500k_00003.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:95692@376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00004.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:119944@1713808
  nova4806_r-hls-16x9-1080p-1080p-6500k_00004.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:167320@3345460
  nova4806_r-hls-16x9-1080p-1080p-6500k_00004.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:146452@376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00005.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:172020@1739000
  nova4806_r-hls-16x9-1080p-1080p-6500k_00005.ts
  #EXTINF:2.002000,
  #EXT-X-BYTERANGE:135548@3396032
  nova4806_r-hls-16x9-1080p-1080p-6500k_00005.ts
  
  ...
  
  #EXTINF:0.100100,
  #EXT-X-BYTERANGE:564@3384376
  nova4806_r-hls-16x9-1080p-1080p-6500k_00532.ts
  #EXT-X-ENDLIST
  
  ```
  
  **Master.m3u8**
  
  ```
  #EXTM3U
  #EXT-X-INDEPENDENT-SEGMENTS
  #EXT-X-VERSION:4
  #EXT-X-MEDIA:URI="nova4806_r-hls-16x9-1080pAudio%20Selector%201.m3u8",TYPE=AUDIO,GROUP-ID="multiple_audio_tracks",LANGUAGE="eng",NAME="English",DEFAULT=YES,AUTOSELECT=YES
  #EXT-X-MEDIA:URI="nova4806_r-captions.m3u8",TYPE=SUBTITLES,GROUP-ID="subs",LANGUAGE="en",NAME="English",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,CHARACTERISTICS="public.accessibility.describes-music-and-sound,public.accessibility.transcribes-spoken-dialog"
  #EXT-X-MEDIA:URI="nova4806_r-hls-16x9-1080pAudio%20Selector%202.m3u8",TYPE=AUDIO,GROUP-ID="multiple_audio_tracks",LANGUAGE="eng",NAME="English AD",DEFAULT=NO,AUTOSELECT=YES,CHARACTERISTICS="public.accessibility.describes-video"
  #EXT-X-STREAM-INF:BANDWIDTH=2629077,AVERAGE-BANDWIDTH=2265370,RESOLUTION=960x540,CODECS="avc1.64001f,mp4a.40.2",AUDIO="multiple_audio_tracks",SUBTITLES="subs"
  nova4806_r-hls-16x9-1080p-540p-2000k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=7966199,AVERAGE-BANDWIDTH=6905882,RESOLUTION=1920x1080,CODECS="avc1.640028,mp4a.40.2",AUDIO="multiple_audio_tracks",SUBTITLES="subs"
  nova4806_r-hls-16x9-1080p-1080p-6500k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=5471302,AVERAGE-BANDWIDTH=4841216,RESOLUTION=1280x720,CODECS="avc1.64001f,mp4a.40.2",AUDIO="multiple_audio_tracks",SUBTITLES="subs"
  nova4806_r-hls-16x9-1080p-720p-4500k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=3909956,AVERAGE-BANDWIDTH=3298061,RESOLUTION=1280x720,CODECS="avc1.64001f,mp4a.40.2",AUDIO="multiple_audio_tracks",SUBTITLES="subs"
  nova4806_r-hls-16x9-1080p-720p-3000k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=1583840,AVERAGE-BANDWIDTH=1338316,RESOLUTION=768x432,CODECS="avc1.64001e,mp4a.40.2",AUDIO="multiple_audio_tracks",SUBTITLES="subs"
  nova4806_r-hls-16x9-1080p-432p-1100k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=1108550,AVERAGE-BANDWIDTH=957278,RESOLUTION=640x360,CODECS="avc1.64001e,mp4a.40.2",AUDIO="multiple_audio_tracks",SUBTITLES="subs"
  nova4806_r-hls-16x9-1080p-360p-730k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=624245,AVERAGE-BANDWIDTH=565523,RESOLUTION=480x270,CODECS="avc1.4d4015,mp4a.40.2",AUDIO="multiple_audio_tracks",SUBTITLES="subs"
  nova4806_r-hls-16x9-1080p-270p-365k.m3u8
  #EXT-X-STREAM-INF:BANDWIDTH=360807,AVERAGE-BANDWIDTH=334708,RESOLUTION=416x234,CODECS="avc1.4d400c,mp4a.40.2",AUDIO="multiple_audio_tracks",SUBTITLES="subs"
  nova4806_r-hls-16x9-1080p-234p-145k.m3u8
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=1030462,RESOLUTION=960x540,CODECS="avc1.64001f",URI="nova4806_r-hls-16x9-1080p-540p-2000k_I-Frame.m3u8"
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=3127072,RESOLUTION=1920x1080,CODECS="avc1.640028",URI="nova4806_r-hls-16x9-1080p-1080p-6500k_I-Frame.m3u8"
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=1349242,RESOLUTION=1280x720,CODECS="avc1.64001f",URI="nova4806_r-hls-16x9-1080p-720p-4500k_I-Frame.m3u8"
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=1343232,RESOLUTION=1280x720,CODECS="avc1.64001f",URI="nova4806_r-hls-16x9-1080p-720p-3000k_I-Frame.m3u8"
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=630297,RESOLUTION=768x432,CODECS="avc1.64001e",URI="nova4806_r-hls-16x9-1080p-432p-1100k_I-Frame.m3u8"
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=436976,RESOLUTION=640x360,CODECS="avc1.64001e",URI="nova4806_r-hls-16x9-1080p-360p-730k_I-Frame.m3u8"
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=215984,RESOLUTION=480x270,CODECS="avc1.4d4015",URI="nova4806_r-hls-16x9-1080p-270p-365k_I-Frame.m3u8"
  #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=96159,RESOLUTION=416x234,CODECS="avc1.4d400c",URI="nova4806_r-hls-16x9-1080p-234p-145k_I-Frame.m3u8"
  
  ```
  
  **Tags:** ffmpeg, video, audio, streaming
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-01-13. Score: 1
  
  I've got same problem yesterday. Solution is first convert them separately to mp4 files and merge audio.mp4 and video.mp4 into one file afterwards.
  
  > **Comments:**
  > **username_0**: Thanks, I'll give that a try next time I run into this. Given that it's been two and a half years, these particular files are long gone from memory, but I'll keep your advice in mind for the future.  
  
  ---
  
  