mp4fragment reduces video file duration - media

Trying to create fragmented MP4 file from a non-fragmented one via command
mp4fragment --fragment-duration 10000 5ca31321e4b068348e2220a9-480p.mp4 5ca31321e4b068348e2220a9-480p.mp4_fragmented
But got media with incorrect duration of 2880000 ms (~ 48 minutes)
mediainfo --Inform=file:///var/cache/tomcat/temp/SC2024943881495774878TMP 5ca31321e4b068348e2220a9-480p.mp4_fragmented
CompleteName=5ca31321e4b068348e2220a9-480p.mp4_fragmented
Duration=2880000
Width=848
Height=480
BitRate=1099968
VideoId=1
AspectRatio=1.767
Language_3=
The original media file duration is 2880040:
mediainfo --Inform=file:///var/cache/tomcat/temp/SC2024943881495774878TMP 5ca31321e4b068348e2220a9-480p.mp4
Duration=2880040
Width=640
Height=360
BitRate=800000
VideoId=1
AspectRatio=1.778
Language_3=

Related

Record rtp stream with FFMPEG can not save files less than 256Kb

I'm using ffmpeg to record only audio rtp stream it's work ok. But if recorded file less than 256Kb ffmpeg is not save the file. I received a new file 0Kb(error). If recorded file greater than 256Kb ffmpeg only save file when 256, 512, 768, 1024,.... Kb.

Ffmpeg pkt_pos vs. hls byterange differs

I have a single ts file and created a single-file m3u8 using ffmpeg. It looks like the following
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:1
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:0.000000,
#EXT-X-BYTERANGE:22184#0
video.ts
#EXTINF:1.000667,
#EXT-X-BYTERANGE:713836#22184
video.ts
#EXTINF:1.000667,
#EXT-X-BYTERANGE:549336#736020
video.ts
#EXTINF:1.000667,
#EXT-X-BYTERANGE:568324#1285356
video.ts
#EXTINF:1.000667,
#EXT-X-BYTERANGE:569264#1853680
video.ts
...
The m3u8 file works perfectly but in its creation, ffmpeg re-creates the ts file. I wanted to avoid this and thought I could simply create the m3u8 file myself. I used the following command to get the byte offset of keyframes. However, none of the keyframe locations agrees with the offsets in the m3u8 file.
ffprobe -loglevel error -skip_frame nokey -select_streams v:0 -show_entries frame=pkt_pos -of compact video.m3u8
frame|pkt_pos=22560
frame|pkt_pos=736396
frame|pkt_pos=1285732
...
All of the offsets disagree by 376 bytes. That number is twice the mpeg-ts package size (which is 188). Both locations contains the ASCII character "G" which is the package header for MPEG-TS.
How can I get the correct offset positions using ffprobe that I can use to create an HLS playlist? Does Ffmpeg just subtract 2 packages for safety, is it important?
ffmpeg re-creates the ts file (which is a byte-wise copy of the original)
No, it’s not a bytewise copy. Ffmpeg still parses and repackages the file. You you need an exact copy, downlod with curl, or wget.
The package the offset points to is a PAT (Program Association Table), followed by a PMT (Program Mapping Table). Each packet takes 188 bytes which makes a total of 376. After this meta data, the actual keyframe starts.
In simple cases the m3u8 offset can point to the keyframe directly and the file will play correctly. However, in general cases, it makes sense for the decoder to be given the list of programs right away when seeking into the middle of a transport stream.

expected audio sample rate doesn't match actual?

I am trying to use pocket sphinx to transcribe audio files.
pocketsphinx_continuous -infile 116-288045-0005.flac.wav
but I am getting the errors:
ERROR: "continuous.c", line 136: Input audio file has sample rate [44100],
but decoder expects [16000]
FATAL: "continuous.c", line 165: Failed to process file '116-288045-0005.flac.wav'
due to format mismatch.
Here's one of the audio files I need to transcribe: Download from GitHub
Eventually I will batch-transcribe over 5 hours of audio files like these, currently they all throw the same error.
Here's some stats of the same file I'm trying to transcribe:
$ soxi 116-288045-0000.flac.wav
Input File : '116-288045-0000.flac.wav'
Channels : 1
Sample Rate : 44100
Precision : 16-bit
Duration : 00:00:10.65 = 469665 samples = 798.75 CDDA sectors
File Size : 939k
Bit Rate : 706k
Sample Encoding: 16-bit Signed Integer PCM
There might be a problem with some of this file's configuration, I've done some pre-processing to merge it with mp3s, convert from flac to wav, among others.
What's the easiest way now for me to get the transcription working?
Is it possible without re-sampling the files back down to 16kHz. Originally the flac files had a sample-rate of 16kHz, but I had to merge them with 44.1kHz mp3 files. Therefore there's some high-frequency information in them now that may be lost if resampled to 16k.
Resample the audio to 16000 samples then try again.
You can resample like this
sox file.wav -r 16000 file-16000.wav

Need help in FFMPEG with AES encryption

I want to segment a video file, create a playlist, encrypt it with AES 128 bit and stream it and play it using FFMPEG on windows platform.
I am able to segment the video file, create playlist. But i need help with AES encryption.
Below is the command i am using:
ffmpeg -i C:\Videos\Sample.mp4 -hls_time 30 -hls_key_info_file file.keyinfo -hls_segment_filename C:\Videos\Output\file%03d.ts C:\Videos\Output\out.m3u8
In my Output directory, I have 15 segmented video files with .ts extension(file000.ts - file014.ts) and 1 playlist file (out.m3u8).
Now out.m3u8 file is as below:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:38
#EXT-X-MEDIA-SEQUENCE:10
#EXTINF:28.653622,
file010.ts
#EXTINF:29.863167,
file011.ts
#EXTINF:37.412378,
file012.ts
#EXTINF:22.814456,
file013.ts
#EXTINF:16.057711,
file014.ts
#EXT-X-ENDLIST
Why is out.m3u8 file showing only file010.ts - file014.ts ?
Why is is not encrypting all the files?
What about the remaining files ?
What am i missing ?

Transcoding via FFmpeg. Set starting pcr value

I transcoding via FFmpeg (video codec - h264, container - MPEG-TS) output writing to local file (out.mpg). When FFmpeg dropped I restarted it with output to the same file (out.mpg). After this my video player shows incorrect file duration due to new FFmpeg process start counting PCR from 0.
Can I set starting pcr value at start FFmpeg ?
Run FFmpeg with key -copyts solved this issue.

Resources