0

I'm trying to reencode input HLS video (h264/aac using ts segments) from Nth to Mth segment into new HLS video. I do it by creating new HLS media playlist containing only segments I need (ie from 4th to 6th) and then using pretty normal ffmpeg command to encode new HLS video while keeping pts info for further processing:

ffmpeg -copyts -i hls/c2.m3u8 -dn -sn \
    -vcodec libx264 -vprofile main -level 3.1 -r 30.0 -preset medium -acodec aac\
    -flags -global_header -map 0 -hls_list_size 0 -hls_time 6 -mpegts_copyts 1 -hls_segment_filename ./hls2/%03d.ts ./hls2/pl.m3u8

If I analyze audio frames using ffprobe I get this output:

[FRAME]                    
stream_index=1             
key_frame=1                
pkt_pts_time=20.792467     
pkt_duration_time=0.023211 
[/FRAME]                   
[FRAME]                    
stream_index=1             
key_frame=1                
pkt_pts_time=20.815689     
pkt_duration_time=0.023211 
[/FRAME]             
...

Output is playable, but there's an extra audio frame at the beginning (one with pkt_pts_time=20.792467), because in the input data audio doesn't start at the exact same time as video (that's ok and expected). Is there any way to tell ffmpeg not to insert that extra audio frame? (it messes with further processing). Or at least is there a way to get rid of that extra audio frame?

I played with some ffmpeg params (itsoffset, async), but couldn't get the desired output. I tried to encode the audio separate (as to remux it after), but again it inserts that extra audio frame.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.