Opened 10 years ago

Last modified 8 years ago

#4037 new defect

[Transcoding] Duration and frame number changed after transcoding

Reported by: Hung Nguyen Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: mpegts
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
The input video has duration:
Duration: 00:00:15.08, start: 91.000511, bitrate: 1428 kb/s

After transcoding it, duration changed to:
Duration: 00:00:15.09, start: 1.469089, bitrate: 922 kb/s

I also use transcoding.c from trunk, modify it abit to work with mpegts file, duration change to:
Duration: 00:00:15.01, start: 90.989133, bitrate: 489 kb/s

How to reproduce:

%ffmpeg -v debug -y -i yeuxa90.ts -vcodec libx264 -vb 500000 -s 640x360 -f mpegts -aspect 16:9 -g 25 -keyint_min 50 -vf scale=640:-1 -x264opts "keyint=50:min-keyint=50:no-scenecut" ffmpeg.ts
ffmpeg version 2.4.1 Copyright (c) 2000-2014 the FFmpeg developers
built on Oct  7 2014 09:23:21 with gcc 4.6 (Ubuntu/Linaro 4.6.4-3ubuntu1)

The input video can be found at :
[http://221.132.35.210/yeuxa90.ts
]
I believe with ffmpeg, there's something make packet/frame duplicated, and with transcoding example, frame was dropped...
Modified version of transcoding here: https://gist.github.com/whatvn/52e23b3f50c1b9c02cc7

Change History (31)

comment:1 by Carl Eugen Hoyos, 10 years ago

Keywords: transcoding removed

Do you think this is a regression?

Is the issue only reproducible with external libraries or also with a native encoder?
To make this a valid ticket, please test current FFmpeg git head and provide your failing command line (without using external libraries if this allows to reproduce the issue) together with the complete, uncut console output.

comment:2 by Hung Nguyen, 10 years ago

I have tried latest build from trunk, here is the output:

 /usr/local/bin/ffmpeg -v debug -y -i yeuxa90.ts -vcodec mpeg2video -vb 500000 -s 640x360 ffmpeg.ts
ffmpeg version N-66929-gf6bb2cd Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct 17 2014 09:36:11 with gcc 4.6 (Ubuntu/Linaro 4.6.4-3ubuntu1)
  configuration: --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --enable-shared --enable-avresample --enable-debug=3 --enable-libfaac --enable-libvo-aacenc --enable-version3
  libavutil      54. 10.100 / 54. 10.100
  libavcodec     56.  8.100 / 56.  8.100
  libavformat    56.  9.100 / 56.  9.100
  libavdevice    56.  1.100 / 56.  1.100
  libavfilter     5.  1.106 /  5.  1.106
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-i' ... matched as input file with argument 'yeuxa90.ts'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'mpeg2video'.
Reading option '-vb' ... matched as AVOption 'vb' with argument '500000'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '640x360'.
Reading option 'ffmpeg.ts' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file yeuxa90.ts.
Successfully parsed a group of options.
Opening an input file: yeuxa90.ts.
[mpegts @ 0x900dc0] Format mpegts probed with size=2048 and score=100
[mpegts @ 0x900dc0] stream=0 stream_type=1b pid=64 prog_reg_desc=
[mpegts @ 0x900dc0] stream=1 stream_type=f pid=65 prog_reg_desc=
[mpegts @ 0x900dc0] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0
[mpegts @ 0x900dc0] All programs have pmt, headers found
[h264 @ 0x904b40] no picture
[mpegts @ 0x900dc0] All info found
[mpegts @ 0x900dc0] After avformat_find_stream_info() pos: 0 bytes read:479376 seeks:2 frames:58
Input #0, mpegts, from 'yeuxa90.ts':
  Duration: 00:00:15.08, start: 91.000511, bitrate: 1428 kb/s
  Program 1
    Stream #0:0[0x64], 21, 1/90000: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(left), 1280x720 [SAR 1:1 DAR 16:9], 1/50, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x65], 37, 1/90000: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 129 kb/s
Successfully opened the file.
Parsing a group of options: output file ffmpeg.ts.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument mpeg2video.
Applying option s (set frame size (WxH or abbreviation)) with argument 640x360.
Successfully parsed a group of options.
Opening an output file: ffmpeg.ts.
Successfully opened the file.
detected 2 logical cores
[graph 0 input from stream 0:0 @ 0x900320] Setting 'video_size' to value '1280x720'
[graph 0 input from stream 0:0 @ 0x900320] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0x900320] Setting 'time_base' to value '1/90000'
[graph 0 input from stream 0:0 @ 0x900320] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:0 @ 0x900320] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x900320] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x900320] w:1280 h:720 pixfmt:yuv420p tb:1/90000 fr:25/1 sar:1/1 sws_param:flags=2
[scaler for output stream 0:0 @ 0x8f8280] Setting 'w' to value '640'
[scaler for output stream 0:0 @ 0x8f8280] Setting 'h' to value '360'
[scaler for output stream 0:0 @ 0x8f8280] Setting 'flags' to value '0x4'
[scaler for output stream 0:0 @ 0x8f8280] w:640 h:360 flags:'0x4' interl:0
[format @ 0x8f89e0] compat: called with args=[yuv420p|yuv422p]
[format @ 0x8f89e0] Setting 'pix_fmts' to value 'yuv420p|yuv422p'
[AVFilterGraph @ 0x8efe40] query_formats: 5 queried, 4 merged, 0 already done, 0 delayed
[scaler for output stream 0:0 @ 0x8f8280] w:1280 h:720 fmt:yuv420p sar:1/1 -> w:640 h:360 fmt:yuv420p sar:1/1 flags:0x4
[graph 1 input from stream 0:1 @ 0x9d1da0] Setting 'time_base' to value '1/44100'
[graph 1 input from stream 0:1 @ 0x9d1da0] Setting 'sample_rate' to value '44100'
[graph 1 input from stream 0:1 @ 0x9d1da0] Setting 'sample_fmt' to value 'fltp'
[graph 1 input from stream 0:1 @ 0x9d1da0] Setting 'channel_layout' to value '0x3'
[graph 1 input from stream 0:1 @ 0x9d1da0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
[audio format for output stream 0:1 @ 0x9d2940] Setting 'sample_fmts' to value 's16'
[audio format for output stream 0:1 @ 0x9d2940] Setting 'sample_rates' to value '44100|48000|32000|22050|24000|16000'
[audio format for output stream 0:1 @ 0x9d2940] Setting 'channel_layouts' to value '0x4|0x3'
[audio format for output stream 0:1 @ 0x9d2940] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:1'
[AVFilterGraph @ 0x900960] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto-inserted resampler 0 @ 0x9d4b80] ch:2 chl:stereo fmt:fltp r:44100Hz -> ch:2 chl:stereo fmt:s16 r:44100Hz
[mpeg2video @ 0x923ae0] intra_quant_bias = 96 inter_quant_bias = 0
[mpegts @ 0x908760] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'ffmpeg.ts':
  Metadata:
    encoder         : Lavf56.9.100
    Stream #0:0, 0, 1/90000: Video: mpeg2video, yuv420p(left), 640x360 [SAR 1:1 DAR 16:9], 1/25, q=2-31, 500 kb/s, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.8.100 mpeg2video
    Stream #0:1, 0, 1/90000: Audio: mp2, 44100 Hz, stereo, s16, 384 kb/s
    Metadata:
      encoder         : Lavc56.8.100 mp2
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))
  Stream #0:1 -> #0:1 (aac (native) -> mp2 (native))
Press [q] to stop, [?] for help
[h264 @ 0xa02920] no picture
[h264 @ 0xa479c0] no picture
*** 2 dup!
[output stream 0:0 @ 0x8efc80] EOF on sink link output stream 0:0:default.bits/s dup=2 drop=0
[output stream 0:1 @ 0x9d2020] EOF on sink link output stream 0:1:default.
No more output streams to write to, finishing.
frame=  377 fps=172 q=5.5 Lsize=    1946kB time=00:00:15.04 bitrate=1059.9kbits/s dup=2 drop=0
video:1034kB audio:704kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 11.966699%
Input file #0 (yeuxa90.ts):
  Input stream #0:0 (video): 375 packets read (2297071 bytes); 375 frames decoded;
  Input stream #0:1 (audio): 646 packets read (244840 bytes); 646 frames decoded (661504 samples);
  Total: 1021 packets (2541911 bytes) demuxed
Output file #0 (ffmpeg.ts):
  Output stream #0:0 (video): 377 frames encoded; 377 packets muxed (1058668 bytes);
  Output stream #0:1 (audio): 575 frames encoded (661504 samples); 575 packets muxed (720979 bytes);
  Total: 952 packets (1779647 bytes) muxed
1025 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x9092c0] Statistics: 0 seeks, 665 writeouts
[AVIOContext @ 0x8fff00] Statistics: 3172664 bytes read, 2 seeks

Here is the ouput duration

ffmpeg -i ffmpeg.ts
ffmpeg version N-66929-gf6bb2cd Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct 17 2014 09:36:11 with gcc 4.6 (Ubuntu/Linaro 4.6.4-3ubuntu1)
  configuration: --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --enable-shared --enable-avresample --enable-debug=3 --enable-libfaac --enable-libvo-aacenc --enable-version3
  libavutil      54. 10.100 / 54. 10.100
  libavcodec     56.  8.100 / 56.  8.100
  libavformat    56.  9.100 / 56.  9.100
  libavdevice    56.  1.100 / 56.  1.100
  libavfilter     5.  1.106 /  5.  1.106
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mpegts, from 'ffmpeg.ts':
  Duration: 00:00:15.09, start: 1.429089, bitrate: 1056 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 640x360 [SAR 1:1 DAR 16:9], max. 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 44100 Hz, stereo, s16p, 371 kb/s

The input duration:

ffmpeg -i yeuxa90.ts
ffmpeg version N-66929-gf6bb2cd Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct 17 2014 09:36:11 with gcc 4.6 (Ubuntu/Linaro 4.6.4-3ubuntu1)
  configuration: --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --enable-shared --enable-avresample --enable-debug=3 --enable-libfaac --enable-libvo-aacenc --enable-version3
  libavutil      54. 10.100 / 54. 10.100
  libavcodec     56.  8.100 / 56.  8.100
  libavformat    56.  9.100 / 56.  9.100
  libavdevice    56.  1.100 / 56.  1.100
  libavfilter     5.  1.106 /  5.  1.106
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mpegts, from 'yeuxa90.ts':
  Duration: 00:00:15.08, start: 91.000511, bitrate: 1428 kb/s
  Program 1
    Stream #0:0[0x64]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x65]: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 129 kb/s

Even if I try with other built-in codec, output's duration is still different from input's duration.

Do you think this is a regression?

I actually don't know.

--
Hung

comment:3 by Carl Eugen Hoyos, 10 years ago

Priority: importantnormal
Version: unspecifiedgit-master

comment:4 by Hung Nguyen, 10 years ago

This happens with current stable ffmpeg 2.4.1 too.

comment:5 by Carl Eugen Hoyos, 10 years ago

But the relevant version is current FFmpeg git head which is not unstable in any sense.

comment:6 by Hung Nguyen, 10 years ago

What I meant is if this happens to current git head, and also effect stable version (2.41), it should be marked as important.
Someone on IRC said FFmpeg should not change video duration if we didn't tell FFmpeg to do so.

comment:7 by Carl Eugen Hoyos, 10 years ago

The ticket is important if it worked with an older version but fails now. Your definition would mean that nearly every ticket is important.

comment:8 by Hung Nguyen, 10 years ago

ok, so may I ask if there's a workaround for this issue while waiting for the patch?

comment:9 by Carl Eugen Hoyos, 10 years ago

I unfortunately don't understand your issue and therefore cannot help.

comment:10 by Hung Nguyen, 10 years ago

As you see in ticket I opened, I have been trying to use FFMpeg API to transcoding mpegts -> mpegts, to change video heigh, width and bitrate...
Attached source code works, but duration of video changed and/or some frame was dropped. So, if I use the transcoded video and make a m3u8 playlist, video will be sometime distorted, it's not continuous.

I would like to transcode mpegts file to mpegts without making changes of its duration, and frame number.

Can you help?

--
Thanks.

comment:11 by Carl Eugen Hoyos, 10 years ago

Can you describe how I can reproduce the issue of distorted output?

comment:12 by Hung Nguyen, 10 years ago

Hi,

Step 1: use ffmpeg (the application) to split mp4 video into ts segments and m3u8 playlist. This playlist can be played well without problem.
Step 2: use ffmpeg to transcode these ts into lower bitrate, lower height/width, keep old file name and play it with playlist created in step 1. Video will be distored, can not be playd well, because transcoded ts file was changed in duration, and frame.

comment:13 by Carl Eugen Hoyos, 10 years ago

What I meant was:
Which command lines used on which input file allow to reproduce the distorted output, if possible without using any external libraries.

comment:14 by Hung Nguyen, 10 years ago

Source file: http://14.0.20.10/Vetmua.mp4

Command to split to ts in step 1 I mentioned:

/usr/local/bin/ffmpeg -i Vetmua.mp4  -codec:v libx264 -b:v 750000 -g 25.0 -keyint_min 50 -x264opts keyint=50:min-keyint=50:no-scenecut -codec:a aac -strict -2 -map 0:v -map 0:a -f ssegment -segment_list playlist.m3u8 -segment_time 5 -segment_format mpegts streams/stream%4d.ts

This playlist (playlist.m3u8) play well, no distortion.

Go to step 2,
2.1

# for i in *.ts; do /usr/local/bin/ffmpeg -y -i $i -vcodec libx264 -vb 500000 -s 640x360 -f mpegts -aspect 16:9 -g 25 -keyint_min 50 -vf scale=640:-1 ../transcode_streams/$i ; done

2.2

cp playlist.m3u8 ../transcode_streams/ 

Now play playlist.m3u8 with transcoded stream --> distortion. Actually I dont know how to name it right, it means, in playlist 1, file was not transcode, stream0000.ts and stream0001.ts are continuous, bit if we transcode them, it's not continuous anymore.

Last edited 10 years ago by Hung Nguyen (previous) (diff)

comment:15 by Carl Eugen Hoyos, 10 years ago

Is the issue only reproducible with libx264 or also with the mpeg2video encoder?

comment:16 by Carl Eugen Hoyos, 10 years ago

Why are you reencoding the output files of the segment muxer? I don't think this is supposed to work.

comment:17 by Hung Nguyen, 10 years ago

These step is use to reproduce the bug.
In our environment, when ts files is produced, we don't have .mp4 file anymore. To make adaptive bitrate works, we have to transcode ts -> ts with different bitrate, and size.

Why are you reencoding the output files of the segment muxer? I don't think this is supposed to work.

Why?

in reply to:  16 comment:18 by Cigaes, 10 years ago

Replying to cehoyos:

Why are you reencoding the output files of the segment muxer? I don't think this is supposed to work.

There is no reason for it not to: the output of the segment muxer are normal files with proper timestamp, and that is all that is required of them.

Of course, the transcode command line destroys the timestamps, and that is probably the cause of the error; -copyts should help; hopefully, the old bugs of the TS muxer with timestamps will not be a problem here.

comment:19 by Hung Nguyen, 10 years ago

Of course, the transcode command line destroys the timestamps, and that is probably the cause of the error; -copyts should help; hopefully, the old bugs of the TS muxer with timestamps will not be a problem here.

I just tried -copyts.
Input video:

  Duration: 00:00:06.02, start: 0.058667, bitrate: 1234 kb/s

Output video:

Duration: 00:00:06.03, start: 1.448644, bitrate: 1099 kb/s

It's still a little bit different.

I will try to implement -copyts into test app to see if problem can be solved or not.

Thanks!

comment:20 by Hung Nguyen, 10 years ago

Update: -copyts maynot be the solution, duration of video is still not the same with input video source.

in reply to:  17 ; comment:21 by Carl Eugen Hoyos, 10 years ago

Replying to hungnv:

In our environment, when ts files is produced, we don't have .mp4 file anymore. To make adaptive bitrate works, we have to transcode ts -> ts with different bitrate, and size.

Why don't you use the m3u8 file as input (or the concat protocol or the concat filter or the concat demuxer)?

in reply to:  21 comment:22 by Hung Nguyen, 10 years ago

Replying to cehoyos:

Replying to hungnv:

In our environment, when ts files is produced, we don't have .mp4 file anymore. To make adaptive bitrate works, we have to transcode ts -> ts with different bitrate, and size.

Why don't you use the m3u8 file as input (or the concat protocol or the concat filter or the concat demuxer)?

I don't get your idea. What I have is simple, we receive mp4 file, then the normal way to do adaptive bitrate is:

  1. Convert that mp4 file into 720p, 480p, 360p... files
  2. Split every of these files into ts segments
  3. Generate m3u8 playlist for every resolution.

Now instead of convert mp4 file into several mp4 file, we split original file first, then transcode ts to ts instead of mp4 to mp4.
Say the segment list will have segment0000.ts, segment0001.ts, 360p ts will have name segment0000_360p.ts, segment0001_36p.ts...

Contat is not what I want to do.

comment:23 by Carl Eugen Hoyos, 10 years ago

You don't have to use the concat protocol (although it was made for your use case), just read the m3u8 file as input and reencode specifying the new parameters like resolution and bitrate (to new segmented transport streams).

comment:24 by Hung Nguyen, 10 years ago

my situation is, after segment mp4 into ts files successfully, my application (which use ffmpeg api) read ts file, then transcode it into lower bitrate, size for other devices to use, that's why I attached modified version of ffmpeg example in opened ticket.

What you 're talking about is absolutely right if it work. But, why ffmpeg can transcode using m3u8 playlist input but cannot transcode single ts file to produce output with right duration, and frame?

Last edited 10 years ago by Hung Nguyen (previous) (diff)

comment:25 by Hung Nguyen, 10 years ago

To understand what I am trying to explain, you can see these 2 videos here: http://221.132.35.210:9090/
The first one: split and muxing and can be play well.
The second, transcoded from the first, ts by ts, has problem between 2 segments, it is discontinuous, sometimes I think it's just one frame dropped or duplicate, but it's not continuous.

in reply to:  24 ; comment:26 by Carl Eugen Hoyos, 10 years ago

Replying to hungnv:

my situation is, after segment mp4 into ts files successfully, my application (which use ffmpeg api) read ts file, then transcode it into lower bitrate, size for other devices to use, that's why I attached modified version of ffmpeg example in opened ticket.

I believe that your situation is that this doesn't currently work and that a simple workaround (and additionally other workarounds) exist. I even thought that it cannot work but Nicholas knows this code much better so I am probably wrong.

What you 're talking about is absolutely right if it work.

Did you test it?

But, why ffmpeg can transcode using m3u8 playlist input but cannot transcode single ts file to produce output with right duration, and frame?

This question sounds to me very much like "Why should I use a simple way of solving my problem if there is a much more complicated way that currently doesn't work?"

comment:27 by Hung Nguyen, 10 years ago

This question sounds to me very much like "Why should I use a simple way of solving my problem if there is a much more complicated way that currently doesn't work?"

Actually if what I am trying to do come up to be possible, it's a better solution. If it worked, I just need to deliver what user asks for. User request segment0000.ts - 360p resolution, my application uses FFMpeg API to transcode and deliver it to user.

To work with the whole playlist, I have to transcode many files at a time, it also takes too much of time.

in reply to:  26 comment:28 by Hung Nguyen, 10 years ago

Replying to cehoyos:

Did you test it?

It does not work, it produces a very strange things like this.
The command with uncut output

root@ubuntu:~# ffmpeg -i "http://ubuntu/vod/bichphuong.m3u8" -vb 1000k -s 640x360 -vcodec libx264 -acodec copy -vf scale=640:-1 streams/bicphuong.m3u8
ffmpeg version N-66929-gf6bb2cd Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct 17 2014 09:36:11 with gcc 4.6 (Ubuntu/Linaro 4.6.4-3ubuntu1)
  configuration: --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --enable-shared --enable-avresample --enable-debug=3 --enable-libfaac --enable-libvo-aacenc --enable-version3
  libavutil      54. 10.100 / 54. 10.100
  libavcodec     56.  8.100 / 56.  8.100
  libavformat    56.  9.100 / 56.  9.100
  libavdevice    56.  1.100 / 56.  1.100
  libavfilter     5.  1.106 /  5.  1.106
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, hls,applehttp, from 'http://ubuntu/vod/bichphuong.m3u8':
  Duration: 00:06:00.38, start: 1.000000, bitrate: 0 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 854x480, 24 fps, 24 tbr, 90k tbn, 48 tbc
    Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 136 kb/s
[libx264 @ 0x19f6100] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x19f6100] profile High, level 3.0
Output #0, hls, to 'streams/bicphuong.m3u8':
  Metadata:
    encoder         : Lavf56.9.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 640x360, q=-1--1, 1000 kb/s, 24 fps, 90k tbn, 24 tbc
    Metadata:
      encoder         : Lavc56.8.100 libx264
    Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, 136 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 8536 fps= 67 q=-1.0 Lsize=N/A time=00:06:00.28 bitrate=N/A dup=3014 drop=0
video:44125kB audio:3741kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x19f6100] frame I:82    Avg QP: 5.75  size: 46376
[libx264 @ 0x19f6100] frame P:3237  Avg QP: 8.51  size:  9914
[libx264 @ 0x19f6100] frame B:5217  Avg QP: 8.91  size:  1780
[libx264 @ 0x19f6100] consecutive B-frames: 14.5%  8.8%  9.7% 67.0%
[libx264 @ 0x19f6100] mb I  I16..4: 31.1% 26.4% 42.4%
[libx264 @ 0x19f6100] mb P  I16..4:  1.4%  3.7%  1.9%  P16..4: 18.5% 13.6% 12.0%  0.0%  0.0%    skip:49.0%
[libx264 @ 0x19f6100] mb B  I16..4:  0.0%  0.2%  0.1%  B16..8: 15.2%  6.1%  2.4%  direct: 2.9%  skip:73.0%  L0:38.4% L1:41.4% BI:20.2%
[libx264 @ 0x19f6100] final ratefactor: 12.09
[libx264 @ 0x19f6100] 8x8 transform intra:46.1% inter:43.5%
[libx264 @ 0x19f6100] coded y,uvDC,uvAC intra: 73.2% 76.9% 70.5% inter: 15.6% 14.5% 6.1%
[libx264 @ 0x19f6100] i16 v,h,dc,p: 45% 31% 10% 15%
[libx264 @ 0x19f6100] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 22% 15%  4%  6%  7%  7%  7%  7%
[libx264 @ 0x19f6100] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 26% 11%  5%  8%  7%  7%  6%  6%
[libx264 @ 0x19f6100] i8c dc,h,v,p: 52% 27% 16%  6%
[libx264 @ 0x19f6100] Weighted P-Frames: Y:3.4% UV:2.6%
[libx264 @ 0x19f6100] ref P L0: 77.6% 10.1%  9.6%  2.7%  0.0%
[libx264 @ 0x19f6100] ref B L0: 93.5%  5.8%  0.7%
[libx264 @ 0x19f6100] ref B L1: 96.3%  3.7%
[libx264 @ 0x19f6100] kb/s:1016.32

Ouput file:

root@ubuntu:~# ls streams/
bicphuong0.ts   bicphuong14.ts  bicphuong19.ts  bicphuong23.ts  bicphuong28.ts  bicphuong32.ts  bicphuong37.ts  bicphuong41.ts  bicphuong46.ts  bicphuong50.ts  bicphuong55.ts  bicphuong5.ts   bicphuong64.ts  bicphuong69.ts  bicphuong73.ts  bicphuong7.ts
bicphuong10.ts  bicphuong15.ts  bicphuong1.ts   bicphuong24.ts  bicphuong29.ts  bicphuong33.ts  bicphuong38.ts  bicphuong42.ts  bicphuong47.ts  bicphuong51.ts  bicphuong56.ts  bicphuong60.ts  bicphuong65.ts  bicphuong6.ts   bicphuong74.ts  bicphuong8.ts
bicphuong11.ts  bicphuong16.ts  bicphuong20.ts  bicphuong25.ts  bicphuong2.ts   bicphuong34.ts  bicphuong39.ts  bicphuong43.ts  bicphuong48.ts  bicphuong52.ts  bicphuong57.ts  bicphuong61.ts  bicphuong66.ts  bicphuong70.ts  bicphuong75.ts  bicphuong9.ts
bicphuong12.ts  bicphuong17.ts  bicphuong21.ts  bicphuong26.ts  bicphuong30.ts  bicphuong35.ts  bicphuong3.ts   bicphuong44.ts  bicphuong49.ts  bicphuong53.ts  bicphuong58.ts  bicphuong62.ts  bicphuong67.ts  bicphuong71.ts  bicphuong76.ts  bicphuong.m3u8
bicphuong13.ts  bicphuong18.ts  bicphuong22.ts  bicphuong27.ts  bicphuong31.ts  bicphuong36.ts  bicphuong40.ts  bicphuong45.ts  bicphuong4.ts   bicphuong54.ts  bicphuong59.ts  bicphuong63.ts  bicphuong68.ts  bicphuong72.ts  bicphuong77.ts

Content of output playlist:

root@ubuntu:~# cat streams/bicphuong.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:73
#EXTINF:8.000000,
bicphuong73.ts
#EXTINF:4.208333,
bicphuong74.ts
#EXTINF:8.583333,
bicphuong75.ts
#EXTINF:10.416667,
bicphuong76.ts
#EXTINF:4.875000,
bicphuong77.ts
#EXT-X-ENDLIST

FFmpeg generated 78 ts segments and create a playlist with just a few of it.

comment:29 by Hung Nguyen, 10 years ago

Update with -mpegts_copyts , -copyts and -vsync options.
Source file:

http://221.132.35.210/video0.ts

Command I use:

fmpeg -y -i ~/video0.ts -vcodec libx264 -vb 500000 -s 640x360 -f mpegts -aspect 16:9 -g 25 -keyint_min 50 -vf scale=640:-1 -copyts -mpegts_copyts 1 -vsync 0 ~/hung.ts

Duration, start time is still different

comment:30 by Soner, 9 years ago

Any updates on this?

comment:31 by Mateus Carlos de Souza, 8 years ago

Any updates on this? I am having the same problem.

Note: See TracTickets for help on using tickets.