Sample Header Ad - 728x90

Ffmpeg generate fixed binary digit filename pattern

1 vote
2 answers
53 views
Suppose I have filenames like these 4-bit patterns:
0000.ts  
0001.ts  
...  
1111.ts
Basically, that file was generated from an RTSP stream that chunks every second. So, for each binary number increment by 1, it represents a 1-second chunk of video. Why do I prefer this pattern? Because I can control filtering with granularity based on powers of 2 using asterisks. For example:
ls 111*.ts   -> gets 2 seconds of video starting at 00:00:14  

ls 10*.ts    -> gets 4 seconds of video starting at 00:00:08

...and you get the idea for the rest.
But with ffmpeg, I can just do this using base 10 (i.e., Unix timestamp). Here are the ffmpeg flags I use:
-i rtsp://10.42.0.128:554/stream1  
     -c copy  
     -f segment  
     -segment_time 15  
     -reset_timestamps 1  
     -strftime 1  
     -segment_format mpegts  
     "/mnt/recordings/%s.ts"
You see that I’m using %s to get the Unix timestamp in base 10. What I really want is that Unix timestamp—but as a 64-bit version that printed in base2.
Asked by Muhammad Ikhwan Perwira (329 rep)
Aug 11, 2025, 07:00 PM
Last activity: Aug 12, 2025, 06:09 AM