<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Carl,<div><br></div><div>Now I can get the video duration if I force enc_ctx (AVFormatContext) ’s time_base into (AVRational){1, 24} or something like this.</div><div>The problem is the duration of input video is different from output video, even when I try with ffmpeg (the application)</div><div><br></div><div>The input: </div><div><div>ffmpeg -i original</div><div>ffmpeg version 2.4.1 Copyright (c) 2000-2014 the FFmpeg developers</div><div>  built on Oct  7 2014 09:23:21 with gcc 4.6 (Ubuntu/Linaro 4.6.4-3ubuntu1)</div><div>  configuration: --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --enable-shared --enable-avresample --enable-debug=3 --enable-libfaac --enable-libvo-aacenc --enable-version3</div><div>  libavutil      54.  7.100 / 54.  7.100</div><div>  libavcodec     56.  1.100 / 56.  1.100</div><div>  libavformat    56.  4.101 / 56.  4.101</div><div>  libavdevice    56.  0.100 / 56.  0.100</div><div>  libavfilter     5.  1.100 /  5.  1.100</div><div>  libavresample   2.  1.  0 /  2.  1.  0</div><div>  libswscale      3.  0.100 /  3.  0.100</div><div>  libswresample   1.  1.100 /  1.  1.100</div><div>  libpostproc    53.  0.100 / 53.  0.100</div><div>Input #0, mpegts, from 'original.ts':</div><div>  Duration: 00:00:10.14, start: 20.818667, bitrate: 1720 kb/s</div><div>  Program 1</div><div>    Stream #0:0[0x64]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 854x480 [SAR 1:1 DAR 427:240], 25 fps, 25 tbr, 90k tbn, 50 tbc</div><div>    Stream #0:1[0x65]: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 130 kb/s</div><div><br></div><div><br></div><div>The output:</div><div><div>ffmpeg -i output</div><div>ffmpeg version 2.4.1 Copyright (c) 2000-2014 the FFmpeg developers</div><div>  built on Oct  7 2014 09:23:21 with gcc 4.6 (Ubuntu/Linaro 4.6.4-3ubuntu1)</div><div>  configuration: --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --enable-shared --enable-avresample --enable-debug=3 --enable-libfaac --enable-libvo-aacenc --enable-version3</div><div>  libavutil      54.  7.100 / 54.  7.100</div><div>  libavcodec     56.  1.100 / 56.  1.100</div><div>  libavformat    56.  4.101 / 56.  4.101</div><div>  libavdevice    56.  0.100 / 56.  0.100</div><div>  libavfilter     5.  1.100 /  5.  1.100</div><div>  libavresample   2.  1.  0 /  2.  1.  0</div><div>  libswscale      3.  0.100 /  3.  0.100</div><div>  libswresample   1.  1.100 /  1.  1.100</div><div>  libpostproc    53.  0.100 / 53.  0.100</div><div>Input #0, mpegts, from 'ffmpeg.ts':</div><div>  Duration: 00:00:10.17, start: 1.429978, bitrate: 907 kb/s</div><div>  Program 1</div><div>    Metadata:</div><div>      service_name    : Service01</div><div>      service_provider: FFmpeg</div><div>    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</div><div>    Stream #0:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 372 kb/s</div></div><div><br></div><div>Duration of input is  <b>00:00:10.14 </b>but the output is <b>00:00:10.17</b></div><div><b><br></b></div><div>Command I use:</div><div>/usr/local/bin/ffmpeg -v debug -y -i original -vcodec libx264 -vb 500000 -s 640x360 -f mpegts -aspect 16:9 -vf scale=640:-1 output</div><div><br></div><div><br></div><div>How can I keep the original duration after transcoding the video?</div><div><br></div><div>Thanks,</div><div><br></div><div>Hung</div><div><br></div><div><br></div><div><br></div><div><div>On Oct 14, 2014, at 8:59 AM, Hung Nguyen <<a href="mailto:Hung.Nguyen@ambientdigitalgroup.com">Hung.Nguyen@ambientdigitalgroup.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Carl,<br><br>Yes, I also scale the input using scale filter. <br>The filter I use is as following:<br>filter_spec = "scale=iw*min(640/iw\\,360/ih):ih*min(640/iw\\,360/ih), pad=640:360:(640-iw*min(640/iw\\,360/ih))/2:(360-ih*min(640/iw\\,360/ih))/2”;<br><br>I still don’t understand why scale video cause duration metadata lost. <br><br>Thanks,<br><br>—<br>Hưng<br><br><br><br>On Oct 13, 2014, at 11:59 PM, Carl Eugen Hoyos <<a href="mailto:cehoyos@ag.or.at">cehoyos@ag.or.at</a>> wrote:<br><br><blockquote type="cite">Hung Nguyen <Hung.Nguyen@...> writes:<br><br><blockquote type="cite">The problem I am facing now is, every time I try to <br>change video size when initialise encoder, the <br>output video does not have video duration: <br><br>enc_ctx->height = 360;<br>enc_ctx->width = 640; <br></blockquote><br>Did you just set the dimensions in the codec context <br>or did you also use the scale your input (with the <br>scale filter)?<br><br>Carl Eugen<br><br>_______________________________________________<br>Libav-user mailing list<br><a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>http://ffmpeg.org/mailman/listinfo/libav-user<br></blockquote><br>_______________________________________________<br>Libav-user mailing list<br><a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>http://ffmpeg.org/mailman/listinfo/libav-user<br></blockquote></div><br></div></body></html>