[Libav-user] [resize video] Lost duration
Hung Nguyen
Hung.Nguyen at ambientdigitalgroup.com
Tue Oct 14 16:23:06 CEST 2014
Hi Carl,
Now I can get the video duration if I force enc_ctx (AVFormatContext) ’s time_base into (AVRational){1, 24} or something like this.
The problem is the duration of input video is different from output video, even when I try with ffmpeg (the application)
The input:
ffmpeg -i original
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)
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. 7.100 / 54. 7.100
libavcodec 56. 1.100 / 56. 1.100
libavformat 56. 4.101 / 56. 4.101
libavdevice 56. 0.100 / 56. 0.100
libavfilter 5. 1.100 / 5. 1.100
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 0.100 / 3. 0.100
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 0.100 / 53. 0.100
Input #0, mpegts, from 'original.ts':
Duration: 00:00:10.14, start: 20.818667, bitrate: 1720 kb/s
Program 1
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
Stream #0:1[0x65]: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 130 kb/s
The output:
ffmpeg -i output
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)
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. 7.100 / 54. 7.100
libavcodec 56. 1.100 / 56. 1.100
libavformat 56. 4.101 / 56. 4.101
libavdevice 56. 0.100 / 56. 0.100
libavfilter 5. 1.100 / 5. 1.100
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 0.100 / 3. 0.100
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 0.100 / 53. 0.100
Input #0, mpegts, from 'ffmpeg.ts':
Duration: 00:00:10.17, start: 1.429978, bitrate: 907 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), 48000 Hz, stereo, s16p, 372 kb/s
Duration of input is 00:00:10.14 but the output is 00:00:10.17
Command I use:
/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
How can I keep the original duration after transcoding the video?
Thanks,
Hung
On Oct 14, 2014, at 8:59 AM, Hung Nguyen <Hung.Nguyen at ambientdigitalgroup.com<mailto:Hung.Nguyen at ambientdigitalgroup.com>> wrote:
Hi Carl,
Yes, I also scale the input using scale filter.
The filter I use is as following:
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”;
I still don’t understand why scale video cause duration metadata lost.
Thanks,
—
Hưng
On Oct 13, 2014, at 11:59 PM, Carl Eugen Hoyos <cehoyos at ag.or.at<mailto:cehoyos at ag.or.at>> wrote:
Hung Nguyen <Hung.Nguyen at ...> writes:
The problem I am facing now is, every time I try to
change video size when initialise encoder, the
output video does not have video duration:
enc_ctx->height = 360;
enc_ctx->width = 640;
Did you just set the dimensions in the codec context
or did you also use the scale your input (with the
scale filter)?
Carl Eugen
_______________________________________________
Libav-user mailing list
Libav-user at ffmpeg.org<mailto:Libav-user at ffmpeg.org>
http://ffmpeg.org/mailman/listinfo/libav-user
_______________________________________________
Libav-user mailing list
Libav-user at ffmpeg.org<mailto:Libav-user at ffmpeg.org>
http://ffmpeg.org/mailman/listinfo/libav-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20141014/6a287ff3/attachment.html>
More information about the Libav-user
mailing list